/* ==========================================================================
   Coin Collector Arcade — game page and canvas styles
   Loaded only on pages that actually contain a game.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.game-section { padding-block: var(--s5) var(--s6); }

.game-shell {
  max-width: 940px;
  margin-inline: auto;
}

/* The stage is the positioning context for the canvas and every overlay.
   Nothing is ever placed on top of it except the game's own overlays —
   in particular, no ad container may be positioned inside it. */
.game-stage {
  position: relative;
  background: #0a0c16;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 240px;
  box-shadow: var(--shadow-lg);
}

.game-stage canvas {
  display: block;
  /* Stops mobile browsers treating game taps as scrolls or zooms. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  background: #0a0c16;
  max-width: 100%;
}

.game-stage canvas:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

/* --------------------------------------------------------------------------
   Overlays — real DOM, so they are keyboard and screen-reader accessible
   -------------------------------------------------------------------------- */

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  background: rgba(8, 10, 20, 0.86);
  backdrop-filter: blur(3px);
  text-align: center;
}

.game-overlay__inner { max-width: 440px; width: 100%; }

.game-overlay__title {
  font-size: clamp(1.4rem, 4vw, 2rem);
  margin-bottom: var(--s3);
  color: var(--gold);
}

.game-overlay__text {
  color: var(--text-muted);
  margin-bottom: var(--s5);
  font-size: 0.96rem;
}

.game-overlay__hint {
  margin: var(--s4) 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.game-overlay--countdown { background: rgba(8, 10, 20, 0.55); }

.game-overlay__count {
  font-size: clamp(3.5rem, 15vw, 7rem);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 6px 34px rgba(255, 197, 49, 0.4);
  line-height: 1;
}

/* Results */

.results-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px var(--s4);
  margin: 0 0 var(--s4);
  text-align: left;
  font-size: 0.93rem;
}

.results-grid dt { color: var(--text-muted); margin: 0; }
.results-grid dd { margin: 0; font-weight: 800; text-align: right; }

.results-best { margin-bottom: var(--s5); }

.results-record {
  display: inline-block;
  background: var(--gold);
  color: #17190d;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 999px;
  margin: 0 0 var(--s3);
}

.results-best__line {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.results-note {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */

.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s3);
}

.game-toolbar__spacer { flex: 1; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease;
}

.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn[aria-pressed="false"] { color: var(--text-dim); }
.icon-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   Touch controls — real buttons, below the canvas, never over it
   -------------------------------------------------------------------------- */

.game-controls-slot { margin-top: var(--s3); }

.touch-controls {
  display: none;
  gap: var(--s3);
  justify-content: center;
  align-items: center;
}

.touch-controls.is-visible { display: flex; }

.touch-btn {
  width: 74px;
  height: 62px;
  font-size: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background-color 0.1s ease, transform 0.1s ease;
}

.touch-btn:active,
.touch-btn.is-active {
  background: var(--gold);
  color: #17190d;
  transform: scale(0.96);
}

.touch-btn--primary {
  width: 110px;
  background: var(--surface-3);
  border-color: var(--gold);
  color: var(--gold);
}

.touch-btn--wide { width: 190px; }

/* --------------------------------------------------------------------------
   Error state
   -------------------------------------------------------------------------- */

.game-error {
  margin-top: var(--s4);
  padding: var(--s5);
  background: rgba(255, 107, 107, 0.09);
  border: 1px solid rgba(255, 107, 107, 0.38);
  border-radius: var(--radius);
  text-align: center;
}

.game-error h2 { font-size: 1.16rem; color: var(--red); }
.game-error p { color: var(--text-muted); font-size: 0.93rem; }
.game-error > *:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Game page content
   -------------------------------------------------------------------------- */

.game-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.game-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s6);
}

.meta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
}

.meta-card__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.meta-card__value { font-weight: 800; font-size: 1rem; }

.scores-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s5);
}

.score-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  text-align: center;
}

.score-chip__value {
  display: block;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1.15;
}

.score-chip__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
}

.powerup-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--s3);
}

.powerup-list li {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  margin: 0;
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.powerup-list__dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.powerup-list strong { display: block; }
.powerup-list span { color: var(--text-muted); font-size: 0.9rem; }

@media (max-width: 640px) {
  .game-section { padding-block: var(--s4); }
  .game-toolbar { justify-content: center; }
  .game-toolbar__spacer { display: none; }
  .touch-btn { width: 64px; height: 56px; }
  .touch-btn--primary { width: 92px; }
  .touch-btn--wide { width: 160px; }
  .results-actions { flex-direction: column; }
  .results-actions .btn { width: 100%; }
}