:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #101a1a;
  color: #f3f0dd;
  --gold: #f4ce79;
  --muted: #a9bcb3;
  --edge: #354a43;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-block-size: 100svh; background: radial-gradient(ellipse at 50% 3%, #233831, #101a1a 70%); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible { outline: 2px solid #fff5c6; outline-offset: 4px; }
.game-shell { width: min(1180px, calc(100% - 56px), calc((100svh - 155px) * 16 / 9)); margin: auto; padding: 23px 0 20px; }
.masthead, .toolbar, .brand, .help-strip, .keyboard { display: flex; align-items: center; }
.masthead, .help-strip { justify-content: space-between; gap: 15px; }
.masthead { margin-bottom: 15px; }
.brand { gap: 10px; font-size: 13px; letter-spacing: .14em; font-weight: 850; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; color: var(--gold); background: #344335; border: 1px solid #706445; font-weight: 900; font-size: 21px; }
.toolbar { gap: 7px; }
.tool { border: 1px solid var(--edge); background: #192724; border-radius: 7px; padding: 7px 10px; font-size: 12px; white-space: nowrap; }
.tool:hover:enabled { background: #2a3d33; }
.tool kbd { margin-left: 4px; }
.shop-button { border-color: #8c784c; color: var(--gold); font-weight: 750; }
.shop-button:hover:enabled { border-color: var(--gold); }
.game-frame { position: relative; overflow: hidden; isolation: isolate; border: 1px solid #607165; border-radius: 14px; background: #102e2c url("assets/klanac-iskri.webp") center/cover; box-shadow: 0 22px 70px #070d0c88; }
#game { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.cover, .modal { position: absolute; inset: 0; display: grid; align-items: center; }
.cover {
  grid-template-columns: minmax(0, 4fr) minmax(0, 5fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(9px, 1.7cqw, 20px) 4%;
  padding: clamp(13px, 2.7cqw, 32px) 6%;
  background: linear-gradient(0deg, #091714e8, transparent 56%), linear-gradient(90deg, #0c1d1bf2 0%, #0c1d1ba8 49%, #0c1d1b40 100%), url("assets/klanac-iskri.webp") center/cover;
}
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--gold); font-size: clamp(9px, 1.15vw, 13px); font-weight: 800; letter-spacing: .18em; }
h1, h2 { font-family: Georgia, serif; letter-spacing: -.055em; }
h1 { margin: .16em 0 .27em; font-size: clamp(29px, 8.2cqw, 100px); line-height: .83; font-weight: 700; text-shadow: 0 4px 30px #080f0e60; }
.game-frame { container-type: inline-size; }
h1 em { color: var(--gold); font-weight: 700; }
.author-credit { margin: 0 0 .65em; color: #f3f0dd; font-size: clamp(13px, 1.45cqw, 16px); font-weight: 650; line-height: 1.4; }
.intro { color: #d5ded2; max-width: 36ch; margin: 0; line-height: 1.5; font-size: clamp(12px, 1.35cqw, 16px); }
.primary { display: inline-flex; align-items: center; gap: 22px; background: var(--gold); color: #25221a; font-weight: 850; border: 1px solid #ffe7a4; border-radius: 7px; padding: 11px 15px; font-size: 14px; box-shadow: 0 4px 0 #986831; }
.primary:hover { background: #ffe3a2; }
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #986831; }
.cover-shop { margin-block-start: clamp(9px, 1.8cqw, 19px); }
.level-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(5px, .8cqw, 10px); }
.level-button { display: grid; align-content: start; text-align: left; gap: 3px; padding: clamp(6px, .9cqw, 11px) clamp(6px, 1.1cqw, 13px); background: #142521ee; border: 1px solid #9caa859c; border-radius: 8px; overflow-wrap: anywhere; }
.level-button:hover { background: #30483b; border-color: var(--gold); }
.level-button strong { font-size: clamp(11px, 1.5cqw, 18px); line-height: 1.2; }
.level-button small { color: #ecd28d; font-size: clamp(9px, 1.05cqw, 12px); line-height: 1.2; }
.skin-picker { grid-column: 1 / -1; }
.skin-picker-top {
  display: flex;
  align-items: center;
  margin: 0 0 7px;
  gap: 6px clamp(6px, 1.5cqw, 12px);
  flex-wrap: wrap;
}
.skin-picker-top::after {
  content: "";
  order: 1;
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #f4ce7960, #a9bcb31a);
}
.skin-heading {
  margin: 0;
  font: 800 clamp(10px, 1.1cqw, 13px)/1.2 system-ui, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.collection-summary {
  order: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: #c1e9d8;
  font-size: clamp(10px, 1.1cqw, 13px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.skin-list { display: grid; grid-template-columns: minmax(0, clamp(90px, 14cqw, 150px)); }
.skin-button {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  min-width: 0;
  padding: 2px 3px 6px;
  border: 1px solid #6a8676a3;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--skin-accent, #f4ce79) 22%, transparent), transparent 70%), #122a26;
}
.skin-button:hover { border-color: var(--skin-accent, var(--gold)); background-color: #284137; }
.skin-button[aria-pressed="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 1px #f4ce7988; background-color: #2c3930; }
.skin-button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 8px;
  width: 5px;
  height: 9px;
  border: solid var(--gold);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.skin-button:focus-visible { outline-offset: 2px; }
.skin-preview { display: block; width: min(100%, clamp(73px, 10.4cqw, 122px)); height: auto; }
.skin-name { font-size: clamp(11px, 1.25cqw, 14px); line-height: 1.2; font-weight: 800; }
.skin-button[aria-pressed="true"] .skin-name { color: var(--gold); }
.hud { position: absolute; top: 4%; left: 3%; right: 3%; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; text-shadow: 0 2px 8px #06120d; }
.hud-location { display: grid; min-width: 0; gap: 2px; }
.hud-location strong { font-family: Georgia, serif; font-size: clamp(12px, 2.35cqw, 28px); }
.hud small { font-size: clamp(7px, 1.1cqw, 11px); letter-spacing: .12em; font-weight: 800; color: #fae7a9; }
.progress { display: flex; gap: 4px; margin-top: 3px; }
.progress i { width: clamp(9px, 2cqw, 22px); height: 3px; background: #d2dfd47d; border-radius: 9px; }
.progress i.active { background: var(--gold); box-shadow: 0 0 6px #f8d78788; }
.hud-stats { display: flex; flex-shrink: 0; align-self: start; align-items: center; gap: clamp(5px, 1.4cqw, 14px); padding: 6px 9px; border-radius: 8px; background: #102522ec; border: 1px solid #c4e7cc48; font-size: clamp(9px, 1.35cqw, 14px); font-variant-numeric: tabular-nums; }
.hud-stats > span { display: flex; gap: 5px; align-items: center; }
.boss-hud {
  --boss-color: #e8ca85;
  position: absolute;
  bottom: 3.5%;
  left: 50%;
  width: clamp(155px, 34%, 320px);
  transform: translateX(-50%);
  display: grid;
  gap: 4px;
  padding: clamp(4px, .8cqw, 9px) clamp(6px, 1.15cqw, 12px);
  border: 1px solid #a5a77c8c;
  border-radius: 8px;
  background: #132720f5;
  pointer-events: none;
}
.boss-hud[data-phase="charging"] { --boss-color: #ffb26a; }
.boss-hud[data-phase="attacking"] { --boss-color: #ff947d; }
.boss-hud[data-phase="exposed"] { --boss-color: #a8f9e6; }
.boss-hud[data-phase="defeated"] { --boss-color: #add1bb; }
.boss-label { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.boss-label strong { font-size: clamp(11px, 1.5cqw, 16px); }
.boss-label span { color: var(--boss-color); font-size: clamp(9px, 1.1cqw, 12px); font-weight: 700; }
#boss-health { display: block; width: 100%; height: clamp(4px, .9cqw, 8px); appearance: none; overflow: hidden; border: 0; border-radius: 9px; background: #3b4c40; }
#boss-health::-webkit-progress-bar { background: #3b4c40; }
#boss-health::-webkit-progress-value { background: var(--boss-color); }
#boss-health::-moz-progress-bar { background: var(--boss-color); }
.spark-icon { width: 8px; height: 8px; background: var(--gold); transform: rotate(45deg); box-shadow: 0 0 9px #f5ce7977; }
.hud-wallet { color: #adf7c6; }
.coin-icon, .shop-balance::before {
  display: inline-block;
  flex-shrink: 0;
  width: clamp(8px, 1.12cqw, 12px);
  aspect-ratio: 1;
  clip-path: polygon(23% 0, 77% 0, 100% 32%, 50% 100%, 0 32%);
  background: conic-gradient(from 20deg at 50% 32%, #adffd0 0deg 52deg, #4fe697 52deg 105deg, #148c5b 105deg 174deg, #31bd7c 174deg 246deg, #64eeaa 246deg 316deg, #bcffe1 316deg);
}
.egg-icon {
  width: 9px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 52% 52% 48% 48% / 65% 65% 38% 38%;
  background: radial-gradient(circle at 36% 33%, #effff1 12%, transparent 22%), #8ddcc8;
  box-shadow: inset -1px -2px 0 #3a998f, 0 0 7px #8ddcc854;
}
.notice { position: absolute; top: 16%; left: 50%; transform: translateX(-50%); padding: 5px 10px; border-radius: 5px; background: #213c33ed; border: 1px solid #7a9d70; color: #f8edc5; font-size: clamp(9px, 1.4cqw, 14px); white-space: nowrap; pointer-events: none; }
.modal { justify-items: center; background: #0b1716b5; }
.modal-card { max-width: calc(100% - 12px); text-align: center; padding: clamp(8px, 3.5cqw, 36px); background: #182c27; border: 1px solid #69806b; border-radius: 12px; }
.modal-card .eyebrow { justify-content: center; }
h2 { color: var(--gold); font-size: clamp(24px, 5.3cqw, 58px); margin: .12em 0; }
#modal-text { color: #d5decf; margin: 0 0 13px; font-size: clamp(11px, 1.6cqw, 16px); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.shop-dialog {
  width: min(570px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: clamp(14px, 5vw, 26px);
  color: inherit;
  background: linear-gradient(145deg, #203d36, #162823 62%);
  border: 1px solid #718777;
  border-radius: 14px;
  box-shadow: 0 22px 70px #071411c9;
}
.shop-dialog::backdrop { background: #081512b8; }
.shop-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.shop-head h2 { margin: 0; font-size: clamp(24px, 5vw, 40px); line-height: 1.1; }
.shop-status { margin: 13px 0; padding-bottom: 14px; border-bottom: 1px solid #78927e58; }
.shop-balance { margin: 0; color: #adf7c6; font-size: 21px; font-weight: 850; font-variant-numeric: tabular-nums; }
.shop-balance::before { content: ""; width: 16px; margin-right: 7px; vertical-align: -.02em; }
.shop-progress { margin: 4px 0 0; color: #c3dbcf; font-size: 13px; }
.hunt-button { margin-top: 9px; border-color: #8c784c; color: var(--gold); }
.shop-tabs { display: flex; gap: 6px; margin: 0 0 10px; }
.shop-tabs .tool { font-weight: 750; }
.shop-tabs [aria-pressed="true"] { background: #37463a; color: var(--gold); border-color: #bb9860; }
.shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
:is(.emote-card, .skin-card) {
  --tier-color: #bbd4c4;
  --tier-shade: #2a423a;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--tier-color) 42%, #1e2b2a);
  border-radius: 10px;
  background: linear-gradient(145deg, var(--tier-shade), #112520 82%);
}
.skin-card { grid-template-columns: 77px minmax(0, 1fr); }
:is(.emote-card, .skin-card)[data-tier="rare"] { --tier-color: #94d5ff; --tier-shade: #224055; }
:is(.emote-card, .skin-card)[data-tier="epic"] { --tier-color: #e3b7ff; --tier-shade: #3d3055; }
:is(.emote-card, .skin-card)[data-tier="legendary"] { --tier-color: #ffdc87; --tier-shade: #56432b; }
.emote-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--tier-color) 55%, var(--tier-shade));
  border-radius: 8px;
  color: var(--tier-color);
  background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--tier-color) 28%, var(--tier-shade)), var(--tier-shade) 75%);
  font: 750 29px/1 system-ui, sans-serif;
  text-shadow: 0 2px 4px #071411bb;
}
.emote-art::after { content: "✦"; position: absolute; top: 7%; right: 10%; font-size: 9px; }
.emote-art--wall::before {
  content: "";
  width: 46%;
  height: 65%;
  border: 2px solid currentColor;
  border-radius: 45% 45% 10% 10%;
  background: linear-gradient(115deg, transparent 31%, #89cfff70 35% 44%, transparent 48%), #121f34;
  box-shadow: inset 0 0 8px #abe4ff7e, 0 0 10px #80c6ff55;
}
.shop-skin-preview {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid color-mix(in srgb, var(--tier-color) 55%, var(--tier-shade));
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 38%, color-mix(in srgb, var(--tier-color) 25%, var(--tier-shade)), var(--tier-shade) 80%);
}
.emote-details h3, .skin-details h3 { margin: 1px 0 3px; font-size: 16px; line-height: 1.14; }
.emote-tier, .skin-tier { margin: 0; color: var(--tier-color); font-size: 9px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.emote-price, .emote-description, .skin-price { margin: 2px 0 0; color: #d2ded3; font-size: 11px; }
:is(.emote-action, .skin-action) {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--tier-color);
  border-radius: 6px;
  color: #18241e;
  background: var(--tier-color);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
}
:is(.emote-action, .skin-action):hover:enabled { background: color-mix(in srgb, var(--tier-color) 82%, white); }
:is(.emote-action, .skin-action):disabled { background: #27382f; color: #bacbc0; border-color: #556d5e; opacity: 1; }
:is(.emote-action, .skin-action)[data-equipped]:not([data-equipped="false"]) { color: var(--tier-color); border-color: var(--tier-color); }
@media (min-width: 476px) {
  .emote-card--discovery { grid-column: 1 / -1; grid-template: auto / 50px minmax(0, 1fr) minmax(86px, auto); }
  .emote-card--discovery .emote-action { grid-column: auto; }
}
@media (max-width: 475px) {
  .shop-grid { grid-template-columns: 1fr; gap: 7px; }
  :is(.emote-card, .skin-card) { grid-template: auto / 42px minmax(0, 1fr) minmax(66px, auto); gap: 7px; padding: 7px; }
  .skin-card { grid-template-columns: 56px minmax(0, 1fr) minmax(66px, auto); }
  .emote-art { font-size: 24px; }
  :is(.emote-action, .skin-action) { grid-column: auto; max-width: 108px; }
}
@media (max-width: 315px) {
  :is(.emote-card, .skin-card) { grid-template: auto auto / 48px minmax(0, 1fr); }
  :is(.emote-action, .skin-action) { grid-column: 1 / -1; max-width: none; }
}
.help-strip { margin-top: 13px; color: var(--muted); font-size: 12px; }
.help-strip p { margin: 0; }
.keyboard { gap: 12px; flex-shrink: 0; flex-wrap: wrap; }
.keyboard span { white-space: nowrap; }
kbd { display: inline-block; font: 11px system-ui, sans-serif; font-weight: 650; padding: 2px 5px; border: 1px solid #496158; border-radius: 4px; color: #ebefe3; background: #23332f; }
.keyboard kbd + kbd { margin-left: 3px; }
.touch, #restart-touch { display: none; }
.touch { align-items: flex-end; justify-content: space-between; gap: 6px 8px; margin-top: 10px; }
.touch-movement, .touch-actions { display: flex; gap: 5px; }
.touch-actions { justify-content: flex-end; flex-wrap: wrap; }
.touch button {
  min-width: 44px;
  min-height: 48px;
  padding: 4px 7px;
  border: 1px solid #647e70;
  background: #243d35;
  border-radius: 8px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  font-size: clamp(11px, 3.5vw, 15px);
  font-weight: 800;
}
.touch-movement button { width: clamp(44px, 12vw, 64px); font-size: 23px; line-height: 1; }
#emote-touch { color: var(--gold); border-color: #a58e59; }
#sword-touch { color: #a8f9e6; border-color: #6b9d90; }
.touch button:is(:active, .is-pressed) { background: #775f33; box-shadow: inset 0 2px 4px #2b1b1499; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (pointer: coarse) { .keyboard, .tool kbd { display: none; } }
@media (max-width: 790px), (max-height: 530px) {
  .game-shell { width: calc(100% - 24px); padding-top: 12px; }
  .help-strip { flex-wrap: wrap; }
  .keyboard { flex-shrink: 1; }
}
@media (max-width: 530px) {
  .game-shell { width: calc(100% - 16px); }
  .masthead { flex-wrap: wrap; gap: 8px 10px; margin-bottom: 9px; }
  .brand { font-size: 10px; gap: 6px; }
  .brand-mark { width: 24px; height: 24px; }
  .tool { padding: 4px 6px; font-size: 11px; }
  .intro { display: none; }
  .primary { padding: 6px 9px; gap: 9px; font-size: 12px; }
  .level-button { gap: 0; border-radius: 5px; padding-block: 3px; }
  .level-button strong, .level-button small { line-height: 1.25; }
  .hud-stats { padding: 3px 5px; }
  .hud-stats > span { gap: 3px; }
  .hud-stats .egg-icon { width: 7px; height: 9px; }
}
@container (max-width: 740px) {
  #game:has(~ .cover:not([hidden])) { display: none; }
  .cover { position: relative; gap: 15px 5%; padding: 16px 5%; }
}
@container (max-width: 550px) {
  .cover { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  h1 { font-size: clamp(35px, 11cqw, 49px); }
  .level-button { padding-block: 6px; }
}
@container (max-width: 375px) {
  .hud-stats { display: grid; grid-template-columns: repeat(3, max-content); row-gap: 3px; }
}

@media (any-pointer: coarse) {
  body { padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
  .game-shell {
    --shell-top: max(8px, env(safe-area-inset-top));
    --shell-bottom: max(8px, env(safe-area-inset-bottom));
    width: min(1180px, calc(100% - 16px));
    padding-block: var(--shell-top) var(--shell-bottom);
  }
  .game-shell:has(#cover[hidden]) {
    /* Keep the stacked controls and help visible on larger touch screens. */
    width: min(1180px, calc(100% - 16px), max(34rem, calc((100svh - var(--shell-top) - var(--shell-bottom) - 146px) * 16 / 9)));
  }
  .masthead { margin-bottom: 8px; }
  .toolbar { flex-wrap: wrap; gap: 4px; }
  button { touch-action: manipulation; }
  :is(.tool, .primary, .level-button, .emote-action, .skin-action) { min-height: 44px; }
  #restart-touch { display: inline-block; }
  .touch { display: flex; }
  .help-strip { margin-top: 8px; }
  .notice {
    top: max(16%, 39px);
    width: max-content;
    max-width: 94%;
    white-space: normal;
    text-align: center;
  }
  .modal { align-items: safe center; overflow-y: auto; }
}

@media (any-pointer: coarse) and (orientation: landscape) and (min-width: 480px) and (max-height: 540px) {
  .game-shell:has(#cover[hidden]) {
    --control-width: 100px;
    --control-gap: 8px;
    /* Leave space for the toolbar and a two-line room hint. */
    --frame-width: calc((100svh - var(--shell-top) - var(--shell-bottom) - 88px) * 16 / 9);
    display: grid;
    grid-template-columns: var(--control-width) minmax(0, 1fr) var(--control-width);
    column-gap: var(--control-gap);
    width: min(1180px, calc(100% - 16px), calc(var(--frame-width) + 2 * (var(--control-width) + var(--control-gap))));
  }
  .game-shell:has(#cover[hidden]) .masthead { grid-area: 1 / 1 / 2 / -1; }
  .game-shell:has(#cover[hidden]) .game-frame { grid-area: 2 / 2; }
  .game-shell:has(#cover[hidden]) .help-strip { grid-area: 3 / 1 / 4 / -1; }
  .touch { display: contents; }
  .touch-movement, .touch-actions { align-self: end; }
  .touch-movement { grid-area: 2 / 1; }
  .touch-movement button { width: 100%; }
  .touch-actions { grid-area: 2 / 3; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .touch-actions button { padding-inline: 2px; font-size: 12px; }
  #game:has(~ .cover:not([hidden])) { display: none; }
  .cover { position: relative; gap: 15px 5%; padding: 16px 5%; }
}
