/* ==========================================================================
   PAC-MAN — Neon Arcade
   ========================================================================== */
:root {
  --bg: #04060f;
  --bg-2: #070b1c;
  --panel: rgba(12, 18, 42, 0.72);
  --panel-line: rgba(94, 132, 255, 0.22);
  --ink: #e8eeff;
  --ink-dim: #97a3ce;
  --neon: #2d5bff;
  --neon-soft: #7ea6ff;
  --gold: #ffe600;
  --danger: #ff2d2d;
  --cyan: #7ef9ff;
  --radius: 16px;
  --font: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --------------------------- background layers --------------------------- */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(45, 91, 255, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 91, 255, 0.075) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 20%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 20%, #000 0%, transparent 78%);
}
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(620px 400px at 50% 0%, rgba(45, 91, 255, 0.20), transparent 70%),
    radial-gradient(500px 340px at 12% 62%, rgba(255, 230, 0, 0.06), transparent 70%),
    radial-gradient(500px 340px at 88% 78%, rgba(126, 249, 255, 0.06), transparent 70%);
}

/* -------------------------------- header -------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(4, 6, 15, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(94, 132, 255, 0.16);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.22em;
  font-weight: 700;
}
.brand-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px rgba(255, 230, 0, 0.8);
}
.site-nav { display: flex; gap: clamp(12px, 2.5vw, 28px); }
.site-nav a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.18s ease;
}
.site-nav a:hover { color: var(--neon-soft); }

/* --------------------------------- hero --------------------------------- */
main { position: relative; z-index: 1; }

.hero {
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(44px, 8vw, 92px) 20px clamp(28px, 5vw, 52px);
  text-align: center;
}
.eyebrow {
  margin: 0 0 18px;
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.title {
  margin: 0;
  font-size: clamp(44px, 12vw, 104px);
  line-height: 0.92;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow:
    0 0 12px rgba(255, 230, 0, 0.55),
    0 0 44px rgba(255, 180, 0, 0.35),
    0 4px 0 rgba(120, 80, 0, 0.35);
}
.title-accent { color: #fff6a8; }
.tagline {
  max-width: 560px;
  margin: 22px auto 0;
  color: var(--ink-dim);
  font-size: 13.5px;
  line-height: 1.75;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 30px;
}

/* -------------------------------- buttons -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: rgba(20, 28, 60, 0.6);
  color: var(--ink);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(126, 166, 255, 0.55); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(180deg, #ffe600, #f2ac00);
  color: #1a1400;
  border-color: rgba(255, 230, 0, 0.6);
  box-shadow: 0 0 24px rgba(255, 200, 0, 0.28);
}
.btn-primary:hover { box-shadow: 0 0 34px rgba(255, 200, 0, 0.42); }
.btn-ghost { background: transparent; }
.btn-small { padding: 8px 14px; font-size: 10.5px; }

/* -------------------------------- arcade -------------------------------- */
.arcade {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(240px, 320px);
  gap: clamp(18px, 3vw, 34px);
  justify-content: center;
  align-items: start;
  padding: 0 20px clamp(40px, 6vw, 72px);
}

.machine {
  position: relative;
  padding: 14px;
  border-radius: calc(var(--radius) + 8px);
  background: linear-gradient(180deg, rgba(16, 24, 56, 0.9), rgba(6, 9, 24, 0.95));
  border: 1px solid rgba(94, 132, 255, 0.3);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5) inset,
    0 26px 70px rgba(0, 0, 0, 0.65),
    0 0 60px rgba(45, 91, 255, 0.14);
}

.machine-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 12px;
}
.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(52px, auto));
  gap: clamp(10px, 2.4vw, 26px);
}
.hud-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hud-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.hud-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 230, 0, 0.35);
  font-variant-numeric: tabular-nums;
}
.hud-value.lives { display: flex; gap: 4px; align-items: center; height: 19px; }
.life {
  display: block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, var(--gold) 0deg 300deg, transparent 300deg 360deg);
  box-shadow: 0 0 8px rgba(255, 230, 0, 0.55);
}
.state-chip {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  border: 1px solid rgba(126, 249, 255, 0.3);
  background: rgba(126, 249, 255, 0.07);
  white-space: nowrap;
}
.state-chip[data-state="playing"] { color: #7dffb0; border-color: rgba(125, 255, 176, 0.35); background: rgba(125, 255, 176, 0.08); }
.state-chip[data-state="paused"] { color: var(--gold); border-color: rgba(255, 230, 0, 0.35); background: rgba(255, 230, 0, 0.08); }
.state-chip[data-state="gameover"] { color: var(--danger); border-color: rgba(255, 45, 45, 0.4); background: rgba(255, 45, 45, 0.1); }

.stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #01020a;
  border: 1px solid rgba(94, 132, 255, 0.22);
  box-shadow: inset 0 0 60px rgba(45, 91, 255, 0.12);
  touch-action: none;
  max-width: 100%;
}
#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 456 / 504;
}

