@font-face {
  font-family: "Golos Text";
  src: url("art/golos-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Golos Text";
  src: url("art/golos-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  font-family: "Golos Text", "Segoe UI", system-ui, sans-serif;
  color: #f0f6fd;
  background: #0a111c;
  --surface: #111c2b;
  --line: #314358;
  --muted: #a9bfd3;
  --ice: #9aeaff;
  --amber: #ffd19f;
  --coral: #ff987e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, select { font: inherit; color: inherit; }
::selection { color: #091521; background: var(--ice); }

.game {
  width: 100%;
  height: 100dvh;
  min-height: 390px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px clamp(12px, 2.4vw, 38px) 10px;
  background: #0a111c;
  overflow: auto;
}

.game:fullscreen { min-height: 0; }

.masthead, .actions, .controls, .menu-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.masthead, .hud, .nexo, footer { flex: 0 0 auto; }
.masthead { justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 760; white-space: nowrap; }
.brand-mark { display: grid; width: 22px; height: 25px; place-items: center; background: #8bc1d9; clip-path: polygon(0 0,100% 0,100% 62%,50% 100%,0 62%); }
.brand-mark::before { content: ""; width: 12px; height: 14px; background: #1a3148; clip-path: polygon(0 0,100% 0,100% 56%,50% 100%,0 56%); }

button, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

button {
  cursor: pointer;
  min-height: 36px;
  padding: 6px 12px;
  font-weight: 620;
  transition: background-color .16s, border-color .16s, color .16s;
}

button:hover:not(:disabled) { background-color: #1a2d44; border-color: #607b96; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--ice); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .48; }
.actions button { font-size: 13px; }
#fullscreen { display: grid; place-items: center; width: 38px; padding: 0; }
#fullscreen svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
#fullscreen[aria-pressed="true"] { color: var(--ice); border-color: #6294a8; }
.game[data-mode="title"] :is(#pause, #restart) { display: none; }

.hud {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(115px, auto) minmax(0, 1fr);
  gap: clamp(8px, 4vw, 68px);
  padding: 1px 6px 3px;
  font-variant-numeric: tabular-nums;
}

.meter { display: grid; gap: 7px; width: min(100%, 390px); }
.health { grid-column: 1; }
.core { grid-column: 3; justify-self: end; }
label { color: var(--muted); font-size: 13px; }
.meter label, .boss-label { display: flex; justify-content: space-between; gap: 8px; }
.meter label > :first-child { color: #eef5fc; }
.clock { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 2px 11px; grid-column: 2; }
.clock span { color: var(--muted); font-size: 12px; }
.clock strong { font-size: 19px; letter-spacing: -.025em; }
#enemyCount { width: 100%; text-align: center; }
#enemyCount:empty { display: none; }

progress {
  --meter-color: var(--coral);
  display: block;
  width: 100%;
  height: 5px;
  appearance: none;
  border: 0;
  border-radius: 3px;
  background: #27374b;
  overflow: hidden;
}
progress::-webkit-progress-bar { background: #27374b; }
progress::-webkit-progress-value { background: var(--meter-color); }
progress::-moz-progress-bar { background: var(--meter-color); }
#core, #recharge { --meter-color: var(--ice); }
#bossHealth { --meter-color: var(--amber); }

.arena {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1 1 auto;
  min-height: 0;
  background: #0d1827;
  border: 1px solid #314759;
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  container-type: size;
}

.stage { position: relative; width: min(100%, 177.7778cqh); aspect-ratio: 16 / 9; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; cursor: crosshair; touch-action: none; image-rendering: pixelated; }
.game[data-mode="title"] .stage { width: 100%; height: 100%; aspect-ratio: auto; }
.game[data-mode="title"] canvas { height: 100%; object-fit: cover; pointer-events: none; }

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: safe center;
  justify-items: center;
  padding: clamp(15px, 4vw, 56px);
  overflow-y: auto;
  background: #081320de;
}

.game[data-mode="title"] #overlay {
  justify-items: start;
  background: linear-gradient(90deg, #081320 3%, #081320f2 28%, #08132094 52%, #08132012 78%);
}

.menu { width: min(100%, 690px); text-align: center; }
.game[data-mode="title"] .menu { width: min(100%, 510px); text-align: left; }

.menu h1 {
  margin: 0;
  font-size: clamp(30px, 5.7vw, 84px);
  line-height: 1.01;
  font-weight: 870;
  letter-spacing: -.038em;
  text-wrap: balance;
}

.game[data-mode="title"] h1 { max-width: 9ch; text-wrap: initial; }
#description { margin: 12px auto 23px; max-width: 43ch; color: #c4d5e6; line-height: 1.5; font-size: clamp(13px, 1.37vw, 18px); }
.game[data-mode="title"] #description { margin-inline: 0; }

#roster {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 445px);
  margin-bottom: 16px;
}

.knight-card {
  --portrait: url("art/clay.png");
  display: grid;
  justify-items: center;
  min-width: 0;
  gap: 4px;
  padding: 4px 2px 8px;
  border-radius: 10px;
  background: #152438e8;
  color: #d7e7f5;
  font-size: clamp(11px, 1.12vw, 13px);
}

.knight-card[data-knight="lancer"] { --portrait: url("art/lance.png"); }
.knight-card[data-knight="scout"] { --portrait: url("art/aaron.png"); }
.knight-card[data-knight="axl"] { --portrait: url("art/axl.png"); }
.knight-card[data-knight="macy"] { --portrait: url("art/macy.png"); }
.knight-card[aria-pressed="true"] { border-color: #78bdd3; background: #203a52; color: #f1fbff; }

.knight-portrait {
  width: min(100%, 52px);
  height: 50px;
  background: var(--portrait) -17px 0 / auto 50px no-repeat;
  image-rendering: pixelated;
}

#knightDetail { grid-column: 1 / -1; min-height: 2.6em; margin: 4px 0 0; color: #bdd2e5; font-size: 13px; line-height: 1.42; }
.menu-actions { flex-wrap: wrap; justify-content: center; gap: 12px 16px; }
.game[data-mode="title"] .menu-actions { justify-content: start; }

#start {
  min-height: 46px;
  padding-inline: 27px;
  background: var(--ice);
  border-color: var(--ice);
  color: #0b2233;
  font-weight: 800;
}
#start:hover { background: #c8f6ff; border-color: #c8f6ff; }
#duelPicker { display: flex; align-items: center; gap: 8px; min-width: 0; }
#duel { min-width: 0; max-width: min(100%, 240px); padding: 7px 8px; }

#callout, #bossHud {
  position: absolute;
  margin: 0;
  background: #0c1727f0;
  border: 1px solid #354b61;
  color: #ecf6ff;
  pointer-events: none;
}
#callout {
  inset: 12px auto auto 50%;
  translate: -50%;
  max-width: calc(100% - 20px);
  width: max-content;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: clamp(11px, 1.25vw, 14px);
  font-weight: 650;
  text-align: center;
}
#callout:empty { display: none; }
#bossHud {
  inset: auto auto 12px 50%;
  translate: -50%;
  display: grid;
  gap: 7px;
  width: min(94%, 400px);
  padding: 8px 12px 9px;
  border-radius: 9px;
  font-size: 12px;
}
.boss-label { align-items: baseline; flex-wrap: wrap; gap: 2px 8px; }
#bossName { color: var(--amber); }
#bossStatus { color: #d8c7b6; }

#rewardChoices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.reward { display: grid; align-content: start; gap: 5px; padding: 13px; text-align: left; }
.reward strong { color: var(--amber); font-size: 14px; }
.reward span { color: #c8daeb; font-size: 13px; font-weight: 400; line-height: 1.4; }

.nexo {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px 16px;
  align-items: center;
  padding: 1px 6px;
}

.power-side { display: grid; gap: 4px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.supply { display: flex; flex-wrap: wrap; gap: 3px 13px; }
#shieldStatus { width: 100%; }
.power-slots { display: flex; align-items: center; gap: 5px; }
.power {
  --glow: var(--ice);
  display: flex;
  gap: 7px;
  align-items: center;
  padding-inline: 8px;
  color: #e4edf7;
  font-size: 12px;
  background: #111c2b;
}
.power[aria-pressed="true"] { border-color: var(--glow); color: var(--glow); background: #1a2d44; }
.power.mirror { --glow: #e0cdff; }
.power.thunder { --glow: #ffd684; }
.badge { display: grid; place-items: center; color: var(--glow); }
.badge svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: square; stroke-linejoin: round; }
.badge .bolt { fill: currentColor; stroke: none; }
.power-label, .cast-key { white-space: nowrap; }
.cast-key { margin-left: 5px; color: var(--muted); font-size: 12px; }
.charge { justify-self: end; width: min(100%, 160px); text-align: right; }
#powerStatus { color: #deeffb; font-weight: 650; }

footer { color: var(--muted); font-size: 12px; }
.controls { flex-wrap: wrap; gap: 4px 13px; }
.controls > span { white-space: nowrap; }
kbd {
  display: inline-block;
  background: #172537;
  color: #e2eefc;
  border: 1px solid #374a61;
  padding: 1px 4px;
  border-radius: 4px;
  font: 600 11px/1.3 ui-monospace, monospace;
}

@media (max-width: 720px) {
  .game { padding: 8px; gap: 8px; }
  .masthead, .actions { gap: 5px; }
  .actions { flex-wrap: wrap; justify-content: end; }
  .actions button { min-height: 34px; padding: 3px 7px; font-size: 11px; }
  .brand { font-size: 13px; gap: 6px; }
  .brand-mark { width: 16px; height: 19px; }
  .brand-mark::before { width: 8px; height: 11px; }
  .arena { border-radius: 10px; }
  .hud { grid-template-columns: minmax(0, 1fr) minmax(86px, auto) minmax(0, 1fr); gap: 4px 9px; padding-inline: 2px; }
  .meter label, .clock span { font-size: 11px; }
  .clock { gap: 1px 5px; }
  .clock strong { font-size: 14px; }
  .game[data-mode="title"] #overlay { background: linear-gradient(100deg, #081320f7 4%, #081320dc 64%, #0813208c); }
  #description { margin: 8px auto 15px; }
  #knightDetail { font-size: 12px; }
  #start { min-height: 40px; }
  #callout { top: 4px; padding-block: 4px; }
  #bossHud { bottom: 4px; padding: 4px 8px 5px; gap: 4px; font-size: 11px; }
  .nexo { grid-template-columns: 1fr 1fr; padding-inline: 0; }
  .power-slots { grid-column: 1 / -1; grid-row: 1; flex-wrap: wrap; }
  .power { min-height: 34px; gap: 4px; padding-inline: 5px; font-size: 11px; }
  .badge svg { width: 14px; height: 14px; }
  .power-side, .controls, .cast-key { font-size: 11px; }
  .reward { padding: 7px; }
  .reward strong, .reward span { font-size: 11px; }
}

@media (max-width: 720px) and (orientation: portrait) {
  .game { height: 100dvh; min-height: 100dvh; }
  .game:fullscreen { height: 100%; }
  .arena { min-height: clamp(158px, 56.25vw, 405px); }
  .game[data-mode="title"] .arena { min-height: min(470px, 75dvh); }
  .game[data-mode="reward"] .arena { min-height: 275px; }
}

@media (max-height: 510px) and (orientation: landscape) {
  .game { min-height: 100dvh; gap: 5px; padding-block: 5px; }
  .game[data-mode="title"] .arena { min-height: 245px; }
  .game[data-mode="title"] h1 { font-size: 34px; max-width: none; }
  #overlay { padding-block: 10px; }
  #description { margin-block: 6px 10px; }
  #roster { margin-bottom: 6px; }
  .knight-portrait { height: 33px; width: 34px; background-position-x: -12px; background-size: auto 33px; }
  #knightDetail { min-height: 1.5em; margin: 0; }
  .masthead button, .power { min-height: 29px; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
