:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #06070d;
  color: #f7fbff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    linear-gradient(125deg, rgba(46, 228, 194, .12), transparent 38%),
    linear-gradient(235deg, rgba(255, 88, 104, .1), transparent 42%),
    linear-gradient(135deg, #070912 0%, #0d1220 54%, #08070f 100%);
}

button {
  font: inherit;
}

.shell {
  width: min(1280px, 100vw);
  height: min(780px, 100vh);
  min-height: 620px;
  margin: 0 auto;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  gap: 14px;
}

.game-frame,
.hud-panel,
.screen-panel {
  border: 1px solid rgba(255, 255, 255, .13);
  background: rgba(9, 14, 25, .9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .46);
}

.game-frame {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
}

.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(88, 222, 200, .08), inset 0 0 42px rgba(88, 222, 200, .05);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #070912;
  touch-action: none;
  cursor: crosshair;
}

.hud-panel {
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0;
  color: #58dec8;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(38px, 6vw, 74px);
  line-height: .94;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

.lead {
  max-width: 520px;
  color: #c8d4e9;
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.btn,
.icon-btn {
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: #f7fbff;
  font-weight: 950;
  cursor: pointer;
  transition: transform .14s ease, filter .14s ease, background .14s ease;
}

.btn {
  min-height: 46px;
  padding: 11px 15px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.primary {
  background: linear-gradient(135deg, #58dec8, #f4d35e);
  color: #071015;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 12, .64);
  backdrop-filter: blur(8px);
}

.screen.hidden {
  display: none;
}

.screen-panel {
  width: min(620px, 94vw);
  max-width: 100%;
  border-radius: 8px;
  padding: clamp(18px, 4vw, 34px);
  display: grid;
  gap: 16px;
  animation: panel-in .22s ease both;
}

.screen-menu .screen-panel {
  width: min(780px, 94vw);
  background:
    linear-gradient(135deg, rgba(19, 42, 52, .94), rgba(34, 18, 30, .94)),
    rgba(9, 14, 25, .94);
}

.mode-select {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  position: relative;
  min-width: 0;
  min-height: 112px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, .065);
  color: #f7fbff;
  text-align: left;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
  overflow: hidden;
}

.mode-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #58dec8, #f4d35e, #ff5868);
  opacity: .32;
}

.mode-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, .095);
}

.mode-card.selected,
.mode-card[aria-pressed="true"] {
  border-color: rgba(88, 222, 200, .86);
  background: linear-gradient(180deg, rgba(88, 222, 200, .2), rgba(255, 255, 255, .065));
  box-shadow: inset 0 0 0 1px rgba(88, 222, 200, .16);
}

.mode-card strong,
.mode-card span,
.mode-card em {
  display: block;
}

.mode-card strong {
  font-size: 16px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.mode-card span {
  margin-top: 9px;
  color: #c5d3ea;
  font-size: 13px;
  font-weight: 800;
}

.mode-card em {
  margin-top: 8px;
  color: #58dec8;
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
  text-transform: uppercase;
}

.mode-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border-left: 3px solid #58dec8;
  padding-left: 12px;
  color: #c8d4e9;
  font-size: 13px;
  line-height: 1.45;
}

.mode-summary strong {
  color: #f7fbff;
  font-size: 14px;
  white-space: nowrap;
}

.menu-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.menu-stats,
.result-stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.result-stats {
  grid-template-columns: repeat(3, 1fr);
}

.menu-stats div,
.result-stats div,
.stat {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, .055);
}

dt,
.stat span,
.meters label,
.controls {
  color: #9eacc8;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

dd,
.stat strong {
  display: block;
  margin: 5px 0 0;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  font-weight: 950;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.meters {
  display: grid;
  gap: 8px;
}

.meters label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.meters strong {
  color: #f7fbff;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .09);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff5868, #f4d35e);
  box-shadow: 0 0 24px rgba(255, 88, 104, .35);
}

.meter.pulse span {
  background: linear-gradient(90deg, #58dec8, #8fd7ff, #f4d35e);
  box-shadow: 0 0 24px rgba(88, 222, 200, .38);
}

.meter.threat span {
  background: linear-gradient(90deg, #8fd7ff, #b892ff, #ff5868);
}

.rune-list {
  display: grid;
  gap: 8px;
}

.runes {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 28px;
}

.rune {
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(88, 222, 200, .1);
  color: #e9fbff;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.controls {
  margin-top: auto;
  display: grid;
  gap: 7px;
  line-height: 1.5;
  text-transform: none;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 24px;
  margin-right: 4px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 12px;
  font-weight: 950;
}

.upgrade-panel {
  width: min(860px, 96vw);
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.upgrade-card {
  min-height: 174px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  padding: 15px;
  background: rgba(255, 255, 255, .07);
  color: #f7fbff;
  text-align: left;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}

.upgrade-card:hover {
  transform: translateY(-2px);
  border-color: rgba(88, 222, 200, .48);
  background: rgba(255, 255, 255, .095);
}

.upgrade-card.rarity-rare {
  border-color: rgba(143, 215, 255, .62);
  background:
    linear-gradient(180deg, rgba(143, 215, 255, .16), rgba(255, 255, 255, .07)),
    rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(143, 215, 255, .12);
}

.upgrade-card.rarity-epic {
  border-color: rgba(244, 211, 94, .72);
  background:
    linear-gradient(180deg, rgba(244, 211, 94, .18), rgba(184, 146, 255, .12)),
    rgba(255, 255, 255, .08);
  box-shadow: inset 0 0 0 1px rgba(244, 211, 94, .16), 0 18px 42px rgba(244, 211, 94, .08);
}

.upgrade-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.1;
}

.upgrade-card span {
  display: block;
  color: #b8c7de;
  font-size: 13px;
  line-height: 1.45;
}

.upgrade-card em {
  display: inline-block;
  margin-top: 14px;
  color: #58dec8;
  font-style: normal;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.upgrade-card.rarity-rare em {
  color: #8fd7ff;
}

.upgrade-card.rarity-epic em {
  color: #f4d35e;
}

.screen-upgrade[data-rarity="rare"] .upgrade-panel {
  border-color: rgba(143, 215, 255, .35);
}

.screen-upgrade[data-rarity="epic"] .upgrade-panel {
  border-color: rgba(244, 211, 94, .42);
}

.screen-result .screen-panel {
  background:
    linear-gradient(135deg, rgba(11, 30, 36, .96), rgba(38, 15, 27, .96)),
    rgba(9, 14, 25, .96);
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .game-frame {
    height: min(68vh, 620px);
    min-height: 430px;
  }

  .hud-panel {
    min-height: auto;
  }

  .controls {
    display: none;
  }
}

@media (max-width: 700px) {
  .shell {
    gap: 10px;
  }

  .game-frame {
    height: 58vh;
    min-height: 360px;
  }

  .hud-panel {
    padding: 12px;
  }

  .menu-stats,
  .result-stats,
  .menu-actions,
  .result-actions,
  .upgrade-grid {
    grid-template-columns: 1fr;
  }

  .mode-select {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upgrade-card {
    min-height: 150px;
  }

  h1 {
    font-size: 40px;
  }

  .lead {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .menu-actions,
  .result-actions,
  .stat-grid,
  .menu-stats,
  .result-stats,
  .mode-select,
  .upgrade-grid {
    grid-template-columns: 1fr;
  }

  .screen {
    padding: 12px;
  }

  .screen-panel {
    padding: 18px;
  }

  dd,
  .stat strong {
    font-size: 20px;
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
