/* Press Start 2P – SIL Open Font License 1.1, siehe fonts/OFL.txt */
@font-face {
  font-family: 'Press Start 2P';
  src: url('../fonts/PressStart2P-Regular.ttf') format('truetype');
  font-display: block;
}

:root {
  --bg: #0b0a1e;
  --bg-dot: #1d1b44;
  --panel: #1a1944;
  --panel-hi: #8a8ad0;
  --panel-lo: #2c2a64;
  --ink: #f4f0ff;
  --muted: #9c98d0;
  --accent: #ffe14a;
  --ok: #5cff7a;
  --hot: #ff5a6e;
  --cyan: #5cd4ff;
  --px: 3px;
  --font: 'Press Start 2P', ui-monospace, 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--bg-dot) 1px, transparent 1.5px),
    linear-gradient(180deg, #0b0a1e 0%, #15123a 60%, #241245 100%);
  background-size: 8px 8px, 100% 100%;
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
}

/* ---------- HUD ---------- */

.hud, .controls {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud {
  background: var(--panel);
  padding: 8px 10px;
  box-shadow:
    inset 2px 2px 0 var(--panel-hi),
    inset -2px -2px 0 var(--panel-lo),
    0 0 0 2px #05040c;
}

.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat.right { align-items: flex-end; }
.stat.lvl { align-items: center; }
.label { font-size: 8px; color: var(--muted); letter-spacing: 1px; }
.value { font-size: 14px; color: var(--accent); text-shadow: 2px 2px 0 #7a3a10; }
.stat.lvl .value { color: var(--cyan); text-shadow: 2px 2px 0 #1a3888; }

.bar {
  width: 64px;
  height: 6px;
  background: #05040c;
  box-shadow: 0 0 0 1px var(--panel-lo);
}
.bar > div {
  height: 100%;
  width: 0;
  background: var(--cyan);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: width .25s steps(6);
}

/* ---------- Bühne ---------- */

#stage {
  position: relative;
  flex: none;
  box-shadow: 0 0 0 2px #05040c, 0 8px 0 rgba(0, 0, 0, .35);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: pointer;
}

#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: calc(var(--px) * 3.4);
  white-space: nowrap;
  color: #fff;
  text-shadow: 2px 2px 0 #05040c, -1px -1px 0 #05040c;
  animation: rise 1.2s steps(12) forwards;
}
.popup.pts { color: var(--accent); }
.popup.label { color: var(--ok); font-size: calc(var(--px) * 3); }
.popup.level {
  color: var(--cyan);
  font-size: calc(var(--px) * 4.5);
  animation: blink-rise 1.3s steps(13) forwards;
}

@keyframes rise {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(.6); }
  15%  { transform: translate(-50%, -60%) scale(1.1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -260%) scale(1); }
}
@keyframes blink-rise {
  0%, 20%, 40% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  10%, 30%     { opacity: .2; }
  100%         { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  text-align: center;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .25) 0 2px, transparent 2px 4px),
    rgba(8, 6, 24, .86);
}
.overlay[hidden] { display: none; }

