:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d1b18;
  --muted: #6b665d;
  --line: #ddd8cc;
  --accent: #5b3fd1;
  --accent-ink: #ffffff;
  --common: #8a8f98;
  --uncommon: #2f9e5b;
  --rare: #2a6fdb;
  --epic: #8b3fd1;
  --legendary: #d99a00;
  --miss: #b0402f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 24px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121216;
    --surface: #1b1b21;
    --surface-2: #24242c;
    --text: #ece9e2;
    --muted: #a19c92;
    --line: #33333d;
    --accent: #9b85ff;
    --accent-ink: #121216;
    --common: #a3a8b1;
    --uncommon: #4cc27f;
    --rare: #5b9bff;
    --epic: #b583ff;
    --legendary: #ffc533;
    --miss: #ff7a66;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

header.site {
  border-bottom: 1px solid var(--line);
}
header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}
.logo {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.logo-gem {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--epic), var(--legendary));
  transform: rotate(45deg);
  border-radius: 4px;
}
nav.site a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  margin-left: 16px;
}
nav.site a:hover { color: var(--text); }

main { padding: 28px 0 48px; }

h1 { font-size: 32px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 8px; }
h2 { font-size: 22px; line-height: 1.3; margin: 40px 0 12px; }
h3 { font-size: 17px; margin: 20px 0 6px; }
.lead { color: var(--muted); font-size: 18px; margin: 0 0 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-block { width: 100%; }

.mode-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.mode-grid .note { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
#stats { margin: 16px 0 0; font-size: 14px; color: var(--muted); }

/* play screen */
.play-top {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}
.play-top strong { color: var(--text); }
.prompt {
  font-size: 30px;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
}
.timer {
  position: relative;
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
#timer-bar {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: left center;
  transition: transform 0.1s linear;
}
#timer-bar.low { background: var(--miss); }
.timer-text { font-size: 13px; color: var(--muted); margin-bottom: 16px; text-align: right; }

#answer-form { display: flex; gap: 10px; }
#answer-input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0 16px;
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 12px;
  outline: none;
}
#answer-input:focus { border-color: var(--accent); }

#result { margin-top: 4px; }
.tier {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gem {
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  border-radius: 3px;
  background: currentColor;
}
.tier-common { color: var(--common); }
.tier-uncommon { color: var(--uncommon); }
.tier-rare { color: var(--rare); }
.tier-epic { color: var(--epic); }
.tier-legendary { color: var(--legendary); }
.tier-miss { color: var(--miss); }
.result-line { font-size: 18px; margin: 6px 0; }
.result-hint { color: var(--muted); font-size: 15px; margin: 6px 0 18px; }

/* end screen */
.end-score { font-size: 56px; font-weight: 800; line-height: 1; margin: 8px 0; }
.end-gems { font-size: 26px; letter-spacing: 4px; margin: 8px 0 4px; }
#end-rank { color: var(--muted); margin: 0 0 20px; }
#end-list { list-style: none; padding: 0; margin: 0 0 20px; border-top: 1px solid var(--line); }
#end-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.end-q { color: var(--muted); grid-column: 1 / -1; font-size: 13px; }
.end-a { font-weight: 650; overflow-wrap: anywhere; }
.end-t { color: var(--muted); white-space: nowrap; }
.end-actions { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.end-actions .btn-primary { grid-column: 1 / -1; }

/* tier table */
.tiers { width: 100%; border-collapse: collapse; font-size: 15px; }
.tiers th, .tiers td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.tiers td:first-child { font-weight: 700; white-space: nowrap; }

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.faq summary { cursor: pointer; font-weight: 650; }
.faq p { margin: 8px 0 0; color: var(--muted); }

.prose p, .prose li { color: var(--text); }
.prose ul { padding-left: 20px; }
.compare { width: 100%; border-collapse: collapse; font-size: 15px; }
.compare th, .compare td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-scroll { overflow-x: auto; }

footer.site {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  padding: 24px 0 40px;
}
footer.site a { color: var(--muted); }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  h1 { font-size: 26px; }
  .prompt { font-size: 25px; }
  .card { padding: 18px; }
  .mode-grid { grid-template-columns: 1fr; }
  nav.site a { margin-left: 12px; font-size: 14px; }
  #answer-form { flex-direction: column; }
  .end-score { font-size: 46px; }
}
