:root {
  color-scheme: light;
  --page-bg: #f9b6cd;
  --page-bg-soft: #ffdbe7;
  --frame: #f7f1ff;
  --card: #fff7fb;
  --line: #ffffff;
  --orange: #f7ad46;
  --orange-soft: #ffd988;
  --orange-deep: #f08f2e;
  --blue: #5fa3ef;
  --blue-deep: #3377c4;
  --green: #41b66c;
  --green-soft: #dbf7e6;
  --red: #d8616d;
  --red-soft: #ffe0e5;
  --number-accent: #7a63d9;
  --number-accent-soft: #efe9ff;
  --text: #583d4f;
  --text-strong: #3a2834;
  --shadow: 0 14px 34px rgba(115, 43, 82, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 28%),
    linear-gradient(180deg, var(--page-bg-soft) 0%, var(--page-bg) 100%);
  color: var(--text);
}

body {
  padding: 0;
  min-height: 100dvh;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 10px 12px 16px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hero {
  flex-shrink: 0;
  padding: 14px 8px 8px;
}

.top-bar {
  --top-bar-pill-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.top-bar-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.top-bar-side {
  display: flex;
  align-items: center;
  min-width: 0;
}

.top-bar-side-left {
  justify-content: flex-start;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.top-bar-side-right {
  justify-content: flex-end;
}

.help-button,
.joker-button,
.title-brand {
  min-height: var(--top-bar-pill-height);
}

.help-button,
.joker-button {
  padding: 14px 16px 16px 18px;
  border-radius: 999px;
}

.help-button,
.joker-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.help-button {
  min-width: 72px;
  background: linear-gradient(180deg, #fff7fb 0%, #ffe1ef 100%);
  color: #8a5071;
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 250, 0.95),
    0 12px 26px rgba(168, 95, 131, 0.12);
  gap: 8px;
}

.help-button:disabled {
  opacity: 0.55;
}

.help-icon {
  font-size: 1.28rem;
  line-height: 1;
}

.help-label {
  font-size: 1rem;
  line-height: 1;
}

.joker-button {
  background: linear-gradient(180deg, #fff7c9 0%, #ffd86d 100%);
  color: #72511b;
  box-shadow:
    inset 0 0 0 2px rgba(255, 248, 208, 0.95),
    0 12px 26px rgba(171, 112, 34, 0.18);
  gap: 10px;
}

.joker-button:disabled {
  opacity: 0.55;
}

.joker-label {
  font-size: 1.12rem;
  line-height: 1;
}

.joker-count {
  min-width: 34px;
  min-height: 34px;
  padding: 0 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  color: #8f5b13;
  box-shadow: inset 0 0 0 2px rgba(255, 230, 156, 0.95);
  font-size: 1.02rem;
}

.title-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: min(100%, 22rem);
  padding: 12px clamp(18px, 5vw, 28px) 14px;
  border-radius: 999px;
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(255, 247, 252, 0.94) 50%,
    rgba(240, 248, 255, 0.9) 100%
  );
  border: 3px solid rgba(255, 255, 255, 0.98);
  box-shadow:
    0 4px 0 rgba(255, 255, 255, 0.55) inset,
    0 12px 32px rgba(91, 153, 225, 0.22),
    0 4px 14px rgba(115, 43, 82, 0.08);
}

.title-exit-button {
  margin: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  gap: 8px;
}

.title-exit-button:active {
  transform: scale(0.98);
}

.title-exit-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  color: var(--blue-deep);
  opacity: 0.9;
}

.title-exit-icon svg {
  display: block;
}

.title-main {
  margin: 0;
  font-family: "Nunito", Arial, Helvetica, sans-serif;
  font-weight: 900;
  font-size: clamp(1.22rem, 3.4vw, 1.38rem);
  line-height: 1.05;
  letter-spacing: 0.03em;
  max-width: min(100%, 22ch);
  background: linear-gradient(
    120deg,
    var(--blue-deep) 0%,
    var(--blue) 28%,
    #8b7fd4 62%,
    #c38df4 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.45));
}

@keyframes titleFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .picker-choice.is-joker-revealed,
  .picker-choice.is-joker-revealed::before {
    animation: none;
  }
}

.card {
  background: var(--card);
  border: 4px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.message-panel,
.board {
  padding: 18px;
  margin-top: 14px;
}

.message-panel {
  flex-shrink: 0;
}

.board {
  padding: 10px 0 0;
  margin-top: 8px;
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

main {
  display: flex;
  flex: 1 1 0%;
  min-height: 0;
}

.section-note {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #73586d;
}

.message-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 8px;
}

.message-char,
.message-space {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 40px;
}

.message-char {
  min-width: 38px;
  border-radius: 12px;
  background: #fff0f6;
  border: 2px solid #ffd3e0;
  font-size: 1.3rem;
  font-weight: 700;
  position: relative;
}

.message-char.is-hidden {
  color: transparent;
  position: relative;
}

.message-char.is-hidden::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 9px;
  height: 4px;
  border-radius: 999px;
  background: #e3a4bd;
}

.message-char.is-celebrating {
  animation: revealBounce 700ms cubic-bezier(0.2, 0.9, 0.2, 1);
  transform-origin: center bottom;
  z-index: 1;
}

.tiles {
  display: flex;
  flex: 1 1 0%;
  min-height: 0;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.tile {
  --tile-top: #ffd991;
  --tile-bottom: #f7ad46;
  --tile-border: #fff4d7;
  --tile-surface: rgba(255, 255, 255, 0.78);
  --tile-inline: rgba(255, 248, 252, 0.72);
  --picked-bg: #d9ecff;
  --picked-ring: #5fa3ef;
  padding: 12px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--tile-top) 0%, var(--tile-bottom) 100%);
  border: 3px solid var(--tile-border);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.tile.is-active {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(109, 62, 18, 0.16);
  outline: 4px solid rgba(95, 163, 239, 0.34);
}

.tile.is-entering {
  animation: tileSlideIn 360ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

@keyframes tileWrongShake {
  0%,
  100% {
    transform: translate3d(0, -1px, 0);
  }
  15% {
    transform: translate3d(-10px, -1px, 0);
  }
  30% {
    transform: translate3d(9px, -1px, 0);
  }
  45% {
    transform: translate3d(-7px, -1px, 0);
  }
  60% {
    transform: translate3d(6px, -1px, 0);
  }
  75% {
    transform: translate3d(-4px, -1px, 0);
  }
  90% {
    transform: translate3d(2px, -1px, 0);
  }
}

.tile.is-wrong {
  background: linear-gradient(180deg, #ffd6de 0%, #ff8ea0 100%);
  border-color: #ffd8df;
  transition: background 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  animation: tileWrongShake 450ms cubic-bezier(0.36, 0.07, 0.25, 1);
  transform-origin: center center;
}

@media (prefers-reduced-motion: reduce) {
  .tile.is-wrong {
    animation: none;
    transform: translateY(-1px);
  }
}

.tile.is-wrong .equation-button {
  background: rgba(255, 244, 246, 0.92);
  box-shadow: inset 0 0 0 2px rgba(219, 97, 109, 0.3);
}

.tile.is-wrong .answer-slot {
  background: #fff4f6;
  border-color: #f3a4af;
  color: #8c2638;
}

.equation-button {
  width: 100%;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--tile-surface);
  color: var(--text-strong);
  min-height: 72px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: left;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65);
}

.sentence-timer {
  height: 16px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
  overflow: hidden;
}

.sentence-timer-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7fd7ff 0%, #7fa8ff 45%, #b98fff 100%);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.25);
}

