/* Sea Cave Run: Dash & Byte's arcade cabinet in the Hallow's Creek sea caves.
   Palette from the series bible: dark grays and plums, lilac and lavender,
   "blood sorbet" accents, plus a little 80s arcade neon. */
:root {
  --bg-cave: #0c0a12;
  --bg-plum: #1a1424;
  --plum: #2a2038;
  --lilac: #c4b5fd;
  --lavender: #a78bfa;
  --sorbet: #e11d48;
  --sorbet-soft: #fda4af;
  --neon-cyan: #22d3ee;
  --neon-lime: #a3e635;
  --beam: #fde68a;
  --text-light: #f1f5f9;
  --text-muted: #b8b0c8;
  --border: rgba(196, 181, 253, 0.4);
  --pixel: 'Press Start 2P', ui-monospace, monospace;
}

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

html,
body {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #241b33 0%, #0e0b15 60%, #060509 100%);
  color: var(--text-light);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px 16px;
  gap: 10px;
}

/* ---------- Marquee / HUD ---------- */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  padding: 8px 16px;
  background: linear-gradient(180deg, #231b30 0%, #15111d 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 18px rgba(124, 58, 237, 0.2);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.bat-crest {
  font-size: 1.25rem;
  filter: drop-shadow(0 0 6px var(--sorbet));
}

.brand-title {
  font-family: var(--pixel);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--text-light);
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.6), 2px 2px 0 var(--sorbet);
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(8, 6, 12, 0.7);
  border: 1px solid rgba(196, 181, 253, 0.3);
  border-radius: 8px;
}

.best-pill {
  border-color: rgba(253, 230, 138, 0.45);
}

.stat-label {
  font-family: var(--pixel);
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.best-pill .stat-label {
  color: var(--beam);
}

.stat-value {
  font-family: var(--pixel);
  font-size: 0.85rem;
  color: var(--neon-lime);
  min-width: 24px;
  text-align: right;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(196, 181, 253, 0.35);
  background: rgba(42, 32, 56, 0.8);
  color: var(--text-light);
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-btn {
  padding: 0 12px;
  font-family: var(--pixel);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
}

.icon-btn:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.4);
  transform: translateY(-1px);
}

/* ---------- Screen ---------- */
.stage-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 900 / 560;
  max-height: calc(100vh - 120px);
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #2a2038;
  box-shadow:
    0 0 0 1px var(--border),
    0 18px 50px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(124, 58, 237, 0.25);
  background: var(--bg-cave);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
  background: radial-gradient(circle at center, rgba(12, 10, 18, 0.5) 0%, rgba(6, 5, 9, 0.85) 100%);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.arcade-card {
  width: 100%;
  max-width: 460px;
  margin: auto;
  padding: 20px 22px;
  text-align: center;
  background: linear-gradient(165deg, rgba(36, 28, 48, 0.96) 0%, rgba(14, 11, 20, 0.98) 100%);
  border: 2px solid var(--lavender);
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.85), 0 0 24px rgba(167, 139, 250, 0.3);
}

.crest-badge {
  display: inline-block;
  padding: 5px 12px;
  margin-bottom: 10px;
  font-family: var(--pixel);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  color: var(--neon-cyan);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 6px;
}

.danger-badge {
  color: var(--sorbet-soft);
  background: rgba(225, 29, 72, 0.12);
  border-color: rgba(225, 29, 72, 0.5);
}

.game-title {
  font-family: var(--pixel);
  font-size: 1.5rem;
  line-height: 1.3;
  margin-bottom: 10px;
  color: var(--text-light);
  text-shadow: 3px 3px 0 var(--sorbet), 0 0 16px rgba(196, 181, 253, 0.5);
}

.game-subtitle {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.barnaby-says {
  margin-bottom: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  font-style: italic;
  color: var(--text-light);
  background: rgba(8, 6, 12, 0.6);
  border-left: 3px solid var(--sorbet);
  border-radius: 6px;
  text-align: left;
}

.barnaby-name {
  font-family: var(--pixel);
  font-style: normal;
  font-size: 0.5rem;
  color: var(--sorbet-soft);
  margin-right: 6px;
}

/* High score table */
.scores-panel {
  margin-bottom: 12px;
  padding: 10px 14px;
  background: rgba(8, 6, 12, 0.7);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 10px;
}

.scores-title {
  font-family: var(--pixel);
  font-size: 0.55rem;
  color: var(--beam);
  margin-bottom: 8px;
  letter-spacing: 0.1em;
}

.score-table {
  list-style: none;
  font-family: var(--pixel);
  font-size: 0.6rem;
  line-height: 1.9;
}

.score-table li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  gap: 8px;
  color: var(--lilac);
}

