:root {
  color-scheme: dark;
  --bg: #060606;
  --dot: rgba(255, 255, 255, 0.05);
  --fg: #d8d8d8;
  --muted: #5c5c5c;
  --amber: #ffb000;
  --notch: 8px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: "VT323", monospace;
  font-size: 20px;
  padding: 2rem 1rem;
  position: relative;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}

.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 4px 4px;
  z-index: 0;
}

/* ---------- cabinet shell ---------- */

.arcade {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.marquee {
  background: linear-gradient(180deg, #1c1c1c, #0a0a0a);
  border: 3px solid #333;
  border-bottom: none;
  padding: 0.85rem 1rem;
  text-align: center;
  clip-path: polygon(0 14px, 14px 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
  touch-action: none;
}

.marquee-text {
  font-family: "Press Start 2P", monospace;
  font-size: 1.4rem;
  letter-spacing: 2px;
  color: var(--amber);
  text-shadow:
    0 0 2px var(--amber),
    0 0 8px var(--amber),
    0 0 20px rgba(255, 176, 0, 0.5);
  animation: flicker 4s infinite;
}

.cabinet-body {
  background:
    repeating-linear-gradient(115deg, rgba(53, 224, 255, 0.05) 0 2px, transparent 2px 26px),
    linear-gradient(180deg, #2c2c30, #17171a 55%, #0c0c0d);
  border: 3px solid #050505;
  border-top: none;
  padding: 1.1rem 1.1rem 1.4rem;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.6),
    0 24px 40px -12px rgba(0, 0, 0, 0.85);
}

/* ---------- screen ---------- */

.screen-bezel {
  background: #050505;
  border: 9px solid #1c1c1c;
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 0 30px rgba(0, 0, 0, 0.9),
    0 0 0 2px #333;
  padding: 8px;
  margin-bottom: 1.25rem;
}

.screen {
  position: relative;
  height: 400px;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.85);
}

.screen.switching {
  animation: crt-switch 0.25s ease;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
  pointer-events: none;
  z-index: 5;
  mix-blend-mode: multiply;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  box-shadow: inset 0 0 60px 10px rgba(0, 0, 0, 0.8);
}

.screen-panel {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  padding: 1rem;
}

.screen-panel.active {
  display: block;
}

#arcade-screen.active {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
}

/* ---------- site-content (reused from previous design) ---------- */

.tagline {
  margin: 0 0 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 1px;
}

.cursor {
  color: var(--amber);
  animation: blink 1s steps(1) infinite;
}

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tile {
  --glow: color-mix(in srgb, var(--c) 55%, transparent);
  background: #0a0a0a;
  border: 2px solid var(--c);
  clip-path: polygon(
    0 var(--notch), var(--notch) var(--notch), var(--notch) 0,
    calc(100% - var(--notch)) 0, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0 calc(100% - var(--notch))
  );
  box-shadow: 0 0 10px -4px var(--glow);
  transition: box-shadow 0.15s ease;
}

.tile[open] {
  box-shadow: 0 0 24px 2px var(--glow);
}

.tile summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  color: var(--c);
  list-style: none;
  cursor: pointer;
  text-shadow: 0 0 6px var(--glow);
  transition: background 0.1s steps(2), color 0.1s steps(2);
}

.tile summary::-webkit-details-marker {
  display: none;
}

.tile summary:hover,
.tile summary:focus-visible {
  background: var(--c);
  color: #060606;
  text-shadow: none;
}

.tile summary:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -4px;
}

.tile[open] summary {
  background: var(--c);
  color: #060606;
  text-shadow: none;
}

.info {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.name {
  font-size: 1.05rem;
  letter-spacing: 1px;
}

.url {
  font-size: 0.9rem;
  opacity: 0.8;
  white-space: nowrap;
}

.indicator {
  font-family: monospace;
  font-size: 1rem;
  flex-shrink: 0;
}

.indicator::before {
  content: "[+]";
}

.tile[open] .indicator::before {
  content: "[-]";
}

.panel {
  padding: 0 1rem 1rem;
  border-top: 2px dashed var(--c);
}

.panel p {
  margin: 0.85rem 0 0;
  color: var(--fg);
  font-size: 0.92rem;
  line-height: 1.4;
}

.panel .visit {
  display: inline-block;
  margin-top: 0.65rem;
  color: var(--c);
  text-decoration: none;
  border-bottom: 1px solid var(--c);
  font-size: 0.92rem;
}

.panel .visit:hover,
.panel .visit:focus-visible {
  color: #fff;
  border-color: #fff;
  text-shadow: 0 0 6px var(--c);
}

/* ---------- arcade screen ---------- */

.arcade-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--amber);
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  padding: 0.4rem 0.4rem 0.6rem;
  text-shadow: 0 0 4px var(--amber);
}

#exit-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  background: none;
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  touch-action: manipulation;
}

#exit-btn:hover,
#exit-btn:focus-visible {
  background: var(--amber);
  color: #000;
}

#pacman-canvas {
  display: block;
  margin: 0 auto;
  width: auto;
  height: 100%;
  max-height: 320px;
  image-rendering: pixelated;
  background: #000;
  touch-action: none;
}

