/* «Дуэль заклинаний» — кремовый матовый стиль меню Джетбокса. */
:root {
  --cream: #f4ecd8;
  --cream2: #ebe1c7;
  --cream3: #e2d6b8;
  --ink: #3b3328;
  --muted: #7a6f5d;
  --line: #d9cdae;
  --line2: #b9ab88;
  --q: #4aa8e0;
  --w: #8b5cd6;
  --e: #ef8a2e;
  --good: #4f8a3c;
  --bad: #c2412d;
  --gold: #c99a1c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--cream); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.duel { height: 100%; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; gap: 16px; padding: 12px 22px; border-bottom: 2px solid var(--line); flex: none; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 20px; }
.logo-mark { width: 36px; height: 36px; display: block; }
.logo-mark svg { width: 100%; height: 100%; }
.top-info { flex: 1; color: var(--muted); font-size: 14px; text-align: right; }
.chip { background: var(--cream2); border: 2px solid var(--line2); border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: 14px; font-weight: 600; }
.chip:hover { border-color: var(--ink); }

.stage { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; overflow: auto; padding: 24px clamp(14px, 3vw, 40px); }
.card { background: var(--cream2); border: 2px solid var(--line); border-radius: 20px; padding: 22px 26px; }
.kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; font-weight: 800; color: var(--muted); }
h1 { margin: 4px 0 10px; font-size: clamp(28px, 3.4vw, 42px); line-height: 1.1; }
h2 { margin: 18px 0 10px; font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 18px; }
.btn { background: var(--ink); color: #fbf6e8; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 18px; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.18); }
.btn:disabled { opacity: 0.4; cursor: default; filter: none; }
.btn.big { font-size: 18px; padding: 12px 24px; }
.btn.huge { font-size: 28px; padding: 18px 60px; border-radius: 18px; margin: 18px 0 8px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line2); }
.btn.ghost:hover { border-color: var(--ink); }
.field { background: var(--cream); border: 2px solid var(--line2); border-radius: 12px; padding: 9px 12px; width: 100%; }
.field:focus { outline: none; border-color: var(--ink); }
.msg { min-height: 1.4em; color: var(--bad); margin-top: 8px; font-weight: 600; }
.t-q { color: var(--q); }
.t-w { color: var(--w); }
.t-e { color: var(--e); }

/* меню */
.menu { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr); gap: 34px; align-items: center; min-height: 100%; }
.menu-art { aspect-ratio: 1; background: var(--cream2); border: 2px solid var(--line); border-radius: 26px; display: grid; place-items: center; padding: 8%; }
.menu-art .art-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: 100%; }
.menu-art .art-grid .orb-svg { width: 100%; height: auto; }
.menu-art .art-spells { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 20px; width: 100%; }
.menu-art .spell-svg { width: 100%; height: auto; border-radius: 12px; }
.lead { font-size: 18px; max-width: 560px; }
.menu-btns { display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin-top: 16px; }
.menu-btns .row { justify-content: stretch; margin: 0; }
.menu-btns .row .btn { flex: 1; }
.history { margin-top: 22px; max-width: 520px; }
.history h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.history li { margin: 3px 0; font-size: 14px; }
.history ol { padding-left: 20px; margin: 0; }

/* правила */
.rules { max-width: 860px; margin: 0 auto; }
.rule-art { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 14px 0; min-height: 90px; }
.rule-art .orb-svg { width: 76px; height: 76px; }
.rule-art .spell-svg { width: 70px; height: 70px; border-radius: 12px; }
.rule-art .arrow { font-size: 34px; color: var(--muted); }
.rule-text { font-size: 18px; }
.rule-text ul { padding-left: 20px; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line2); }
.dots i.on { background: var(--ink); }

