:root {
  color-scheme: dark;
  --bg: #10120f;
  --panel: #191d19;
  --panel-strong: #222821;
  --line: #475142;
  --text: #f5f6e8;
  --muted: #b9c0ad;
  --gold: #f6c846;
  --green: #5ee388;
  --red: #ff3b3b;
  --cyan: #62d8ff;
  --orange: #f2a33a;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(39, 55, 42, 0.94), rgba(15, 17, 17, 0.97)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 34px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  touch-action: manipulation;
}

button {
  appearance: none;
  border: 0;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.hub-shell {
  width: min(100vw, 1100px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px);
  display: grid;
  align-items: center;
}

.hub-hero {
  display: grid;
  gap: 20px;
}

.hub-kicker {
  margin: 0;
  color: var(--gold);
  font-size: clamp(14px, 2.6vw, 18px);
  font-weight: 800;
}

.hub-hero h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(42px, 9vw, 88px);
  line-height: 0.98;
  letter-spacing: 0;
}

.game-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(12px, 2vw, 18px);
  margin-top: 10px;
}

.game-link {
  min-height: 190px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(245, 246, 232, 0.18);
  border-radius: 8px;
  display: grid;
  align-content: end;
  gap: 10px;
  background:
    linear-gradient(145deg, rgba(245, 246, 232, 0.06), rgba(0, 0, 0, 0.08)),
    var(--panel);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.game-link span {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 900;
  line-height: 1;
}

.game-link strong {
  color: var(--muted);
  font-size: clamp(14px, 2.6vw, 18px);
  line-height: 1.3;
}

.coin-link {
  background:
    radial-gradient(circle at 78% 24%, rgba(246, 200, 70, 0.72) 0 18px, transparent 19px),
    linear-gradient(145deg, rgba(94, 227, 136, 0.16), rgba(0, 0, 0, 0.08)),
    var(--panel);
}

.red-link {
  background:
    radial-gradient(circle at 78% 24%, rgba(255, 59, 59, 0.74) 0 18px, transparent 19px),
    linear-gradient(145deg, rgba(242, 163, 58, 0.15), rgba(0, 0, 0, 0.08)),
    var(--panel);
}

.maze-link {
  background:
    linear-gradient(90deg, rgba(94, 227, 136, 0.72) 0 18px, transparent 18px 42px),
    radial-gradient(circle at 80% 22%, rgba(246, 200, 70, 0.72) 0 16px, transparent 17px),
    linear-gradient(145deg, rgba(98, 216, 255, 0.16), rgba(0, 0, 0, 0.08)),
    var(--panel);
}

.game-shell {
  width: min(100vw, 1100px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 24px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.8vw, 18px);
}

.back-link {
  justify-self: start;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(245, 246, 232, 0.18);
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: rgba(25, 29, 25, 0.82);
  font-size: 14px;
  font-weight: 800;
}

.maze-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.warehouse-button {
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid rgba(246, 200, 70, 0.38);
  border-radius: 8px;
  background: rgba(47, 35, 16, 0.9);
  color: var(--gold);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

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

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

.stat {
  min-height: 68px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 246, 232, 0.14);
  border-radius: 8px;
  background: rgba(25, 29, 25, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: clamp(12px, 2.4vw, 14px);
  line-height: 1.2;
}

.stat strong {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-size: clamp(24px, 4.4vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

.stat strong span {
  display: inline;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.stage {
  position: relative;
  align-self: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 260px;
  max-height: calc(100vh - 380px);
  border: 1px solid rgba(245, 246, 232, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #151812;
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.game-over {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 18px;
  background: rgba(16, 18, 15, 0.72);
  backdrop-filter: blur(2px);
}

.game-over[hidden] {
  display: none;
}

.result {
  color: #fff7f7;
  font-size: clamp(42px, 10vw, 88px);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    0 0 18px rgba(255, 59, 59, 0.75),
    0 5px 0 rgba(120, 0, 0, 0.8);
  letter-spacing: 0;
  text-align: center;
}

.result-detail {
  min-height: 28px;
  color: var(--text);
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}

#restart-button {
  min-width: 148px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--gold);
  color: #201809;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 0 #9b6b10;
}

#restart-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #9b6b10;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 116px;
}

.maze-controls {
  justify-content: center;
}

.dpad {
  width: 154px;
  height: 116px;
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 48px);
  gap: 10px;
}

.control-btn,
.jump-btn,
.action-btn {
  display: grid;
  place-items: center;
  border: 1px solid rgba(245, 246, 232, 0.2);
  background: var(--panel-strong);
  cursor: pointer;
  user-select: none;
  box-shadow:
    0 7px 0 #0a0d0a,
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.control-btn {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: var(--cyan);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.control-btn.up {
  grid-column: 2;
}

.control-btn.left {
  grid-column: 1;
  grid-row: 2;
}

.control-btn.down {
  grid-column: 2;
  grid-row: 2;
}

.control-btn.right {
  grid-column: 3;
  grid-row: 2;
}

.jump-btn,
.action-btn {
  width: min(28vw, 132px);
  height: min(28vw, 132px);
  min-width: 92px;
  min-height: 92px;
  border-radius: 50%;
  background: #2b2418;
  color: var(--orange);
  font-size: clamp(30px, 8vw, 48px);
  font-weight: 900;
}

.jump-btn {
  background: #233021;
  color: var(--green);
}

.interact-btn {
  background: #183022;
  color: var(--green);
}

.interact-btn.is-ready {
  background: #234822;
  color: #f3ffe9;
  box-shadow:
    0 7px 0 #0a0d0a,
    0 0 18px rgba(94, 227, 136, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.warehouse-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 24px);
  background: rgba(7, 9, 7, 0.66);
  backdrop-filter: blur(2px);
}

.warehouse-panel[hidden] {
  display: none;
}

.warehouse-window {
  width: min(100%, 760px);
  max-height: calc(100vh - clamp(24px, 6vw, 48px));
  overflow: auto;
  border: 1px solid rgba(245, 246, 232, 0.2);
  border-radius: 8px;
  background: rgba(19, 23, 18, 0.97);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

.warehouse-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid rgba(245, 246, 232, 0.14);
  background: rgba(19, 23, 18, 0.98);
}

.warehouse-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.warehouse-head strong {
  display: block;
  color: var(--gold);
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
}

.warehouse-close {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(245, 246, 232, 0.16);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.warehouse-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.warehouse-section h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.1;
}

.store-list {
  display: grid;
  gap: 10px;
}

.store-item {
  min-height: 104px;
  padding: 12px;
  border: 1px solid rgba(245, 246, 232, 0.13);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: rgba(31, 36, 29, 0.9);
}

.store-item.is-owned {
  border-color: rgba(94, 227, 136, 0.36);
}

.store-item.is-equipped {
  background: rgba(32, 59, 36, 0.92);
}

.store-swatch {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(245, 246, 232, 0.22);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.store-name {
  min-width: 0;
}

.store-name strong,
.store-name span {
  display: block;
}

.store-name strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.15;
}

.store-name span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.store-buy {
  min-width: 76px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--gold);
  color: #211707;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.store-buy:disabled {
  cursor: default;
  opacity: 0.58;
}

.control-btn.is-pressed,
.jump-btn.is-pressed,
.action-btn.is-pressed {
  transform: translateY(5px);
  box-shadow:
    0 2px 0 #0a0d0a,
    inset 0 0 16px rgba(242, 163, 58, 0.22);
}

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

  .stage {
    min-height: 220px;
    max-height: none;
  }

  .controls {
    min-height: 104px;
  }

  .dpad {
    width: 136px;
    height: 104px;
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(2, 42px);
    gap: 10px;
  }

  .control-btn {
    width: 42px;
    height: 42px;
    font-size: 24px;
  }

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

  .game-link {
    min-height: 144px;
  }
}

@media (max-width: 430px) {
  .hud {
    gap: 6px;
  }

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

  .stat {
    min-height: 58px;
    padding: 9px;
  }

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

  .store-item {
    grid-template-columns: 36px minmax(0, 1fr) auto;
  }

  .store-swatch {
    width: 36px;
    height: 36px;
  }
}

.dodge-link {background:radial-gradient(circle at 80% 24%, #ff7386 0 14px, transparent 15px),radial-gradient(circle at 66% 36%, #ffda62 0 9px, transparent 10px),linear-gradient(145deg,#183d51,#111c30);}

.parkour-link { background: linear-gradient(120deg, #375b57, #202e31); border-color: #91c9ad; }
.parkour-link span { color: #ffab77; }
