@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ── Reset + cursors ── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4' fill='none' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='12' y1='2' x2='12' y2='8' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='12' y1='16' x2='12' y2='22' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='2' y1='12' x2='8' y2='12' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='16' y1='12' x2='22' y2='12' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Crect x='1' y='1' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1' opacity='0.45'/%3E%3Crect x='18' y='1' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1' opacity='0.45'/%3E%3Crect x='1' y='18' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1' opacity='0.45'/%3E%3Crect x='18' y='18' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1' opacity='0.45'/%3E%3C/svg%3E") 12 12, crosshair !important;
}

/* Pointer: locked-on reticle */
a, button, [onclick], [role="button"], select, label,
.cell, .sq, .nkey, .nav-btn, .play-btn, .filter-btn,
.ltab, .jtab, .go-btn, .t-go-btn, .t-go-btn-scores,
.touch-btn, .side-btn, .promo-piece, .score-tab, .auth-toggle a,
.google-btn, .submit-btn {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4' fill='%2300f5ff' fill-opacity='0.25' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Ccircle cx='12' cy='12' r='1.5' fill='%2300f5ff'/%3E%3Cline x1='12' y1='2' x2='12' y2='8' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='12' y1='16' x2='12' y2='22' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='2' y1='12' x2='8' y2='12' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='16' y1='12' x2='22' y2='12' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Crect x='1' y='1' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Crect x='18' y='1' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Crect x='1' y='18' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Crect x='18' y='18' width='5' height='5' fill='none' stroke='%2300f5ff' stroke-width='1.5'/%3E%3C/svg%3E") 12 12, pointer !important;
}

/* Not-allowed: red X reticle */
.cell.given, .cell.taken, [disabled], button:disabled {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='7' fill='none' stroke='%23ff2244' stroke-width='1.5'/%3E%3Cline x1='7' y1='7' x2='17' y2='17' stroke='%23ff2244' stroke-width='1.5'/%3E%3Cline x1='17' y1='7' x2='7' y2='17' stroke='%23ff2244' stroke-width='1.5'/%3E%3Crect x='1' y='1' width='4' height='4' fill='none' stroke='%23ff2244' stroke-width='1' opacity='0.5'/%3E%3Crect x='19' y='1' width='4' height='4' fill='none' stroke='%23ff2244' stroke-width='1' opacity='0.5'/%3E%3Crect x='1' y='19' width='4' height='4' fill='none' stroke='%23ff2244' stroke-width='1' opacity='0.5'/%3E%3Crect x='19' y='19' width='4' height='4' fill='none' stroke='%23ff2244' stroke-width='1' opacity='0.5'/%3E%3C/svg%3E") 12 12, not-allowed !important;
}

/* Text cursor for inputs */
input, textarea {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cline x1='12' y1='3' x2='12' y2='21' stroke='%2300f5ff' stroke-width='2'/%3E%3Cline x1='8' y1='3' x2='16' y2='3' stroke='%2300f5ff' stroke-width='1.5'/%3E%3Cline x1='8' y1='21' x2='16' y2='21' stroke='%2300f5ff' stroke-width='1.5'/%3E%3C/svg%3E") 12 12, text !important;
}

/* ── Variables ── */
:root {
  --bg: #05050f;
  --card-bg: #0d0d1f;
  --pink: #ff00cc;
  --cyan: #00f5ff;
  --yellow: #ffcc00;
  --purple: #7b2fff;
  --text: #e0e0e0;
  --muted: #666;
  --border: rgba(255,0,204,0.25);
}

/* ── Base ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Press Start 2P', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

/* CRT scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 3px,
    rgba(0,0,0,0.07) 3px, rgba(0,0,0,0.07) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── Floating background squares ── */
