:root {
  color-scheme: dark;
  --bg: #0b1022;
  --panel: #151c36;
  --panel-2: #1d2647;
  --line: rgba(140, 170, 255, 0.22);
  --text: #f3f6ff;
  --muted: #a8b2d6;
  --accent: #7c5cff;
  --accent-2: #a58bff;
  --gold: #ffcf3f;
  --gem: #5ee7ff;
  --hp: #ff5468;
  --hp-2: #ff9a62;
  --ok: #5fe08a;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled {
  cursor: default;
}
:focus-visible {
  outline: 3px solid #ffd84d;
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}

/* ---------- layout: portrait stacks HUD / field / dock; landscape moves the dock to the right ---------- */
.ss-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "hud" "stage" "dock";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(120% 80% at 50% 45%, #18244a 0%, #0d1530 55%, #070b18 100%);
}
@media (min-aspect-ratio: 5/4) and (min-width: 560px) {
  .ss-shell {
    grid-template-columns: minmax(0, 1fr) clamp(220px, 28vw, 320px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "hud dock" "stage dock";
  }
  .ss-dock {
    flex-direction: column;
    justify-content: center;
    border-top: 0 !important;
    border-left: 1px solid var(--line);
  }
  .ss-boosts {
    grid-template-columns: 1fr !important;
  }
  .ss-spells {
    justify-content: center;
  }
}

/* ---------- HUD ---------- */
.ss-hud {
  grid-area: hud;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  min-width: 0;
}
.ss-wave {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 70px;
}
.ss-wave-label {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.ss-wave-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.ss-wave-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7c5cff, #5ee7ff);
  transition: width 0.2s;
}
.ss-hp {
  position: relative;
  flex: 1;
  min-width: 70px;
  height: 22px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.ss-hp-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  background: linear-gradient(180deg, var(--hp-2), var(--hp));
  transition: transform 0.15s;
}
.ss-hp.is-hit .ss-hp-fill {
  filter: brightness(1.6);
}
.ss-hp-text {
  position: relative;
  display: block;
  text-align: center;
  font-size: 12.5px;
  line-height: 20px;
  text-shadow: 0 1px 2px #000;
}
.ss-coins,
.ss-gems {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 6px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 207, 63, 0.35);
  color: var(--gold);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.ss-gems {
  border-color: rgba(94, 231, 255, 0.35);
  color: var(--gem);
}
.ss-coin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b8 0 18%, #ffd23f 40%, #d9900f 100%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.ss-gem {
  width: 14px;
  height: 16px;
  background: linear-gradient(160deg, #e9fdff 0%, #5ee7ff 45%, #2a7dff 100%);
  clip-path: polygon(50% 0, 100% 35%, 80% 100%, 20% 100%, 0 35%);
}
.ss-gem-big {
  width: 34px;
  height: 38px;
}
.ss-gem-text {
  color: var(--gem);
}
.ss-hud-btns {
  display: flex;
  gap: 6px;
}
.ss-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 900;
}
.ss-icon[aria-pressed="true"] {
  background: #3b2f86;
  border-color: var(--accent-2);
}
#mute-btn .ss-wave-off,
#mute-btn[aria-pressed="true"] .ss-wave-on {
  display: none;
}
#mute-btn[aria-pressed="true"] .ss-wave-off {
  display: inline;
}

/* ---------- stage ---------- */
.ss-stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  overflow: hidden;
}
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.ss-banner {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -10px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(8, 12, 30, 0.72);
  border: 1px solid rgba(165, 139, 255, 0.5);
  font-size: clamp(16px, 4.2vw, 24px);
  font-weight: 900;
  white-space: nowrap;
  transition:
    opacity 0.25s,
    transform 0.25s;
}
.ss-banner.is-on {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.ss-banner.is-boss {
  color: #ffd0d0;
  border-color: #ff5468;
  background: rgba(60, 6, 16, 0.8);
}
.ss-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: min(92%, 420px);
  padding: 9px 14px;
  border-radius: 14px;
  background: rgba(255, 246, 214, 0.96);
  color: #2b1d05;
  font-size: 14.5px;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: ss-bob 1.4s ease-in-out infinite;
}
@keyframes ss-bob {
  50% {
    transform: translate(-50%, -4px);
  }
}
.ss-boss {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(70%, 360px);
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffc2c8;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.ss-boss-track {
  height: 8px;
  margin-top: 3px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 84, 104, 0.5);
  overflow: hidden;
}
.ss-boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff3355, #ff9a62);
  transform-origin: left center;
}

