@font-face {
  font-family: 'Crack Man';
  src: url('assets/fonts/crackman-front.otf') format('opentype');
  font-display: swap;
}

/* SALTMAN — colour arcade cabinet (deep stage, neon accents) */
:root {
  --ink: #f4f8ff;
  --paper: #08090c;
  --grey: #93a0b8;
  --line: rgba(120, 170, 255, 0.22);
  --accent: #00e5ff;
  --accent-soft: rgba(0, 229, 255, 0.55);
  --warm: #ffc85e;
  --glow: 0 0 14px rgba(0, 229, 255, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse 120% 90% at 50% 8%, #101a33 0%, #08090c 55%, #05060a 100%);
  color: var(--ink);
  font-family: 'Crack Man', ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
}

#game-mount { position: fixed; inset: 0; }
#game-mount canvas { display: block; }

/* ------------------------------------------------------------------ HUD */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 14px 20px 0;
  pointer-events: none;
  z-index: 25;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: opacity 260ms ease;
}
body[data-state="menu"] #hud,
body[data-state="boot"] #hud { opacity: 0.25; }
body[data-state="gameover"] #hud { opacity: 0.5; }

.hud-left, .hud-right { display: flex; gap: 22px; align-items: flex-start; }
.hud-cell { display: flex; flex-direction: column; gap: 3px; }
.hud-label { color: #ff5a8a; font-size: 9px; letter-spacing: 0.08em; text-shadow: 2px 2px 0 #000; }
.hud-value {
  color: #ffffff;
  font-size: 15px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 2px 2px 0 #000, 0 0 16px rgba(0, 229, 255, 0.65);
}

.hud-mid { flex: 1; display: flex; justify-content: center; padding-top: 2px; }
.power-meter { width: 200px; display: flex; align-items: center; gap: 9px; opacity: 0.55; transition: opacity 200ms ease; }
.power-meter.active { opacity: 1; }
.power-track {
  flex: 1; height: 5px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  overflow: hidden;
}
.power-fill {
  height: 100%; width: 0%;
  background: linear-gradient(to right, #00e5ff, #7cf9ff);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.95);
  transition: width 90ms linear;
}
.power-label { font-size: 8px; color: #ffcf3a; letter-spacing: 0.04em; }

.lives-row { display: flex; gap: 4px; align-items: center; min-height: 18px; }
.life-icon { width: 18px; height: 18px; opacity: 0.98; filter: drop-shadow(0 0 6px rgba(0,229,255,0.55)); }
.life-fallback {
  display: inline-block; width: 14px; height: 14px;
  border: 1.5px solid var(--ink); border-radius: 50%;
}
.life-empty { color: var(--grey); }

/* -------------------------------------------------------------- overlays */
#overlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 45;
  padding: 24px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.92) 70%);
  backdrop-filter: blur(2px);
}
#overlay.show { display: flex; animation: fadein 260ms ease both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.panel {
  text-align: center;
  max-width: 560px;
  width: 100%;
  animation: rise 340ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.panel h2 {
  margin: 0 0 18px;
  font-size: clamp(20px, 4vw, 30px);
  letter-spacing: 0.28em;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 0 22px rgba(0, 229, 255, 0.7), 0 2px 8px rgba(0,0,0,0.9);
}
.panel-menu { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.logo-wrap { width: min(78vw, 620px); margin-bottom: 2px; }
.logo {
  width: 100%; height: auto; display: block;
  filter: drop-shadow(0 0 26px rgba(0, 229, 255, 0.42)) drop-shadow(0 4px 18px rgba(0,0,0,0.85));
}
.wordmark {
  font-size: clamp(30px, 8vw, 62px);
  letter-spacing: 0.2em;
  font-weight: 700;
  text-shadow: var(--glow);
}
.subtitle {
  font-size: clamp(13px, 2.1vw, 18px);
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--warm);
  margin: 2px 0 6px;
  padding-left: 0.34em;
  text-shadow: 0 0 20px rgba(255, 200, 94, 0.7), 0 2px 6px rgba(0,0,0,0.9);
}
/* cinematic title: full-bleed canvas (src/systems/cover.js) with the UI on top */
#overlay[data-kind="menu"] { background: #000; padding: 0; backdrop-filter: none; }
body.og .menu-actions { display: none; }
#cover-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay[data-kind="menu"] .panel-menu {
  position: absolute; inset: 0; max-width: none;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  padding: max(7vh, 52px) 5vw max(8vh, 56px);
  pointer-events: none; text-align: left;
}
#overlay[data-kind="menu"] .logo-wrap {
  width: min(46vw, 760px);
  animation: slam 900ms cubic-bezier(.2,1.6,.4,1) 500ms both;
}
@keyframes slam { from { opacity: 0; transform: scale(1.8) rotate(-4deg); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
#overlay[data-kind="menu"] .tagline {
  font-family: 'Crack Man', ui-monospace, monospace;
  font-size: clamp(9px, 1.25vw, 17px); line-height: 1.6; letter-spacing: 0.06em;
  color: #fff; margin-top: 0.9em; padding-left: 0.4em;
  text-shadow: 3px 3px 0 #e2231a, -2px -2px 0 #22b8f0, 0 0 18px rgba(255,210,60,0.55);
}
#overlay[data-kind="menu"] .logo { filter: drop-shadow(0 10px 30px rgba(0,0,0,0.9)) drop-shadow(0 0 30px rgba(255,90,40,0.35)); }
.menu-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; pointer-events: auto;
  animation: rise 600ms cubic-bezier(.2,.8,.2,1) 1300ms both; }
