:root {
  --bg: #10141f;
  --panel: #1a2030;
  --panel-2: #232b3f;
  --line: #2f3953;
  --text: #e8e4d8;
  --muted: #9aa3b8;
  --gold: #d9b45a;
  --good: #4fbf7f;
  --bad: #e05d5d;
  --flame: #ff8a3d;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px);
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; margin: 0; }
h1 { color: var(--gold); font-size: 28px; letter-spacing: .5px; }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

button {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2);
  border-radius: var(--radius); padding: 14px 16px;
}
button:active { transform: scale(.98); }
.btn-primary { background: var(--gold); color: #1a1406; border-color: var(--gold); font-weight: 700; }
.btn-ghost { background: transparent; }

.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.back { padding: 8px 12px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat-tile .v { font-size: 24px; font-weight: 700; }
.stat-tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.rank { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.rank .title { color: var(--gold); font-weight: 700; }
.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--gold); }

.menu { display: grid; gap: 10px; margin-top: 18px; }
.menu button { text-align: left; display: flex; flex-direction: column; gap: 2px; }
.menu button b { font-size: 17px; }

.hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 8px; }
.streak { font-weight: 800; font-size: 20px; color: var(--muted); transition: color .2s; }
.streak.hot { color: var(--flame); }
.mult { font-size: 12px; background: var(--flame); color: #200; border-radius: 99px; padding: 2px 8px; margin-left: 6px; font-weight: 800; }
.lives { letter-spacing: 2px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; margin-bottom: 14px;
}
.card .tag { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--gold); }
.card .unit { font-size: 15px; color: var(--muted); margin-top: 6px; }
.card .q { font-size: 21px; margin-top: 10px; line-height: 1.35; font-family: Georgia, serif; }
.card .q.long { font-size: 16px; font-family: inherit; }

.options { display: grid; gap: 10px; }
.options.grid { grid-template-columns: 1fr 1fr; }
.options button { text-align: left; line-height: 1.35; min-height: 54px; }
.options.grid button { text-align: center; font-size: 24px; font-weight: 700; }
.options button.correct { background: rgba(79,191,127,.18); border-color: var(--good); }
.options button.wrong { background: rgba(224,93,93,.18); border-color: var(--bad); }
.options button:disabled { cursor: default; }

.feedback { margin-top: 14px; padding: 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); font-size: 14px; line-height: 1.45; }
.feedback.good { border-color: var(--good); }
.feedback.bad { border-color: var(--bad); }
.next { width: 100%; margin-top: 12px; }

.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.shake { animation: shake .35s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

table.profile { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
table.profile th, table.profile td { border-bottom: 1px solid var(--line); padding: 6px 2px; text-align: center; }
table.profile th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.profile td:first-child, table.profile th:first-child { text-align: left; }
.wrap-table { overflow-x: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-size: 13px; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--gold); }
.rule-list dt { font-weight: 700; margin-top: 10px; }
.rule-list dd { margin: 2px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.mastery { font-size: 12px; color: var(--muted); }

.over { text-align: center; padding: 30px 10px; }
.over .big { font-size: 56px; font-weight: 800; color: var(--gold); }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%); background: var(--gold); color: #1a1406; padding: 8px 16px; border-radius: 99px; font-weight: 700; z-index: 10; animation: pop .4s ease; }
