:root {
  --bg: #0a0c1b;
  --bg2: #12152e;
  --card: #181c38;
  --card2: #222748;
  --ink: #f2f4ff;
  --muted: #9aa0c8;
  --line: #2c3163;
  --accent: #6c8cff;
  --accent2: #22d3ee;
  --good: #34d399;
  --bad: #fb7185;
  --warn: #fbbf24;
  /* skill colors */
  --listening: #38bdf8;
  --speaking: #f472b6;
  --reading: #34d399;
  --writing: #fbbf24;
  --mixed: #a78bfa;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(124,140,255,.18), transparent 60%),
    radial-gradient(900px 500px at 92% -4%, rgba(34,211,238,.14), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 22px 18px 90px; }
a { color: var(--accent); }
button { font-family: inherit; }

/* ---- top bar / HUD ---- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .back {
  text-decoration: none; color: var(--muted); font-weight: 600;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.topbar .back:hover { color: var(--ink); border-color: var(--accent); }
.daychip { font-weight: 800; font-size: 14px; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.skillbadge { font-weight: 800; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; padding: 6px 11px; border-radius: 999px; color: #0c1024; }
.badge3d {
  font-weight: 900; font-size: 11px; letter-spacing: .08em; padding: 5px 9px; border-radius: 8px; color: #04121a;
  background: linear-gradient(135deg, var(--accent2), #67e8f9); box-shadow: 0 0 16px rgba(34,211,238,.5);
}
.spacer { flex: 1; }
.shufbtn {
  cursor: pointer; font-weight: 800; font-size: 13px; padding: 8px 13px; border-radius: 999px;
  background: var(--card); color: var(--muted); border: 1px solid var(--line); transition: .15s;
}
.shufbtn:hover { color: var(--ink); border-color: var(--accent); }
.shufbtn.on { background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; border-color: transparent; box-shadow: 0 0 18px rgba(124,140,255,.5); }
.combopill { font-weight: 900; font-size: 14px; padding: 6px 10px; border-radius: 999px; opacity: 0; transform: scale(.6); transition: .15s; color: #04121a; background: var(--warn); }
.combopill.show { opacity: 1; transform: scale(1); box-shadow: 0 0 16px rgba(251,191,36,.6); }
.scorepill { font-weight: 800; font-size: 14px; padding: 8px 13px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); }

/* ---- headings ---- */
h1 { font-size: 30px; margin: 6px 0 6px; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: 0 0 12px; max-width: 64ch; }
.enginetag {
  display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent2); border: 1px solid rgba(34,211,238,.35); background: rgba(34,211,238,.08);
  padding: 4px 10px; border-radius: 8px; margin-bottom: 16px;
}

/* ---- stage / cards ---- */
.stage { position: relative; }
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg2) 140%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.prompt-big { font-size: 25px; font-weight: 800; line-height: 1.35; margin: 6px 0 18px; color: var(--ink); }
.prompt-word { font-size: 34px; font-weight: 900; letter-spacing: -.01em; color: var(--accent2); text-shadow: 0 0 24px rgba(34,211,238,.35); margin: 4px 0 18px; }
.hint { color: var(--muted); font-size: 14px; }

