/* =========================================================
   ARCADE – gemeinsames Retro-Theme fuer Startseite und alle Spiele.
   Spiele binden diese Datei ein und ergaenzen nur Spielspezifisches
   in ihrer eigenen styles.css. Farben pro Spiel: --accent ueberschreiben.
   ========================================================= */

@font-face {
  font-family: "Press Start 2P";
  src: url("/public/fonts/PressStart2P.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "VT323";
  src: url("/public/fonts/VT323.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #07031a;
  --panel: #130b33;
  --panel-2: #1e1250;
  --ink: #f6f1ff;
  --muted: #a99fd6;
  --yellow: #ffe14a;
  --cyan: #2ff3ff;
  --pink: #ff3fa4;
  --green: #3dff7a;
  --red: #ff4b4b;
  --orange: #ff9a2f;
  --purple: #9d5cff;
  --black: #000;
  --accent: var(--cyan);
  --px: 4px; /* Pixelgroesse fuer Rahmen */
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-text: "VT323", "Courier New", monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-text);
  font-size: 22px;
  line-height: 1.15;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Hintergrund: Sterne + Synthwave-Gitter + CRT ---------- */
.bg-stars, .bg-grid, .crt { position: fixed; pointer-events: none; }

.bg-stars {
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 34% 42%, var(--cyan) 50%, transparent 51%),
    radial-gradient(1px 1px at 62% 30%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 52%, var(--pink) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 66%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 48% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 6% 48%, var(--yellow) 50%, transparent 51%),
    linear-gradient(180deg, #07031a 0%, #150a3d 55%, #3a0f5c 100%);
}

.bg-grid {
  left: -50%;
  right: -50%;
  bottom: 0;
  height: 38vh;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 63, 164, 0.55) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 63, 164, 0.55) 2px, transparent 2px);
  background-size: 48px 48px;
  transform: perspective(260px) rotateX(62deg);
  transform-origin: bottom center;
  animation: grid-move 1.6s linear infinite;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 60%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 60%);
  opacity: 0.55;
}

.crt {
  inset: 0;
  z-index: 50;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0, rgba(0, 0, 0, 0.22) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

@keyframes grid-move { to { background-position: 0 48px; } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes pulse-glow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }

.blink { animation: blink 1s steps(1) infinite; }
.pop { animation: pop 0.35s steps(6) both; }
.shake { animation: shake 0.4s steps(8); }

/* ---------- Layout ---------- */
.cabinet {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 14px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.cabinet.wide { max-width: 1100px; }

.hidden { display: none !important; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.row > * { flex: 1 1 140px; }
.mt { margin-top: 14px; }
.muted { color: var(--muted); }

h1, h2, h3, .pixel { font-family: var(--font-pixel); font-weight: 400; line-height: 1.5; }
h2 { font-size: 13px; color: var(--yellow); text-transform: uppercase; }
h3 { font-size: 11px; color: var(--accent); text-transform: uppercase; }
p { color: var(--ink); }
strong { color: var(--yellow); font-weight: 400; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.topbar a, .icon-btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel-2);
  border: 0;
  padding: 10px;
  min-height: 40px;
  min-width: 40px;
  cursor: pointer;
  box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--ink), 0 var(--px) 0 0 var(--ink), calc(-1 * var(--px)) 0 0 0 var(--ink), var(--px) 0 0 0 var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar a:active, .icon-btn:active { background: var(--accent); color: var(--black); }
.topbar .tools { display: flex; gap: 14px; }

.title { text-align: center; padding: 6px 0 2px; }
.title h1 {
  font-size: clamp(22px, 7vw, 38px);
  color: var(--yellow);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 rgba(0, 0, 0, 0.6);
  letter-spacing: 2px;
}
.title p {
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.7;
  color: var(--accent);
  margin-top: 14px;
  text-transform: uppercase;
}

/* ---------- Pixel-Panel ---------- */
.panel {
  position: relative;
  background: var(--panel);
  padding: 18px 16px;
  margin: var(--px);
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--accent), 0 var(--px) 0 0 var(--accent),
    calc(-1 * var(--px)) 0 0 0 var(--accent), var(--px) 0 0 0 var(--accent),
    8px 12px 0 0 rgba(0, 0, 0, 0.55);
}
.panel > h2:first-child, .panel > h3:first-child { margin-bottom: 14px; }
.panel.yellow { --accent: var(--yellow); }
.panel.pink { --accent: var(--pink); }
.panel.green { --accent: var(--green); }
.panel.red { --accent: var(--red); }
.panel.inset { background: var(--black); box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--panel-2), 0 var(--px) 0 0 var(--panel-2), calc(-1 * var(--px)) 0 0 0 var(--panel-2), var(--px) 0 0 0 var(--panel-2); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--black);
  background: var(--ink);
  border: 0;
  padding: 14px 12px;
  min-height: 52px;
  margin: var(--px) var(--px) calc(var(--px) * 2.5);
  cursor: pointer;
  position: relative;
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--black), calc(-1 * var(--px)) 0 0 0 var(--black), var(--px) 0 0 0 var(--black),
    0 var(--px) 0 0 var(--black),
    inset 0 calc(-1 * var(--px)) 0 0 rgba(0, 0, 0, 0.3),
    0 calc(var(--px) * 2.5) 0 0 rgba(0, 0, 0, 0.6);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(var(--px)); box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--black), calc(-1 * var(--px)) 0 0 0 var(--black), var(--px) 0 0 0 var(--black), 0 var(--px) 0 0 var(--black), inset 0 var(--px) 0 0 rgba(0, 0, 0, 0.3); }
