/* ==========================================================================
   Ninja Arcade — Game shell styles
   Canvas stage, HUD, overlays, touch controls and the game directory grid.
   Ad slots are deliberately kept outside .game-stage so nothing can ever
   sit on top of a control the player is about to press.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Game page layout
   -------------------------------------------------------------------------- */

.game-page-head { padding-block: var(--sp-5) var(--sp-4); }
.game-page-head h1 { margin-bottom: var(--sp-2); }
.game-page-head .card__meta { margin-bottom: var(--sp-3); }

.game-stage-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--sp-5);
  align-items: start;
}

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

/* --------------------------------------------------------------------------
   2. Canvas stage
   -------------------------------------------------------------------------- */

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0a0c11;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  /* Stop the browser from scrolling or zooming while the player taps */
  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(--c-ember); outline-offset: 3px; }

/* --------------------------------------------------------------------------
   3. HUD
   -------------------------------------------------------------------------- */

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: #fff;
  background: linear-gradient(180deg, rgba(4, 6, 10, 0.8), transparent);
  pointer-events: none;
}
.hud__item { display: flex; flex-direction: column; line-height: 1.15; }
.hud__item span {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
}
.hud__item strong { font-size: 1.15rem; font-weight: 800; }
.hud__item--right { margin-left: auto; text-align: right; }
.hud__combo { color: var(--c-ember); }

/* --------------------------------------------------------------------------
   4. Overlays (menu / paused / game over)
   -------------------------------------------------------------------------- */

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-5);
  background: rgba(8, 10, 15, 0.86);
  backdrop-filter: blur(3px);
  color: #fff;
}
.game-overlay[hidden] { display: none; }
.game-overlay h2 {
  font-size: clamp(1.4rem, 1.1rem + 1.6vw, 2.1rem);
  margin: 0;
  color: #fff;
}
.game-overlay p { margin: 0; color: rgba(255, 255, 255, 0.78); max-width: 46ch; font-size: 0.95rem; }
.game-overlay .btn--primary { min-width: 190px; }
.game-overlay__keys {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
}
.game-overlay__scores {
  display: flex;
  gap: var(--sp-6);
  margin-block: var(--sp-2);
}
.game-overlay__scores div span {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.game-overlay__scores div strong { font-size: 1.7rem; font-family: var(--font-display); }

kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.18em 0.5em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  line-height: 1.5;
}
.prose kbd, .panel kbd {
  background: var(--c-surface-2);
  border-color: var(--c-border-strong);
  color: var(--c-text);
}

/* New-best flourish */
.badge-best {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #0a0c11;
  background: var(--c-ember);
  padding: 0.25em 0.7em;
  border-radius: var(--r-pill);
}

/* --------------------------------------------------------------------------
   5. Control bar (below the canvas, never over it)
   -------------------------------------------------------------------------- */

.game-controls-bar {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-top: var(--sp-3);
  flex-wrap: wrap;
}
.game-controls-bar .spacer { flex: 1; }

.game-controls-bar .btn { min-width: 108px; }

/* --------------------------------------------------------------------------
   6. Touch controls
   -------------------------------------------------------------------------- */

.touch-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 4;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: var(--sp-4);
  pointer-events: none;
}
.touch-controls[data-enabled="true"] { display: flex; }

.touch-cluster { display: flex; gap: var(--sp-3); pointer-events: auto; }

.touch-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(14, 18, 26, 0.55);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.touch-btn:active { background: var(--c-accent); border-color: var(--c-accent); }
.touch-btn svg { width: 26px; height: 26px; }

/* --------------------------------------------------------------------------
   7. Info panels beside / below the game
   -------------------------------------------------------------------------- */

.control-table { width: 100%; font-size: 0.9rem; }
.control-table th { width: 42%; font-weight: 600; color: var(--c-muted); background: transparent; }
.control-table td, .control-table th { padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-border); }

.score-panel { text-align: center; }
.score-panel__value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--c-accent);
  line-height: 1.1;
}
.score-panel__label { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-muted); }

.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li {
  position: relative;
  padding-left: 1.6rem;
  margin-bottom: var(--sp-3);
  font-size: 0.95rem;
}
.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--c-accent);
  transform: rotate(45deg);
}

/* --------------------------------------------------------------------------
   8. Game directory
   -------------------------------------------------------------------------- */

.directory-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-4);
}
.directory-toolbar .search-box { flex: 1 1 260px; }
.directory-toolbar select { width: auto; min-width: 150px; }

.result-count { font-size: 0.88rem; color: var(--c-muted); margin-bottom: var(--sp-4); }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: var(--sp-4);
}

/* Recently played strip */
.recent-strip {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-3);
  scrollbar-width: thin;
}
.recent-strip .card { min-width: 230px; }
.recent-strip:empty { display: none; }

/* --------------------------------------------------------------------------
   9. Thumbnail art (inline SVG scenes drawn with CSS-safe gradients)
   -------------------------------------------------------------------------- */

.thumb-art { width: 100%; height: 100%; display: block; }

/* Loading state while games.json is fetched */
.skeleton {
  background: linear-gradient(90deg, var(--c-surface) 25%, var(--c-surface-2) 50%, var(--c-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.4s linear infinite;
  border-radius: var(--r-lg);
  min-height: 300px;
}
@keyframes skeleton {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
