:root {
  color-scheme: dark;
  --bg: #111318;
  --ink: #f6efe2;
  --muted: #b9b2a4;
  --coin: #f5b942;
  --amber: #d57a28;
  --cyan: #5ac8c8;
  --green: #72b56a;
  --red: #e45f4f;
  --panel: rgba(22, 24, 29, 0.86);
  --panel-strong: rgba(35, 33, 35, 0.94);
  --line: rgba(246, 239, 226, 0.16);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(245, 185, 66, 0.16) 0 18%, transparent 18%),
    linear-gradient(120deg, #111318, #1d1a1c 44%, #101817);
}

button {
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  color: #17110a;
  background: linear-gradient(180deg, #ffd76f, var(--coin));
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 10px 24px rgba(245, 185, 66, 0.22);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  color: var(--ink);
  background: linear-gradient(180deg, #3a4144, #22262b);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.24);
}

.game-shell {
  width: min(1380px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 18px;
  align-items: stretch;
}

.stage,
.side-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stage {
  min-height: calc(100vh - 44px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
}

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

.hud > div,
.ticker,
.stats > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.hud > div {
  padding: 10px 12px;
}

.hud-label,
.eyebrow,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1rem, 2.8vw, 1.55rem);
}

canvas {
  width: 100%;
  height: 100%;
  min-height: 460px;
  display: block;
  border-radius: 8px;
  border: 2px solid rgba(246, 239, 226, 0.14);
  background: #17191f;
  image-rendering: pixelated;
}

.mobile-controls {
  display: none;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 10px;
}

.control-button {
  min-height: 52px;
  color: var(--ink);
  background: linear-gradient(180deg, #4a4f56, #262b30);
  font-size: 1.45rem;
}

.control-button.accent {
  color: #17110a;
  background: linear-gradient(180deg, #ffd76f, var(--coin));
}

.side-panel {
  padding: 22px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

h1,
p,
dl {
  margin: 0;
}

h1 {
  font-size: clamp(2.45rem, 5vw, 4.35rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.lede {
  color: var(--muted);
  line-height: 1.55;
}

.menu,
.upgrades,
.stats {
  display: grid;
  gap: 10px;
}

.menu {
  grid-template-columns: 1fr 0.72fr;
}

.menu button {
  min-height: 50px;
}

.upgrades {
  grid-template-columns: 1fr;
}

.upgrade {
  min-height: 56px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(90, 200, 200, 0.2), rgba(42, 49, 53, 0.96));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22);
}

.upgrade strong {
  color: var(--coin);
}

.ticker {
  min-height: 76px;
  padding: 14px;
  display: flex;
  align-items: center;
  color: #f7e7c0;
  line-height: 1.45;
}

.stats {
  margin-top: auto;
}

.stats > div {
  padding: 12px;
}

dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-weight: 750;
}

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

  .game-shell {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: auto;
  }

  canvas {
    aspect-ratio: 3 / 2;
    min-height: 0;
  }

  .mobile-controls {
    display: grid;
  }

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

@media (max-width: 620px) {
  .game-shell {
    width: min(100% - 16px, 1380px);
    padding: 8px 0;
    gap: 8px;
  }

  .stage,
  .side-panel {
    padding: 10px;
  }

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

  .menu {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.45rem;
  }
}