/* ---- canvas ---- */
.gamecanvas { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #070914; box-shadow: var(--shadow); touch-action: manipulation; }
.canvas-wrap { position: relative; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 14px 20px; font-size: 16px; font-weight: 800;
  cursor: pointer; color: #06112b;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 6px 18px rgba(124,140,255,.35); transition: transform .06s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: var(--card2); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.big { width: 100%; padding: 18px; font-size: 18px; }
.btn.rec { background: linear-gradient(135deg, #fb7185, #ef4444); color: #fff; box-shadow: 0 6px 18px rgba(251,113,133,.4); }
.btn.rec.on { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { filter: brightness(1); transform: scale(1); } 50% { filter: brightness(1.25); transform: scale(1.03); } }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- choices ---- */
.choice {
  display: block; width: 100%; text-align: left; margin: 9px 0;
  background: var(--card2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 12px; padding: 15px 16px; font-size: 16px; font-weight: 600; cursor: pointer; transition: .12s;
}
.choice:hover { border-color: var(--accent); transform: translateX(3px); }
.choice.correct { background: rgba(52,211,153,.2); border-color: var(--good); color: #d1fae5; }
.choice.wrong { background: rgba(251,113,133,.18); border-color: var(--bad); color: #fecdd3; }
.choice[disabled] { cursor: default; }

/* ---- inputs ---- */
.txt, textarea.txt {
  width: 100%; background: #0b0e22; border: 1px solid var(--line); color: var(--ink);
  border-radius: 12px; padding: 14px 16px; font-size: 17px; outline: none;
}
.txt:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,140,255,.18); }
textarea.txt { min-height: 120px; resize: vertical; line-height: 1.6; }

/* ---- progress ---- */
.progress { height: 9px; background: var(--card2); border-radius: 999px; overflow: hidden; margin: 4px 0 4px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0; transition: width .3s ease; }
.meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ---- feedback ---- */
.fb { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-weight: 700; }
.fb.good { background: rgba(52,211,153,.16); color: #6ee7b7; }
.fb.bad { background: rgba(251,113,133,.16); color: #fda4af; }
.fb.neutral { background: transparent; color: var(--muted); padding: 8px 2px; font-weight: 600; font-style: italic; }

/* ---- floating score popups ---- */
.scorepop {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%);
  font-weight: 900; font-size: 28px; pointer-events: none; z-index: 20; color: var(--good);
  text-shadow: 0 2px 12px rgba(0,0,0,.6); animation: floatup .9s ease-out forwards;
}
.scorepop.bad { color: var(--bad); }
.scorepop.combo { color: var(--warn); }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%,-30%) scale(.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-130%) scale(1.1); } }

/* ---- result ---- */
.result { text-align: center; padding: 34px 22px; position: relative; overflow: hidden; }
.stars { font-size: 46px; letter-spacing: 8px; margin: 6px 0 4px; animation: pop .5s ease; }
.bignum { font-size: 60px; font-weight: 900; margin: 4px 0; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }

/* ---- transcript / tiles / misc ---- */
.tscript { background: #0b0e22; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; min-height: 48px; }
.warnbox { background: rgba(251,191,36,.12); border: 1px solid var(--warn); color: var(--warn); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.tilebank, .tileline { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; align-content: flex-start; }
.tileline { background: #0b0e22; border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin: 8px 0 14px; }
.tile { background: var(--card2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 10px 14px; font-size: 16px; font-weight: 600; cursor: pointer; user-select: none; transition: .1s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.w-ok { color: var(--good); } .w-miss { color: var(--bad); text-decoration: line-through; }

/* ================= LAUNCHER ================= */
.hero { margin-bottom: 18px; }
.hero h1 { font-size: 34px; }
.hero .sub { font-size: 15px; }
.streakrow { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; min-width: 96px; }
.stat b { display: block; font-size: 28px; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.chapter-block { margin-bottom: 24px; }
.chapter-block h3 { margin: 0 0 4px; font-size: 17px; }
.chapter-block .crange { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 9px; }
.cell {
  position: relative; aspect-ratio: 1/1; border-radius: 14px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card), var(--bg2)); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-decoration: none; color: var(--ink); font-weight: 800; gap: 2px; overflow: hidden;
}
.cell .dn { font-size: 19px; } .cell .dd { font-size: 10px; color: var(--muted); font-weight: 600; }
.cell.locked { opacity: .38; cursor: not-allowed; }
.cell.playable:hover { border-color: var(--accent); transform: translateY(-3px); transition: transform .12s; box-shadow: 0 8px 22px rgba(0,0,0,.4); }
.cell.today { outline: 2px solid var(--accent2); outline-offset: 2px; }
.cell .done { position: absolute; top: 4px; right: 6px; font-size: 12px; }
.cell .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; }
.cell .pct { position: absolute; bottom: 7px; font-size: 9px; color: var(--muted); font-weight: 700; }

@media (max-width: 540px) {
  .grid { gap: 5px; } .cell .dn { font-size: 15px; } h1 { font-size: 24px; } .hero h1 { font-size: 26px; }
  .prompt-big { font-size: 21px; } .prompt-word { font-size: 28px; }
}
