/* Retro Locker – Designsystem
   Palette:  --bg #0D0A14 (CRT aus) · --surface #171226 · --line #2B2342
             --text #EFEAFB · --muted #9C92BE · --amber #FFB300 (Phosphor)
   Typo:     Press Start 2P (Display, sparsam) · Inter (Body) · IBM Plex Mono (Daten)
   Signatur: Spiele als Cartridge-Karten mit Kerbe und farbigem System-Etikett */

:root {
  --bg: #0D0A14;
  --surface: #171226;
  --surface-2: #1F1834;
  --line: #2B2342;
  --text: #EFEAFB;
  --muted: #9C92BE;
  --amber: #FFB300;
  --danger: #FF5C5C;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
}
.logo {
  font-family: "Press Start 2P", monospace;
  font-size: 13px;
  letter-spacing: 1px;
}
.logo span { color: var(--amber); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--amber);
  color: #1a1304;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 500;
  font-size: 14px;
}
.btn-ghost:hover { border-color: var(--muted); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-primary:focus-visible, .btn-ghost:focus-visible, input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ---------- Anmeldung ---------- */
.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 61px);
  padding: 40px 20px;
}
.auth-card { width: min(440px, 100%); }
.eyebrow {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: var(--amber);
  letter-spacing: 2px;
  margin: 0 0 18px;
}
.auth-card h1 {
  font-size: 38px;
  line-height: 1.15;
  margin: 0 0 14px;
  font-weight: 600;
  letter-spacing: -0.5px;
}
.auth-sub { color: var(--muted); margin: 0 0 28px; }
.auth-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.auth-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.auth-actions { display: flex; gap: 12px; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 13px; margin: 0 0 10px; }
.legal-note {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Bibliothek ---------- */
.library-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* Modulschacht (Upload) */
.upload-slot {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 30px 20px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.upload-slot:hover, .upload-slot.dragover {
  border-color: var(--amber);
  background: rgba(255, 179, 0, 0.04);
}
.slot-arrow { color: var(--amber); font-size: 18px; margin-bottom: 6px; }
.slot-title {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  margin: 0 0 10px;
}
.slot-hint { color: var(--muted); font-size: 13px; margin: 0; }
.slot-progress { margin-top: 16px; font-size: 13px; color: var(--muted); }
.slot-progress-bar {
  height: 6px;
  width: 0%;
  background: var(--amber);
  border-radius: 3px;
  margin-bottom: 8px;
  transition: width 0.2s;
}

.library-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 40px 0 18px;
}
.library-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.library-count { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--muted); }

/* Cartridge-Karten */
.cart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.cart {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px 6px 12px 12px;
  /* Kerbe oben wie am Modul */
  clip-path: polygon(0 14px, 12% 14px, 12% 0, 88% 0, 88% 14px, 100% 14px, 100% 100%, 0 100%);
  padding: 26px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.12s, border-color 0.12s;
}
.cart:hover { transform: translateY(-3px); border-color: var(--muted); }
.cart-label {
  display: inline-block;
  align-self: flex-start;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  letter-spacing: 1px;
  padding: 5px 8px;
  border-radius: 3px;
  color: #0d0a14;
}
.cart-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  margin: 0;
  word-break: break-word;
}
.cart-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: var(--muted);
  margin: 0;
}
.cart-state { color: var(--amber); }
.cart-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}
.cart-actions .btn-primary { flex: 1; }
.btn-delete {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
}
.btn-delete:hover { color: var(--danger); border-color: var(--danger); }

.empty-shelf {
  text-align: center;
  padding: 60px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.empty-shelf p { margin: 4px 0; }

/* ---------- BIOS ---------- */
.bios-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.bios-intro { font-size: 13px; margin: 0 0 14px; }
.bios-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.bios-row .cart-meta { flex: 1; }
.bios-actions { display: flex; gap: 8px; }

/* ---------- System-Dialog ---------- */
.system-dialog {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  max-width: 380px;
}
.system-dialog::backdrop { background: rgba(13, 10, 20, 0.8); }
.system-dialog .auth-actions { flex-wrap: wrap; margin-top: 18px; }

/* ---------- Player ---------- */
.player-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}
.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.player-title { margin: 0; font-size: 18px; font-weight: 600; }
.player-sub { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--muted); }
.player-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.crt-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
}
#game { width: 100%; height: 100%; }
.crt-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025) 0px,
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 3px
  );
}
.player-status {
  margin-top: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 18px;
}

@media (max-width: 600px) {
  .auth-card h1 { font-size: 30px; }
  .topbar { padding: 12px 16px; }
  .library-wrap, .player-wrap { padding: 20px 14px 60px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Tarif & Speicher ---------- */
.quota-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 36px;
}
.quota-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.plan-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: 6px;
  padding: 2px 10px;
}
.quota-bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--amber); border-radius: 5px; transition: width .4s; }
.quota-fill.quota-full { background: var(--danger); }
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.plan-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-card p { margin: 0; }
.plan-card button { margin-top: 10px; }
.plan-current { border-color: var(--amber); }
.plan-name { font-family: "Press Start 2P", monospace; font-size: 12px; }
.plan-price { font-size: 20px; font-weight: 600; }
.plan-price span { font-size: 13px; color: var(--muted); font-weight: 400; }

/* ---------- Controller-Navigation ---------- */
.gamepad-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--amber);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  z-index: 50;
}
.gp-focus, :focus-visible {
  outline: 3px solid var(--amber) !important;
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- Mobil ---------- */
@media (max-width: 700px) {
  body { font-size: 14px; }
  .topbar { padding: 10px 14px; }
  .library-wrap, .auth-wrap, .player-wrap { padding-left: 14px; padding-right: 14px; }
  .cart-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .quota-meta { flex-direction: column; align-items: flex-start; gap: 6px; }
  .player-head { flex-direction: column; gap: 12px; align-items: flex-start; }
  .player-actions { width: 100%; display: flex; gap: 10px; }
  .player-actions button { flex: 1; padding: 12px 8px; }
  .crt-frame { margin-left: -14px; margin-right: -14px; border-radius: 0; border-left: none; border-right: none; }
  /* Touch-Ziele vergrößern */
  .btn-primary, .btn-ghost { padding: 12px 18px; }
  .btn-delete { min-width: 42px; min-height: 42px; }
}
/* Handy quer: Spielfläche maximieren */
@media (max-width: 940px) and (orientation: landscape) {
  .topbar, .player-head, .player-status { display: none; }
  .player-wrap { padding: 0; max-width: none; }
  .crt-frame { margin: 0; border: none; border-radius: 0; height: 100vh; }
  .crt-frame #game { height: 100vh; }
}