#overlay[data-kind="menu"] .btn-primary {
  background: #ffcf3a; color: #1a0b00; border: 0; border-radius: 999px;
  padding: 18px 30px 17px; font-size: 14px; letter-spacing: 0.06em;
  box-shadow: 0 6px 0 #b7790b, 0 0 40px rgba(255,190,40,0.55);
  animation: pulse 1.15s ease-in-out infinite;
}
#overlay[data-kind="menu"] .btn-primary:hover, #overlay[data-kind="menu"] .btn-primary:focus-visible {
  background: #fff1a8; color: #1a0b00; box-shadow: 0 6px 0 #b7790b, 0 0 60px rgba(255,210,80,0.85);
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@media (orientation: portrait) {
  #overlay[data-kind="menu"] .panel-menu { align-items: center; text-align: center; padding: max(4vh, 44px) 16px max(5vh, 36px); }
  #overlay[data-kind="menu"] .logo-wrap { width: min(92vw, 520px); }
  #overlay[data-kind="menu"] .tagline { font-size: clamp(8px, 2.6vw, 12px); padding-left: 0; }
  .menu-actions { align-items: center; }
  #overlay[data-kind="menu"] .btn-primary { padding: 15px 20px 14px; font-size: 11px; }
  #overlay[data-kind="menu"] .hint { font-size: 8px; }
}

button { font-family: inherit; cursor: pointer; }

.btn-primary {
  background: rgba(0, 229, 255, 0.08);
  color: #ffffff;
  border: 2px solid var(--accent);
  padding: 17px 40px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
  box-shadow: 0 0 0 rgba(255,255,255,0);
}
.btn-primary:hover, .btn-primary:focus-visible {
  background: var(--accent); color: #04121a;
  box-shadow: 0 0 30px rgba(0,229,255,0.6);
  outline: none;
}
.btn-primary:active { transform: scale(0.97); }


.hint {
  font-size: 10px; line-height: 1.8; letter-spacing: 0.06em;
  color: #ffffff; text-transform: uppercase;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.6), 0 2px 5px rgba(0,0,0,0.95);
  opacity: 1;
}

/* ---------------------------------------------------------------- topbar */
#topbar {
  position: fixed; right: 16px; bottom: 14px;
  display: flex; align-items: center; gap: 8px; z-index: 50;
}
.chip {
  background: rgba(0,0,0,0.8);
  color: #efefef;
  padding: 8px 10px 7px;
  font-size: 8px;
  letter-spacing: 0.04em;
  border: 2px solid #2a3cff; border-radius: 4px;
  text-transform: uppercase;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
  backdrop-filter: blur(4px);
}
.chip:hover, .chip:focus-visible {
  color: var(--ink); border-color: rgba(255,255,255,0.5); outline: none;
  background: rgba(255,255,255,0.08);
}
.volume-chip { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
#volume { width: 76px; accent-color: #ffcf3a; cursor: pointer; }

/* ---------------------------------------------------------------- stamp */
#stamp {
  position: fixed; left: 18px; bottom: 15px;
  font-size: 7px; letter-spacing: 0.08em; line-height: 1.5; color: rgba(255,255,255,0.42);
  text-transform: uppercase; z-index: 35; pointer-events: none;
  display: flex; flex-direction: column; gap: 3px;
}
#stamp span { color: rgba(255,255,255,0.26); letter-spacing: 0.06em; }

