:root {
  --bg-top: #f2f3ff;
  --bg-bottom: #e2e5ff;
  --surface: #ffffff;
  --surface-soft: #f6f7ff;
  --purple-main: #7b5cff;
  --purple-dark: #5437c9;
  --purple-deep: #3d2c78;
  --gold-ring: #ffb732;
  --gold-dark: #d48800;
  --green-boost: #4cd949;
  --green-boost-dark: #28a326;
  --text-main: #332a5c;
  --text-muted: #766ea0;
  --shadow-soft: 0 10px 28px rgba(61, 44, 120, 0.14);
  --font-display: 'Jua', 'Fredoka', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text-main);
  background: radial-gradient(circle at 50% 20%, #fffdf8 0%, var(--bg-top) 45%, var(--bg-bottom) 100%);
  user-select: none;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 100dvh;
  min-height: 100svh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 540px) {
  body {
    background: linear-gradient(155deg, #dcd7ff 0%, #ebe9ff 50%, #d5ddff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #app {
    height: min(95dvh, 900px);
    border-radius: 28px;
    background: linear-gradient(180deg, #f5f6ff 0%, #eaeaff 100%);
    box-shadow: 0 24px 60px rgba(48, 34, 108, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.75);
  }
}

.bg-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(45deg, rgba(145, 134, 232, 0.14) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(145, 134, 232, 0.14) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(145, 134, 232, 0.14) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(145, 134, 232, 0.14) 75%);
  background-size: 56px 56px;
  background-position: 0 0, 0 28px, 28px -28px, -28px 0;
}

/* Open Casual-Game Stage Container (no double card border) */
.knit-card {
  position: relative;
  z-index: 4;
  flex: 1 1 0;
  min-height: 0;
  margin: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.knit-card::before {
  display: none;
}

/* Top HUD */
.hud-top {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 12px 2px;
  gap: 6px;
  flex-shrink: 0;
}

.hud-left-group {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
}

.hud-right-group {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-self: end;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #543734;
  letter-spacing: -0.2px;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 4px;
  border-radius: 999px;
  background: #fff9ee;
  border: 1.5px solid #edd29d;
  box-shadow: 0 1px 3px rgba(130, 92, 42, 0.12);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: #5e4124;
  line-height: 1.1;
}

.coin-disc {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #ffe97a 0%, #f0b232 65%, #c58214 100%);
  border: 1.5px solid #fff3bd;
  color: #8c5308;
  font-size: 10px;
  display: inline-grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(128, 78, 12, 0.25);
}

.daynight-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 40px;
  height: 22px;
  padding: 2px 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #5d6988 0%, #4b5672 100%);
  border: 1.5px solid #d5dce9;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.dn-cloud {
  font-size: 11px;
  color: #ffffff;
  line-height: 1;
}

.dn-sun {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff08a 0%, #f4b730 100%);
  color: transparent;
  font-size: 0;
  box-shadow: 0 0 3px rgba(255, 224, 110, 0.7);
}

.hud-circle-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid var(--gold-ring);
  background: linear-gradient(180deg, #987dff 0%, var(--purple-main) 55%, var(--purple-dark) 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--gold-dark), 0 6px 14px rgba(61, 44, 120, 0.24);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  padding: 0;
}

.hud-gear-btn {
  background: linear-gradient(180deg, #987dff 0%, var(--purple-main) 55%, var(--purple-dark) 100%);
  box-shadow: 0 3px 0 var(--gold-dark), 0 6px 14px rgba(61, 44, 120, 0.24);
}

.hud-circle-btn:hover {
  transform: translateY(-1px);
}

.hud-circle-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--gold-dark), 0 3px 6px rgba(61, 44, 120, 0.2);
}

.hud-hint-btn {
  width: 34px;
  height: 34px;
  background: linear-gradient(180deg, #a78eff 0%, #7d5ff6 100%);
}

.hud-speed-btn {
  width: 34px;
  height: 34px;
}

.hud-icon {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.22));
}

.btn-badge {
  position: absolute;
  right: -5px;
  bottom: -4px;
  background: #ffffff;
  color: var(--purple-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 9px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  border: 1.5px solid var(--purple-dark);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.hud-circle-btn.speed-fast .btn-badge {
  background: #ffe46b;
  color: #7c3c00;
  border-color: #d48800;
}

/* Level Purple Pill + Floral Ribbon Header */
.hud-level-banner {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 2px 10px 5px;
  flex-shrink: 0;
}

.level-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #9863d0 0%, #6f3ca1 100%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 0 #512878, 0 4px 8px rgba(109, 58, 158, 0.25);
}

.level-ribbon-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: 100%;
}

.ribbon-flourish {
  font-size: 11px;
  opacity: 0.85;
  flex-shrink: 0;
}

.level-name-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #4f312b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ribbon-dot {
  color: #b78d82;
  font-weight: 800;
  font-size: 12px;
}

