:root {
  --bg: #0d1117;
  --panel: #161c26;
  --panel-2: #1d2531;
  --line: #2a3445;
  --text: #e9eef6;
  --muted: #8b98ad;
  --amber: #ffc857;
  --teal: #4de1c1;
  --red: #ff6b6b;
  --green: #5fd38d;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 0.95rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h3 { font-size: 0.8rem; color: var(--muted); margin: 14px 0 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.top {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.35rem; letter-spacing: -0.01em; }
.brand p { color: var(--muted); font-size: 0.85rem; }
.logo { font-size: 1.9rem; background: var(--panel-2); border-radius: 12px; padding: 6px 10px; }

.tabs { display: flex; gap: 6px; background: var(--panel); padding: 5px; border-radius: 999px; border: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; color: var(--muted); padding: 8px 18px; border-radius: 999px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.tabs button.active { background: var(--amber); color: #20180a; }
.tabs button:not(.active):hover { color: var(--text); }

.banner {
  margin: 16px 28px 0; padding: 12px 16px; border-radius: 12px;
  background: #3a2327; border: 1px solid #6b3138; color: #ffd6d6;
}
.banner.info { background: #1b2a3a; border-color: #2f4a66; color: #cfe6ff; }

.layout {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 22px;
  padding: 22px 28px; max-width: 1280px; margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 16px; } .top { padding: 14px 16px; } }

.prompt {
  display: flex; gap: 22px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 22px; margin-bottom: 14px;
}
.prompt-main {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 4.2rem; line-height: 1; min-width: 90px; text-align: center; color: var(--amber);
  letter-spacing: 0.04em;
}
.prompt-main.word { font-size: 2.6rem; }
.prompt-main .done { color: var(--green); }
.prompt-main .cur { color: var(--amber); text-decoration: underline; text-underline-offset: 8px; }
.prompt-main .todo { color: #5b6678; }
.prompt-side { flex: 1; min-width: 0; }
.prompt-sub { color: var(--muted); margin-bottom: 8px; min-height: 1.3em; }
.hold { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
#holdBar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width 0.08s linear; }
.score-line { margin-top: 8px; font-weight: 600; color: var(--text); min-height: 1.3em; }

.stage {
  position: relative; aspect-ratio: 4 / 3; background: #05070a; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line);
}
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.stage.flash { animation: flash 0.5s ease; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 0 rgba(95, 211, 141, 0); } 30% { box-shadow: inset 0 0 0 8px rgba(95, 211, 141, 0.9); } 100% { box-shadow: inset 0 0 0 0 rgba(95, 211, 141, 0); } }
.badge {
  position: absolute; top: 12px; left: 12px; background: rgba(13, 17, 23, 0.82); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 12px; font-weight: 700; font-size: 1.1rem; backdrop-filter: blur(4px);
}
.badge small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.badge.match { border-color: var(--green); color: var(--green); }
.start {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #182131, #0a0e14); text-align: center; padding: 20px;
}
.start p { color: var(--muted); max-width: 36ch; font-size: 0.9rem; }
.start[hidden] { display: none; }

.controls { display: flex; gap: 10px; margin-top: 12px; }
button { font: inherit; cursor: pointer; }
button.primary { background: var(--amber); color: #20180a; border: 0; padding: 11px 22px; border-radius: 12px; font-weight: 700; }
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; }
button.ghost:hover:not(:disabled) { border-color: var(--muted); }
button.ghost.small { padding: 4px 10px; font-size: 0.8rem; border-radius: 8px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; margin-top: 12px; padding: 0; font-size: 0.8rem; }

.right { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#ref { width: 100%; max-width: 320px; display: block; margin: 0 auto; background: var(--panel-2); border-radius: 12px; aspect-ratio: 1; }
#ref.flipped { transform: scaleX(-1); }
.legend { text-align: center; font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 4px 0 10px; }
.dot.teal { background: var(--teal); } .dot.amber { background: var(--amber); }

.tutor { margin-top: 8px; font-size: 1rem; min-height: 3.2em; }
.tutor ul { margin: 0; padding-left: 18px; }
.tutor .ok { color: var(--green); font-weight: 600; }
.tutor .muted, .muted { color: var(--muted); }

.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; margin-top: 10px; }
.letters button {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-weight: 700; font-size: 0.95rem;
}
.letters button.low { background: #3b2528; border-color: #6b3138; }
.letters button.mid { background: #3a3220; border-color: #6b5a2c; }
.letters button.high { background: #1f3a2b; border-color: #2f6b49; }
.letters button.target { outline: 2px solid var(--amber); }
.letters button:disabled { cursor: default; opacity: 1; }

.confusions { margin: 0; padding-left: 18px; font-size: 0.9rem; }
.confusions li { margin: 3px 0; }

.summary { position: fixed; inset: 0; background: rgba(5, 7, 10, 0.72); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.summary[hidden] { display: none; }
.summary-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 26px 30px; max-width: 440px; width: 100%; text-align: center; }
.summary-card h2 { font-size: 1.4rem; color: var(--amber); text-transform: none; letter-spacing: 0; margin-bottom: 14px; }
.summary-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.summary-card .stat { background: var(--panel-2); border-radius: 12px; padding: 10px; }
.summary-card .stat b { display: block; font-size: 1.5rem; }
.summary-card .stat span { color: var(--muted); font-size: 0.8rem; }
.summary-card p { color: var(--muted); margin-bottom: 14px; }

footer { max-width: 1280px; margin: 0 auto; padding: 4px 28px 32px; color: var(--muted); font-size: 0.82rem; display: grid; gap: 6px; }