.sentence-timer-bar.is-warning {
  background: linear-gradient(90deg, #ffd36b 0%, #ffb45f 55%, #ff8d65 100%);
}

.sentence-timer-bar.is-danger {
  background: linear-gradient(90deg, #ff8c8c 0%, #ff6f86 50%, #ff5670 100%);
  box-shadow:
    inset 0 0 10px rgba(255, 255, 255, 0.22),
    0 0 12px rgba(255, 111, 134, 0.28);
}

.sentence-retry-panel {
  margin-top: 12px;
  padding: 18px 16px;
  border-radius: 18px;
  background: rgba(255, 249, 238, 0.94);
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  text-align: center;
}

.retry-button {
  min-height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff0f5 0%, #ffc9da 100%);
  color: #873f62;
  box-shadow:
    inset 0 0 0 2px rgba(255, 238, 245, 0.95),
    0 8px 18px rgba(156, 77, 112, 0.18);
  font-weight: 900;
}

.equation-button:focus-visible,
.picker-choice:focus-visible {
  outline: 4px solid rgba(51, 119, 196, 0.3);
  outline-offset: 2px;
}

.equation-text {
  font-size: clamp(1.15rem, 5vw, 1.58rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.equation-number {
  color: var(--number-accent);
}

.equation-symbol {
  color: var(--text-strong);
}

.answer-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.answer-slot {
  min-width: 56px;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: 16px;
  background: #fffdf8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.62rem;
  font-weight: 700;
  border: 2px solid #ffe9bf;
}

.number-slot {
  color: var(--number-accent);
  border-color: #d9cfff;
  background: var(--number-accent-soft);
}

.letter-slot {
  min-width: 56px;
}

.success-card {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #dcf5e4 0%, #bdeccf 100%);
  border: 2px solid #eefcf2;
  color: #225739;
  font-weight: 800;
  text-align: center;
}

.success-card h3,
.success-card p {
  margin: 0;
}

.success-card p {
  margin-top: 8px;
  font-weight: 700;
}

.inline-picker {
  display: none;
  margin-top: 10px;
  padding: 10px;
  border-radius: 18px;
  background: var(--tile-inline);
  border: 2px solid rgba(255, 255, 255, 0.72);
}

.tile.is-active .inline-picker {
  display: block;
}

.tile.is-entering .inline-picker {
  animation: tileSlideIn 420ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 0;
  align-content: start;
}

.picker-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 48px;
  padding: 4px 6px;
  position: relative;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: var(--text-strong);
  box-shadow: inset 0 0 0 2px #ffe1ad;
  font-size: 1.05rem;
  font-weight: 800;
  transition: opacity 180ms ease;
}

.picker-choice.is-picked {
  background: var(--picked-bg);
  box-shadow: inset 0 0 0 3px var(--picked-ring);
}

.picker-choice.is-joker-revealed {
  background: transparent;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.75),
    0 0 16px rgba(108, 182, 255, 0.42);
  isolation: isolate;
  animation: jokerRainbowPulse 1550ms ease-in-out infinite;
}

.picker-choice.is-joker-revealed::before,
.picker-choice.is-joker-revealed::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.picker-choice.is-joker-revealed::before {
  inset: -3px;
  border-radius: 16px;
  background: conic-gradient(
    from 0deg,
    #ff7fad 0deg,
    #ffd45f 72deg,
    #7ce6a3 144deg,
    #68c6ff 216deg,
    #b986ff 288deg,
    #ff7fad 360deg
  );
  animation: jokerRainbowSpin 1350ms linear infinite;
}

.picker-choice.is-joker-revealed::after {
  inset: 3px;
  border-radius: 11px;
  background: linear-gradient(180deg, #f3fbff 0%, #def4ff 100%);
}

.picker-choice.is-joker-revealed .picker-choice-letter {
  position: relative;
  z-index: 1;
}

.picker-choice.is-joker-dimmed {
  opacity: 0.25;
}

.picker-choice.is-disabled-choice {
  background: linear-gradient(180deg, #fff0f3 0%, #ffd7df 100%);
  color: #8c2638;
  box-shadow:
    inset 0 0 0 2px rgba(216, 97, 109, 0.55),
    inset 0 10px 18px rgba(255, 255, 255, 0.35);
}

.picker-choice.is-disabled-choice::after {
  content: "";
}

.picker-choice.is-disabled-choice .picker-choice-letter {
  visibility: hidden;
}

.picker-choice-letter {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
}

.choice-helper {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--number-accent);
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(92, 53, 78, 0.28);
}

.help-overlay[hidden] {
  display: none;
}

.help-overlay-card {
  position: relative;
  width: min(100%, 420px);
  padding: 22px 18px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdf6 0%, #fff4fb 100%);
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 18px 40px rgba(115, 43, 82, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.help-close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #fff0f6;
  color: var(--text-strong);
  box-shadow: inset 0 0 0 2px #ffd9e6;
  font-size: 1.3rem;
  line-height: 1;
}

.help-overlay-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-strong);
}

.help-overlay-copy {
  margin: 10px 0 0;
  font-size: 1.02rem;
  line-height: 1.45;
  font-weight: 700;
}

.help-overlay-progress {
  height: 12px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(180, 180, 192, 0.4);
  overflow: hidden;
}

.help-overlay-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #7f97bd;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.35);
}

.loading,
.error-state {
  padding: 18px;
  border-radius: 18px;
  background: #fff9ef;
  font-weight: 700;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.confetti-piece {
  position: fixed;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  opacity: 0.95;
  animation: confettiBurst 850ms ease-out forwards;
}

@keyframes revealBounce {
  0% {
    transform: scale(0.7) translateY(8px);
  }

  35% {
    transform: scale(1.28) translateY(-10px);
  }

  55% {
    transform: scale(0.95) translateY(2px);
  }

  75% {
    transform: scale(1.12) translateY(-4px);
  }

  100% {
    transform: scale(1) translateY(0);
  }
}

@keyframes tileSlideIn {
  0% {
    opacity: 0;
    transform: translateX(26px);
  }

  65% {
    opacity: 1;
    transform: translateX(-5px);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes confettiBurst {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate3d(var(--burst-x), var(--burst-y), 0) rotate(var(--burst-rotate)) scale(0.7);
    opacity: 0;
  }
}

@keyframes jokerRainbowSpin {
  0%,
  100% {
    transform: rotate(360deg);
  }
}

@keyframes jokerRainbowPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.75),
      0 0 14px rgba(108, 182, 255, 0.34);
  }

  50% {
    transform: scale(1.045);
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.9),
      0 0 24px rgba(183, 128, 255, 0.42),
      0 0 32px rgba(97, 203, 255, 0.28);
  }
}