.level-pct {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: #f9e8eb;
  border: 1px solid #ecc2cb;
  color: #8b4252;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Main Stage */
.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  min-height: 0;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.toast-banner {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(82, 54, 42, 0.94);
  color: #fffaf3;
  font-weight: 700;
  font-size: 13px;
  padding: 7px 16px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(74, 51, 41, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
  z-index: 8;
}

.toast-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Bottom Dock */
.hud-bottom {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}

.dock-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(61, 44, 120, 0.1);
  transition: transform 0.12s ease, background 0.12s ease;
}

.dock-btn:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.dock-btn:active {
  transform: translateY(1px);
}

.dock-icon {
  width: 19px;
  height: 19px;
  color: var(--purple-main);
}

.dock-pill {
  position: absolute;
  top: -6px;
  right: 4px;
  background: var(--purple-main);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1.5px solid #ffffff;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(52, 34, 24, 0.52);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 430px;
  max-height: min(84dvh, calc(100dvh - 24px));
  background: var(--surface);
  border-radius: 26px;
  padding: 20px;
  box-shadow: 0 24px 54px rgba(64, 42, 30, 0.32);
  border: 2px solid #ead9c3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.orientation-lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, rgba(82, 54, 42, 0.96), rgba(166, 66, 48, 0.96));
  color: #fffaf3;
  text-align: center;
}

.orientation-lock.hidden {
  display: none;
}

.orientation-lock-card {
  width: min(100%, 320px);
  padding: 28px 24px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 24px;
  background: rgba(255, 253, 249, 0.14);
  box-shadow: 0 18px 48px rgba(40, 22, 16, 0.28);
}

.orientation-lock-icon {
  margin-bottom: 8px;
  font-size: 56px;
  line-height: 1;
}

.orientation-lock-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
}

.orientation-lock-card p {
  margin: 10px 0 0;
  color: rgba(255, 250, 243, 0.86);
  font-size: 14px;
  line-height: 1.5;
}

.modal-card-sm {
  max-width: 360px;
}

.modal-card-wide {
  max-width: 460px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--purple-deep);
}

.modal-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.modal-close:hover {
  background: #efe2cf;
  color: var(--purple-deep);
}

.modal-subtitle {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Level Grid */
.levels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 2px 6px;
}

.level-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border-radius: 16px;
  border: 2px solid #ead9c3;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.level-tile:hover {
  border-color: var(--purple-main);
  background: #ffffff;
  transform: translateY(-1px);
}

.level-tile.active {
  border-color: var(--purple-main);
  background: #fdf0ec;
}

.level-tile.completed {
  border-color: #6fd774;
}

.level-thumb {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  background: #fffdf9;
  border: 1px solid #e4d2ba;
  flex-shrink: 0;
}

.level-tile-info {
  min-width: 0;
  flex: 1;
}

.level-tile-num {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--purple-deep);
  display: flex;
  align-items: center;
  gap: 4px;
}

.level-tile-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.check-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3bc94c;
  color: #ffffff;
  font-size: 10px;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  overflow-y: auto;
  padding: 2px 2px 6px;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 2px solid #ead9c3;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--purple-main);
}

.gallery-card.unlocked {
  background: #ffffff;
  border-color: #ffd064;
  box-shadow: 0 6px 14px rgba(255, 183, 50, 0.16);
}

.gallery-canvas {
  width: 78px;
  height: 78px;
  border-radius: 12px;
}

.gallery-title {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--purple-deep);
  text-align: center;
  line-height: 1.2;
}

.gallery-tag {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Settings */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-soft);
  border-radius: 14px;
  cursor: pointer;
}

.setting-row strong {
  display: block;
  font-size: 14px;
  color: var(--purple-deep);
}

.setting-row small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.setting-row input[type="checkbox"] {
  appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #dccbb5;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.setting-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.setting-row input[type="checkbox"]:checked {
  background: var(--purple-main);
}

.setting-row input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.settings-footer {
  display: flex;
  gap: 10px;
}

.settings-footer > button {
  flex: 1;
}

/* How to play */
.howto-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.howto-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-soft);
  padding: 10px 12px;
  border-radius: 14px;
}

.howto-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-main);
}

.howto-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--purple-main);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* Win Card */
.win-card {
  text-align: center;
  align-items: center;
}

.win-sparkles {
  font-size: 26px;
  margin-bottom: 2px;
}

.win-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--purple-deep);
}

.win-subtitle {
  margin: 4px 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.win-preview-box {
  width: 200px;
  height: 200px;
  border-radius: 20px;
  background: var(--surface-soft);
  border: 2px solid #ead9c3;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 8px rgba(82, 54, 42, 0.08);
}

#win-preview-canvas {
  width: 184px;
  height: 184px;
}

.win-stats {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
}

.stat-chip {
  flex: 1;
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 8px 10px;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.stat-chip strong {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--purple-deep);
}

/* Buttons */
.modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.modal-actions > button {
  flex: 1;
}