.arcade-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.88);
  color: var(--amber);
  text-align: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 7;
}

.arcade-message.show {
  opacity: 1;
  pointer-events: auto;
}

.msg-title {
  font-family: "Press Start 2P", monospace;
  font-size: 1rem;
  text-shadow: 0 0 8px var(--amber);
}

.msg-sub {
  font-family: "VT323", monospace;
  font-size: 1.2rem;
  color: var(--fg);
}

.arcade-message button {
  font-family: "VT323", monospace;
  font-size: 1.1rem;
  background: none;
  border: 2px solid var(--amber);
  color: var(--amber);
  padding: 0.4rem 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

.arcade-message button:hover,
.arcade-message button:focus-visible {
  background: var(--amber);
  color: #000;
}

.initials-entry {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.letter-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem;
  border: 1px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.letter-slot.active {
  border-color: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.letter-slot .letter {
  font-family: "Press Start 2P", monospace;
  font-size: 1.2rem;
  color: var(--amber);
  text-shadow: 0 0 6px var(--amber);
  width: 1.3em;
  text-align: center;
}

.letter-slot button {
  background: none;
  border: 1px solid var(--amber);
  color: var(--amber);
  cursor: pointer;
  touch-action: manipulation;
  width: 1.6rem;
  height: 1.4rem;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0;
}

.letter-slot button:hover,
.letter-slot button:focus-visible {
  background: var(--amber);
  color: #000;
}

.leaderboard {
  font-family: "VT323", monospace;
  font-size: 1.1rem;
  color: var(--fg);
  width: 100%;
  max-width: 220px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0.5rem;
}

.score-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.05);
}

.score-row span:first-child {
  color: var(--muted);
  width: 1.6em;
}

/* ---------- control panel ---------- */

.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.25rem 0.5rem 1.1rem;
  touch-action: none;
}

.joystick {
  position: relative;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
}

.joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a3a3a, #0e0e0e 70%);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.08);
}

.joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff5555, #900 70%);
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
  transition: transform 0.08s ease;
}

.joystick-stick.up { transform: translate(-50%, -75%); }
.joystick-stick.down { transform: translate(-50%, -25%); }
.joystick-stick.left { transform: translate(-75%, -50%); }
.joystick-stick.right { transform: translate(-25%, -50%); }

.joystick-zone {
  position: absolute;
  width: 34%;
  height: 34%;
  z-index: 2;
  touch-action: none;
}

.joystick-zone.up { top: 0; left: 33%; }
.joystick-zone.down { bottom: 0; left: 33%; }
.joystick-zone.left { left: 0; top: 33%; }
.joystick-zone.right { right: 0; top: 33%; }

.buttons {
  display: flex;
  gap: 0.75rem;
}

.arcade-btn {
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5), inset 0 2px 2px rgba(255, 255, 255, 0.3);
}

.arcade-btn.red { background: radial-gradient(circle at 35% 30%, #ff6b6b, #a00); }
.arcade-btn.yellow { background: radial-gradient(circle at 35% 30%, #ffe066, #a67c00); }

/* ---------- coin door / secret button ---------- */

.cabinet-lower {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
  border-top: 2px solid #050505;
  touch-action: none;
}

.coin-door {
  width: 75%;
  background: linear-gradient(180deg, #38383a, #19191a);
  border: 2px solid #050505;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  touch-action: none;
}

.coin-slot {
  width: 26px;
  height: 8px;
  background: #000;
  border-radius: 2px;
  box-shadow: inset 0 0 4px #000, 0 1px 0 rgba(255, 255, 255, 0.08);
}

.rivet {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2a2a2a;
  border: 1px solid #111;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
  transition: box-shadow 0.2s ease;
  touch-action: manipulation;
}

.rivet::after {
  content: "";
  position: absolute;
  inset: -17px;
}

.rivet:hover,
.rivet:focus-visible {
  box-shadow: 0 0 6px 2px var(--amber);
  outline: none;
}

/* ---------- footer ---------- */

footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 1px;
}

/* ---------- animations ---------- */

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes flicker {
  0%, 3%, 6%, 100% { opacity: 1; }
  4% { opacity: 0.4; }
  5% { opacity: 0.9; }
}

@keyframes crt-switch {
  0% { filter: brightness(3) contrast(0); opacity: 0.2; }
  20% { filter: brightness(0.3); opacity: 1; }
  100% { filter: brightness(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor, .marquee-text, .screen.switching {
    animation: none;
  }
}

@media (max-width: 400px) {
  .screen { height: 340px; }
  #pacman-canvas { max-height: 260px; }
}

@media (max-height: 700px) {
  body { padding: 1rem 1rem; }
  .marquee { padding: 0.55rem 1rem; }
  .marquee-text { font-size: 1.1rem; }
  .screen { height: 280px; }
  #pacman-canvas { max-height: 220px; }
  .control-panel { padding: 0.15rem 0.5rem 0.75rem; }
  .joystick { width: 56px; height: 56px; }
}