@media (max-width: 700px) {
  html,
  body {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 2px 8px max(6px, env(safe-area-inset-bottom, 0));
  }

  .hero {
    padding: 0 4px 0;
  }

  .top-bar {
    --top-bar-pill-height: 50px;
    gap: 5px;
  }

  .help-button,
  .joker-button {
    padding: 4px 7px;
    gap: 4px;
  }

  .help-button {
    min-width: 50px;
  }

  .title-brand {
    min-height: var(--top-bar-pill-height);
    max-width: min(100%, 13.5rem);
    gap: 5px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .joker-label {
    font-size: 0.9rem;
  }

  .joker-count {
    min-width: 20px;
    min-height: 20px;
    padding: 0 5px;
    font-size: 0.72rem;
  }

  .help-icon {
    font-size: 1.08rem;
  }

  .title-brand {
    padding: 2px 8px 4px;
    border-width: 2px;
    box-shadow:
      0 3px 0 rgba(255, 255, 255, 0.55) inset,
      0 8px 20px rgba(91, 153, 225, 0.16),
      0 2px 8px rgba(115, 43, 82, 0.06);
  }

  .title-main {
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    max-width: min(100%, 11ch);
  }

  .title-exit-icon svg {
    width: 17px;
    height: 17px;
  }

  .message-panel {
    flex-shrink: 1;
    min-height: 0;
    padding: 10px;
    margin-top: 6px;
    border-width: 3px;
  }

  .section-note {
    font-size: 0.85rem;
  }

  .message-strip {
    gap: 8px 8px;
    max-height: min(176px, 40dvh);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .message-char,
  .message-space {
    height: 42px;
  }

  .message-char {
    min-width: 36px;
    font-size: 1.32rem;
    border-radius: 12px;
  }

  .message-char.is-hidden::after {
    left: 8px;
    right: 8px;
    bottom: 9px;
  }

  .board {
    margin-top: 4px;
    padding-top: 2px;
    overflow: hidden;
  }

  main {
    overflow: hidden;
  }

  .tiles {
    overflow: hidden;
  }

  .tile {
    overflow-y: hidden;
    padding: 6px;
    border-radius: 18px;
  }

  .equation-button {
    min-height: 62px;
    padding: 8px 10px;
  }

  .sentence-timer {
    height: 12px;
    margin-top: 8px;
  }

  .sentence-retry-panel {
    margin-top: 10px;
    padding: 14px 12px;
    border-radius: 14px;
  }

  .retry-button {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 14px;
    font-size: 0.92rem;
  }

  .equation-text {
    font-size: clamp(1.02rem, 4.5vw, 1.45rem);
  }

  .answer-slot {
    min-width: 50px;
    min-height: 46px;
    padding: 6px 8px;
    font-size: 1.38rem;
    border-radius: 13px;
  }

  .letter-slot {
    min-width: 50px;
  }

  .inline-picker {
    padding: 6px;
    margin-top: 6px;
    border-radius: 12px;
  }

  .picker-grid {
    gap: 3px;
  }

  .picker-choice {
    min-height: 58px;
    padding: 2px;
    border-radius: 11px;
    font-size: 1.12rem;
  }

  .choice-helper {
    font-size: 0.9rem;
  }

  .help-overlay {
    padding: 12px;
  }

  .help-overlay-card {
    width: min(100%, 340px);
    padding: 18px 14px 14px;
    border-radius: 18px;
  }

  .help-close-button {
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    font-size: 1.1rem;
  }

  .help-overlay-title {
    font-size: 0.92rem;
  }

  .help-overlay-copy {
    margin-top: 8px;
    font-size: 0.9rem;
    line-height: 1.34;
  }

  .help-overlay-progress {
    height: 10px;
    margin-top: 10px;
  }

  .gallery-shell {
    padding: 18px 14px 18px;
    border-radius: 24px;
  }

  .gallery-badge-row {
    gap: 6px;
    margin-bottom: 12px;
  }

  .gallery-badge {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.68rem;
  }

  .gallery-hero-mark {
    gap: 8px;
    margin-bottom: 12px;
  }

  .gallery-hero-bubble {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .gallery-title {
    font-size: clamp(1.38rem, 5.6vw, 1.7rem);
  }

  .gallery-subtitle {
    font-size: 0.9rem;
  }

  .collection-card {
    padding: 14px 14px 14px 16px;
    border-radius: 18px;
  }

  .collection-card-state {
    min-height: 25px;
    padding: 0 9px;
    font-size: 0.64rem;
  }

  .collection-card-title {
    font-size: 1rem;
  }

  .collection-card-meta {
    font-size: 0.82rem;
  }

  .collection-card-badge {
    width: 32px;
    height: 32px;
    font-size: 0.92rem;
  }
}

@media (min-width: 700px) {
  .picker-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* ——— Collection gallery ——— */
/* `hidden` must win over layout display — otherwise the gallery stays on top of the game. */
.view-gallery[hidden],
.view-play[hidden] {
  display: none !important;
}

.view-gallery {
  min-height: 100dvh;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg-page, linear-gradient(165deg, #e8f4ff 0%, #fff5e6 45%, #f5e8ff 100%));
}

.gallery-shell {
  width: min(100%, 520px);
  padding: 20px 18px 22px;
  margin-top: 8px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(255, 220, 120, 0.34), transparent 30%),
    radial-gradient(circle at top left, rgba(116, 182, 255, 0.22), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 247, 251, 0.96) 100%);
  isolation: isolate;
}

.gallery-shell::before,
.gallery-shell::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.gallery-shell::before {
  top: -42px;
  right: -58px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(255, 212, 95, 0.32) 0%, rgba(255, 212, 95, 0) 72%);
}

.gallery-shell::after {
  bottom: -70px;
  left: -50px;
  width: 170px;
  height: 170px;
  background: radial-gradient(circle, rgba(115, 193, 255, 0.18) 0%, rgba(115, 193, 255, 0) 72%);
}

.gallery-header {
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.gallery-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.gallery-sparkle {
  position: absolute;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 240, 173, 0.95) 100%);
  clip-path: polygon(50% 0%, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0% 50%, 37% 37%);
  opacity: 0.8;
  filter: drop-shadow(0 0 10px rgba(255, 205, 84, 0.32));
  animation: sparkleFloat 5.2s ease-in-out infinite;
}

.gallery-sparkle-a {
  top: 34px;
  left: 26px;
  animation-delay: -0.4s;
}

.gallery-sparkle-b {
  top: 76px;
  right: 68px;
  width: 18px;
  height: 18px;
  animation-delay: -2.2s;
}

.gallery-sparkle-c {
  right: 34px;
  bottom: 94px;
  width: 12px;
  height: 12px;
  animation-delay: -1.1s;
}

.gallery-sparkle-d {
  left: 54px;
  bottom: 48px;
  width: 16px;
  height: 16px;
  animation-delay: -3.2s;
}

.gallery-badge-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  animation: galleryFadeUp 700ms ease-out both;
}