.btn:disabled { background: #4a4270; color: #1a1436; cursor: not-allowed; }
.btn.primary { background: var(--yellow); }
.btn.go { background: var(--green); }
.btn.danger { background: var(--red); color: #fff; }
.btn.pink { background: var(--pink); color: #fff; }
.btn.cyan { background: var(--cyan); }
.btn.ghost { background: var(--panel-2); color: var(--ink); }
.btn.big { font-size: 13px; min-height: 64px; }
.btn.block { display: block; width: calc(100% - 2 * var(--px)); }
.btn.small { font-size: 9px; min-height: 36px; padding: 8px 10px; }
.btn.attention:not(:disabled) { animation: pulse-glow 1s steps(2) infinite; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 8px; font-family: var(--font-pixel); font-size: 9px; color: var(--muted); text-transform: uppercase; }
.input {
  font-family: var(--font-text);
  font-size: 26px;
  color: var(--green);
  background: var(--black);
  border: var(--px) solid var(--accent);
  border-radius: 0;
  padding: 8px 12px;
  width: 100%;
  min-height: 52px;
  outline: none;
  caret-color: var(--green);
}
.input:focus { border-color: var(--yellow); }
.input::placeholder { color: #4f4a78; }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stepper .label { font-size: 20px; color: var(--ink); flex: 1; }
.stepper .ctrl { display: flex; align-items: center; gap: 6px; }
.stepper .value { font-family: var(--font-pixel); font-size: 13px; color: var(--yellow); min-width: 44px; text-align: center; }
.stepper .btn { min-height: 40px; min-width: 40px; padding: 6px; margin-bottom: var(--px); font-size: 12px; }

/* ---------- Spielerliste / Highscore ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel-2);
  padding: 8px 12px;
  min-height: 44px;
  border-left: calc(var(--px) * 2) solid var(--c, var(--accent));
}
.list-item .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list-item .tag { font-family: var(--font-pixel); font-size: 9px; color: var(--c, var(--accent)); flex: none; }
.list-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 24px; }
.list-item .state { font-family: var(--font-pixel); font-size: 9px; color: var(--muted); flex: none; text-align: right; }
.list-item .state.on { color: var(--green); }
.list-item .state.off { color: var(--red); }
.list-item .score { font-family: var(--font-pixel); font-size: 12px; color: var(--yellow); flex: none; }
.list-item.me { background: #2b1c6e; }
.list-item.me .name::after { content: " ◄"; color: var(--yellow); }
.list-item.empty { border-left-color: #3a3166; color: #5a5190; justify-content: center; font-family: var(--font-pixel); font-size: 9px; }
.list-item.first { background: #3d3410; }
.list-item.dim { opacity: 0.45; }

/* Spielerfarben 1UP..8UP */
.c1 { --c: var(--yellow); } .c2 { --c: var(--cyan); } .c3 { --c: var(--pink); } .c4 { --c: var(--green); }
.c5 { --c: var(--orange); } .c6 { --c: var(--purple); } .c7 { --c: var(--red); } .c8 { --c: var(--ink); }

/* ---------- Statuszeilen ---------- */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
}
.hud .timer { color: var(--yellow); }
.hud .timer.low { color: var(--red); animation: blink 0.5s steps(1) infinite; }

.banner {
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.7;
  text-align: center;
  padding: 12px;
  background: var(--black);
  color: var(--yellow);
  border: var(--px) dashed var(--yellow);
  text-transform: uppercase;
}
.banner.warn { color: var(--red); border-color: var(--red); }
.banner .btn { margin-top: 10px; }

/* Kleine Spieler-Marken (Status, Punkte) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { font-family: var(--font-pixel); font-size: 9px; line-height: 1.4; padding: 6px 8px; background: var(--panel-2); color: var(--ink); border-left: 6px solid var(--c, var(--accent)); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.me { background: #2b1c6e; }
.chip.dim { opacity: 0.45; }
.chip b { color: var(--yellow); font-weight: 400; }

.hint { font-size: 20px; color: var(--muted); text-align: center; }
.big-text { font-family: var(--font-pixel); font-size: clamp(16px, 5.5vw, 26px); line-height: 1.5; color: var(--yellow); text-align: center; text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.7); }

/* ---------- Overlay / Modal / Toast ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 1, 12, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; }
.modal h2 { margin-bottom: 14px; }
.rules { font-size: 22px; line-height: 1.25; }
.rules p, .rules ul, .rules ol { margin-bottom: 12px; }
.rules ul, .rules ol { padding-left: 26px; }
.rules li { margin-bottom: 6px; }
.rules h3 { margin: 16px 0 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 70;
  width: max-content;
  max-width: calc(100vw - 32px);
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
  background: var(--red);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 0 0 var(--px) var(--black), 6px 8px 0 0 rgba(0, 0, 0, 0.6);
}

@media (max-width: 420px) {
  body { font-size: 20px; }
  .cabinet { padding: 10px 10px 50px; gap: 14px; }
  .panel { padding: 14px 12px; }
  .btn { font-size: 10px; }
  .btn.big { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-grid, .blink, .btn.attention:not(:disabled), .hud .timer.low { animation: none; }
}
