/* ==========================================================================
   Cat Arcade - game shell
   Loaded only on game pages. The canvas keeps its intrinsic aspect ratio via
   its width/height attributes, so filling the stage causes no layout shift.
   ========================================================================== */

.game-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: var(--s-4);
  margin-bottom: var(--s-6);
}

/* --------------------------------------------------------------------------
   HUD
   -------------------------------------------------------------------------- */

.game-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  min-height: 52px;
  align-items: center;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  min-width: 78px;
}

.hud-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 750;
  color: var(--ink-3);
}

.hud-value {
  font-size: 1.16rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hud-stat-highlight .hud-value {
  color: var(--primary);
}

.hud-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.btn-icon-text {
  min-width: 118px;
}

/* --------------------------------------------------------------------------
   Stage & canvas
   -------------------------------------------------------------------------- */

.game-stage {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #1b2430;
  line-height: 0;
  isolation: isolate;
}

.game-canvas {
  display: block;
  width: 100%;
  height: auto;
  /* Prevent double-tap zoom and page panning while playing. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
}

.game-shell.is-playing .game-canvas {
  touch-action: none;
  cursor: crosshair;
}

.game-shell.is-playing.game-pointer-default .game-canvas {
  cursor: pointer;
}

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

/* --------------------------------------------------------------------------
   Overlay (menu / paused / game over)
   -------------------------------------------------------------------------- */

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  background: rgba(16, 22, 30, 0.74);
  backdrop-filter: blur(3px);
  line-height: 1.5;
  z-index: 2;
}

.game-overlay[hidden] {
  display: none;
}

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  max-width: 460px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.overlay-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 var(--s-2);
}

.overlay-title {
  margin: 0 0 var(--s-2);
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem);
}

.overlay-text {
  margin: 0 0 var(--s-4);
  color: var(--ink-2);
  font-size: 0.95rem;
}

.overlay-score {
  display: flex;
  justify-content: center;
  gap: var(--s-5);
  margin: 0 0 var(--s-4);
  flex-wrap: wrap;
}

.overlay-score div {
  display: flex;
  flex-direction: column;
}

.overlay-score .hud-label {
  order: 2;
}

.overlay-score .hud-value {
  font-size: 1.7rem;
}

.overlay-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: center;
  flex-wrap: wrap;
}

.overlay-new-best {
  display: inline-block;
  margin: 0 0 var(--s-3);
  padding: 0.25em 0.8em;
  border-radius: var(--r-pill);
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 750;
  font-size: 0.83rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Touch controls
   -------------------------------------------------------------------------- */

.touch-controls {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4);
  pointer-events: none;
  z-index: 1;
  line-height: 1;
}

.touch-controls[hidden] {
  display: none;
}

.touch-group {
  display: flex;
  gap: var(--s-3);
  pointer-events: none;
}

.touch-btn {
  pointer-events: auto;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(20, 28, 38, 0.42);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  backdrop-filter: blur(2px);
}

.touch-btn svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.touch-btn.is-down {
  background: rgba(255, 138, 76, 0.75);
  border-color: #fff;
}

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

.touch-hint {
  position: absolute;
  left: 50%;
  bottom: var(--s-4);
  transform: translateX(-50%);
  margin: 0;
  padding: 0.35em 0.9em;
  border-radius: var(--r-pill);
  background: rgba(20, 28, 38, 0.6);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 650;
  pointer-events: none;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Status line, options & extras
   -------------------------------------------------------------------------- */

.game-status {
  margin: var(--s-3) 0 0;
  font-size: 0.9rem;
  color: var(--ink-2);
  min-height: 1.5em;
  text-align: center;
}

.game-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  padding: var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.game-options-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  margin-right: var(--s-2);
}

.option-btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  padding: 0.4em 0.9em;
  min-height: 38px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.option-btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.feature-list {
  display: grid;
  gap: var(--s-2);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-4);
}

.feature-list li {
  position: relative;
  padding: var(--s-3) var(--s-3) var(--s-3) 40px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 0.93rem;
  color: var(--ink-2);
  margin: 0;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 8px;
  margin-top: -6px;
  border-left: 2.5px solid var(--primary);
  border-bottom: 2.5px solid var(--primary);
  transform: rotate(-45deg);
}

/* --------------------------------------------------------------------------
   Responsive tweaks
   -------------------------------------------------------------------------- */

@media (max-width: 767px) {
  .game-shell {
    padding: var(--s-3);
    border-radius: var(--r-lg);
  }

  .game-hud {
    justify-content: center;
  }

  .hud-controls {
    width: 100%;
    justify-content: center;
  }

  .hud-controls .btn {
    flex: 1 1 auto;
    min-width: 96px;
  }

  .hud-stat {
    min-width: 68px;
    padding: 5px 10px;
  }

  .hud-value {
    font-size: 1.05rem;
  }

  .overlay-card {
    padding: var(--s-4);
  }

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

@media (max-width: 420px) {
  .btn-icon-text {
    min-width: 0;
  }

  .touch-controls {
    padding: var(--s-3);
  }

  .touch-group {
    gap: var(--s-2);
  }
}

/* Tall portrait canvases (Kitty Jump) should not overflow the viewport. */
@media (orientation: portrait) {
  .game-stage[data-tall="true"] .game-canvas {
    max-height: 68vh;
    width: auto;
    margin-inline: auto;
  }

  .game-stage[data-tall="true"] {
    display: flex;
    justify-content: center;
    background: var(--surface-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-overlay {
    backdrop-filter: none;
  }
}