.gallery-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff5bd 0%, #ffd77b 100%);
  color: #805100;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow:
    inset 0 0 0 2px rgba(255, 248, 215, 0.95),
    0 8px 18px rgba(190, 135, 26, 0.14);
}

.gallery-badge-soft {
  background: linear-gradient(180deg, #edf6ff 0%, #d9ebff 100%);
  color: #42699c;
  box-shadow:
    inset 0 0 0 2px rgba(246, 251, 255, 0.95),
    0 8px 18px rgba(72, 116, 176, 0.1);
}

.gallery-hero-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
  animation: galleryFadeUp 820ms ease-out both;
}

.gallery-hero-bubble {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Nunito", Arial, Helvetica, sans-serif;
  font-size: 1.24rem;
  font-weight: 900;
  color: #4b3657;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 240, 246, 0.92) 100%);
  border: 2px solid rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 24px rgba(115, 43, 82, 0.12);
  transform: rotate(-4deg);
  animation: heroBubbleFloat 4.6s ease-in-out infinite;
}

.gallery-hero-bubble:nth-child(2) {
  color: #416bc8;
  transform: translateY(7px) rotate(4deg);
  animation-duration: 4s;
  animation-delay: -1.4s;
}

.gallery-hero-bubble:nth-child(3) {
  color: #2f9b6a;
  transform: rotate(6deg);
  animation-duration: 5.4s;
  animation-delay: -2.1s;
}