.logo {
  margin: 0 0 4px;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-size: clamp(22px, calc(var(--px) * 10), 44px);
  font-weight: normal;
}
.logo span:first-child { color: var(--accent); text-shadow: 3px 3px 0 #b8401c, 6px 6px 0 #05040c; }
.logo span:last-child  {
  color: #ff8a4a;
  text-shadow: 3px 3px 0 #a0202c, 6px 6px 0 #05040c;
  animation: logo-heat 1.2s steps(3) infinite;
}
@keyframes logo-heat { 50% { color: #ffb05a; } }

h2 {
  margin: 0;
  font-size: 22px;
  font-weight: normal;
  color: var(--accent);
  text-shadow: 3px 3px 0 #05040c;
}
h2.over { color: var(--hot); line-height: 1.4; animation: flicker 1s steps(2) infinite; }

@keyframes flicker { 50% { opacity: .75; } }

.rules {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 8px;
  line-height: 2.1;
  color: var(--muted);
}
.rules b { color: var(--ink); font-weight: normal; }
.star, .j { color: var(--accent); font-family: system-ui, sans-serif; }

.big { margin: 0; font-size: 22px; color: var(--accent); text-shadow: 3px 3px 0 #7a3a10; }
.small { margin: 0; font-size: 8px; line-height: 1.8; color: var(--muted); }
.newhi { margin: 0; font-size: 10px; color: var(--ok); animation: flicker .4s steps(2) infinite; }

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font);
  font-size: 12px;
  color: #05040c;
  background: var(--accent);
  border: 0;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow:
    inset -3px -3px 0 #b87a12,
    inset 3px 3px 0 #fff6b0,
    0 0 0 2px #05040c,
    0 4px 0 2px #05040c;
}
.btn:active { transform: translateY(3px); box-shadow: inset -3px -3px 0 #b87a12, inset 3px 3px 0 #fff6b0, 0 0 0 2px #05040c; }
.btn:focus-visible { outline: 2px dashed var(--cyan); outline-offset: 6px; }
.btn.alt {
  background: #8a8ad0;
  box-shadow: inset -3px -3px 0 #4c4a96, inset 3px 3px 0 #d0d0ff, 0 0 0 2px #05040c, 0 4px 0 2px #05040c;
}
.btn.icon {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 12px;
  flex: none;
  background: #8a8ad0;
  box-shadow: inset -3px -3px 0 #4c4a96, inset 3px 3px 0 #d0d0ff, 0 0 0 2px #05040c, 0 4px 0 2px #05040c;
}
#btnSound { font-family: system-ui, sans-serif; font-size: 18px; }
#btnSound.off { opacity: .5; text-decoration: line-through; }

.hint {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 8px;
  line-height: 1.7;
  color: var(--muted);
}
.hint.ok { color: var(--ok); }
.hint.wip { color: var(--accent); }
.hint small { display: block; font-size: 7px; color: var(--muted); }

/* ---------- Sprachwahl ---------- */

.lang-switch { display: flex; gap: 10px; margin-top: 4px; }
.btn.lang {
  font-size: 9px;
  padding: 8px 10px;
  background: #4c4a96;
  color: var(--muted);
  box-shadow: inset -2px -2px 0 #2c2a64, inset 2px 2px 0 #8a8ad0, 0 0 0 2px #05040c, 0 3px 0 2px #05040c;
}
.btn.lang[aria-pressed="true"] {
  background: var(--cyan);
  color: #05040c;
  box-shadow: inset -2px -2px 0 #1a6a98, inset 2px 2px 0 #c8f0ff, 0 0 0 2px #05040c, 0 3px 0 2px #05040c;
}

/* ---------- Hi-Score-Tabelle ---------- */

.btn-col { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.btn-col[hidden], .name-form[hidden] { display: none; }

.scores {
  border-collapse: collapse;
  font-size: 9px;
  width: min(100%, 260px);
  background: rgba(5, 4, 12, .6);
  box-shadow: 0 0 0 2px var(--panel-lo);
}
.scores th {
  font-weight: normal;
  font-size: 7px;
  color: var(--muted);
  padding: 7px 6px;
  border-bottom: 2px solid var(--panel-lo);
}
.scores td { padding: 6px; color: var(--ink); }
.scores tbody tr:nth-child(even) td { background: rgba(76, 74, 150, .2); }
.scores th:first-child, .scores td:first-child { text-align: right; color: var(--muted); width: 2.5em; }
.scores th:nth-child(2), .scores td:nth-child(2) { text-align: left; }
.scores th:nth-child(3), .scores td:nth-child(3) { text-align: right; color: var(--cyan); }
.scores th:last-child, .scores td:last-child { text-align: right; color: var(--accent); }
.scores tbody tr:first-child td:nth-child(2) { color: var(--accent); }
.scores tr.new td { color: var(--ok) !important; animation: flicker .5s steps(2) infinite; }
.scores td.empty { text-align: center !important; color: var(--muted); padding: 16px 6px; width: auto; }

.name-form { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.place { margin: 0; font-size: 12px; color: var(--cyan); text-shadow: 2px 2px 0 #1a3888; }
.name-row { display: flex; gap: 10px; align-items: center; }
#nameInput {
  width: 10em;
  font-family: var(--font);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent);
  background: #05040c;
  border: 0;
  padding: 11px 8px;
  box-shadow: inset 0 0 0 2px var(--panel-hi);
  caret-color: var(--ok);
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
#nameInput:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ok); }

/* ---------- Würfel-Icons im Text ---------- */

.ico {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: -4px 2px 0 0;
  vertical-align: middle;
  background: center / 100% 100% no-repeat;
  image-rendering: pixelated;
}
.ico-joker { background-image: var(--ico-joker); }
.ico-bomb  { background-image: var(--ico-bomb); }
.popup.boom { color: #ffc66e; font-size: calc(var(--px) * 4); }

.ico-die { background-image: var(--ico-die); }
.logo { align-items: flex-start; } /* beide Zeilen linksbündig, Logo als Ganzes zentriert */
.logo .ico-die { margin-left: 0.3em; }
.logo .logo-ico {
  width: 1em;
  height: 1em;
  margin: 0 0 0 0.15em;
  vertical-align: 0.1em;
  filter: drop-shadow(3px 3px 0 #05040c);
}

.popup.bonus { animation-duration: 2.2s; }
.popup.pts.bonus { font-size: calc(var(--px) * 4); }

/* ---------- Debug-Leiste (nur mit ?debug) ---------- */

.debug-bar {
  position: fixed;
  top: max(4px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 4px 6px;
  background: rgba(255, 90, 110, .85);
  box-shadow: 0 0 0 2px #05040c;
}
.debug-bar .btn { font-size: 7px; padding: 6px 7px; }

/* ---------- MIX-Leiste ---------- */

.btn.mix {
  width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 9px;
}
.mix-seg { display: flex; gap: 2px; }
.mix-seg i {
  display: block;
  width: 10px;
  height: 5px;
  background: #2c2a64;
  box-shadow: 0 0 0 1px #05040c;
}
.mix-seg i.on { background: #ffc66e; }
.btn.mix:disabled { cursor: default; color: #2c2a64; }
.btn.mix:disabled:active { transform: none; }
.btn.mix.ready {
  background: var(--accent);
  color: #05040c;
  box-shadow: inset -3px -3px 0 #b87a12, inset 3px 3px 0 #fff6b0, 0 0 0 2px #05040c, 0 4px 0 2px #05040c;
  animation: flicker .5s steps(2) infinite;
}
.btn.mix.ready .mix-seg i.on { background: #ff5a6e; }

.hint.stuck { color: var(--hot); animation: flicker .6s steps(2) infinite; }

/* ---------- Anleitung ---------- */

#screenHelp .rules {
  text-align: left;
  line-height: 1.9;
}
#screenHelp .rules li { padding: 3px 0; }
#screenHelp .rules li + li { border-top: 1px dashed rgba(138, 138, 208, .25); }

.copyright {
  margin: 14px 0 0;
  font-size: 7px;
  color: var(--muted);
  opacity: .7;
  letter-spacing: 1px;
}
