:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.09);
  --text: rgba(255, 255, 255, 0.9);
  --muted: rgba(255, 255, 255, 0.65);
  --accent: #42f5c5;
  --warn: #ffcc66;
  --danger: #ff5a7a;
  --shadow: rgba(0, 0, 0, 0.35);
  --ring: rgba(66, 245, 197, 0.25);
  /* .main padding + buffer; used with aspect-ratio so the frame fits in the viewport (no page scroll) */
  --game-viewport-pad: 52px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
    Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 700px at 15% 10%, #1a2554, var(--bg));
  overflow-x: hidden;
}

#app {
  height: 100%;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr;
  min-height: 0;
}

.help__keys {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 18px var(--shadow);
  color: rgba(255, 255, 255, 0.86);
  font-weight: 700;
  font-size: 11px;
}

.main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
  align-items: center;
  justify-items: center;
}

#game {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.15);
  min-height: 0;
  /*
   * As wide as the row allows, but never so wide that 49:30 height exceeds the viewport.
   * (No fixed 980px cap — that matched old canvas size but shrank the frame after the sidebar was removed.)
   */
  width: min(100%, calc((100dvh - var(--game-viewport-pad)) * 49 / 30));
  max-width: 100%;
  aspect-ratio: 49 / 30; /* Phaser desktop 980×600 proportion */
  height: auto;
  max-height: calc(100dvh - var(--game-viewport-pad));
  justify-self: center;
}

#game canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
}

@media (max-width: 900px) {
  :root {
    --game-viewport-pad: 36px;
  }

  .main {
    padding: 10px;
    gap: 10px;
    grid-auto-rows: min-content;
    grid-template-columns: 1fr;
  }
  #game {
    height: auto;
    border-radius: 14px;
    width: min(100%, calc((100dvh - var(--game-viewport-pad)) * 49 / 30));
    max-height: calc(100dvh - var(--game-viewport-pad));
  }
  #game canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  #game {
    aspect-ratio: 43 / 76;
    /* Prefer full device width on phones; the old dvh-based width made the game look squashed. */
    width: 100%;
    max-height: calc(100dvh - var(--game-viewport-pad));
  }
}

