/* Shared layout for all game pages: keeps gameplay-specific effects in each game CSS. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body.game {
  --game-canvas-size: min(92vw, 600px);
  --game-radius: 20px;
  --game-border: rgba(255, 255, 255, 0.14);
  --game-panel: rgba(8, 12, 24, 0.72);
  --game-panel-border: rgba(255, 255, 255, 0.1);
  padding-bottom: 48px;
}

.game h2 {
  text-align: center;
}

.game-shell {
  width: min(100% - 24px, 1180px);
  margin: 24px auto 42px;
}

.game-main {
  display: grid;
  grid-template-columns: minmax(0, var(--game-canvas-size));
  justify-content: center;
  gap: 22px;
  align-items: start;
}

.game-stage,
.game-side {
  min-width: 0;
}

.game-wrapper {
  position: relative;
  width: var(--game-canvas-size) !important;
  max-width: 600px !important;
  aspect-ratio: 1 / 1;
  margin: 0 auto !important;
  border-radius: var(--game-radius);
  overflow: visible;
  background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,0) 38%), rgba(0,0,0,.45);
  border: 1px solid var(--game-border);
  box-shadow: 0 24px 70px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.12);
}

#game,
.game-wrapper > canvas,
.game-wrapper > #game,
.game-wrapper #game canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  aspect-ratio: 1 / 1;
  border-radius: var(--game-radius) !important;
  image-rendering: auto;
}

.overlay {
  border-radius: var(--game-radius) !important;
}

.hud {
  width: 100% !important;
  max-width: 600px !important;
  margin: 14px auto 0 !important;
}

.scoreline {
  width: 100%;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.scoreline .sep {
  display: none !important;
}

.scoreline .item {
  color: white;
  min-height: 78px;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 14px 34px rgba(0,0,0,.22);
  text-align: center;
}

.scoreline .item:not(:has(#score)):not(:has(#bestScore)):not(:has(#globalBest)) {
  display: none !important;
}

.scoreline .item:has(#score),
.scoreline .item:has(#bestScore),
.scoreline .item:has(#globalBest) {
  order: 0;
}

.game-side .game-meta-card,
.game-side .leaderboard {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.game-side .leaderboard {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 0 25px rgba(0,0,0,0.6),
    inset 0 0 20px rgba(255,255,255,0.03);
}

.leaderboard h3 {
  margin: 0 0 10px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.08em;
  opacity: 0.9;
}

#leaderboardList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#leaderboardList li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 14px;
  transition: 0.2s;
}

#leaderboardList li:hover {
  transform: translateX(4px);
  opacity: 1;
}

.game-main > .game-badges {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

@media (max-width: 520px) {
  .scoreline {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 980px) {
  body.game {
    --game-canvas-size: 600px;
  }

  .game-main {
    grid-template-columns: 600px minmax(280px, 360px);
    justify-content: center;
    gap: 30px;
  }

  .game-side {
    grid-column: 2;
    align-self: start;
  }

  .game-side > .hud {
    margin-top: 0 !important;
  }

  .game-side .scoreline,
  .game-side .leaderboard,
  .game-side .score-status,
  .game-side .controls {
    width: 100% !important;
    max-width: none !important;
  }

  .game-side .hint {
    opacity: .78;
    font-size: 14px;
  }

  .game-side .leaderboard {
    margin-top: 12px;
  }

  .game-side .scoreline {
    grid-row: 1;
    margin-top: 0 !important;
  }

  .game-side .leaderboard {
    margin-top: 12px;
  }

  .game-main > .game-badges {
    grid-column: 1 / -1;
    margin-top: 12px;
  }
}
