:root {
  --bg: #0b0d12; --surface: #141824; --surface2: #1c2232; --border: #2a3246;
  --text: #f3f5fa; --muted: #8b94a8; --accent: #7c5cff; --accent2: #22d3ee;
  --right: #22c55e; --wrong: #3a4258;
  --radius: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb; --surface: #ffffff; --surface2: #eef0f6; --border: #dde1ec;
    --text: #0d1220; --muted: #5b6478; --wrong: #c9cfdc;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  background-image: radial-gradient(60rem 30rem at 50% -10rem, color-mix(in srgb, var(--accent) 18%, transparent), transparent);
}
button { font: inherit; color: inherit; cursor: pointer; }

.top { display: flex; align-items: center; justify-content: space-between; max-width: 480px; margin: 0 auto; padding: 14px 16px 6px; }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.logo { display: inline-flex; flex-direction: column; gap: 3px; }
.logo i { display: block; height: 4px; border-radius: 2px; background: var(--accent); }
.logo i:nth-child(1) { width: 18px; background: var(--right); } .logo i:nth-child(2) { width: 13px; } .logo i:nth-child(3) { width: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; display: grid; place-items: center; }

main { max-width: 480px; margin: 0 auto; padding: 4px 16px 32px; display: flex; flex-direction: column; align-items: stretch; }
.meta { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 14px; }
.meta .dot { margin: 0 8px; }
.label { margin: 0; font-weight: 700; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; text-align: center; color: var(--accent2); }
.top-label::before { content: "▲ "; } .bottom-label::before { content: "▼ "; }

.cards { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.card {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 12px 14px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 18px; font-weight: 650; user-select: none; touch-action: manipulation;
  transition: border-color .15s, background-color .25s, transform .15s, box-shadow .15s;
}
.card .pos { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; color: var(--muted); background: var(--surface2); flex: none; }
.card .ico { font-size: 22px; width: 30px; text-align: center; flex: none; }
.card .ico.sym { font-size: 14px; font-weight: 800; border: 1.5px solid var(--border); border-radius: 8px; height: 30px; line-height: 27px; color: var(--accent2); }
.card .nm { flex: 1; }
.card .val { font-size: 13px; font-weight: 600; color: var(--muted); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); transform: scale(1.02); }
.card.right { background: color-mix(in srgb, var(--right) 22%, var(--surface)); border-color: var(--right); }
.card.right .pos { background: var(--right); color: #fff; }
.card.locked { cursor: default; }
.card.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.04); } }
.card.shake { animation: shake .35s ease; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.tries { display: flex; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.tries span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); transition: opacity .3s, transform .3s; }
.tries span.used { opacity: .2; transform: scale(.8); }
.hint { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 14px; min-height: 20px; }

.primary {
  display: block; width: 100%; padding: 15px; border: 0; border-radius: 14px; font-weight: 750; font-size: 17px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent2)));
  color: #fff; transition: transform .1s, opacity .2s;
}
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .45; }
.primary.ghost { background: var(--surface); border: 1.5px solid var(--border); color: var(--text); }
.hidden { display: none !important; }
.link-btn { display: block; margin: 10px auto 0; background: none; border: 0; color: var(--muted); padding: 8px; }

dialog {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  border: 1px solid var(--border); border-radius: 22px; padding: 22px 20px; background: var(--surface); color: var(--text);
}
dialog[open] { animation: rise .28s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
dialog::backdrop { background: rgb(0 0 0 / .55); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: -0.01em; text-align: center; }
.howto { padding-left: 20px; margin: 0 0 14px; } .howto li { margin: 6px 0; }
.example { display: flex; align-items: center; gap: 4px; margin: 0 0 18px; justify-content: center; }
.sq { width: 20px; height: 20px; border-radius: 5px; background: var(--wrong); display: inline-block; }
.sq.right { background: var(--right); }
.ex-txt { margin-left: 8px; color: var(--muted); font-size: 14px; }
.score { text-align: center; margin: 0 0 10px; color: var(--muted); }
.grid { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 14px; }
.grid div { display: flex; gap: 4px; }
.answer { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.answer li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--surface2); font-weight: 650; }
.answer .val { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 600; text-align: right; }
.fact { font-size: 15px; margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid var(--accent2); background: color-mix(in srgb, var(--accent2) 8%, transparent); border-radius: 6px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin: 0 0 16px; }
.stats b { display: block; font-size: 24px; } .stats span { font-size: 12px; color: var(--muted); }
.toast { text-align: center; min-height: 20px; margin: 8px 0 0; color: var(--right); font-size: 14px; }
.next { text-align: center; color: var(--muted); margin: 6px 0 0; }
.next b { color: var(--text); font-variant-numeric: tabular-nums; }
.src { text-align: center; font-size: 12px; color: var(--muted); margin: 10px 0 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