.score-table li:nth-child(1) {
  color: var(--neon-cyan);
}

.score-table li.fresh {
  color: var(--neon-lime);
  animation: blink 0.8s steps(2) infinite;
}

.score-table .rank {
  text-align: right;
  color: var(--text-muted);
}

.score-table .name {
  text-align: left;
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.scores-panel.compact .score-table {
  line-height: 1.7;
}

.controls-guide {
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 3px 7px;
  font-family: var(--pixel);
  font-size: 0.5rem;
  color: var(--text-light);
  background: linear-gradient(180deg, #3b2f4d 0%, #241c31 100%);
  border: 1px solid var(--lavender);
  border-bottom-width: 3px;
  border-radius: 5px;
}

.score-summary {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 12px;
  padding: 10px;
  background: rgba(8, 6, 12, 0.65);
  border: 1px solid rgba(196, 181, 253, 0.3);
  border-radius: 10px;
}

.summary-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.summary-label {
  font-family: var(--pixel);
  font-size: 0.5rem;
  color: var(--text-muted);
}

.summary-number {
  font-family: var(--pixel);
  font-size: 1.2rem;
  color: var(--neon-lime);
}

.summary-divider {
  width: 1px;
  height: 40px;
  background: rgba(196, 181, 253, 0.25);
}

.record-tag {
  padding: 3px 6px;
  font-family: var(--pixel);
  font-size: 0.45rem;
  color: #0c0a12;
  background: var(--beam);
  border-radius: 4px;
}

/* Initials entry */
.initials-form {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px dashed rgba(163, 230, 53, 0.5);
  border-radius: 10px;
}

.initials-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--neon-lime);
}

.initials-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

#initials-input {
  width: 7.5em;
  padding: 8px 10px;
  font-family: var(--pixel);
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  color: var(--neon-lime);
  background: #08060c;
  border: 2px solid var(--neon-lime);
  border-radius: 6px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

#initials-input:focus {
  box-shadow: 0 0 12px rgba(163, 230, 53, 0.45);
}

.arcade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 20px;
  font-family: var(--pixel);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: #ffffff;
  background: linear-gradient(180deg, #e11d48 0%, #9f1239 100%);
  border: 2px solid var(--sorbet-soft);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 #4c0519, 0 8px 20px rgba(225, 29, 72, 0.35);
  transition: transform 0.1s ease, filter 0.15s ease;
}

.arcade-btn:hover {
  filter: brightness(1.12);
}

.arcade-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #4c0519, 0 4px 10px rgba(225, 29, 72, 0.3);
}

.arcade-btn.small {
  width: auto;
  padding: 8px 14px;
  font-size: 0.6rem;
  background: linear-gradient(180deg, #65a30d 0%, #3f6212 100%);
  border-color: var(--neon-lime);
  box-shadow: 0 3px 0 #1a2e05;
}

#start-btn span {
  animation: blink 1.2s steps(2) infinite;
}

/* ---------- Footer ---------- */
.hud-footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.8;
  text-align: center;
}

.hud-footer strong {
  color: var(--lilac);
}

/* Small or short screens: menus take the whole screen instead of the small game window */
@media (max-width: 640px), (max-height: 560px) {
  .overlay {
    position: fixed;
    z-index: 20;
    background: rgba(6, 5, 9, 0.92);
  }
}

@media (max-width: 640px) {
  .brand-title {
    display: none;
  }
  .hud-bar {
    padding: 8px 10px;
  }
  .hud-stats {
    gap: 6px;
  }
  .stat-pill {
    padding: 5px 8px;
  }
  .home-btn {
    display: none;
  }
  .game-title {
    font-size: 1.1rem;
  }
  .arcade-card {
    padding: 14px;
  }
  .game-subtitle,
  .barnaby-says {
    font-size: 0.8rem;
  }
  .hud-footer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #start-btn span,
  .score-table li.fresh {
    animation: none;
  }
}
