/* ============================================
   $REPLAY — Game Page Styles
   ============================================ */

/* ---- Game Page Layout ---- */
.game-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding-top: 64px; /* clear the fixed nav */
  padding-bottom: 8px;
  /* overflow kept visible so leaderboard below is reachable */
}

.game-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* ---- Game Nav overrides ---- */
.nav-game {
  background: rgba(10, 10, 10, 0.97) !important;
  border-bottom: 1px solid var(--color-border);
}

/* ---- Arcade Bezel ---- */
.game-bezel {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: #0e0e0e;
  border: 2px solid #1e1e1e;
  border-radius: 12px;
  box-shadow:
    0 0 0 1px #2a2a2a,
    0 0 60px rgba(0, 212, 255, 0.1),
    0 0 120px rgba(0, 212, 255, 0.04),
    inset 0 0 40px rgba(0,0,0,0.6);
  overflow: hidden;

  /* Fill available space after nav + padding, with a little breathing room */
  height: calc(100vh - 84px);
  width: min(520px, calc((100vh - 84px) * 0.62));
}

/* ---- Bezel Top Bar ---- */
.bezel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: #080808;
  border-bottom: 1px solid #1a1a1a;
  gap: 0.5rem;
  flex-shrink: 0;
}

.bezel-title {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--color-blue);
  text-shadow: var(--glow-blue);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.bezel-scores {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.score-display,
.hiscore-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.score-label {
  font-family: var(--font-pixel);
  font-size: 0.3rem;
  color: var(--color-muted);
  letter-spacing: 0.1em;
}

.score-value {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--color-white);
  letter-spacing: 0.05em;
  min-width: 60px;
  text-align: right;
}

/* ---- Player Bar ---- */
.player-bar {
  background: #060606;
  border-bottom: 1px solid #141414;
  padding: 0.25rem 1rem;
  flex-shrink: 0;
  text-align: center;
}

.player-bar-text {
  font-family: var(--font-pixel);
  font-size: 0.3rem;
  color: var(--color-muted);
  letter-spacing: 0.08em;
}

.player-bar-text.has-wallet {
  color: var(--color-blue);
}

/* ---- Canvas Container ---- */
.canvas-container {
  position: relative;
  background: #000;
  flex: 1;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- Bezel Bottom ---- */
.bezel-bottom {
  padding: 0.75rem 1rem;
  background: #080808;
  border-top: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bezel-controls {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.bezel-joystick {
  width: 28px; height: 28px;
  background: #1a1a1a;
  border: 2px solid #2a2a2a;
  border-radius: 50%;
  position: relative;
}
.bezel-joystick::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  background: #2a2a2a;
  border-radius: 50%;
}

.bezel-btns {
  display: flex;
  gap: 0.5rem;
}
.bezel-btn-circle {
  display: block;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
}
.bezel-btn-circle.red  { background: rgba(255, 50, 50, 0.4); }
.bezel-btn-circle.blue { background: rgba(0, 212, 255, 0.3); }

/* ---- Game Overlay (Start / Game Over) ---- */
.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity 0.3s ease;
}

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

.overlay-content {
  text-align: center;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.overlay-title {
  font-family: var(--font-pixel);
  font-size: clamp(1.2rem, 5vw, 2rem);
  color: var(--color-blue);
  text-shadow: var(--glow-blue);
  letter-spacing: 0.05em;
}
.overlay-title.red-text {
  color: var(--color-pink);
  text-shadow: var(--glow-pink);
}

.overlay-sub {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--color-muted);
  letter-spacing: 0.15em;
}

.overlay-insert {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--color-yellow);
  letter-spacing: 0.08em;
  margin-top: 0.5rem;
}

.overlay-hint {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--color-muted);
  letter-spacing: 0.05em;
}

.overlay-controls {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.control-hint {
  font-size: 0.75rem;
  color: #555;
  font-family: var(--font-body);
}

.overlay-score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.overlay-score-label {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--color-muted);
  letter-spacing: 0.1em;
}
.overlay-final-score {
  font-family: var(--font-pixel);
  font-size: 1.4rem;
  color: var(--color-white);
  text-shadow: 0 0 20px rgba(255,255,255,0.3);
}

/* ---- New High Score celebration overlay ---- */