.bg-squares {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-sq {
  position: absolute;
  border: 1px solid;
  opacity: 0;
  animation: floatUp linear infinite;
}

.bg-sq:nth-child(1)  { width:18px; height:18px; left:8%;   border-color:rgba(123,47,255,0.5);  animation-duration:14s; animation-delay:0s;   background:rgba(123,47,255,0.08); }
.bg-sq:nth-child(2)  { width:10px; height:10px; left:18%;  border-color:rgba(0,245,255,0.4);   animation-duration:18s; animation-delay:2s;   background:rgba(0,245,255,0.05); }
.bg-sq:nth-child(3)  { width:24px; height:24px; left:30%;  border-color:rgba(255,0,204,0.35);  animation-duration:22s; animation-delay:4s;   background:rgba(255,0,204,0.06); }
.bg-sq:nth-child(4)  { width:14px; height:14px; left:45%;  border-color:rgba(123,47,255,0.45); animation-duration:16s; animation-delay:1s;   background:rgba(123,47,255,0.07); }
.bg-sq:nth-child(5)  { width:20px; height:20px; left:60%;  border-color:rgba(0,245,255,0.35);  animation-duration:20s; animation-delay:6s;   background:rgba(0,245,255,0.04); }
.bg-sq:nth-child(6)  { width:12px; height:12px; left:72%;  border-color:rgba(255,0,204,0.4);   animation-duration:17s; animation-delay:3s;   background:rgba(255,0,204,0.05); }
.bg-sq:nth-child(7)  { width:28px; height:28px; left:82%;  border-color:rgba(123,47,255,0.3);  animation-duration:25s; animation-delay:8s;   background:rgba(123,47,255,0.06); }
.bg-sq:nth-child(8)  { width:10px; height:10px; left:90%;  border-color:rgba(0,245,255,0.5);   animation-duration:13s; animation-delay:5s;   background:rgba(0,245,255,0.07); }
.bg-sq:nth-child(9)  { width:16px; height:16px; left:25%;  border-color:rgba(255,204,0,0.3);   animation-duration:19s; animation-delay:9s;   background:rgba(255,204,0,0.04); }
.bg-sq:nth-child(10) { width:22px; height:22px; left:55%;  border-color:rgba(123,47,255,0.4);  animation-duration:23s; animation-delay:7s;   background:rgba(123,47,255,0.05); }

@keyframes floatUp {
  0%   { transform:translateY(110vh) rotate(0deg);   opacity:0; }
  5%   { opacity:1; }
  95%  { opacity:0.7; }
  100% { transform:translateY(-20vh) rotate(360deg); opacity:0; }
}

/* ── z-index layer ── */
.page, nav, footer, .auth-wrap, .leaderboard-box { position:relative; z-index:1; }

/* ── Page layout (home + leaderboard + login) ── */
.page { max-width:900px; margin:0 auto; padding:40px 20px; }

/* ── Unified nav bar (all game pages) ── */
.arcade-nav-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: 1px solid rgba(255,0,204,0.2);
  position: relative;
  z-index: 1;
}

.arcade-nav-bar nav {
  margin: 0;
  padding: 12px 20px;
}

/* ── Title ── */
.arcade-title {
  font-size: clamp(20px, 4.5vw, 44px);
  color: var(--yellow);
  text-shadow: 0 0 10px var(--yellow), 0 0 30px #ffcc0066;
  text-align: center;
  letter-spacing: 8px;
  animation: flicker 5s infinite;
  position: relative;
  z-index: 1;
  margin-top: 20px;
}

.subtitle {
  text-align: center;
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 4px;
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

@keyframes flicker {
  0%,94%,100% { opacity:1; }
  95% { opacity:0.5; }
  97% { opacity:0.8; }
  99% { opacity:0.3; }
}

/* ── Nav ── */
nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 28px 0;
  flex-wrap: wrap;
}

.nav-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--pink);
  background: transparent;
  border: 1px solid var(--border);
  padding: 10px 18px;
  text-decoration: none;
  transition: all 0.15s;
  letter-spacing: 1px;
}
.nav-btn:hover, .nav-btn.active {
  background: rgba(255,0,204,0.12);
  border-color: var(--pink);
  box-shadow: 0 0 12px rgba(255,0,204,0.3);
  color: #fff;
}

/* ── User bar ── */
.user-bar {
  width: 100%;
  text-align: center;
  font-size: 7px;
  color: var(--muted);
  padding: 7px 16px;
  background: rgba(0,245,255,0.04);
  border-bottom: 1px solid rgba(0,245,255,0.1);
}
.user-bar span { color: var(--cyan); }
.user-bar button {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--muted);
  background: none;
  border: none;
  margin-left: 12px;
  text-decoration: underline;
}
.user-bar button:hover { color: var(--pink); }

