/* KVAZAR — rozloženie vypĺňa celé okno bez rolovania: hracia plocha vľavo, stavový panel vpravo. */
:root {
  --bg: #05070f;
  --panel: #0c1224;
  --panel-2: #131a31;
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8ecf6;
  --muted: #8d99b5;
  --accent: #7dd3fc;
  --accent-ink: #04202e;
  --gold: #fcd34d;
  --danger: #fb7185;
  --good: #86efac;
  --pad: 12px;
  --side: clamp(232px, 21vw, 300px);
  --ratio: 1.4;                 /* 1120 / 800 */
  --radius: 14px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 90% at 30% 0%, #0d1430 0%, var(--bg) 60%) fixed;
  color: var(--text);
  font: 14px/1.4 var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, dl, dd, p, h1, h2 { margin: 0; padding: 0; }
ul { list-style: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

kbd {
  display: inline-block;
  padding: 0.05em 0.5em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--panel-2);
  font: 600 0.82em var(--font);
  color: var(--text);
}

/* ---------- rozloženie ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  gap: var(--pad);
  height: 100vh;
  height: 100dvh;
  padding: var(--pad);
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
}
.stage { display: grid; place-items: center; min-width: 0; min-height: 0; }
.field {
  position: relative;
  width: min(100%, calc((100vh - 2 * var(--pad)) * var(--ratio)));
  width: min(100%, calc((100dvh - 2 * var(--pad)) * var(--ratio)));
  aspect-ratio: 1120 / 800;
  container-type: inline-size;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px rgba(0, 0, 0, 0.55);
  touch-action: none;
}
.field canvas { display: block; width: 100%; height: 100%; }
.field.playing canvas { cursor: none; }

/* ---------- hlášky nad plochou ---------- */
.hint, .toast {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}
.hint {
  bottom: 17%;
  padding: 0.5em 1.1em;
  border-radius: 999px;
  background: rgba(8, 12, 26, 0.72);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: clamp(12px, 1.5cqw, 17px);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.toast {
  top: 58%;
  font-size: clamp(15px, 2.4cqw, 28px);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--good);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.8);
  opacity: 0;
}
.toast.bad { color: var(--danger); }
.toast.show { animation: toast 1.5s ease-out both; }
@keyframes toast {
  0% { opacity: 0; transform: translateY(14px) scale(0.92); }
  12% { opacity: 1; transform: none; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px); }
}

