/* ==========================================================================
   Food Arcade — Game player styles
   Canvas stage, HUD, overlays, touch controls, game-page layout.
   Rule: no ad slot is ever placed inside .game-stage or .game-toolbar.
   ========================================================================== */

/* ------------------------------------------------------------------
   Game page layout
   ------------------------------------------------------------------ */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--fa-sp-5);
  align-items: start;
}

.game-side {
  position: sticky;
  top: calc(var(--fa-header-h) + var(--fa-sp-4));
  display: grid;
  gap: var(--fa-sp-4);
}

/* ------------------------------------------------------------------
   Stage
   ------------------------------------------------------------------ */
.game-shell {
  background: var(--fa-surface);
  border: 1px solid var(--fa-line);
  border-radius: var(--fa-radius-lg);
  box-shadow: var(--fa-shadow);
  overflow: hidden;
}

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #17110f;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

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

/* ------------------------------------------------------------------
   HUD — drawn in DOM above the canvas for accessibility & crispness
   ------------------------------------------------------------------ */
.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.55rem 0.7rem;
  background: linear-gradient(to bottom, rgba(12, 8, 7, 0.78), rgba(12, 8, 7, 0));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 3;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.hud-item .hud-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.68);
  font-weight: 700;
}

.hud-item .hud-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

.hud-combo {
  margin-left: auto;
  padding: 0.15rem 0.5rem;
  border-radius: var(--fa-radius-pill);
  background: rgba(255, 176, 46, 0.22);
  border: 1px solid rgba(255, 176, 46, 0.5);
  color: #ffd79a;
  transition: transform 140ms ease;
}

.hud-combo.is-hot {
  background: rgba(232, 69, 44, 0.35);
  border-color: rgba(255, 140, 120, 0.7);
  color: #ffd9d2;
  transform: scale(1.06);
}

/* Power-up strip */
.hud-powerups {
  position: absolute;
  left: 0.7rem;
  bottom: 0.7rem;
  display: flex;
  gap: 0.4rem;
  z-index: 3;
  pointer-events: none;
}

.pu-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--fa-radius-pill);
  background: rgba(12, 8, 7, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.pu-chip .pu-bar {
  width: 34px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.pu-chip .pu-bar i {
  display: block;
  height: 100%;
  background: var(--fa-amber);
  width: 100%;
}

/* ------------------------------------------------------------------
   Overlays (loading / ready / paused / game over / error)
   ------------------------------------------------------------------ */
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  padding: var(--fa-sp-4);
  background: rgba(14, 9, 8, 0.82);
  backdrop-filter: blur(3px);
  color: #fff;
  text-align: center;
}

.game-overlay.is-active {
  display: grid;
}

.overlay-card {
  max-width: 420px;
  width: 100%;
  background: rgba(34, 24, 21, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--fa-radius-lg);
  padding: var(--fa-sp-5);
  box-shadow: var(--fa-shadow-lg);
  max-height: 100%;
  overflow-y: auto;
}

.overlay-card h2,
.overlay-card h3 {
  color: #fff;
  font-size: 1.35rem;
  margin-bottom: 0.4rem;
}

.overlay-card p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.92rem;
  margin-bottom: var(--fa-sp-4);
}

.overlay-card .btn-row {
  justify-content: center;
}

.overlay-glyph {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.overlay-controls {
  list-style: none;
  margin: 0 0 var(--fa-sp-4);
  padding: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  text-align: left;
}

.overlay-controls li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  margin: 0;
}

.overlay-controls .k {
  flex: 0 0 auto;
  min-width: 92px;
  font-weight: 800;
  color: var(--fa-amber);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Score summary on game over */
.score-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: var(--fa-sp-4);
}

.score-summary div {
  background: rgba(255, 255, 255, 0.07);
  border-radius: var(--fa-radius-sm);
  padding: 0.55rem;
}

.score-summary dt,
.score-summary .s-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
}

.score-summary dd,
.score-summary .s-value {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.new-best {
  display: inline-block;
  margin-bottom: var(--fa-sp-3);
  padding: 0.25rem 0.7rem;
  border-radius: var(--fa-radius-pill);
  background: var(--fa-amber);
  color: #3a2600;
  font-weight: 900;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Countdown */
.countdown-number {
  font-family: var(--fa-font-display);
  font-size: 5rem;
  font-weight: 900;
  color: var(--fa-amber);
  line-height: 1;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* Loading spinner */
.game-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--fa-amber);
  animation: fa-spin 800ms linear infinite;
  margin: 0 auto var(--fa-sp-3);
}

@keyframes fa-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-spinner {
    animation: none;
    border-top-color: rgba(255, 255, 255, 0.5);
  }
}