/* ── Footer ── */
footer {
  text-align: center;
  font-size: 7px;
  color: var(--muted);
  padding: 32px 20px 20px;
  position: relative;
  z-index: 1;
}
footer a { color: var(--pink); text-decoration: none; }

/* ── Game cards ── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.game-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 24px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.game-card:hover {
  border-color: var(--pink);
  box-shadow: 0 0 20px rgba(255,0,204,0.15);
}
.game-card.coming-soon { opacity:0.45; pointer-events:none; }

.card-icon { font-size:22px; margin-bottom:12px; }
.card-title { font-size:11px; color:var(--cyan); letter-spacing:2px; margin-bottom:10px; }
.card-desc  { font-size:7px;  color:var(--muted); line-height:1.8; margin-bottom:20px; }

.play-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--pink);
  background: transparent;
  border: 1px solid rgba(255,0,204,0.4);
  padding: 10px 16px;
  text-decoration: none;
  display: inline-block;
  letter-spacing: 1px;
  transition: all 0.15s;
}
.play-btn:hover {
  background: rgba(255,0,204,0.15);
  box-shadow: 0 0 14px rgba(255,0,204,0.35);
}

/* ── Leaderboard ── */
.leaderboard-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 28px;
  margin-top: 20px;
}

.lb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow);
}

.lb-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--muted);
  background: transparent;
  border: 1px solid #333;
  padding: 7px 12px;
  transition: all 0.15s;
}
.filter-btn.active, .filter-btn:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,245,255,0.2);
}