/* настройки матча */
.setup, .check, .prep, .results { max-width: 900px; margin: 0 auto; }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.names label span { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode { text-align: left; background: var(--cream); border: 2px solid var(--line2); border-radius: 16px; padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.mode b { font-size: 18px; }
.mode span { color: var(--muted); font-size: 14px; }
.mode.on { border-color: var(--ink); background: #fffaf0; box-shadow: inset 0 0 0 2px var(--ink); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { background: var(--cream); border: 2px solid var(--line2); border-radius: 12px; padding: 8px 14px; cursor: pointer; }
.seg button.on { border-color: var(--ink); background: #fffaf0; font-weight: 700; }

/* проверка клавиш */
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.key { background: var(--cream); border: 2px solid var(--line2); border-radius: 16px; padding: 12px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: background 0.15s, border-color 0.15s; }
.key .cap { font-size: 22px; font-weight: 900; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 12px; background: #fffaf0; min-width: 64px; box-shadow: 0 4px 0 var(--line2); }
.key .orb-svg { width: 46px; height: 46px; }
.key .lbl { font-size: 13px; color: var(--muted); min-height: 2.6em; }
.key .ok { font-weight: 800; color: var(--good); min-height: 1.4em; }
.key.done { border-color: var(--good); background: #eef3df; }
.key.flash .cap { transform: translateY(3px); box-shadow: 0 1px 0 var(--line2); }
.key.binding { border-color: var(--ink); background: #fffaf0; }
.key .rebind { font-size: 12px; background: none; border: 0; text-decoration: underline; color: var(--muted); cursor: pointer; }
.check-demo { display: flex; align-items: center; gap: 20px; justify-content: center; flex-wrap: wrap; }
.check-spell { font-size: 20px; font-weight: 800; min-width: 260px; }

/* подготовка */
.prep { text-align: center; padding: 40px 26px; }
.prep h1 { font-size: clamp(40px, 6vw, 72px); }
.prep-mode { font-size: 20px; color: var(--muted); margin: 0; }
.prep-keys { display: flex; gap: 10px; justify-content: center; margin: 22px 0 6px; flex-wrap: wrap; }
.prep-keys span { border: 2px solid var(--line2); border-radius: 12px; padding: 6px 12px; background: var(--cream); font-weight: 700; }
.prep-prev { margin: 14px auto 0; max-width: 520px; background: var(--cream); border: 2px dashed var(--line2); border-radius: 14px; padding: 10px 14px; }

/* игра */
.screen.play { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.hud { display: flex; align-items: center; gap: 18px; padding: 10px 22px; border-bottom: 2px solid var(--line); background: var(--cream2); flex: none; }
.hud-who { display: flex; flex-direction: column; min-width: 200px; }
.hud-who b { font-size: 24px; line-height: 1.1; }
.hud-stats { flex: 1; display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat b { font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat.good b { color: var(--good); }
.stat.bad b { color: var(--bad); }
.arena { flex: 1; min-height: 0; position: relative; }

.speed { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 14px; }
.time { font-size: clamp(44px, 7vh, 80px); font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.time.low { color: var(--bad); }

.task { position: relative; background: #fffaf0; border: 3px solid var(--ink); border-radius: 24px; padding: 18px 28px; display: flex; align-items: center; gap: 22px; min-width: min(560px, 92vw); transition: border-color 0.15s; }
.task .spell-svg { width: clamp(90px, 16vh, 150px); height: auto; border-radius: 18px; flex: none; }
.task .t-name { font-size: clamp(30px, 5.4vh, 56px); font-weight: 900; line-height: 1.05; }
.task .t-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.task .combo { margin-top: 10px; }
.task.small { min-width: 0; width: 100%; padding: 12px 14px; gap: 12px; border-radius: 18px; }
.task.small .spell-svg { width: 72px; }
.task.small .t-name { font-size: 24px; }
.task.empty { border-style: dashed; border-color: var(--line2); color: var(--muted); justify-content: center; min-height: 100px; }
.task.err { border-color: var(--bad); animation: shake 0.28s; box-shadow: 0 0 0 5px rgba(194, 65, 45, 0.25); }
@keyframes shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } }

.combo { display: inline-flex; gap: 6px; }
.mini-orb { width: 30px; height: 30px; display: inline-block; }
.mini-orb .orb-svg { width: 100%; height: 100%; display: block; }
.combo.tiny .mini-orb { width: 20px; height: 20px; }

.orb-tray { display: flex; gap: clamp(10px, 2vw, 22px); }
.orb-slot { width: clamp(70px, 12vh, 112px); aspect-ratio: 1; border-radius: 50%; border: 3px dashed var(--line2); display: grid; place-items: center; position: relative; }
.orb-slot .orb-svg { width: 100%; height: 100%; display: block; }
.orb-slot.new .orb-svg { animation: orbIn 0.16s ease-out; }
.orb-slot.filled { border-color: transparent; }
@keyframes orbIn { from { transform: scale(0.6); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
.orb-tray.small .orb-slot { width: 62px; }
.tray-labels { display: flex; justify-content: space-between; width: clamp(240px, 42vh, 380px); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }

/* вспышки стихий (не блокируют ввод) */
.fx { position: absolute; inset: -12px; border-radius: 30px; pointer-events: none; opacity: 0; }
.fx.go { animation: fx 0.38s ease-out; }
.fx.ice { background: radial-gradient(circle, rgba(74, 168, 224, 0.55), rgba(74, 168, 224, 0) 70%); }
.fx.bolt { background: radial-gradient(circle, rgba(139, 92, 214, 0.55), rgba(139, 92, 214, 0) 70%); }
.fx.fire { background: radial-gradient(circle, rgba(239, 138, 46, 0.6), rgba(239, 138, 46, 0) 70%); }
.fx.mix { background: conic-gradient(rgba(74, 168, 224, 0.5), rgba(139, 92, 214, 0.5), rgba(239, 138, 46, 0.5), rgba(74, 168, 224, 0.5)); }
@keyframes fx { 0% { opacity: 0.9; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.12); } }

/* падающий режим */
.falling { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(150px, 1fr) auto minmax(260px, 1.2fr); gap: clamp(14px, 3vw, 40px); padding: 16px clamp(14px, 3vw, 40px); align-items: stretch; }
.fall-side { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.fall-side.left { align-items: flex-end; text-align: right; }
.big-num { font-size: clamp(40px, 7vh, 72px); font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.level-box { background: var(--cream2); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: 14px; }
.level-box b { font-size: 20px; }
.toast-slot { min-height: 44px; }
.toast-slot .lvl-up { display: inline-block; background: var(--ink); color: #fbf6e8; border-radius: 12px; padding: 8px 14px; font-weight: 800; animation: toast 1.6s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
.well-wrap { display: flex; gap: 10px; align-items: stretch; height: 100%; }
.gauge { width: 14px; border-radius: 8px; background: var(--cream2); border: 2px solid var(--line2); position: relative; overflow: hidden; }
.gauge i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--good); transition: height 0.15s, background 0.2s; }
.gauge.danger i { background: var(--bad); }
.well { position: relative; height: 100%; aspect-ratio: 0.36; min-width: 180px; max-width: 300px; background: #fffaf0; border: 3px solid var(--ink); border-top: 3px dashed var(--bad); border-radius: 0 0 18px 18px; overflow: hidden; background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(10% - 1px), var(--line) calc(10% - 1px), var(--line) 10%); }
.well.danger { box-shadow: 0 0 0 4px rgba(194, 65, 45, 0.25); }
.well.hidden-tasks .fcard { visibility: hidden; }
.fcard { position: absolute; left: 4px; right: 4px; top: 0; height: calc(10% - 4px); margin-top: 2px; border-radius: 10px; background: var(--cream2); border: 2px solid var(--line2); display: flex; align-items: center; gap: 8px; padding: 0 8px; will-change: transform; }
.fcard .spell-svg { height: 82%; width: auto; border-radius: 8px; flex: none; }
.fcard .fc-name { font-weight: 800; font-size: clamp(11px, 1.9vh, 17px); line-height: 1.05; flex: 1; min-width: 0; }
.fcard .combo { flex: none; }
.fcard.falling-now { opacity: 0.92; border-style: dashed; }
.fcard.target { background: #fffaf0; border: 3px solid var(--ink); box-shadow: 0 0 0 3px rgba(59, 51, 40, 0.18); }
.fcard.target.err { border-color: var(--bad); animation: shake 0.28s; }
.fcard.vanish { animation: vanish 0.3s ease-out forwards; }
.fcard.vanish.ice { background: var(--q); }
.fcard.vanish.bolt { background: var(--w); }
.fcard.vanish.fire { background: var(--e); }
@keyframes vanish { to { opacity: 0; transform: var(--tf) scale(1.15); } }
.free { font-size: 18px; font-weight: 700; margin-top: 6px; }
.free.danger { color: var(--bad); }
.cast-note { min-height: 1.4em; font-weight: 700; color: var(--bad); }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(244, 236, 216, 0.82); z-index: 5; }
.overlay.pause { background: rgba(244, 236, 216, 0.97); }
.overlay .card { text-align: center; max-width: 460px; }
.count { font-size: clamp(100px, 20vh, 200px); font-weight: 900; line-height: 1; }
.count-sub { font-size: 22px; font-weight: 700; color: var(--muted); }

/* итоги */
.results h1.draw { color: var(--muted); }
.board { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 18px; }
.board th, .board td { padding: 10px 12px; border-bottom: 2px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.board th:first-child, .board td:first-child { text-align: left; }
.board th { font-size: 14px; color: var(--muted); }
.board th.win { color: var(--ink); }
.board td.best { font-weight: 900; }
.board tr.key-row td { background: #fffaf0; }

/* тренировка */
.train { display: grid; grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr); gap: 20px; max-width: 1200px; margin: 0 auto; }
.ref-list { display: grid; gap: 6px; }
.ref-item { display: flex; align-items: center; gap: 10px; background: var(--cream); border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.ref-item .spell-svg { width: 40px; height: 40px; border-radius: 8px; }
.ref-item b { flex: 1; }
.ref-item.cur { border-color: var(--ink); background: #fffaf0; }
.practice { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.practice .task { min-width: 0; width: 100%; }
.train-stats { font-size: 18px; }
.toggle { display: flex; gap: 8px; align-items: center; cursor: pointer; }

@media (max-width: 900px) {
  .menu, .train { grid-template-columns: 1fr; }
  .names, .modes { grid-template-columns: 1fr; }
  .keys { grid-template-columns: 1fr 1fr; }
  .falling { grid-template-columns: 1fr auto; }
  .fall-side.left { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .task.err, .fcard.target.err { animation: none; }
  .fx.go { animation-duration: 0.01s; }
}