.gallery-title {
  font-size: clamp(1.55rem, 5vw, 1.95rem);
  margin: 0;
  letter-spacing: 0.02em;
  color: #3a2834;
  animation: galleryFadeUp 950ms ease-out both;
}

.gallery-subtitle {
  max-width: 32ch;
  margin: 10px auto 0;
  font-size: 0.96rem;
  line-height: 1.5;
  color: rgba(58, 40, 52, 0.72);
  animation: galleryFadeUp 1080ms ease-out both;
}

.collection-gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.gallery-loading {
  text-align: center;
  padding: 28px 12px;
  font-size: 0.95rem;
  color: rgba(0, 0, 0, 0.55);
}

.collection-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 16px 16px 16px 18px;
  text-align: left;
  font-family: inherit;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(255, 250, 241, 0.96) 48%,
    rgba(245, 248, 255, 0.94) 100%
  );
  box-shadow:
    0 16px 34px rgba(96, 55, 88, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.22s ease,
    border-color 0.2s ease,
    background 0.2s ease;
  animation:
    galleryCardIn 620ms cubic-bezier(0.2, 0.9, 0.2, 1) both,
    galleryCardBob 4.8s ease-in-out infinite;
  animation-delay:
    calc(var(--card-index, 0) * 90ms),
    calc(700ms + var(--card-index, 0) * 120ms);
}

