:root {
  --night: #1b1446;
  --night-2: #2a1f66;
  --night-3: #3a2c85;
  --gold: #ffc93c;
  --gold-deep: #f5a30b;
  --coral: #ff6b6b;
  --teal: #2ec4b6;
  --sky: #5ab0ff;
  --cream: #fff8e7;
  --paper: #fffdf6;
  --ink: #2b2250;
  --ink-soft: #5b5486;
  --green: #22c55e;
  --green-deep: #15803d;
  --red: #ef4444;
  --white: #ffffff;
  --muted: #c9c3f0;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
  --font-play: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --font-read: "Andika", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--night);
  color: var(--white);
  font-family: var(--font-play);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff 60%, transparent 61%),
    radial-gradient(1px 1px at 25% 70%, #fff 60%, transparent 61%),
    radial-gradient(2px 2px at 40% 35%, #ffe9a8 60%, transparent 61%),
    radial-gradient(1px 1px at 55% 85%, #fff 60%, transparent 61%),
    radial-gradient(1.5px 1.5px at 70% 15%, #fff 60%, transparent 61%),
    radial-gradient(1px 1px at 82% 55%, #fff 60%, transparent 61%),
    radial-gradient(2px 2px at 92% 80%, #ffe9a8 60%, transparent 61%),
    radial-gradient(1px 1px at 5% 92%, #fff 60%, transparent 61%),
    radial-gradient(1.5px 1.5px at 62% 48%, #fff 60%, transparent 61%),
    radial-gradient(ellipse at 50% 120%, #4b2f9a 0%, transparent 60%),
    linear-gradient(180deg, #120d33 0%, var(--night) 45%, #251a5e 100%);
}

/* ---------- screens ---------- */
.screen { display: none; min-height: 100vh; padding: 16px; }
.screen.active { display: block; animation: screenIn 0.35s ease; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-play);
  font-weight: 600;
  font-size: 1.1rem;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  color: var(--ink);
  background: var(--cream);
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn-small { font-size: 0.95rem; padding: 8px 16px; }
.btn-ghost { background: rgba(255, 255, 255, 0.12); color: var(--white); box-shadow: none; border: 2px solid rgba(255, 255, 255, 0.25); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.2); }
.btn-go {
  background: linear-gradient(180deg, #ffd45e, var(--gold-deep));
  color: #4a2a00;
  font-size: 1.5rem;
  padding: 12px 38px;
  box-shadow: 0 6px 0 #b86f00;
}
.btn-go:active { box-shadow: 0 2px 0 #b86f00; }
.btn-danger { background: var(--red); color: white; }

/* ---------- home ---------- */
#screen-home { max-width: 980px; margin: 0 auto; }
.hero { text-align: center; padding: 12px 0 4px; }
.logo { margin: 0; line-height: 0.9; }
.logo-line { display: block; font-weight: 700; letter-spacing: 0.5px; }
.logo-line:first-child { font-size: clamp(1.6rem, 5vw, 2.4rem); color: var(--teal); }
.logo-big {
  font-size: clamp(3rem, 12vw, 5.5rem);
  color: var(--gold);
  text-shadow: 0 5px 0 #b86f00, 0 10px 24px rgba(255, 201, 60, 0.35);
}
.logo-star { display: inline-block; margin-left: 6px; animation: twirl 4s ease-in-out infinite; }
@keyframes twirl { 0%, 100% { transform: rotate(-12deg) scale(1); } 50% { transform: rotate(14deg) scale(1.15); } }
.tagline { font-size: 1.2rem; color: var(--muted); margin: 14px 0 0; }

.how {
  background: rgba(255, 255, 255, 0.07);
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 20px auto 8px;
  max-width: 760px;
}
.how ol { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.how li { display: flex; gap: 10px; align-items: flex-start; font-size: 1.05rem; line-height: 1.3; }
.how-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--teal); color: var(--night); display: grid; place-items: center; font-weight: 700;
}
.how-goal { text-align: center; margin: 12px 0 0; color: var(--cream); }
.how-goal b { color: var(--gold); }

.section-title { text-align: center; font-size: 1.6rem; margin: 22px 0 12px; }
.level-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.level-card {
  position: relative;
  text-align: left;
  font-family: var(--font-play);
  border: 0; cursor: pointer;
  border-radius: 22px;
  padding: 16px 16px 14px;
  color: var(--ink);
  background: var(--cream);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 150px;
}
.level-card:hover { transform: translateY(-3px) rotate(-0.6deg); }
.level-card:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28); }
.level-card[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.level-card .lv-emoji { font-size: 2.2rem; line-height: 1; }
.level-card .lv-name { font-size: 1.45rem; font-weight: 700; }
.level-card .lv-blurb { font-size: 0.98rem; color: var(--ink-soft); line-height: 1.25; }
.level-card .lv-meta { margin-top: auto; font-size: 0.85rem; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap; padding-top: 8px; }
.lv-pill { background: rgba(43, 34, 80, 0.08); padding: 2px 8px; border-radius: 999px; }
.lv-best { color: #a15c00; font-weight: 600; }
.level-card.custom { background: #e6fbf8; }
.lv-tag { position: absolute; top: 12px; right: 12px; font-size: 0.75rem; background: var(--teal); color: var(--night); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.level-card:nth-child(5n+1) { border-bottom: 6px solid var(--gold); }
.level-card:nth-child(5n+2) { border-bottom: 6px solid var(--teal); }
.level-card:nth-child(5n+3) { border-bottom: 6px solid var(--coral); }
.level-card:nth-child(5n+4) { border-bottom: 6px solid var(--sky); }
.level-card:nth-child(5n+5) { border-bottom: 6px solid #b088ff; }

.home-foot { display: flex; justify-content: center; gap: 12px; margin: 28px 0 12px; flex-wrap: wrap; }

/* ---------- game ---------- */
#screen-game { max-width: 1100px; margin: 0 auto; padding-top: 10px; }
.game-bar {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 8px 10px;
}
#btn-quit { white-space: nowrap; flex: none; }
.game-level { font-size: 1.15rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star-meter { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.star-count {
  display: flex; align-items: center; gap: 4px;
  font-size: 1.7rem; font-weight: 700; color: var(--gold);
  min-width: 96px; justify-content: flex-end;
  text-shadow: 0 3px 0 #8a5300;
}
.star-icon { display: inline-block; }
.star-count.pulse .star-icon { animation: starPulse 0.35s ease; }
@keyframes starPulse { 50% { transform: scale(1.6) rotate(20deg); } }
.star-count.shake { animation: shake 0.5s ease; color: var(--coral); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
.meter { position: relative; width: 140px; height: 14px; background: rgba(0, 0, 0, 0.35); border-radius: 999px; overflow: visible; }
.meter-fill { height: 100%; width: 40%; border-radius: 999px; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width 0.5s ease; }
.meter-goal { position: absolute; right: -2px; top: -20px; font-size: 0.7rem; color: var(--muted); }

.round-info { display: flex; justify-content: space-between; align-items: center; padding: 10px 8px 4px; color: var(--muted); font-size: 1.05rem; }
.tries { display: flex; gap: 6px; }
.try-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px rgba(255, 201, 60, 0.6); transition: all 0.3s; }
.try-dot.used { background: rgba(255, 255, 255, 0.15); box-shadow: none; }

.board {
  display: grid;
  grid-template-columns: 1fr minmax(0, 2.2fr) 1fr;
  grid-template-rows: auto minmax(200px, auto) auto;
  grid-template-areas:
    "s0 s1 s2"
    "s3 mid s4"
    "s5 s6 s7";
  gap: 22px 18px;
  align-items: center;
  justify-items: center;
  margin-top: 10px;
}
.sentence-panel {
  grid-area: mid;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px;
  padding: 22px 22px 18px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3), inset 0 0 0 4px #ffe7a3;
  text-align: center;
  min-height: 200px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
}
.sentence {
  font-family: var(--font-read);
  font-size: clamp(1.4rem, 3.2vw, 2.1rem);
  line-height: 1.5;
  font-weight: 700;
}
.sentence .prompt { font-family: var(--font-play); font-weight: 600; color: var(--ink-soft); font-size: clamp(1.2rem, 2.6vw, 1.6rem); }
.sentence.reveal { animation: sentenceIn 0.45s ease; }
@keyframes sentenceIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.blank {
  display: inline-block;
  min-width: 4.2em;
  border-bottom: 5px solid var(--sky);
  color: transparent;
  margin: 0 0.08em;
  line-height: 1.1;
  vertical-align: baseline;
  transition: color 0.3s;
}
.blank.filled { color: var(--green-deep); border-bottom-color: var(--green); animation: blankPop 0.5s ease; }
.blank.filled.missed { color: #b45309; border-bottom-color: var(--gold-deep); }
@keyframes blankPop { 40% { transform: scale(1.25); } }
/* words inside the sentence (for wave + read-along) */
.sentence .w {
  display: inline-block;
  padding: 0 0.06em;
  border-radius: 10px;
  transition: transform 0.16s ease, color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
  transform-origin: 50% 80%;
}
.sentence.reading .w { color: #8a85ad; }
.sentence.reading .w.spoken { color: var(--ink); }
.sentence.reading .w.speaking {
  color: #6d28d9;
  background: #fff1b8;
  box-shadow: 0 0 0 4px #fff1b8, 0 6px 14px rgba(245, 163, 11, 0.35);
  transform: translateY(-5px) scale(1.16);
  position: relative;
  z-index: 1;
}
.sentence.reading .w.speaking .blank { color: var(--green-deep); }
.sentence.reading .w.speaking .blank.missed { color: #b45309; }
.sentence.wave .w { animation: wordWave 0.55s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes wordWave {
  0% { transform: none; }
  40% { transform: translateY(-14px) scale(1.12) rotate(-3deg); color: #6d28d9; }
  100% { transform: none; }
}
.blank.pending { color: transparent !important; border-bottom-color: var(--gold); animation: blankWait 0.5s ease-in-out infinite alternate; }
@keyframes blankWait { to { box-shadow: 0 6px 14px rgba(255, 201, 60, 0.6); } }
.blank.landing { animation: wordLand 0.8s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes wordLand {
  0% { transform: scale(2.2) rotate(-6deg); text-shadow: 0 0 30px rgba(34, 197, 94, 0.9); }
  35% { transform: scale(0.85) rotate(2deg); }
  60% { transform: scale(1.18); text-shadow: 0 0 22px rgba(255, 201, 60, 0.9); }
  100% { transform: none; text-shadow: none; }
}
.fly-word {
  position: fixed; left: 0; top: 0; z-index: 65; pointer-events: none;
  font-family: var(--font-read); font-weight: 700; font-size: 1.7rem;
  color: var(--green-deep); background: #dcfce7;
  border: 3px solid var(--green); border-radius: 14px;
  padding: 4px 14px; white-space: nowrap;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.7), 0 8px 0 rgba(0, 0, 0, 0.25);
}
.fly-word.missed { color: #8a4b00; background: #fff3c4; border-color: var(--gold-deep); box-shadow: 0 0 30px rgba(245, 163, 11, 0.7), 0 8px 0 rgba(0, 0, 0, 0.25); }
.fly-star.spark { font-size: 1.4rem; }
.panel-actions { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-actions .btn-ghost { color: var(--ink); border-color: rgba(43, 34, 80, 0.2); background: rgba(43, 34, 80, 0.05); }
#btn-go, #btn-next, #btn-speak { display: none; }
.board[data-phase="memorize"] #btn-go { display: inline-block; }
.board[data-phase="guess"] #btn-speak,
.board[data-phase="resolved"] #btn-speak { display: inline-block; }
.board[data-phase="resolved"] #btn-next { display: inline-block; }

/* cards */
.card {
  display: block;
  width: min(190px, 100%);
  height: 110px;
  perspective: 900px;
  border: 0; padding: 0; background: none;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
}
.card:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; border-radius: 16px; }
.card-inner {
  display: block;
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.card.up .card-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: grid; place-items: center;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
}
.face.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.18) 0 22px, transparent 23px),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 8px, transparent 8px 16px),
    linear-gradient(135deg, var(--coral), #c2477a);
  border: 3px solid rgba(255, 255, 255, 0.5);
  color: var(--gold);
  font-size: 2.2rem;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.card:nth-child(even) .face.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.18) 0 22px, transparent 23px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 0 8px, transparent 8px 16px),
    linear-gradient(135deg, var(--teal), #2563eb);
}
.face.front {
  transform: rotateY(180deg);
  background: var(--paper);
  color: var(--ink);
  border: 3px solid #ffe7a3;
  font-family: var(--font-read);
  font-weight: 700;
  font-size: 1.6rem;
  padding: 0 8px;
  word-break: break-word;
  text-align: center;
  line-height: 1.1;
}
.card.long .face.front { font-size: 1.25rem; }
.card.xlong .face.front { font-size: 1.05rem; }
.card.wrong .face.front { background: #ffe4e4; border-color: var(--red); color: #9f1d1d; }
.card.wrong .face.front::after {
  content: "✗"; position: absolute; top: -12px; right: -10px;
  width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: white;
  font-family: var(--font-play); font-size: 1.1rem; display: grid; place-items: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.card.right .face.front { background: #dcfce7; border-color: var(--green); color: var(--green-deep); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.35), 0 0 40px rgba(34, 197, 94, 0.7); }
.card.right .card-inner { animation: cardWin 0.7s ease 0.4s; }
@keyframes cardWin { 30% { transform: rotateY(180deg) scale(1.18); } 60% { transform: rotateY(180deg) scale(0.96); } }
.card.revealed .face.front { background: #fff3c4; border-color: var(--gold-deep); color: #8a4b00; box-shadow: 0 0 0 6px rgba(245, 163, 11, 0.35); }
.card.wrong .card-inner { animation: cardNo 0.45s ease 0.45s; }
@keyframes cardNo { 25% { transform: rotateY(180deg) translateX(-8px); } 75% { transform: rotateY(180deg) translateX(8px); } }
.card.dealing { animation: deal 0.45s cubic-bezier(0.2, 1.4, 0.5, 1) both; }
@keyframes deal { from { opacity: 0; transform: translateY(-30px) scale(0.6) rotate(-8deg); } to { opacity: 1; transform: none; } }
.card[aria-disabled="true"] { cursor: default; }
.board[data-phase="guess"] .card:not(.up):hover .card-inner { transform: translateY(-4px) rotate(-1.5deg); }

/* banner + flying stars */
.banner {
  position: fixed; left: 50%; top: 74%;
  width: max-content; max-width: 92vw; text-align: center; line-height: 1.05;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  z-index: 50;
  font-size: clamp(2.6rem, 9vw, 5rem);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 6px 0 #8a5300, 0 0 40px rgba(255, 201, 60, 0.7);
}
.banner.show { animation: bannerPop 1.6s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
.banner.sad { color: var(--coral); text-shadow: 0 5px 0 #7f1d1d; font-size: clamp(2rem, 7vw, 3.6rem); }
@keyframes bannerPop {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-12deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(0.9); opacity: 0; }
}
.fly-star {
  position: fixed; z-index: 60; pointer-events: none;
  font-size: 2rem; color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 201, 60, 0.9), 0 2px 0 #8a5300;
  left: 0; top: 0; will-change: transform, opacity;
}
.float-text {
  position: fixed; z-index: 61; pointer-events: none;
  font-size: 2rem; font-weight: 700;
}
.float-text.plus { color: var(--gold); text-shadow: 0 3px 0 #8a5300; }
.float-text.minus { color: var(--coral); text-shadow: 0 3px 0 #7f1d1d; }
.confetti { position: fixed; z-index: 55; pointer-events: none; width: 10px; height: 14px; border-radius: 2px; left: 0; top: 0; }
.flash { position: fixed; inset: 0; z-index: 40; pointer-events: none; background: radial-gradient(circle, rgba(255, 220, 120, 0.55), transparent 70%); animation: flash 0.7s ease forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- end ---------- */
.end-card {
  max-width: 640px; margin: 24px auto; text-align: center;
  background: rgba(255, 255, 255, 0.08); border-radius: 28px; padding: 26px 20px;
  border: 2px solid rgba(255, 255, 255, 0.15);
}
.end-emoji { font-size: 4.5rem; animation: twirl 3s ease-in-out infinite; }
.end-title { font-size: clamp(2.2rem, 8vw, 3.4rem); margin: 6px 0; color: var(--gold); text-shadow: 0 5px 0 #8a5300; }
.end-title.lose { color: var(--coral); text-shadow: 0 5px 0 #7f1d1d; }
.end-sub { font-size: 1.2rem; color: var(--cream); margin: 0 0 16px; }
.end-stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-chip { background: var(--cream); color: var(--ink); border-radius: 16px; padding: 10px 14px; min-width: 96px; }
.stat-chip b { display: block; font-size: 1.6rem; }
.stat-chip span { font-size: 0.85rem; color: var(--ink-soft); }
.end-list { text-align: left; max-height: 300px; overflow: auto; background: rgba(0, 0, 0, 0.2); border-radius: 16px; padding: 6px 12px; margin-bottom: 18px; }
.end-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-family: var(--font-read); font-size: 1rem; line-height: 1.35; }
.end-row:last-child { border-bottom: 0; }
.end-row .sent { flex: 1; }
.end-row .sent b { color: var(--gold); }
.badge { flex: none; font-family: var(--font-play); font-weight: 600; font-size: 0.85rem; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.t1 { background: var(--green); color: #053b1b; }
.badge.t2 { background: var(--sky); color: #0a2a4f; }
.badge.t3 { background: var(--gold); color: #4a2a00; }
.badge.tx { background: var(--coral); color: #4a0b0b; }
.end-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ---------- parent ---------- */
#screen-parent { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.parent-wrap { max-width: 980px; margin: 0 auto; background: #f7f5ff; color: var(--ink); border-radius: 22px; padding: 18px; min-height: 80vh; }
.parent-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.parent-head h2 { margin: 0; font-family: var(--font-play); }
.parent-head .btn-ghost, .parent-wrap .btn-ghost { color: var(--ink); border-color: rgba(43, 34, 80, 0.2); background: white; }
.gate { text-align: center; padding: 40px 10px; }
.gate-q { font-size: 2rem; font-weight: 700; font-family: var(--font-play); }
.gate-form { display: flex; gap: 8px; justify-content: center; }
.gate-form input { font-size: 1.4rem; width: 120px; padding: 8px 12px; border-radius: 12px; border: 2px solid #cfc9ef; text-align: center; }
.gate-err { color: var(--red); min-height: 1.2em; }

.tabs { display: flex; gap: 6px; margin: 16px 0; border-bottom: 2px solid #e3defa; flex-wrap: wrap; }
.tab { font: 600 1rem var(--font-play); background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--ink-soft); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--ink); border-bottom-color: var(--coral); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.level-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip-btn { font: 600 0.95rem var(--font-play); border: 2px solid #d9d3f5; background: white; color: var(--ink); padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.chip-btn.active { background: var(--ink); color: white; border-color: var(--ink); }
.chip-btn.custom { border-style: dashed; }

.level-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.level-head h3 { margin: 0; font-family: var(--font-play); font-size: 1.4rem; }
.level-head .meta { color: var(--ink-soft); font-size: 0.9rem; }
.level-head .spacer { flex: 1; }

.s-table { width: 100%; border-collapse: collapse; background: white; border-radius: 14px; overflow: hidden; }
.s-table th, .s-table td { text-align: left; padding: 10px; border-bottom: 1px solid #eeeaff; vertical-align: top; font-size: 0.95rem; }
.s-table th { background: #efeaff; font-weight: 600; font-size: 0.85rem; color: var(--ink-soft); }
.s-table td.sent { font-family: var(--font-read); font-size: 1.05rem; }
.s-table .ans { color: var(--green-deep); font-weight: 700; background: #dcfce7; padding: 0 4px; border-radius: 4px; }
.words { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.word { font-size: 0.8rem; background: #f1eefc; padding: 1px 7px; border-radius: 999px; color: var(--ink-soft); }
.hist { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.hdot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.hdot.h1 { background: var(--green); }
.hdot.h2 { background: var(--sky); }
.hdot.h3 { background: var(--gold); }
.hdot.h0 { background: var(--coral); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-soft); margin: 8px 0 12px; align-items: center; }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.muted { color: var(--ink-soft); }
.row-actions { display: flex; gap: 6px; }
.icon-btn { border: 1px solid #ddd6fb; background: white; border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 0.85rem; color: var(--ink); }
.icon-btn:hover { background: #f1eefc; }
.icon-btn.danger { color: var(--red); }

.form { background: white; border-radius: 16px; padding: 16px; display: grid; gap: 12px; margin-bottom: 16px; border: 1px solid #e6e1fb; }
.form h3, .form h4 { margin: 0; font-family: var(--font-play); }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.form input, .form select, .form textarea { font: 1rem system-ui, sans-serif; padding: 9px 11px; border-radius: 10px; border: 2px solid #ddd6fb; width: 100%; background: #fff; color: var(--ink); }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--sky); }
.form .btn { justify-self: start; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 0.85rem; color: var(--ink-soft); margin: 0; font-weight: 400; }
.form-err { color: var(--red); font-size: 0.9rem; min-height: 1em; margin: 0; }
.check-list { margin: 0; padding: 10px 12px; background: #faf8ff; border-radius: 10px; list-style: none; display: grid; gap: 4px; font-family: var(--font-read); }
.check-list li.ok { color: var(--green-deep); font-weight: 700; }
.check-list li { color: var(--ink-soft); }
.io-row { display: flex; gap: 10px; flex-wrap: wrap; }
.file-btn { display: inline-block; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }
.sum-card { background: white; border-radius: 14px; padding: 12px; border: 1px solid #e6e1fb; }
.sum-card h4 { margin: 0 0 6px; font-family: var(--font-play); }
.sum-card .big { font-size: 1.5rem; font-weight: 700; }
.games { display: grid; gap: 6px; }
.game-row { background: white; border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; border: 1px solid #eeeaff; font-size: 0.92rem; }
.game-row .res { font-weight: 700; }
.game-row .res.win { color: var(--green-deep); }
.game-row .res.lose { color: var(--red); }
.game-row .res.quit { color: var(--ink-soft); }
.danger-zone { margin-top: 26px; padding-top: 10px; border-top: 2px dashed #e3defa; }
.danger-zone p { color: var(--ink-soft); font-size: 0.9rem; }
.empty { background: white; border: 2px dashed #ddd6fb; border-radius: 14px; padding: 20px; text-align: center; color: var(--ink-soft); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .how ol { grid-template-columns: 1fr; }
  .meter { display: none; }
  #btn-quit { white-space: nowrap; flex: none; }
.game-level { font-size: 1rem; }
  .board {
    grid-template-columns: repeat(2, 1fr);
    grid-template-areas: none;
    grid-template-rows: none;
    gap: 12px;
  }
  .board .card { grid-area: auto !important; width: 100%; height: 76px; }
  .sentence-panel { grid-area: auto; grid-column: 1 / -1; order: -1; min-height: 170px; padding: 16px 14px 14px; }
  .face.front { font-size: 1.4rem; }
  .s-table thead { display: none; }
  .s-table, .s-table tbody, .s-table tr, .s-table td { display: block; width: 100%; }
  .s-table tr { border-bottom: 2px solid #eeeaff; }
  .s-table td { border: 0; padding: 6px 10px; }
}
@media (max-width: 420px) {
  .star-count { font-size: 1.4rem; min-width: 70px; }
  .btn-go { font-size: 1.3rem; padding: 10px 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