.lb-table { width:100%; border-collapse:collapse; }
.lb-table th {
  font-size: 7px;
  color: var(--muted);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #1a1a2e;
  letter-spacing: 1px;
}
.lb-table td {
  font-size: 8px;
  padding: 12px 10px;
  border-bottom: 1px solid #0f0f1e;
}
.lb-table tr:nth-child(1) td { color:#ffd700; }
.lb-table tr:nth-child(2) td { color:#c0c0c0; }
.lb-table tr:nth-child(3) td { color:#cd7f32; }

.rank-badge { display:inline-block; width:22px; text-align:center; font-size:9px; }
.score-val  { color:var(--pink); text-shadow:0 0 6px rgba(255,0,204,0.4); }

/* ── Auth form ── */
.auth-wrap {
  max-width: 420px;
  margin: 48px auto 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 36px;
}

.auth-title {
  font-size: 13px;
  color: var(--pink);
  text-shadow: 0 0 10px var(--pink);
  margin-bottom: 28px;
  text-align: center;
}

/* Google button (moved from login.html inline style) */
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #fff;
  background: rgba(255,0,204,0.1);
  border: 1px solid var(--pink);
  padding: 14px;
  letter-spacing: 1px;
  transition: all 0.15s;
  margin-top: 8px;
}
.google-btn:hover {
  background: rgba(255,0,204,0.25);
  box-shadow: 0 0 16px rgba(255,0,204,0.4);
}
.google-icon { width:18px; height:18px; flex-shrink:0; }

.auth-divider {
  text-align: center;
  font-size: 7px;
  color: var(--muted);
  margin: 20px 0;
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: #1a1a2e;
}
.auth-divider::before { left:0; }
.auth-divider::after  { right:0; }

.form-group { margin-bottom:18px; }
.form-group label {
  display: block;
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.form-group input {
  width: 100%;
  background: #0a0a18;
  border: 1px solid #2a2a3e;
  color: var(--text);
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--pink); }

.submit-btn {
  width: 100%;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #fff;
  background: rgba(255,0,204,0.15);
  border: 1px solid var(--pink);
  padding: 14px;
  letter-spacing: 2px;
  transition: all 0.15s;
  margin-top: 8px;
}
.submit-btn:hover {
  background: rgba(255,0,204,0.3);
  box-shadow: 0 0 16px rgba(255,0,204,0.4);
}

.auth-toggle {
  text-align: center;
  margin-top: 18px;
  font-size: 7px;
  color: var(--muted);
}
.auth-toggle a { color:var(--cyan); text-decoration:none; }
.auth-toggle a:hover { text-decoration:underline; }

.msg {
  font-size: 7px;
  padding: 10px;
  margin-bottom: 14px;
  text-align: center;
  display: none;
}
.msg.error   { color:#ff4444; border:1px solid #ff444433; background:#ff000011; display:block; }
.msg.success { color:#44ff88; border:1px solid #44ff8833; background:#00ff4411; display:block; }

/* ── Global responsive ── */
@media (max-width: 600px) {
  .arcade-title {
    font-size: clamp(14px, 6vw, 28px);
    letter-spacing: 4px;
    margin-top: 14px;
  }
  .subtitle { font-size: 7px; letter-spacing: 2px; }

  nav { gap: 8px; margin: 16px 0; }
  .nav-btn { font-size: 8px; padding: 8px 12px; }

  .page { padding: 20px 12px; }

  .games-grid { grid-template-columns: 1fr; gap: 14px; }
  .game-card  { padding: 18px; }
  .card-title { font-size: 10px; }
  .card-desc  { font-size: 6px; }

  .leaderboard-box { padding: 16px; }
  .lb-header { font-size: 10px; }
  .lb-filter { gap: 6px; }
  .filter-btn { font-size: 6px; padding: 6px 8px; }
  .lb-table th { font-size: 6px; padding: 6px 6px; }
  .lb-table td { font-size: 7px; padding: 10px 6px; }

  .auth-wrap { padding: 24px 16px; margin-top: 20px; }
  .auth-title { font-size: 10px; }
  .form-group input { font-size: 8px; padding: 10px; }
  .submit-btn { font-size: 8px; padding: 12px; }
  .google-btn { font-size: 7px; padding: 12px; }

  footer { font-size: 6px; padding: 20px 12px 16px; }
}

/* ══════════════════════════════════════════════════════════════════
   SHARED GAME-OVER POPUP — used by chess, ttt, tetris, jigsaw
   ══════════════════════════════════════════════════════════════════ */
.gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: goSharedFadeIn 0.25s ease;
}
.gameover-box {
  background: #0a0a1a;
  border: 1px solid var(--pink);
  padding: 36px 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 0 40px rgba(255,0,204,0.3), 0 0 80px rgba(255,0,204,0.1);
  animation: goSharedPopIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
}
.gameover-box::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 3px,
    rgba(0,0,0,0.06) 3px, rgba(0,0,0,0.06) 4px
  );
  pointer-events: none;
}
.gameover-icon {
  font-size: 48px;
  margin-bottom: 14px;
  display: block;
  animation: goSharedIconPulse 1.5s ease-in-out infinite;
}
.gameover-headline {
  font-size: 13px;
  letter-spacing: 3px;
  margin-bottom: 8px;
  line-height: 1.6;
}
.gameover-sub {
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 2px;
  margin-bottom: 24px;
  line-height: 2;
}
/* row used by chess, tetris, jigsaw */
.gameover-moves {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.gameover-moves span { color: var(--cyan); font-size: 11px; }
.gameover-moves a    { color: #ff9900; text-decoration: none; font-size: 7px; }
/* score total used by jigsaw */
.gameover-total {
  font-size: 18px;
  color: var(--pink);
  text-shadow: 0 0 10px var(--pink);
  margin: 14px 0 20px;
  letter-spacing: 2px;
}
/* score grid used by ttt */
.gameover-scores {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
}
.gameover-score-col {
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.gameover-score-col span {
  font-size: 20px;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}
.gameover-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}
.go-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 11px 16px;
  border: 1px solid;
  letter-spacing: 1px;
  transition: all 0.15s;
  background: transparent;
}
.go-btn-primary   { color: var(--pink);  border-color: var(--pink); }
.go-btn-primary:hover  { background: rgba(255,0,204,0.15); box-shadow: 0 0 16px rgba(255,0,204,0.35); }
.go-btn-secondary { color: var(--muted); border-color: #333; }
.go-btn-secondary:hover { color: var(--cyan); border-color: var(--cyan); }

@keyframes goSharedFadeIn { from { opacity:0; }                        to { opacity:1; } }
@keyframes goSharedPopIn  { from { transform:scale(0.8); opacity:0; }  to { transform:scale(1); opacity:1; } }
@keyframes goSharedIconPulse {
  0%,100% { transform:scale(1);    filter:drop-shadow(0 0 8px currentColor); }
  50%      { transform:scale(1.12); filter:drop-shadow(0 0 20px currentColor); }
}