.collection-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent 55%);
  pointer-events: none;
}

.collection-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 18px 38px rgba(96, 55, 88, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.collection-card:active:not(:disabled) {
  transform: scale(0.98);
}

.collection-card-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a5c14;
  background: rgba(255, 238, 194, 0.9);
  box-shadow: inset 0 0 0 1px rgba(255, 224, 153, 0.95);
}

.collection-card-title {
  font-weight: 900;
  font-size: 1.14rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: #332532;
}

.collection-card-meta {
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(51, 37, 50, 0.58);
}

.collection-card-progress {
  position: relative;
  width: 100%;
  height: 10px;
  margin-top: 2px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(224, 209, 229, 0.52);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.52);
}

.collection-card-progress-bar {
  display: block;
  height: 100%;
  width: var(--progress-width, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #7fa8ff 0%, #a482ff 55%, #ff9fba 100%);
  box-shadow: 0 0 12px rgba(127, 168, 255, 0.3);
  animation:
    galleryProgressIn 900ms cubic-bezier(0.2, 0.9, 0.2, 1) both,
    galleryProgressGlow 2.4s ease-in-out infinite;
  animation-delay:
    calc(160ms + var(--card-index, 0) * 90ms),
    calc(1200ms + var(--card-index, 0) * 120ms);
}

.collection-card-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #2e9d5c;
  font-weight: 900;
  background: rgba(239, 255, 245, 0.95);
  box-shadow: inset 0 0 0 2px rgba(192, 241, 210, 0.95);
}