/* ------------------------------------------------------------------
   Toolbar under the stage
   ------------------------------------------------------------------ */
.game-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.7rem;
  background: var(--fa-surface-2);
  border-top: 1px solid var(--fa-line);
  flex-wrap: wrap;
}

.game-toolbar .spacer {
  flex: 1 1 auto;
}

.game-toolbar .icon-btn {
  width: 42px;
  height: 42px;
}

.toolbar-score {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--fa-text-muted);
  font-weight: 700;
  flex-wrap: wrap;
}

.toolbar-score b {
  color: var(--fa-ink);
  font-variant-numeric: tabular-nums;
}

/* Difficulty selector */
.diff-select {
  display: inline-flex;
  border: 1px solid var(--fa-line-strong);
  border-radius: var(--fa-radius-pill);
  overflow: hidden;
  background: var(--fa-surface);
}

.diff-select button {
  border: 0;
  background: transparent;
  color: var(--fa-ink-3);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.4rem 0.7rem;
  min-height: 38px;
  cursor: pointer;
}

.diff-select button[aria-pressed="true"] {
  background: var(--fa-tomato);
  color: #fff;
}

/* ------------------------------------------------------------------
   Touch controls
   ------------------------------------------------------------------ */
.touch-controls {
  display: none;
  position: absolute;
  inset: auto 0 0 0;
  padding: 0.7rem;
  z-index: 4;
  pointer-events: none;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5rem;
}

.game-stage[data-touch="on"] .touch-controls {
  display: flex;
}

.touch-cluster {
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 13, 11, 0.5);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  backdrop-filter: blur(2px);
}

.touch-btn:active,
.touch-btn.is-down {
  background: rgba(232, 69, 44, 0.65);
  border-color: rgba(255, 255, 255, 0.6);
}

.touch-btn--wide {
  width: 92px;
  border-radius: var(--fa-radius-pill);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.touch-hint {
  position: absolute;
  left: 50%;
  bottom: 0.9rem;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.72rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 4;
  text-align: center;
  padding: 0 1rem;
}

/* ------------------------------------------------------------------
   Game meta panels
   ------------------------------------------------------------------ */
.game-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: var(--fa-sp-4);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
}

.stat-box {
  background: var(--fa-surface-3);
  border: 1px solid var(--fa-line);
  border-radius: var(--fa-radius-sm);
  padding: 0.6rem 0.7rem;
  text-align: center;
}

.stat-box .s-label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fa-text-muted);
  font-weight: 800;
  margin-bottom: 0.15rem;
}

.stat-box .s-value {
  font-family: var(--fa-font-display);
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--fa-tomato-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.local-best-note {
  font-size: 0.74rem;
  color: var(--fa-text-muted);
  margin-top: 0.6rem;
  margin-bottom: 0;
  line-height: 1.4;
}

/* Controls reference list on the page (outside canvas, for a11y) */
.controls-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.controls-list li {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  margin: 0;
  font-size: 0.88rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed var(--fa-line);
}

.controls-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.controls-list .k {
  flex: 0 0 auto;
  min-width: 108px;
  font-weight: 800;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fa-tomato-dark);
}

/* Collectible / power-up reference tables */
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}

.legend-item {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  background: var(--fa-surface);
  border: 1px solid var(--fa-line);
  border-radius: var(--fa-radius-sm);
}

.legend-glyph {
  font-size: 1.5rem;
  line-height: 1;
  flex: 0 0 auto;
}

.legend-item strong {
  display: block;
  font-size: 0.92rem;
}

.legend-item span {
  font-size: 0.82rem;
  color: var(--fa-text-muted);
  line-height: 1.45;
}

/* Related games strip */
.related-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--fa-sp-3);
}

/* Error state */
.game-error {
  padding: var(--fa-sp-5);
  text-align: center;
}

.game-error h3 {
  color: #fff;
}

/* Ensure nothing overlaps gameplay on small screens */
@media (max-width: 720px) {
  .game-stage {
    aspect-ratio: 4 / 3;
  }

  .touch-btn {
    width: 58px;
    height: 58px;
  }

  .game-hud {
    font-size: 0.72rem;
  }

  .game-hud .hud-item .hud-value {
    font-size: 0.85rem;
  }
}

@media (max-width: 420px) {
  .game-stage {
    aspect-ratio: 3 / 4;
  }
}