/* ------------------------------------------------------------------ CRT */
#crt { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.13) 3px,
    rgba(0,0,0,0.13) 4px
  );
  opacity: 0.45;
  mix-blend-mode: multiply;
}
/* Scanlines must never sit on UI text (critic: dialogue was "laborious to read"). */
#hud, #overlay, #topbar, #stamp { isolation: isolate; }
.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 52%, rgba(0,0,0,0.55) 100%);
}
.flicker {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.02);
  animation: flick 5.5s steps(2, end) infinite;
  opacity: 0.5;
}
@keyframes flick {
  0%, 96%, 100% { opacity: 0.35; }
  97% { opacity: 0.6; }
  98% { opacity: 0.25; }
}

/* ------------------------------------------------- arcade screens (pause/clear/over) */
.pixel, .arcade, .btn-arcade, .hint, .chip, #stamp, .hud-label, .hud-value, .power-label,
#overlay[data-kind="menu"] .btn-primary {
  font-family: 'Crack Man', ui-monospace, monospace;
}
/* Pac-Man style double maze wall around the panel, a pellet trail scrolling on top */
.arcade {
  position: relative; max-width: 600px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 34px 30px 26px;
  background: radial-gradient(ellipse 90% 60% at 50% 0%, rgba(42, 60, 255, 0.22), transparent 70%), #04050d;
  border: 4px solid #2a3cff; border-radius: 20px;
  box-shadow: 0 0 0 5px #04050d, 0 0 0 9px #2a3cff, 0 0 46px rgba(42, 60, 255, 0.55),
              inset 0 0 34px rgba(42, 60, 255, 0.3);
}
.arcade::before {
  content: ''; position: absolute; left: 22px; right: 22px; top: 13px; height: 8px;
  background: radial-gradient(circle, #ffd7a8 2.5px, transparent 3px) 0 50% / 22px 8px repeat-x;
  animation: pellets 1.6s linear infinite; opacity: 0.85;
}
@keyframes pellets { to { background-position: -22px 50%; } }

.arc-title { margin: 4px 0 0; line-height: 0; animation: slam 700ms cubic-bezier(.2,1.6,.4,1) both; }
.arc-title img { display: block; max-width: 100%; max-height: 92px; width: auto; margin: 0 auto;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.9)); }
.arc-title span { display: none; }
.arc-title-text { line-height: 1.4; }
.arc-title-text span {
  display: inline; font-family: 'Crack Man', monospace; font-size: clamp(20px, 4.4vw, 34px);
  color: #ffcf3a; letter-spacing: 0.04em;
  text-shadow: 4px 4px 0 #e2231a, -3px -3px 0 #22b8f0;
}
.arc-scene { display: block; max-width: 92%; max-height: min(30vh, 230px); width: auto; margin: -4px auto 0;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.8)); animation: bob 2.4s ease-in-out infinite; }
.arc-scene-over { max-height: min(32vh, 250px); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-7px) rotate(1deg); } }