/* ---------- prekryvné obrazovky ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 3cqw;
  background: rgba(4, 6, 14, 0.66);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  font-size: clamp(12px, 1.45cqw, 17px);
  overflow: auto;
}
.panel {
  display: grid;
  justify-items: center;
  gap: 0.9em;
  width: min(100%, 31em);
  text-align: center;
  animation: rise 0.28s ease-out both;
}
.panel.wide { width: min(100%, 46em); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.kicker {
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.logo {
  font-size: clamp(40px, 9.5cqw, 120px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #ffffff 10%, #bae6fd 55%, #6366f1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 26px rgba(125, 211, 252, 0.3));
}
.panel h2 { font-size: 2.4em; font-weight: 800; line-height: 1.1; }
.lead { color: var(--muted); max-width: 30em; text-wrap: balance; }
.foot { color: var(--muted); font-size: 0.85em; min-height: 1.4em; }

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 100%;
  padding: 4px;
  border-radius: 14px;
  background: rgba(12, 18, 36, 0.8);
  border: 1px solid var(--line);
}
.seg button {
  display: grid;
  gap: 1px;
  padding: 0.55em 0.4em;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  color: var(--muted);
}
.seg small { font-size: 0.72em; font-weight: 500; opacity: 0.85; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.45); }

.actions { display: grid; gap: 0.55em; width: min(100%, 20em); }
.actions.row { width: auto; }
.btn {
  padding: 0.75em 1.4em;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  font-weight: 700;
  font-size: 1.05em;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
}
.btn:hover { border-color: rgba(125, 211, 252, 0.5); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn[data-primary] {
  background: linear-gradient(180deg, #a5e4ff, #5cc4f5);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 8px 26px rgba(92, 196, 245, 0.28);
}
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost[data-primary] { background: var(--panel-2); color: var(--text); box-shadow: none; border-color: var(--line); }
.btn.ghost:hover { color: var(--text); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6em; width: min(100%, 20em); }
.stats > div { padding: 0.7em; border-radius: 12px; background: rgba(12, 18, 36, 0.8); border: 1px solid var(--line); }
.stats dt { font-size: 0.75em; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.stats dd { font: 700 1.5em var(--mono); font-variant-numeric: tabular-nums; }

.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5em; width: 100%; }
.level-grid button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 0.75em;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(12, 18, 36, 0.85);
  text-align: left;
  font-weight: 600;
}
.level-grid b {
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
  border-radius: 8px;
  background: hsl(var(--hue) 70% 60% / 0.2);
  color: hsl(var(--hue) 90% 78%);
  font: 700 0.95em var(--mono);
}
.level-grid span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-grid button:hover:not(:disabled) { border-color: hsl(var(--hue) 80% 70% / 0.7); }
.level-grid button:disabled { opacity: 0.38; cursor: not-allowed; }

.help { display: grid; gap: 0.6em; text-align: left; color: var(--muted); }
.help li { padding: 0.6em 0.9em; border-radius: 12px; background: rgba(12, 18, 36, 0.8); border: 1px solid var(--line); }
.help b { color: var(--text); }

/* ---------- bočný panel ---------- */
.side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; color: var(--accent); }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand strong { display: block; font-size: 20px; font-weight: 900; letter-spacing: 0.14em; color: var(--text); line-height: 1.1; }
.brand span { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.card { padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
output { display: block; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.big { font-size: clamp(28px, 2.9vw, 40px); line-height: 1.1; letter-spacing: -0.01em; }
.pair { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.pair output { font-size: 16px; }
.combo { color: var(--muted); text-align: right; transition: color 0.15s, transform 0.15s; transform-origin: right center; }
.combo.hot { color: var(--gold); transform: scale(1.25); }

.chip { padding: 2px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; font-weight: 700; color: var(--accent); }
.level-name { display: block; margin: 3px 0 9px; font-size: 19px; font-weight: 800; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--accent), #a5b4fc); transition: transform 0.25s; }
.lives-row { margin-top: 11px; }
.lives { display: flex; gap: 5px; }
.lives i { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #bae6fd 70%); box-shadow: 0 0 8px rgba(186, 230, 253, 0.6); }
.lives i.off { background: var(--panel-2); box-shadow: none; }

.effects-card { flex: 1 1 96px; min-height: 76px; overflow: hidden; }
.effects { display: grid; gap: 7px; margin-top: 8px; }
.effects li { display: grid; grid-template-columns: 22px 1fr; align-items: center; column-gap: 8px; font-weight: 600; font-size: 13px; }
.effects .empty { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.pill {
  display: grid;
  place-items: center;
  width: 22px;
  height: 16px;
  border-radius: 8px;
  background: var(--c, var(--accent));
  color: #020617;
  font: 800 10.5px var(--font);
}
.pill.bad { outline: 1px dashed #fecaca; outline-offset: 1px; }
.effects .timer { grid-column: 2; height: 3px; margin-top: 3px; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.effects .timer i { display: block; height: 100%; background: var(--c, var(--accent)); transform-origin: left; }

.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 7px; min-width: 0; }
.legend span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.keys { display: grid; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.keys > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.keys dd { text-align: right; }

.tools { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.tool {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.tool:hover { border-color: rgba(125, 211, 252, 0.5); }
.tool svg { width: 20px; height: 20px; fill: currentColor; }
.tool .cross { display: none; }
.tool[aria-pressed="true"] { color: var(--danger); }
.tool[aria-pressed="true"] .waves { display: none; }
.tool[aria-pressed="true"] .cross { display: block; }
.volume { flex: 1; display: flex; min-width: 0; }
.volume input { width: 100%; accent-color: var(--accent); }

/* nižšie okná: najprv zmizne ovládanie, potom legenda */
@media (max-height: 760px) { .keys-card { display: none; } }
@media (max-height: 640px) { .legend-card { display: none; } .card { padding: 9px 12px; } .side { gap: 7px; } }
@media (max-height: 520px) { .brand { display: none; } }

/* úzke okná a telefóny: panel sa zloží do pásu nad plochou */
@media (max-width: 820px), (max-aspect-ratio: 11/10) {
  :root { --strip: 64px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--strip) minmax(0, 1fr); gap: 8px; }
  .side { order: -1; flex-direction: row; align-items: stretch; gap: 8px; }
  .card { flex: 1; min-width: 0; padding: 6px 12px; display: flex; flex-direction: column; justify-content: center; }
  .side .brand, .side .effects-card, .side .legend-card, .side .keys-card,
  .side .pair, .side .volume, .side .level-name, .side .bar, .side #btnFull { display: none; }
  .label { white-space: nowrap; }
  .big { font-size: 22px; }
  .lives-row { margin-top: 4px; }
  .tools { margin: 0; }
  .field {
    width: min(100%, calc((100vh - var(--strip) - 8px - 2 * var(--pad)) * var(--ratio)));
    width: min(100%, calc((100dvh - var(--strip) - 8px - 2 * var(--pad)) * var(--ratio)));
  }
  .level-grid { grid-template-columns: repeat(2, 1fr); }
}

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

/* CSP-safe finite palettes and native progress meters. */
.power-wide { --c: #5eead4; }
.power-multi { --c: #c4b5fd; }
.power-laser { --c: #fdba74; }
.power-slow { --c: #7dd3fc; }
.power-fire { --c: #fb923c; }
.power-magnet { --c: #f0abfc; }
.power-shield { --c: #86efac; }
.power-life { --c: #fda4af; }
.power-shrink { --c: #f87171; }
.power-fast { --c: #f87171; }
.level-color-0 { --hue: 205; }
.level-color-1 { --hue: 28; }
.level-color-2 { --hue: 215; }
.level-color-3 { --hue: 150; }
.level-color-4 { --hue: 8; }
.level-color-5 { --hue: 265; }
.level-color-6 { --hue: 185; }
.level-color-7 { --hue: 40; }
.level-color-8 { --hue: 320; }
.level-color-9 { --hue: 345; }
.level-color-10 { --hue: 95; }
.level-color-11 { --hue: 225; }
.level-color-12 { --hue: 130; }
.level-color-13 { --hue: 48; }
.level-color-14 { --hue: 285; }
.level-color-15 { --hue: 355; }
progress { appearance: none; border: 0; background: var(--panel-2); color: var(--c, var(--accent)); }
.bar progress { display: block; width: 100%; height: 6px; }
progress::-webkit-progress-bar { background: var(--panel-2); }
progress::-webkit-progress-value { background: var(--c, var(--accent)); }
progress::-moz-progress-bar { background: var(--c, var(--accent)); }
.effects progress.timer { width: 100%; }
@media (max-width: 480px) {
 .side #diffChip { display: none; }
 .overlay { align-items: safe center; padding: 8px; }
 [data-screen="menu"] { gap: 5px; }
 [data-screen="menu"] .logo { font-size: 34px; }
 [data-screen="menu"] .kicker, [data-screen="menu"] .foot { display: none; }
 [data-screen="menu"] .actions { width: 100%; grid-template-columns: 1fr 1fr; gap: 5px; }
 [data-screen="menu"] .btn { padding: 7px 5px; font-size: 12px; }
 [data-screen="menu"] .seg button { padding: 5px 2px; }
}