.collection-card--locked {
  opacity: 0.62;
  cursor: not-allowed;
  filter: grayscale(0.16) saturate(0.88);
  box-shadow: none;
}

.collection-card--locked .collection-card-state {
  color: #6f6784;
  background: rgba(231, 229, 238, 0.92);
  box-shadow: inset 0 0 0 1px rgba(206, 201, 220, 0.95);
}

.collection-card--done:not(.collection-card--locked) {
  border-color: rgba(46, 157, 92, 0.35);
  background: linear-gradient(
    145deg,
    rgba(240, 255, 245, 0.95) 0%,
    rgba(255, 255, 255, 0.92) 60%,
    rgba(237, 255, 245, 0.96) 100%
  );
}

.collection-card--done .collection-card-state {
  color: #1f7b47;
  background: rgba(220, 247, 229, 0.96);
  box-shadow: inset 0 0 0 1px rgba(181, 235, 201, 0.95);
}

.collection-card--active:not(.collection-card--locked) {
  border-color: rgba(218, 165, 32, 0.85);
  background: linear-gradient(
    145deg,
    rgba(255, 251, 228, 0.98) 0%,
    rgba(255, 244, 214, 0.96) 45%,
    rgba(255, 255, 255, 0.98) 100%
  );
  box-shadow:
    0 0 0 3px rgba(255, 215, 100, 0.55),
    0 0 28px rgba(255, 190, 60, 0.45),
    0 6px 18px rgba(120, 80, 0, 0.12);
  animation: collection-golden-pulse 2.4s ease-in-out infinite;
}

.collection-card--active .collection-card-state {
  color: #8f5b13;
  background: rgba(255, 239, 189, 0.96);
}

@keyframes collection-golden-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(255, 215, 100, 0.5),
      0 0 24px rgba(255, 190, 60, 0.4),
      0 6px 18px rgba(120, 80, 0, 0.1);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(255, 230, 140, 0.65),
      0 0 34px rgba(255, 200, 80, 0.55),
      0 8px 22px rgba(120, 80, 0, 0.14);
  }
}

@keyframes galleryFadeUp {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sparkleFloat {
  0%,
  100% {
    opacity: 0.45;
    transform: translate3d(0, 0, 0) scale(0.88) rotate(0deg);
  }

  50% {
    opacity: 1;
    transform: translate3d(0, -10px, 0) scale(1.12) rotate(14deg);
  }
}

@keyframes heroBubbleFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }

  50% {
    transform: translateY(-8px) rotate(2deg);
  }
}

@keyframes galleryCardIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes galleryCardBob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

@keyframes galleryProgressIn {
  0% {
    width: 0;
  }

  100% {
    width: var(--progress-width, 0%);
  }
}

@keyframes galleryProgressGlow {
  0%,
  100% {
    filter: saturate(1);
    box-shadow: 0 0 12px rgba(127, 168, 255, 0.22);
  }

  50% {
    filter: saturate(1.08);
    box-shadow: 0 0 18px rgba(183, 130, 255, 0.28);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-badge-row,
  .gallery-hero-mark,
  .gallery-title,
  .gallery-subtitle,
  .gallery-sparkle,
  .gallery-hero-bubble,
  .collection-card,
  .collection-card-progress-bar,
  .collection-card--active:not(.collection-card--locked) {
    animation: none;
  }
}

.success-next-button {
  margin-top: 16px;
  width: 100%;
  font-family: inherit;
  font-weight: 900;
  font-size: 1rem;
  padding: 14px 16px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  color: #2a1f08;
  background: linear-gradient(180deg, #ffe08a 0%, #f0b73a 100%);
  box-shadow: 0 3px 0 rgba(180, 120, 20, 0.35);
}

.success-next-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(180, 120, 20, 0.35);
}