.modal-actions-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-primary,
.btn-secondary,
.btn-boost,
.btn-danger-outline {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #eb8672 0%, var(--purple-main) 100%);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--purple-dark);
}

.btn-boost {
  background: linear-gradient(180deg, #64ea60 0%, var(--green-boost) 100%);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--green-boost-dark);
}

.btn-secondary {
  background: #f5e9da;
  color: var(--purple-deep);
}

.btn-danger-outline {
  background: #fff0f2;
  color: #cc334d;
  border: 1.5px solid #f7c3cd;
}

.btn-primary:active,
.btn-boost:active,
.btn-secondary:active {
  transform: translateY(2px);
}

.full-width {
  width: 100%;
}

/* Card Footer: Progress Bar + Gift Box & Yarn Ball Palette Row */
.card-footer {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 2px 12px 8px;
  flex-shrink: 0;
}

.progress-gift-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.progress-bar-track {
  position: relative;
  width: 168px;
  height: 18px;
  border-radius: 999px;
  background: #e7ddd2;
  border: 1.5px solid #d4c3b2;
  box-shadow: inset 0 2px 4px rgba(82, 54, 42, 0.14);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe075 0%, #f2b738 100%);
  box-shadow: inset 0 -1px 2px rgba(176, 112, 18, 0.25);
  transition: width 0.2s ease;
}

.progress-bar-text {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: #4f3428;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

.gift-badge {
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(96, 48, 48, 0.2));
}

.palette-swatches {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 8px;
}

/* Tactile Round Knit Yarn Balls */
.palette-swatch {
  padding: 0;
  cursor: pointer;
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fffdf9;
  background-color: var(--yarn-color, #d8654f);
  background-image:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.08) 38%, rgba(45, 24, 18, 0.24) 100%),
    repeating-linear-gradient(
      -34deg,
      rgba(255, 255, 255, 0.14) 0px,
      rgba(255, 255, 255, 0.14) 2px,
      rgba(40, 22, 16, 0.11) 2px,
      rgba(40, 22, 16, 0.11) 4px
    );
  box-shadow:
    inset 0 -3px 5px rgba(45, 25, 15, 0.22),
    0 3px 6px rgba(82, 54, 42, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: #ffffff;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.18s ease;
}

.palette-swatch:hover {
  transform: translateY(-2px) scale(1.06);
}

.palette-swatch[aria-pressed="true"] {
  transform: translateY(-3px) scale(1.1);
  outline: 2.5px solid #c94e38;
  outline-offset: 2px;
  box-shadow:
    inset 0 -3px 5px rgba(45, 25, 15, 0.22),
    0 5px 10px rgba(182, 74, 54, 0.34);
}

.palette-swatch.is-cleared {
  opacity: 0.46;
  transform: scale(0.86);
}

.palette-swatch.is-cleared::after {
  content: '✓';
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

@media (max-height: 700px) {
  .knit-card {
    margin: 4px 8px 2px;
    border-width: 5px;
    border-radius: 20px;
  }
  .hud-top {
    padding: 4px 8px 1px;
  }
  .hud-level-banner {
    padding: 0 8px 2px;
    gap: 1px;
  }
  .level-name-text {
    font-size: 14px;
  }
  .card-footer {
    gap: 4px;
    padding: 1px 10px 6px;
  }
  .palette-swatch {
    width: 24px;
    height: 24px;
  }
  .hud-bottom {
    padding: 4px 10px 6px;
  }
  .dock-btn {
    padding: 5px 4px;
  }
}

@media (pointer: coarse) and (max-width: 539px) {
  .hud-circle-btn {
    width: 34px;
    height: 34px;
  }

  .hud-hint-btn,
  .hud-speed-btn {
    width: 33px;
    height: 33px;
  }

  .modal-close {
    width: 38px;
    height: 38px;
  }

  .btn-primary,
  .btn-secondary,
  .btn-boost,
  .btn-danger-outline {
    min-height: 44px;
  }
}

@media (orientation: landscape) and (max-width: 899px) {
  .orientation-lock:not(.hidden) {
    display: grid;
  }
}

/* Modal Pagination for 1,000+ Levels */
.modal-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1.5px solid rgba(196, 152, 118, 0.25);
  flex-wrap: wrap;
}

.btn-page {
  width: 34px;
  height: 30px;
  border-radius: 10px;
  border: 1.5px solid rgba(196, 152, 118, 0.5);
  background: #fff7ed;
  color: var(--purple-deep);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}

.btn-page:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--purple-deep);
  min-width: 58px;
  text-align: center;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.page-jump-input {
  width: 58px;
  height: 30px;
  border-radius: 10px;
  border: 1.5px solid rgba(196, 152, 118, 0.5);
  background: #ffffff;
  color: var(--purple-deep);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  padding: 0 7px;
  text-align: center;
}

.btn-page-go {
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: none;
  background: var(--purple-main);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.level-card-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #8a6454;
  margin-top: 2px;
}