.btn-arcade {
  position: relative; margin-top: 6px;
  background: #ffcf3a; color: #160900; border: 0; border-radius: 6px;
  padding: 16px 26px 15px; font-size: 14px; letter-spacing: 0.08em;
  box-shadow: 4px 4px 0 #e2231a, -3px -3px 0 #22b8f0, 0 0 30px rgba(255, 190, 40, 0.45);
  transition: transform 90ms steps(2), background 120ms steps(2);
}
.btn-arcade::before { content: '\25B6'; position: absolute; left: -30px; top: 50%; transform: translateY(-50%);
  color: #ffcf3a; font-size: 14px; opacity: 0; }
.btn-arcade:hover, .btn-arcade:focus-visible { background: #fff1a8; outline: none; }
.btn-arcade:hover::before, .btn-arcade:focus-visible::before { opacity: 1; animation: blink 0.8s steps(1) infinite; }
.btn-arcade:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #e2231a, 0 0 30px rgba(255, 190, 40, 0.45); }

.arcade .hint { font-size: 10px; line-height: 1.7; letter-spacing: 0.06em; color: #ffffff; text-shadow: 2px 2px 0 #000; }
.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.score-table { width: min(100%, 380px); display: flex; flex-direction: column; gap: 10px; margin: 2px 0; }
.score-line { display: flex; align-items: baseline; font-family: 'Crack Man', monospace; font-size: 12px; }
.score-line span { color: #ff5a8a; text-shadow: 2px 2px 0 #000; }
.score-line i { flex: 1; margin: 0 10px; border-bottom: 4px dotted rgba(255, 215, 168, 0.75); transform: translateY(-3px); }
.score-line b { color: #ffcf3a; font-weight: 400; text-shadow: 2px 2px 0 #b7790b; }
.new-best { font-family: 'Crack Man', monospace; font-size: 11px; letter-spacing: 0.05em;
  animation: rainbow 0.9s steps(1) infinite; text-shadow: 2px 2px 0 #000; }
@keyframes rainbow { 0% { color: #ffcf3a; } 25% { color: #ff5a8a; } 50% { color: #22e0ff; } 75% { color: #7dff3a; } }

.donate-link {
  display: inline-block; margin-top: 6px; max-width: 34em; pointer-events: auto;
  font-family: 'Crack Man', monospace; font-size: 9px; line-height: 1.9; letter-spacing: 0.02em;
  color: #22e0ff; text-decoration: underline; text-underline-offset: 4px; text-shadow: 2px 2px 0 #000;
}
.donate-link:hover, .donate-link:focus-visible { color: #ffcf3a; outline: none; }

/* the level-clear card is a toast: the run keeps its input */
#overlay[data-kind="clear"] { background: rgba(0, 0, 0, 0.55); pointer-events: none; backdrop-filter: none; }

@media (max-width: 720px) {
  .arcade { padding: 30px 16px 20px; gap: 11px; border-radius: 14px; }
  .arc-title img { max-height: 58px; }
  .arc-scene { max-height: 22vh; }
  .btn-arcade { font-size: 12px; padding: 14px 20px 13px; }
  .score-line { font-size: 9px; }
  .arcade .hint { font-size: 8px; }
}
@media (max-height: 520px) {
  .arc-scene { display: none; }
  .arcade { gap: 8px; padding-top: 28px; }
  .arc-title img { max-height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .arcade::before, .arc-title, .arc-scene, .blink, .new-best,
  .btn-arcade:hover::before, .btn-arcade:focus-visible::before { animation: none; }
  .flicker { animation: none; opacity: 0.3; }
  .panel, #overlay.show, .menu-actions, #overlay[data-kind="menu"] .logo-wrap,
  #overlay[data-kind="menu"] .btn-primary { animation: none; }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 720px) {
  #hud { padding: 10px 12px 0; font-size: 10px; gap: 0.5rem; }
  .hud-left, .hud-right { gap: 14px; }
  .hud-value { font-size: 10px; }
  .hud-label { font-size: 7px; }
  .hud-mid { flex: 0 1 auto; padding-top: 4px; }
  .power-meter { width: 74px; gap: 5px; }
  .power-label { font-size: 6px; letter-spacing: 0; }
  .life-icon { width: 15px; height: 15px; }
  #topbar { right: 10px; bottom: 10px; }
  #volume { width: 54px; }
  #stamp { display: none; }
}

@media (max-height: 520px) {
  .subtitle { margin-bottom: 2px; }
}

/* Display the title and screen headings in the same Pac-Man-inspired face. */
#overlay[data-kind="menu"] .logo { display: none; }
#overlay[data-kind="menu"] .wordmark {
  display: block !important; color: #ffcf3a;
  font-size: clamp(46px, 7.2vw, 108px); line-height: 1;
  letter-spacing: .025em; -webkit-text-stroke: 1px #130d0a;
  text-shadow: 3px 3px 0 #e2231a, -2px -2px 0 #22b8f0, 0 6px 16px #000;
}
.arc-title { line-height: 1.15; }
.arc-title img { display: none; }
.arc-title span { display: inline; font-family: 'Crack Man', monospace;
  font-size: clamp(32px, 5vw, 58px); color: #ffcf3a; letter-spacing: .04em;
  text-shadow: 3px 3px 0 #e2231a, -2px -2px 0 #22b8f0; }
/* Crack Man's cap height is compact; enlarge small labels for legibility. */
#overlay[data-kind="menu"] .tagline { font-size: clamp(16px, 1.8vw, 24px); letter-spacing: .02em; }
#overlay[data-kind="menu"] .btn-primary, .btn-arcade { font-size: 18px; }
.hud-label, .power-label { font-size: 13px; }
.hud-value { font-size: 19px; }
.hint, .arcade .hint, .donate-link { font-size: 14px; }
.score-line, .new-best { font-size: 16px; }
@media (max-width: 720px) {
  #overlay[data-kind="menu"] .tagline { font-size: clamp(14px, 3.4vw, 18px); }
  #overlay[data-kind="menu"] .btn-primary, .btn-arcade { font-size: 16px; }
  #overlay[data-kind="menu"] .hint, .hint, .arcade .hint, .donate-link { font-size: 12px; }
  .score-line, .new-best { font-size: 13px; }
}
