:root {
  --bg: #0f0f12;
  --surface: #1a1a20;
  --surface-2: #24242c;
  --border: #33333d;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #7c5cff;
  --accent-2: #00d4a0;
  --correct: #2ecc71;
  --wrong: #e74c3c;
  --gold: #ffcf40;
  --silver: #c8ccd4;
  --bronze: #cd7f52;
  --radius: 14px;
  --maxw: 480px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: var(--maxw);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 16px);
  background: var(--bg);
}

/* ---------- Header ---------- */
.tr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tr-header .logo {
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 18px;
}
.tr-header .logo span { color: var(--accent); }
.tr-header .meta {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  line-height: 1.4;
}

/* ---------- Progress dots ---------- */
.progress {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  justify-content: center;
}
.progress .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.2s, background 0.2s;
}
.progress .dot.active { background: var(--accent); transform: scale(1.25); }
.progress .dot.correct { background: var(--correct); }
.progress .dot.wrong { background: var(--wrong); }

/* ---------- Round card ---------- */
.screen { flex: 1; display: flex; flex-direction: column; }
.round-num {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-2);
  font-weight: 700;
  margin-bottom: 6px;
}
.prompt {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 20px;
}

/* Option buttons */
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 16px 16px;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  line-height: 1.35;
}
.opt:active { transform: scale(0.99); }
.opt.selected { border-color: var(--accent); background: var(--surface-2); }
.opt.correct { border-color: var(--correct); background: rgba(46,204,113,0.12); }
.opt.wrong { border-color: var(--wrong); background: rgba(231,76,60,0.12); }
.opt.disabled { opacity: 0.55; pointer-events: none; }

/* Order round list */
.order-list { display: flex; flex-direction: column; gap: 10px; }
.order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
  font-size: 15px;
  line-height: 1.3;
}
.order-item .rank {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.order-item .label { flex: 1; }
.order-item .moves { display: flex; flex-direction: column; gap: 4px; }
.order-item .moves button {
  width: 30px; height: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.order-item .moves button:disabled { opacity: 0.3; cursor: default; }
.order-item.correct { border-color: var(--correct); }
.order-item.wrong { border-color: var(--wrong); }

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
  background: var(--accent);
  color: white;
  transition: opacity 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.99); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.4; cursor: default; }

.spacer { flex: 1; }

/* Call the theme banner */
.call-theme {
  margin-top: 14px;
  background: linear-gradient(135deg, rgba(124,92,255,0.15), rgba(0,212,160,0.1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.call-theme .ct-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.call-theme .ct-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* Feedback line */
.feedback {
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
  min-height: 20px;
  line-height: 1.4;
}
.feedback strong { color: var(--text); }

/* ---------- Start / Result screens ---------- */
.center-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 24px 8px;
}
.center-screen h1 { font-size: 34px; font-weight: 800; letter-spacing: 0.5px; }
.center-screen h1 span { color: var(--accent); }
.center-screen .tagline { color: var(--muted); font-size: 15px; max-width: 320px; line-height: 1.5; }
.center-screen .how {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
  width: 100%;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}
.center-screen .how b { color: var(--text); }

/* Reveal */
.reveal-label {
  font-size: 40px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: pop 0.5s ease;
}
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Result */
.medal { font-size: 64px; animation: pop 0.5s ease; }
.stars { font-size: 28px; letter-spacing: 4px; }
.result-grid { font-size: 26px; letter-spacing: 3px; margin: 6px 0; }
.result-line { font-size: 14px; color: var(--muted); }
.streak { font-size: 16px; font-weight: 700; }
.medal-name { font-size: 20px; font-weight: 800; }
.medal-name.gold { color: var(--gold); }
.medal-name.silver { color: var(--silver); }
.medal-name.bronze { color: var(--bronze); }
.medal-name.none { color: var(--muted); }

.share-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.6;
  width: 100%;
  margin: 8px 0;
  text-align: left;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; }

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding-top: 18px;
}
