:root {
  --bg: #12121c;
  --panel: #1c1c2b;
  --panel-2: #25253a;
  --line: #34344f;
  --text: #ececf4;
  --muted: #9a9ab5;
  --magenta: #ff6ad5;
  --cyan: #5ee7ff;
  --yellow: #ffd84d;
  --green: #4ade80;
  --red: #ff6b6b;
  --blue: #7aa2ff;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(18, 18, 28, .94); backdrop-filter: blur(6px); z-index: 5;
}

.brand {
  all: unset; cursor: pointer; font-weight: 900; letter-spacing: .25em; font-size: 22px;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; border-radius: 4px; }

.hud { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; font-variant-numeric: tabular-nums; }
.hud b { font-weight: 700; }
.hud .score { color: var(--cyan); }
.hud .points { color: var(--magenta); }
.hud .streak { color: var(--yellow); }
.clock { font-weight: 800; color: var(--green); }
.clock.warn { color: var(--yellow); }
.clock.danger { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

main { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }

h1 { font-size: 28px; margin: 0 0 6px; }
h2 { font-size: 21px; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.crumbs { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.crumbs b { color: var(--cyan); }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-top: 18px; }

.card {
  display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; color: inherit; font: inherit; transition: transform .08s, border-color .15s, background .15s;
}
.card:hover, .card:focus-visible { border-color: var(--cyan); background: var(--panel-2); outline: none; }
.card:active { transform: scale(.98); }
.card .icon { font-size: 28px; }
.card .title { font-weight: 700; }
.card .sub { color: var(--muted); font-size: 14px; }
.card.big { padding: 22px; }
.card.big .title { font-size: 20px; }

.box {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--cyan);
  border-radius: var(--radius); padding: 18px 20px; margin: 16px 0; white-space: pre-wrap;
}
.box.passage { border-left-color: var(--blue); max-height: 45vh; overflow: auto; font-size: 16px; }
.box.question { font-size: 19px; font-weight: 600; }

.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); transition: width .3s; }
.qmeta { display: flex; justify-content: space-between; color: var(--muted); font-size: 15px; }

.options { display: grid; gap: 10px; margin-top: 8px; }
.opt {
  display: flex; gap: 14px; align-items: center; text-align: left; cursor: pointer; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  color: inherit; font: inherit; transition: border-color .15s, background .15s;
}
.opt:hover:not(:disabled), .opt:focus-visible { border-color: var(--yellow); background: var(--panel-2); outline: none; }
.opt .key {
  flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--panel-2); color: var(--yellow); font-weight: 800;
}
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--green); background: rgba(74, 222, 128, .12); }
.opt.correct .key { background: var(--green); color: #0b2814; }
.opt.wrong { border-color: var(--red); background: rgba(255, 107, 107, .12); }
.opt.wrong .key { background: var(--red); color: #2b0b0b; }
.opt.dim { opacity: .5; }

.fill { display: flex; gap: 10px; }
input[type=text], input[type=number] {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  font: inherit; padding: 13px 16px;
}
input:focus { outline: none; border-color: var(--cyan); }

.btn {
  cursor: pointer; border: 0; border-radius: 12px; padding: 13px 22px; font: inherit; font-weight: 700;
  background: linear-gradient(90deg, var(--magenta), #b26bff); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.go { background: linear-gradient(90deg, #22c55e, #14b8a6); }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }

.feedback { margin-top: 18px; padding: 14px 18px; border-radius: 12px; font-weight: 600; }
.feedback.ok { background: rgba(74, 222, 128, .12); border: 1px solid var(--green); color: var(--green); }
.feedback.bad { background: rgba(255, 107, 107, .1); border: 1px solid var(--red); color: var(--red); }
.feedback .bonus { display: block; color: var(--yellow); font-weight: 500; font-size: 15px; margin-top: 4px; }

.counts { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.chip {
  cursor: pointer; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 99px; padding: 8px 16px; font: inherit; font-weight: 600;
}
.chip:hover, .chip:focus-visible { border-color: var(--cyan); outline: none; }

.rules { padding-left: 20px; color: var(--muted); }
.rules li { margin: 4px 0; }

.summary { text-align: center; }
.badge-art { font-size: 84px; line-height: 1; margin: 10px 0; }
.badge-name { font-size: 28px; font-weight: 900; letter-spacing: .06em; }
.confetti { font-size: 24px; letter-spacing: .25em; margin: 10px 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .v { font-size: 24px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.banner { display: inline-block; padding: 6px 14px; border-radius: 8px; font-weight: 800; margin-bottom: 8px; }
.banner.ok { background: #16a34a; }
.banner.bad { background: #dc2626; }

.review { text-align: left; }
.review .item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 10px 0; }
.review .yours { color: var(--red); }
.review .right { color: var(--green); }
.review .item.ok { border-left: 4px solid var(--green); }
.review .item.no { border-left: 4px solid var(--red); }

details.result { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
details.result summary { cursor: pointer; font-weight: 600; }
details.result summary span { color: var(--muted); font-weight: 400; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--yellow); color: #222;
  padding: 10px 18px; border-radius: 99px; font-weight: 700; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

.hint { font-size: 13px; color: var(--muted); margin-top: 14px; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  main { padding: 20px 14px 50px; }
  .stats { grid-template-columns: 1fr; }
  .hud { gap: 10px; font-size: 14px; }
}
