@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/press-start-2p.woff2') format('woff2');
}

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

body {
  background: #0a0a1a;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

/* ── SCREENS ── */
.screen { display: none; flex-direction: column; align-items: center; gap: 28px; }
.screen.active { display: flex; }

/* ── LEGAL ── */
.legal-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  text-align: center;
}
.legal-line {
  font-size: 0.55rem;
  color: #888;
  letter-spacing: 1px;
  line-height: 1.8;
}
.legal-prompt {
  font-size: 0.55rem;
  color: #444;
  letter-spacing: 3px;
  animation: legal-blink 1.2s step-start infinite;
}
@keyframes legal-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── HOME ── */
.title {
  font-size: 4rem;
  color: #00F0F0;
  text-shadow: 0 0 24px #00F0F0, 6px 6px 0 #005050;
  letter-spacing: 10px;
  margin-bottom: 16px;
}

.menu { display: flex; flex-direction: column; align-items: stretch; gap: 16px; width: fit-content; }

/* ── BUTTONS ── */
.menu-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9rem;
  background: #00F0F0;
  color: #0a0a1a;
  border: none;
  padding: 16px 40px;
  cursor: pointer;
  letter-spacing: 3px;
  transition: background 0.1s, color 0.1s;
  text-align: center;
}
.menu-btn:hover { background: #fff; }
.menu-btn.secondary {
  background: transparent;
  color: #00F0F0;
  border: 2px solid #00F0F0;
}
.menu-btn.secondary:hover { background: #00F0F0; color: #0a0a1a; }
.menu-btn.small { font-size: 0.6rem; padding: 8px 16px; }

.btn-row { display: flex; gap: 16px; }

/* ── COMMON SCREEN ELEMENTS ── */
.screen-title {
  font-size: 1.4rem;
  color: #00F0F0;
  letter-spacing: 4px;
}
.screen-sub {
  font-size: 0.55rem;
  color: #aaa;
  letter-spacing: 2px;
}

/* ── HELP ── */
#help-content {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  max-width: 720px;
  max-height: 480px;
  overflow-y: auto;
  justify-content: center;
}
#help-content::-webkit-scrollbar { width: 6px; }
#help-content::-webkit-scrollbar-thumb { background: #333355; }
.help-section { min-width: 280px; flex: 1; }
.help-heading {
  font-size: 0.55rem;
  color: #00F0F0;
  letter-spacing: 3px;
  margin-bottom: 10px;
  border-bottom: 1px solid #222244;
  padding-bottom: 6px;
}
.help-table { width: 100%; border-collapse: collapse; }
.help-table tr { border-bottom: 1px solid #1a1a33; }
.help-key { font-size: 0.45rem; color: #00F0F0; padding: 5px 12px 5px 0; white-space: nowrap; }
.help-desc { font-size: 0.45rem; color: #aaa; padding: 5px 0; }

/* ── MODE SELECT ── */
.mode-btn.active-mode,
.mode-btn.active-mode.secondary { background: #00F0F0; color: #0a0a1a; border-color: #00F0F0; }

.level-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.level-picker-row {
  display: flex;
  align-items: center;
  gap: 24px;
}
#level-display {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.4rem;
  color: #00F0F0;
  min-width: 40px;
  text-align: center;
}
/* Hide level picker for non-marathon modes */
.level-picker.hidden { display: none; }

/* ── NAME INPUT ── */
#name-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  background: #111128;
  color: #fff;
  border: 3px solid #00F0F0;
  padding: 14px 24px;
  outline: none;
  text-align: center;
  letter-spacing: 4px;
  width: 340px;
}
#name-input:focus { border-color: #fff; box-shadow: 0 0 12px #00F0F0; }
#name-error { font-size: 0.55rem; color: #F00000; min-height: 1em; }

/* ── LEADERBOARD ── */
.lb-tabs {
  display: flex;
  gap: 8px;
}
.lb-tabs .menu-btn { min-width: unset; }

#leaderboard-list {
  width: 520px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#leaderboard-list::-webkit-scrollbar { width: 6px; }
#leaderboard-list::-webkit-scrollbar-thumb { background: #333355; }

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.6rem;
}
.lb-table thead th {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  color: #555;
  letter-spacing: 2px;
  padding: 0 8px 8px;
  text-align: right;
  border-bottom: 1px solid #222244;
}
.lb-table thead th.lb-th-name { text-align: left; }
.lb-table thead th.lb-th-stats { text-align: left; }
.lb-table tbody tr { background: #111128; }
.lb-table tbody tr:not(:last-child) { border-bottom: 1px solid #222244; }
.lb-table td { padding: 10px 8px; text-align: right; white-space: nowrap; }
.lb-rank  { color: #888; text-align: right !important; width: 1%; }
.lb-rank.gold   { color: #F0F000; }
.lb-rank.silver { color: #C0C0C0; }
.lb-rank.bronze { color: #F0A000; }
.lb-name  { color: #fff; letter-spacing: 2px; text-align: left !important; width: 99%; }
.lb-score { color: #00F0F0; letter-spacing: 1px; }
.lb-lines { color: #aaa; font-size: 0.5rem; }
.lb-level { color: #888; font-size: 0.5rem; }
.lb-stats { color: #666; font-size: 0.5rem; letter-spacing: 1px; text-align: left !important; }
.lb-stats span { cursor: default; }
.lb-empty { font-size: 0.6rem; color: #555; text-align: center; padding: 32px 0; }

#lb-pagination {
  display: flex;
  align-items: center;
  gap: 16px;
}
#lb-page-indicator {
  font-size: 0.55rem;
  color: #888;
  letter-spacing: 2px;
  min-width: 80px;
  text-align: center;
}

/* ── GAME SCREEN ── */
#screen-game { flex-direction: row; align-items: flex-start; gap: 0; }

#game-wrap {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

#board-wrap {
  position: relative;
}

canvas#board {
  display: block;
  image-rendering: pixelated;
  border: 3px solid #333355;
  box-shadow: 0 0 40px #00003388;
}

/* ── ACTION NOTIFICATIONS ── */
#action-notification {
  position: absolute;
  left: 0; right: 0;
  top: 40%;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  color: #fff;
  text-shadow: 2px 2px 0 #000, 0 0 16px #00F0F0;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: none;
  letter-spacing: 2px;
  line-height: 1.8;
}
#action-notification.outside {
  position: static;
  text-align: left;
  margin-top: 8px;
}
#action-notification.show {
  animation: notif-pop 1.8s ease-out forwards;
}
@keyframes notif-pop {
  0%   { opacity: 1; transform: translateY(0) scale(1.1); }
  15%  { opacity: 1; transform: translateY(-4px) scale(1); }
  70%  { opacity: 1; transform: translateY(-4px); }
  100% { opacity: 0; transform: translateY(-12px); }
}

/* ── SIDE PANELS ── */
#panel-left, #panel-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 140px;
  padding-top: 0;
}

/* keep old #panel selector working if referenced */
#panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 140px;
}

.panel-box {
  background: #111128;
  border: 2px solid #333355;
  padding: 10px 14px;
}
.panel-label {
  font-size: 0.45rem;
  color: #888;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.panel-value {
  font-size: 0.75rem;
  color: #fff;
  letter-spacing: 1px;
  word-break: break-all;
}
.panel-value.big { font-size: 1rem; color: #00F0F0; }

.stats-table { width: 100%; border-collapse: collapse; }
.stats-label { font-size: 0.4rem; color: #888; letter-spacing: 1px; padding: 2px 0; }
.stats-value { font-size: 0.4rem; color: #fff; text-align: right; padding: 2px 0; letter-spacing: 1px; }

canvas.preview {
  display: block;
  image-rendering: pixelated;
  margin: 6px auto 0;
}

/* ── COUNTDOWN OVERLAY ── */
#countdown-overlay {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  z-index: 25;
  pointer-events: none;
}
#countdown-overlay.active { display: flex; }
#countdown-number {
  font-family: 'Press Start 2P', monospace;
  font-size: 8rem;
  color: #fff;
  text-shadow: 0 0 40px #00F0F0, 6px 6px 0 #003344;
  animation: countdown-pop 0.8s ease-out forwards;
}
@keyframes countdown-pop {
  0%   { transform: scale(1.4); opacity: 1; }
  80%  { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0; }
}

/* ── PAUSE OVERLAY ── */
#pause-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.80);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 32px;
  z-index: 15;
}
#pause-overlay.active { display: flex; }
/* Hide game content while paused per guideline */
#pause-overlay.active ~ #screen-game canvas,
body:has(#pause-overlay.active) #board,
body:has(#pause-overlay.active) .preview { visibility: hidden; }
#pause-overlay h2 {
  font-size: 2.2rem;
  color: #00F0F0;
  text-shadow: 4px 4px 0 #005050, 0 0 24px #00F0F0;
  letter-spacing: 8px;
}
.pause-toggles {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 240px;
}

/* ── QUIT CONFIRM OVERLAY ── */
#quit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  z-index: 30;
}
#quit-overlay.active { display: flex; }
#quit-overlay h2 {
  font-size: 1.6rem;
  color: #F0F000;
  text-shadow: 3px 3px 0 #505000, 0 0 20px #F0F000;
  letter-spacing: 4px;
}
#quit-overlay p { font-size: 0.55rem; color: #aaa; }

/* ── GAME OVER OVERLAY ── */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  z-index: 20;
}
#overlay.active { display: flex; }
#overlay h2 {
  font-size: 2.2rem;
  color: #F00000;
  text-shadow: 4px 4px 0 #500000, 0 0 24px #F00000;
  letter-spacing: 4px;
}
#overlay p { font-size: 0.65rem; color: #aaa; }
#overlay .final-score { font-size: 1.1rem; color: #F0F000; }
#overlay-rank { font-size: 0.65rem; color: #00F0F0; min-height: 1.2em; }

/* ── SETTINGS ── */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 420px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.setting-label {
  font-size: 0.7rem;
  color: #fff;
  letter-spacing: 2px;
}
.toggle-btn {
  min-width: 90px;
  text-align: center;
}
.volume-control { display: flex; align-items: center; gap: 10px; }
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: #333355;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #00F0F0;
  cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #00F0F0;
  border: none;
  cursor: pointer;
}
.volume-value { font-size: 0.55rem; color: #00F0F0; width: 36px; text-align: right; }
.toggle-btn.on {
  background: #00F0F0;
  color: #0a0a1a;
  border-color: #00F0F0;
}
.toggle-btn.off {
  background: transparent;
  color: #666;
  border-color: #444;
}
