*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
  font-family: 'Courier New', monospace;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── App shell — portrait 3∶5 aspect ratio ── */
#app {
  position: relative;
  width:  min(96vw, calc(96vh * 0.6));
  aspect-ratio: 3 / 5;
  /* All child screens are absolute inset:0 */
}

/* Fullscreen: expand to fill viewport */
:fullscreen #app,
:-webkit-full-screen #app {
  width: min(100vw, calc(100vh * 0.6));
}

/* ── Shared screen overlay ── */
#screen-menu,
#screen-settings,
#screen-shop,
#game-container {
  position: absolute;
  inset: 0;
}

.hidden { display: none !important; }

/* ══════════════════════════════
   SHARED BUTTON STYLES
══════════════════════════════ */
.btn {
  display: block;
  width: 200px;
  padding: 11px 0;
  margin: 7px auto;
  background: transparent;
  border: 2px solid #4c1d95;
  border-radius: 8px;
  color: #c4b5fd;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover        { background: #4c1d95; color: #fff; box-shadow: 0 0 14px #7c3aed; }
.btn-primary      { border-color: #7c3aed; color: #e9d5ff; font-size: 1rem; }
.btn-primary:hover{ background: #7c3aed; }

/* ══════════════════════════════
   MENU SCREEN
══════════════════════════════ */
#screen-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(160deg, #020817 0%, #0f172a 60%, #1e1b4b 100%);
}

.game-title {
  font-size: clamp(2rem, 10vw, 3rem);
  color: #60a5fa;
  letter-spacing: 6px;
  text-align: center;
  line-height: 1.1;
  text-shadow: 0 0 20px #3b82f6, 0 0 50px #1d4ed8;
  animation: titleGlow 2.5s ease-in-out infinite;
  margin-bottom: 4px;
}
@keyframes titleGlow {
  0%,100% { text-shadow: 0 0 20px #3b82f6, 0 0 50px #1d4ed8; }
  50%     { text-shadow: 0 0 40px #93c5fd, 0 0 80px #3b82f6; }
}

.coin-badge {
  color: #fbbf24;
  font-size: 1rem;
  margin: 2px 0 10px;
}

.section-label {
  color: #64748b;
  font-size: 0.65rem;
  letter-spacing: 3px;
  margin-top: 4px;
}

/* Difficulty row */
.diff-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 10px;
}
.diff-btn {
  padding: 7px 16px;
  background: transparent;
  border: 2px solid #334155;
  border-radius: 6px;
  color: #64748b;
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}
.diff-btn:hover       { border-color: #3b82f6; color: #93c5fd; }
.diff-btn.active      { border-color: #3b82f6; color: #fff; background: rgba(59,130,246,0.2); }
.diff-btn[data-diff="medium"].active { border-color: #f59e0b; color: #fff; background: rgba(245,158,11,0.2); }
.diff-btn[data-diff="hard"].active   { border-color: #ef4444; color: #fff; background: rgba(239,68,68,0.2); }

.hint {
  color: #374151;
  font-size: 0.65rem;
  letter-spacing: 1px;
  margin-top: 6px;
}

/* ══════════════════════════════
   SETTINGS SCREEN
══════════════════════════════ */
#screen-settings {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: linear-gradient(160deg, #020817 0%, #0f172a 60%, #1e1b4b 100%);
  padding: 24px;
}

.screen-title {
  color: #60a5fa;
  font-size: 1.4rem;
  letter-spacing: 4px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.setting-label {
  color: #64748b;
  font-size: 0.65rem;
  letter-spacing: 3px;
}

.toggle-row {
  display: flex;
  gap: 8px;
}
.toggle-btn {
  padding: 8px 24px;
  background: transparent;
  border: 2px solid #334155;
  border-radius: 6px;
  color: #64748b;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-btn:hover  { border-color: #3b82f6; color: #93c5fd; }
.toggle-btn.active { border-color: #3b82f6; background: rgba(59,130,246,0.2); color: #fff; }

.option-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.opt-btn {
  padding: 7px 14px;
  background: transparent;
  border: 2px solid #334155;
  border-radius: 6px;
  color: #64748b;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 52px;
}
.opt-btn:hover  { border-color: #3b82f6; color: #93c5fd; }
.opt-btn.active { border-color: #3b82f6; background: rgba(59,130,246,0.2); color: #fff; }

/* ══════════════════════════════
   SHOP SCREEN
══════════════════════════════ */
#screen-shop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(160deg, #020817 0%, #0f172a 60%, #1e1b4b 100%);
  padding: 20px 16px;
}

#theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 300px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: 2px solid #334155;
  border-radius: 8px;
  padding: 10px 8px 8px;
  cursor: pointer;
  background: rgba(15,23,42,0.6);
  color: #94a3b8;
  font-size: 0.7rem;
  text-align: center;
  transition: all 0.2s;
}
.theme-card:hover { border-color: #3b82f6; background: rgba(59,130,246,0.1); }
.theme-card.active { border-color: #fbbf24; }
.theme-card.locked { cursor: not-allowed; opacity: 0.6; }

.theme-preview {
  width: 100%;
  height: 34px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
}
.theme-preview.theme-classic { background: linear-gradient(135deg, #1e3a8a, #1e40af); }
.theme-preview.theme-neon    { background: linear-gradient(135deg, #052e0f, #0f3d0f); border-color: #00e676; }
.theme-preview.theme-fire    { background: linear-gradient(135deg, #3b0000, #7f1d1d); border-color: #ff4500; }
.theme-preview.theme-galaxy  { background: radial-gradient(ellipse, #1a0b2e, #0d0d1a); border-color: #7c3aed; }
.theme-preview.theme-gold    { background: linear-gradient(135deg, #1a1400, #4a3800); border-color: #fbbf24; }
.theme-preview.theme-ice     { background: linear-gradient(135deg, #c8e8ff, #ddf5ff); border-color: #38bdf8; }

.theme-name   { font-weight: bold; color: #cbd5e1; font-size: 0.75rem; }
.theme-desc   { color: #475569; font-size: 0.62rem; }
.theme-status { color: #fbbf24; font-size: 0.68rem; }
.theme-price  { color: #94a3b8; font-size: 0.68rem; }

/* ══════════════════════════════
   GAME CONTAINER
══════════════════════════════ */
#game-container {
  display: flex;
  flex-direction: column;
  background: #000;
}

/* HUD bar */
#hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  height: 42px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 13px;
  z-index: 10;
}
.hud-side   { color: #93c5fd; font-weight: bold; }
.hud-side b { font-size: 1.2rem; }
#hud-timer  { color: #a78bfa; font-size: 1rem; font-weight: bold; letter-spacing: 2px; }
#btn-pause {
  background: transparent;
  border: 1px solid rgba(59,130,246,0.45);
  border-radius: 6px;
  color: #93c5fd;
  font-size: 0.85rem;
  width: 28px; height: 24px;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  font-family: 'Courier New', monospace;
  transition: all 0.15s;
}
#btn-pause:hover { background: rgba(59,130,246,0.25); color: #fff; }

/* Table */
#table {
  flex: 1;
  position: relative;
  overflow: hidden;
  border: 6px solid #94a3b8;
  border-radius: 16px;
  /* Default theme - overridden by theme class */
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 50%, #1e3a8a 100%);
  box-shadow: 0 0 30px rgba(59,130,246,0.5), inset 0 0 50px rgba(0,0,0,0.3);
}

/* Center line */
#table::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 6%;
  right: 6%;
  height: 2px;
  background: rgba(255,255,255,0.2);
  transform: translateY(-50%);
  pointer-events: none;
}
/* Center circle */
#table::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(50px, 18%, 80px);
  height: clamp(50px, 18%, 80px);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  pointer-events: none;
}

/* ── Table themes ── */
#table.theme-classic {
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 50%, #1e3a8a 100%);
  border-color: #94a3b8;
  box-shadow: 0 0 30px rgba(59,130,246,0.5), inset 0 0 50px rgba(0,0,0,0.3);
}
#table.theme-neon {
  background: linear-gradient(180deg, #052e0f 0%, #0f3d0f 50%, #052e0f 100%);
  border-color: #00e676;
  box-shadow: 0 0 30px rgba(0,230,118,0.5), inset 0 0 50px rgba(0,0,0,0.4);
}
#table.theme-fire {
  background: linear-gradient(180deg, #3b0000 0%, #7f1d1d 50%, #3b0000 100%);
  border-color: #ff4500;
  box-shadow: 0 0 30px rgba(255,69,0,0.5), inset 0 0 50px rgba(0,0,0,0.4);
}
#table.theme-galaxy {
  background: radial-gradient(ellipse at 50% 50%, #1a0b2e 0%, #0d0d1f 60%, #000010 100%);
  border-color: #7c3aed;
  box-shadow: 0 0 40px rgba(124,58,237,0.6), inset 0 0 60px rgba(0,0,0,0.6);
}
#table.theme-gold {
  background: linear-gradient(180deg, #1a1400 0%, #4a3800 50%, #1a1400 100%);
  border-color: #fbbf24;
  box-shadow: 0 0 30px rgba(251,191,36,0.4), inset 0 0 50px rgba(0,0,0,0.5);
}
#table.theme-ice {
  background: linear-gradient(180deg, #c8e8ff 0%, #ddf5ff 50%, #c8e8ff 100%);
  border-color: #38bdf8;
  box-shadow: 0 0 25px rgba(56,189,248,0.4), inset 0 0 40px rgba(255,255,255,0.25);
}
/* Ice theme: dark center elements */
#table.theme-ice::before { background: rgba(0,60,120,0.18); }
#table.theme-ice::after  { border-color: rgba(0,60,120,0.15); }

/* ── Goals ── */
.goal {
  position: absolute;
  width: 50%;
  height: 13%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220,38,38,0.2);
  border: 3px solid rgba(220,38,38,0.6);
  border-radius: 10px;
}
#goal-player { bottom: 0; border-bottom: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
#goal-ai     { top: 0;    border-top:    none; border-top-left-radius:    0; border-top-right-radius:    0; }

/* ── Puck ── */
#puck {
  position: absolute;
  width: 38px;
  height: 38px;
  background: radial-gradient(circle, #fde68a 0%, #fbbf24 55%, #b45309 100%);
  border-radius: 50%;
  box-shadow: 0 0 18px #fbbf24, 0 3px 6px rgba(0,0,0,0.5);
  z-index: 5;
  pointer-events: none;
}

/* ── Paddles ── */
.paddle {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  z-index: 10;
  pointer-events: none;
}
#paddle-player {
  background: radial-gradient(circle, #60a5fa 0%, #1d4ed8 70%, #1e3a8a 100%);
  box-shadow: 0 0 14px rgba(96,165,250,0.8), 0 3px 6px rgba(0,0,0,0.5);
}
#paddle-ai {
  background: radial-gradient(circle, #f87171 0%, #b91c1c 70%, #7f1d1d 100%);
  box-shadow: 0 0 14px rgba(248,113,113,0.8), 0 3px 6px rgba(0,0,0,0.5);
}

/* Powerup glow */
.paddle.powerup {
  transform: scale(1.4);
  filter: brightness(1.4) drop-shadow(0 0 16px #a78bfa);
}

/* ── Score flash ── */
@keyframes scoreFlash {
  0%   { opacity: 1; transform: scale(1); }
  50%  { opacity: 0.5; transform: scale(1.5); }
  100% { opacity: 1; transform: scale(1); }
}
.score-flash { animation: scoreFlash 0.4s ease-out; }

/* ── Pause overlay ── */
#game-pause {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 101;
}
#game-pause h2 { color: #93c5fd; font-size: 1.6rem; letter-spacing: 4px; }

/* ── Game over overlay ── */
#game-over {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1);   }
}
#result { font-size: clamp(1.6rem, 8vw, 2.4rem); }
.winner { color: #4ade80; }
.loser  { color: #f87171; }
.draw   { color: #fbbf24; }
#reward-text { color: #94a3b8; font-size: 0.85rem; }
