/* VoidCode – Terminal-Optik. Grün auf Schwarz, CRT, Matrix. Vanilla, offline. */

@font-face {
  font-family: "VT323";
  src: url("/fonts/vt323.woff2") format("woff2");
  font-display: swap;
  /* Fällt auf System-Monospace zurück, falls die Datei fehlt. */
}

:root {
  --green: #00ff5a;
  --green-dim: #00a13a;
  --green-trail: #044d20;
  --amber: #ffb000;
  --red: #ff3b3b;
  --bg: #000600;
  --panel: #03110a;
  --glow: 0 0 6px currentColor;
  --mono: "VT323", "Share Tech Mono", "Fira Code", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

/* Matrix-Hintergrund */
#matrix {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.18;
  pointer-events: none;
}

/* CRT-Scanlines + Vignette */
.crt::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0) 4px
    ),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%);
}
.crt::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 51;
  pointer-events: none;
  background: rgba(0, 255, 90, 0.02);
  animation: flicker 6s infinite steps(60);
}
@keyframes flicker {
  0%, 96%, 100% { opacity: 0.7; }
  97% { opacity: 0.4; }
  98% { opacity: 0.9; }
}

/* Layout */
.app {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 14px 16px 18px;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--green-trail);
  margin-bottom: 10px;
  flex: 0 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.brand .logo {
  width: 34px; height: 34px;
  filter: drop-shadow(var(--glow));
}
.brand .title { font-size: 24px; text-shadow: var(--glow); letter-spacing: 1px; }
.brand .subtitle { font-size: 14px; color: var(--green-dim); }
.rankbadge {
  font-size: 16px;
  color: var(--amber);
  text-shadow: 0 0 6px var(--amber);
  text-align: right;
  white-space: nowrap;
}

.screen {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.screen.active { display: flex; }

/* Terminal-Ausgabe */
.terminal {
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: var(--glow);
}
.terminal .line { display: block; }
.terminal .ok { color: var(--green); }
.terminal .bad { color: var(--red); text-shadow: 0 0 6px var(--red); }
.terminal .warn { color: var(--amber); text-shadow: 0 0 6px var(--amber); }
.terminal .dim { color: var(--green-dim); }

.cursor::after {
  content: "█";
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Buttons */
.btn {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--green);
  background: transparent;
  border: 1px solid var(--green-dim);
  padding: 12px 16px;
  margin: 6px 0;
  cursor: pointer;
  text-align: left;
  text-shadow: var(--glow);
  transition: background 0.12s, box-shadow 0.12s, transform 0.05s;
  width: 100%;
}
.btn:hover, .btn:focus { background: rgba(0,255,90,0.08); box-shadow: var(--glow); outline: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { color: var(--green-trail); border-color: var(--green-trail); cursor: not-allowed; text-shadow: none; }
.btn.primary { border-color: var(--green); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.amber { color: var(--amber); border-color: var(--amber); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1 1 auto; text-align: center; }

/* Eingaben */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--green);
  background: var(--panel);
  border: 1px solid var(--green-dim);
  padding: 10px 12px;
  width: 100%;
  margin: 6px 0;
  caret-color: var(--green);
  text-shadow: var(--glow);
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--green); }
select option { background: var(--panel); color: var(--green); }
label { display: block; margin-top: 12px; font-size: 17px; color: var(--green-dim); }

/* Karten / Level-Liste */
.card {
  border: 1px solid var(--green-trail);
  background: var(--panel);
  padding: 12px 14px;
  margin: 8px 0;
}
.level-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--green-trail);
  background: var(--panel);
  padding: 12px 14px;
  margin: 8px 0;
  cursor: pointer;
}
.level-item.locked { opacity: 0.45; cursor: not-allowed; }
.level-item.done { border-color: var(--green); }
.level-item .num {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.level-item .meta { flex: 1; }
.level-item .lname { font-size: 20px; }
.level-item .ldesc { font-size: 15px; color: var(--green-dim); }
.level-item .status { font-size: 22px; }

/* Code-Editor / Lückentext */
.code {
  background: #02160c;
  border: 1px solid var(--green-trail);
  padding: 14px;
  font-size: 20px;
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 10px 0;
}
.code .kw { color: var(--amber); text-shadow: 0 0 5px var(--amber); }
.code .str { color: #7CFC00; }
.code .com { color: var(--green-dim); }
.blank {
  display: inline-block;
  min-width: 90px;
  border-bottom: 2px dashed var(--amber);
  color: var(--amber);
  text-align: center;
  padding: 0 6px;
}
.blank.filled { border-bottom-style: solid; color: var(--green); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  font-family: var(--mono);
  font-size: 19px;
  border: 1px solid var(--amber);
  color: var(--amber);
  background: transparent;
  padding: 8px 14px;
  cursor: pointer;
  text-shadow: 0 0 5px var(--amber);
}
.chip:hover { background: rgba(255,176,0,0.12); }
.chip.used { opacity: 0.3; pointer-events: none; }

/* Fortschrittsbalken */
.bar {
  height: 22px;
  border: 1px solid var(--green-dim);
  background: #021a0e;
  margin: 10px 0;
  position: relative;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--green), var(--green) 10px, var(--green-dim) 10px, var(--green-dim) 14px);
  box-shadow: var(--glow);
  transition: width 0.15s linear;
}
.bar .pct {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #000; mix-blend-mode: difference; font-size: 15px;
}

/* Hilfsklassen */
.big { font-size: 30px; text-shadow: var(--glow); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.hint { color: var(--amber); font-size: 17px; text-shadow: 0 0 5px var(--amber); }
.success-flash { animation: flashok 0.5s; }
@keyframes flashok { from { background: rgba(0,255,90,0.25); } to { background: transparent; } }
.shake { animation: shake 0.3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* Glitch */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; left: 0; top: 0; width: 100%;
  overflow: hidden;
}
.glitch::before { color: #ff00c8; transform: translate(2px,0); clip-path: inset(0 0 60% 0); animation: g1 1.2s infinite linear alternate; }
.glitch::after  { color: #00fff2; transform: translate(-2px,0); clip-path: inset(60% 0 0 0); animation: g2 1s infinite linear alternate; }
@keyframes g1 { to { transform: translate(-2px,1px); } }
@keyframes g2 { to { transform: translate(2px,-1px); } }

/* Übernahme-Vollbild (Companion + Vorschau) */
.takeover {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  color: var(--red);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}
.takeover.active { display: flex; }
.takeover .hd { font-size: 13vw; color: var(--red); text-shadow: 0 0 18px var(--red); line-height: 1; }
.takeover .by { font-size: 8vw; color: var(--green); text-shadow: var(--glow); margin-top: 10px; }
.takeover .msg { font-size: 5vw; color: var(--amber); margin-top: 16px; max-width: 90%; }
.takeover .meme { font-size: 28vw; margin: 10px 0; }
.takeover .small { font-size: 4vw; color: var(--green-dim); margin-top: 20px; }

/* Eltern-Modus deutlich abgesetzt */
.parent-banner {
  background: var(--amber);
  color: #000;
  text-align: center;
  padding: 6px;
  font-size: 16px;
  margin: -14px -16px 12px;
}

@media (max-width: 480px) {
  html, body { font-size: 19px; }
  .brand .title { font-size: 20px; }
}

/* Bewegungsreduktion respektieren */
@media (prefers-reduced-motion: reduce) {
  #matrix { display: none; }
  .crt::before { animation: none; }
  .glitch::before, .glitch::after { animation: none; }
  .cursor::after { animation: none; }
}