/* ---------- dock ---------- */
.ss-dock {
  grid-area: dock;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(21, 28, 54, 0.92), rgba(11, 16, 34, 0.98));
}
.ss-spells {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.ss-spell {
  --cd: 0;
  position: relative;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: radial-gradient(circle at 50% 35%, var(--c1), var(--c2));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}
.ss-spell::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(rgba(5, 8, 20, 0.72) calc(var(--cd) * 1turn), transparent 0);
  pointer-events: none;
}
.ss-spell svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}
.ss-spell .ss-spell-cd {
  position: absolute;
  z-index: 1;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 1px 3px #000;
}
.ss-spell.is-ready {
  border-color: #fff;
  animation: ss-ready 1.2s ease-in-out infinite;
}
@keyframes ss-ready {
  50% {
    box-shadow:
      0 4px 0 rgba(0, 0, 0, 0.35),
      0 0 18px var(--c1);
  }
}
.ss-spell.is-locked {
  filter: grayscale(1) brightness(0.55);
}
.ss-boosts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.ss-boost {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #24305c, #19213f);
  box-shadow: 0 3px 0 #0a0f22;
  text-align: left;
  min-width: 0;
}
.ss-boost:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0a0f22;
}
.ss-boost-ico {
  grid-row: span 2;
  width: 30px;
  height: 30px;
}
.ss-boost-name {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ss-boost-name small {
  color: var(--muted);
  font-size: 11.5px;
}
.ss-boost-cost {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.ss-boost-cost .ss-coin {
  width: 12px;
  height: 12px;
}
.ss-boost.is-poor {
  opacity: 0.55;
}
.ss-boost.is-poor .ss-boost-cost {
  color: #ffb3a6;
}
.ss-boost.is-pulse {
  border-color: var(--gold);
  animation: ss-glow 1s ease-in-out infinite;
}
@keyframes ss-glow {
  50% {
    box-shadow:
      0 3px 0 #0a0f22,
      0 0 0 3px rgba(255, 207, 63, 0.55);
  }
}

/* ---------- overlays ---------- */
.ss-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 8, 20, 0.62);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  animation: ss-fade 0.18s ease;
}
.ss-overlay-dim {
  background: rgba(5, 8, 20, 0.74);
}
@keyframes ss-fade {
  from {
    opacity: 0;
  }
}
.ss-card {
  width: min(100%, 420px);
  padding: 22px 20px;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(165deg, #222c58 0%, #161d3d 60%, #10162e 100%);
  border: 1px solid rgba(165, 139, 255, 0.35);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.ss-title {
  margin: 0 0 6px;
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 900;
  letter-spacing: -0.01em;
  color: #f1ecff;
  text-shadow: 0 3px 0 #3b2a8f;
}
.ss-title span {
  color: var(--gem);
  text-shadow: 0 3px 0 #135a87;
}
.ss-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.45;
}
.ss-crest {
  display: block;
  width: 86px;
  height: 108px;
  margin: -4px auto 6px;
  filter: drop-shadow(0 0 16px rgba(94, 231, 255, 0.45));
}
.ss-menu-stats,
.ss-end-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.ss-end-stats {
  grid-template-columns: repeat(4, 1fr);
}
.ss-menu-stats div,
.ss-end-stats div {
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.ss-menu-stats span,
.ss-end-stats span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ss-menu-stats strong,
.ss-end-stats strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}
.ss-end-gems strong {
  color: var(--gem);
}
.ss-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.ss-btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 0;
  font-size: 16px;
  font-weight: 900;
}
.ss-btn-big {
  min-width: 170px;
  font-size: 19px;
}
.ss-btn-primary {
  background: linear-gradient(180deg, #9c82ff, #6a46f2);
  box-shadow: 0 4px 0 #3a228f;
}
.ss-btn-secondary {
  background: #2a3463;
  box-shadow: 0 4px 0 #161c3a;
}
.ss-btn-reward {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  color: #2b1d05;
  background: linear-gradient(180deg, #ffe27a, #ffb52e);
  box-shadow: 0 4px 0 #a86a07;
}
.ss-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: none;
}
.ss-btn:disabled {
  opacity: 0.6;
}
.ss-ad-note {
  margin: -4px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

/* workshop */
.ss-shop {
  width: min(100%, 560px);
  text-align: left;
}
.ss-shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.ss-shop-head h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
}
.ss-shop-sub {
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.ss-shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.ss-shop-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #1b2347;
  text-align: left;
}
.ss-shop-item strong {
  font-size: 14.5px;
}
.ss-shop-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.ss-shop-item .ss-shop-lvl {
  font-size: 11px;
  color: var(--accent-2);
}
.ss-shop-item .ss-shop-price {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--gem);
  font-size: 14px;
}
.ss-shop-item.is-max .ss-shop-price {
  color: var(--ok);
}
.ss-shop-item:disabled {
  opacity: 0.55;
}
.ss-shop-item.is-max:disabled,
.ss-shop-item.is-owned:disabled {
  opacity: 0.85;
}
.ss-shop .ss-btn-primary {
  display: block;
  width: 100%;
  margin-top: 8px;
}

