:root {
  color-scheme: dark;
  --ink: #f8f4e8;
  --muted: #b9c1d9;
  --panel: rgba(16, 18, 42, 0.92);
  --panel-strong: #11142f;
  --line: rgba(255, 255, 255, 0.16);
  --gold: #ffe166;
  --mint: #70dbc9;
  --coral: #f16464;
  --sky: #76d7ff;
  --violet: #6e52ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 225, 102, 0.18), transparent 26rem),
    radial-gradient(circle at 82% 18%, rgba(112, 219, 201, 0.15), transparent 24rem),
    linear-gradient(145deg, #16103a 0%, #122540 52%, #151529 100%);
  color: var(--ink);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.arcade-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 18px;
}

.stage-panel,
.arcade-menu {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.stage-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.brand-button {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.08);
}

.brand-button img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-button span {
  font-weight: 800;
  white-space: nowrap;
}

.score-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}

.score-strip span {
  min-width: 90px;
  padding: 8px 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.28);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  background: #081326;
  touch-action: none;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.control-row button,
.game-card button {
  min-height: 48px;
  background: #20264d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 900;
  text-transform: uppercase;
}

.control-row button:active,
.game-card button:active,
.game-card.is-active button {
  background: var(--gold);
  color: #201b12;
}

.arcade-menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  overflow: auto;
}

.menu-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
}

.menu-header p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.game-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.game-card.is-active {
  border-color: var(--gold);
  background: rgba(255, 225, 102, 0.1);
}

.game-art {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #18244a;
}

.game-art img {
  width: 92px;
  height: 64px;
  object-fit: contain;
}

.game-copy h2 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.1;
}

.game-copy p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.game-card button {
  width: 100%;
  min-height: 40px;
}

.arcade-stats {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.arcade-stats div {
  padding: 14px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
}

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

.arcade-stats strong {
  display: block;
  margin-top: 6px;
  color: var(--gold);
  font-size: 28px;
}

@media (max-width: 920px) {
  .arcade-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .stage-panel {
    min-height: 70vh;
  }

  .arcade-menu {
    order: -1;
    max-height: none;
  }

  .game-list {
    grid-template-columns: repeat(3, minmax(210px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .game-card {
    min-width: 210px;
    grid-template-columns: 52px minmax(0, 1fr);
  }

  h1 {
    font-size: 34px;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .score-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .score-strip span {
    min-width: 0;
    padding-inline: 6px;
    font-size: 12px;
  }

  #gameCanvas {
    min-height: 430px;
  }

  .control-row {
    position: sticky;
    bottom: 0;
    background: var(--panel-strong);
  }
}