.machine-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 4px 4px;
}
.foot-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------- dpad --------------------------------- */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(2, 40px);
  gap: 5px;
}
.dpad-btn {
  border-radius: 10px;
  border: 1px solid rgba(94, 132, 255, 0.32);
  background: rgba(20, 28, 60, 0.75);
  color: var(--neon-soft);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.14s ease, color 0.14s ease;
}
.dpad-btn:active { background: rgba(45, 91, 255, 0.55); color: #fff; }
.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 2; }
.dpad-btn.right { grid-column: 3; grid-row: 2; }

/* -------------------------------- panel --------------------------------- */
.panel {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.panel-title {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
}
.panel-title + .panel-title,
.key-list + .panel-title { margin-top: 26px; }
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.key-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-dim);
  flex-wrap: wrap;
}
.key-list li span { margin-left: auto; color: var(--ink); }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 3px 6px;
  text-align: center;
  border-radius: 6px;
  border: 1px solid rgba(94, 132, 255, 0.35);
  border-bottom-width: 2px;
  background: rgba(24, 32, 68, 0.8);
  color: var(--ink);
  font-size: 10px;
  font-family: var(--font);
}
.touch-only { margin-left: 0 !important; font-size: 11px; }

.score-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.score-table td { padding: 7px 0; border-bottom: 1px dashed rgba(94, 132, 255, 0.16); color: var(--ink-dim); }
.score-table td:last-child { text-align: right; color: var(--gold); font-variant-numeric: tabular-nums; }
.score-table tr:last-child td { border-bottom: none; }
.swatch {
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 50%;
}
.swatch.dot { background: #ffd9a0; }
.swatch.power { width: 13px; height: 13px; background: #ffe9c4; box-shadow: 0 0 10px rgba(255, 233, 196, 0.8); }
.swatch.ghost { background: var(--c, #fff); box-shadow: 0 0 10px var(--c, #fff); }
.swatch.fruit { background: #ff2d55; box-shadow: 0 0 10px rgba(255, 45, 85, 0.8); }
.panel-note { margin: 14px 0 0; font-size: 11px; color: var(--ink-dim); }

/* --------------------------------- how ---------------------------------- */
.how { padding: 0 20px clamp(50px, 8vw, 90px); max-width: 1080px; margin: 0 auto; }
.how h2 {
  font-size: clamp(20px, 3.4vw, 28px);
  letter-spacing: 0.08em;
  margin: 0 0 26px;
  text-align: center;
  color: var(--ink);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.card {
  padding: 22px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(16, 24, 56, 0.6), rgba(6, 9, 24, 0.6));
  border: 1px solid var(--panel-line);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.card:hover { transform: translateY(-3px); border-color: rgba(126, 166, 255, 0.45); }
.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.card p { margin: 0; font-size: 12px; line-height: 1.8; color: var(--ink-dim); }
.g-red { color: #ff6b6b; }
.g-pink { color: #ffb8ff; }
.g-cyan { color: #64e8ff; }
.g-orange { color: #ffb851; }

/* -------------------------------- footer -------------------------------- */
.site-footer {
  position: relative;
  z-index: 1;
  padding: 30px 20px 44px;
  text-align: center;
  border-top: 1px solid rgba(94, 132, 255, 0.14);
  color: var(--ink-dim);
  font-size: 11px;
}
.site-footer p { margin: 0 0 8px; }
.site-footer .tiny { font-size: 10px; color: rgba(151, 163, 206, 0.65); max-width: 620px; margin: 0 auto; line-height: 1.7; }

/* ------------------------------ responsive ------------------------------ */
@media (max-width: 860px) {
  .arcade { grid-template-columns: minmax(0, 1fr); }
  .machine { max-width: 520px; margin: 0 auto; width: 100%; }
  .panel { max-width: 520px; margin: 0 auto; width: 100%; }
}
@media (max-width: 560px) {
  .site-nav { display: none; }
  .machine { padding: 10px; }
  .machine-top { flex-direction: column; align-items: stretch; gap: 10px; }
  .hud { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .hud-value { font-size: 14px; }
  .state-chip { align-self: flex-start; }
  .machine-foot { justify-content: center; }
  .foot-buttons { justify-content: center; width: 100%; }
  .dpad { margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card:hover, .btn:hover { transform: none; }
}