/* rune cards */
.ss-cards-wrap {
  width: min(100%, 680px);
  text-align: center;
}
.ss-cards-title {
  margin: 0;
  font-size: clamp(26px, 6vw, 34px);
  font-weight: 900;
  color: #fff3c4;
  text-shadow: 0 3px 0 #8a5a00;
}
.ss-offers {
  --n: 3;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.ss-offer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 150px;
  padding: 14px 10px 12px;
  border-radius: 16px;
  border: 2px solid var(--rc);
  background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 22%, #1a2246), #121933);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  animation: ss-deal 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.ss-offer:nth-child(2) {
  animation-delay: 0.06s;
}
.ss-offer:nth-child(3) {
  animation-delay: 0.12s;
}
.ss-offer:nth-child(4) {
  animation-delay: 0.18s;
}
@keyframes ss-deal {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.92);
  }
}
.ss-offer:hover {
  transform: translateY(-3px);
}
.ss-offer[data-rarity="common"] {
  --rc: #8fa3d9;
}
.ss-offer[data-rarity="rare"] {
  --rc: #5ee7ff;
}
.ss-offer[data-rarity="epic"] {
  --rc: #c58bff;
}
.ss-offer-rune {
  width: 46px;
  height: 46px;
}
.ss-offer strong {
  font-size: 15.5px;
}
.ss-offer small {
  color: #d5dcf5;
  font-size: 13px;
  line-height: 1.35;
}
.ss-offer .ss-offer-tag {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rc);
}
.ss-offer .ss-offer-key {
  position: absolute;
  top: 6px;
  left: 9px;
  font-size: 11px;
  color: var(--muted);
}
.ss-cards-wrap .ss-btn-reward {
  width: auto;
  margin: 0 auto;
}

.ss-build {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 14px;
}
.ss-build span {
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  font-size: 12.5px;
}
.ss-offline-gems {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 34px;
  color: var(--gem);
}
.ss-adblock {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.8);
  font-size: 18px;
}

@media (max-width: 520px) {
  .ss-offers[style*="--n: 4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ss-offer {
    min-height: 0;
    padding: 12px 6px 10px;
  }
  .ss-offer small {
    font-size: 12px;
  }
}
@media (max-width: 420px) {
  .ss-hud {
    gap: 6px;
    padding: 6px 8px;
  }
  .ss-icon {
    width: 32px;
    height: 32px;
  }
  .ss-wave {
    min-width: 58px;
  }
  .ss-boost {
    padding: 7px 7px;
    column-gap: 6px;
  }
  .ss-boost-ico {
    width: 24px;
    height: 24px;
  }
  .ss-boost-name small {
    display: none;
  }
  .ss-spell {
    width: 50px;
    height: 50px;
  }
  .ss-end-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-height: 520px) and (min-aspect-ratio: 5/4) {
  .ss-spell {
    width: 46px;
    height: 46px;
  }
  .ss-boost {
    padding: 6px 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ss-hint,
  .ss-spell.is-ready,
  .ss-boost.is-pulse,
  .ss-offer {
    animation: none;
  }
}

/* ---------- landscape stats panel (portrait has no room for it) ---------- */
.ss-stats {
  display: none;
}
@media (min-aspect-ratio: 5/4) and (min-width: 560px) {
  .ss-stats {
    display: block;
    order: -1;
  }
}
.ss-stats dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 0 0 8px;
}
.ss-stats dl div {
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.ss-stats dt {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ss-stats dd {
  margin: 0;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.ss-runes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 30vh;
  overflow-y: auto;
}
.ss-runes span {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #8fa3d9;
}
.ss-runes span[data-rarity="rare"] {
  border-color: #5ee7ff;
}
.ss-runes span[data-rarity="epic"] {
  border-color: #c58bff;
}
.ss-runes em {
  font-size: 12.5px;
  color: var(--muted);
}