/* Rainbow color cycle for record text */
@keyframes rainbowText {
  0%   { color: var(--color-yellow);  text-shadow: 0 0 14px rgba(255,215,0,0.8); }
  25%  { color: var(--color-blue);    text-shadow: 0 0 14px rgba(0,212,255,0.8); }
  50%  { color: var(--color-pink);    text-shadow: 0 0 14px rgba(255,0,128,0.8); }
  75%  { color: var(--color-green);   text-shadow: 0 0 14px rgba(0,255,65,0.8); }
  100% { color: var(--color-yellow);  text-shadow: 0 0 14px rgba(255,215,0,0.8); }
}

/* Score count-up pop */
@keyframes scorePop {
  0%   { transform: scale(0.5);  opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

/* Overlay border pulse when new record */
@keyframes borderPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(255,215,0,0.4), 0 0 30px rgba(255,215,0,0.1); }
  50%       { box-shadow: inset 0 0 0 2px rgba(255,215,0,1),   0 0 60px rgba(255,215,0,0.3); }
}

/* Confetti pieces rain down */
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(300px) rotate(720deg); opacity: 0; }
}

.new-record-screen .overlay-content {
  animation: borderPulse 1.2s ease-in-out infinite;
  border: 2px solid rgba(255,215,0,0.5);
  border-radius: 8px;
  padding: 1.5rem;
}

.new-record-screen .overlay-final-score {
  animation: scorePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  color: var(--color-yellow);
  text-shadow: 0 0 30px rgba(255,215,0,0.6);
}

.new-record-screen .overlay-title {
  animation: rainbowText 1.5s linear infinite;
}

/* Confetti container */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.confetti-piece {
  position: absolute;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  animation: confettiFall linear infinite;
}

/* Keep overlay content above confetti */
.game-overlay .overlay-content { position: relative; z-index: 1; }

.new-record {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--color-yellow);
  letter-spacing: 0.08em;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.overlay-btn {
  margin-top: 0.5rem;
  font-size: 0.5rem;
}

.overlay-home-link {
  font-family: var(--font-pixel);
  font-size: 0.4rem;
  color: var(--color-muted);
  letter-spacing: 0.08em;
  transition: color var(--transition);
}
.overlay-home-link:hover { color: var(--color-blue); }

/* Blink utility */
.blink-text {
  animation: blink 1s step-end infinite;
}

/* ---- Touch Zones (inside canvas-container) ---- */
.touch-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  z-index: 200;
  pointer-events: all;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.touch-left  { left: 0; }
.touch-right { right: 0; }

/* On desktop, touch zones shouldn't interfere */
@media (pointer: fine) {
  .touch-zone {
    pointer-events: none;
  }
}

/* ============================================
   RESPONSIVE — Game
   ============================================ */
@media (max-width: 768px) {
  .game-bezel {
    border-radius: 0;
    border-left: none;
    border-right: none;
    width: 100% !important;
    height: calc(100vh - 72px) !important;
  }

  .bezel-top { padding: 0.5rem 0.75rem; }
  .bezel-bottom { padding: 0.5rem; }
  .bezel-controls { gap: 1rem; }

  .mobile-hint { display: block; }

  .overlay-content {
    padding: 1.5rem 1rem;
    gap: 0.75rem;
  }
}

@media (pointer: fine) {
  .mobile-hint { display: none; }
}

@media (max-height: 600px) {
  .bezel-bottom { display: none; }
  .bezel-top { padding: 0.4rem 0.75rem; }
  .player-bar { padding: 0.15rem 0.75rem; }
}

/* ============================================
   GAME PAGE — LEADERBOARD SECTION
   ============================================ */
.game-leaderboard {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding: 3.5rem 1rem 5rem;
}

.lb-inner {
  max-width: min(520px, 96vw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

.lb-title {
  font-family: var(--font-pixel);
  font-size: clamp(0.85rem, 4vw, 1.3rem);
  color: var(--color-white);
  letter-spacing: 0.05em;
  margin: 0;
}

.lb-inner .leaderboard-wrap {
  width: 100%;
}

/* Highlight rows */
.lb-you td {
  background: rgba(0, 255, 65, 0.06) !important;
  color: var(--color-green) !important;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.35) !important;
}

.lb-highlight td {
  animation: lbFlash 0.7s ease 0.3s 4 alternate;
}

@keyframes lbFlash {
  from { background: transparent; }
  to   { background: rgba(255, 215, 0, 0.12); }
}

.lb-score {
  text-align: right;
}

/* ---- Score column right-align globally ---- */
.lb-table .lb-score { text-align: right; }
