/* ============================================================
   portal.css — Spieleportal
   Fonts: Syne (Display) + DM Mono (Body/Code)
   ============================================================ */

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  --bg:        #0c0e15;
  --surf:      #12141d;
  --surf-hi:   #1a1d2a;
  --bdr:       #252840;
  --bdr-hi:    #353a55;
  --tx:        #ede8de;
  --tx-2:      #8a90aa;
  --tx-3:      #4a5068;
  --acc:       #eeaa30;
  --acc-dim:   rgba(238, 170, 48, 0.12);
  --acc-glow:  rgba(238, 170, 48, 0.06);
  --ok:        #42c28e;
  --err:       #e04866;
  --rad:       7px;
  --rad-lg:    13px;
  --fnt-h:     'Syne', sans-serif;
  --fnt-m:     'DM Mono', monospace;
  --grid-line: rgba(255, 255, 255, 0.022);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { cursor: pointer; font: inherit; background: none; border: none; }
input  { font: inherit; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--tx);
  font-family: var(--fnt-m);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Subtiles Raster als Hintergrund-Textur */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 52px 52px;
  pointer-events: none;
  z-index: 0;
}

/* ── Views ──────────────────────────────────────────────────── */
.view {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.view.active {
  display: flex;
  animation: rise 0.22s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ── Header ─────────────────────────────────────────────────── */
.hdr {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 32px;
  background: rgba(18, 20, 29, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bdr);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  font-family: var(--fnt-h);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.1em;
  flex: 1;
}

/* Zentrierter Titel in Nicht-Home-Headern */
.hdr-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--fnt-h);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--acc);
  white-space: nowrap;
  pointer-events: none;
}

.spacer { flex: 1; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-ghost {
  border: 1px solid var(--bdr);
  color: var(--tx-2);
  padding: 9px 18px;
  border-radius: var(--rad);
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-ghost:hover {
  border-color: var(--bdr-hi);
  color: var(--tx);
  background: var(--surf-hi);
}

.btn-ghost.sm {
  padding: 7px 14px;
  font-size: 12px;
}

.btn-accent {
  background: var(--acc);
  color: #080a10;
  font-weight: 500;
  padding: 10px 22px;
  border-radius: var(--rad);
  font-size: 13px;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-accent:hover:not(:disabled) {
  background: #f8b840;
  transform: translateY(-1px);
}

.btn-accent:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* ── Inputs ─────────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surf);
  border: 1px solid var(--bdr);
  color: var(--tx);
  padding: 10px 14px;
  border-radius: var(--rad);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder { color: var(--tx-3); }

.input:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-dim);
}

/* Monospace-Variante für Raum-IDs */
.input.mono  { font-size: 17px; letter-spacing: 0.15em; }
.input.upper { text-transform: uppercase; }

/* ── Labels ─────────────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tx-3);
  margin-bottom: 8px;
}

/* ── Sections (Home) ────────────────────────────────────────── */
.sect {
  display: flex;
  flex-direction: column;
}

.sect-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 18px;
}

.sect-title {
  font-family: var(--fnt-h);
  font-size: 19px;
  font-weight: 700;
}

.sect-badge {
  font-family: var(--fnt-m);
  font-size: 11px;
  color: var(--tx-3);
}

/* ═══════════════════════════════════════════════════════════
   VIEW: HOME
   ═══════════════════════════════════════════════════════════ */
.home-layout {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 52px 32px;
  display: flex;
  flex-direction: column;
  gap: 56px;
}

/* Namensfeld */
#sect-name .input { max-width: 380px; }

/* Spiele-Grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.game-card {
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: var(--rad-lg);
  padding: 26px 22px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

/* Amber-Glow auf Hover */
.game-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--acc-glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.game-card:hover {
  border-color: var(--acc);
  transform: translateY(-3px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--acc);
}

.game-card:hover::after { opacity: 1; }

.game-card-name {
  font-family: var(--fnt-h);
  font-weight: 700;
  font-size: 22px;
  color: var(--tx);
}

.game-card-players {
  font-size: 11px;
  color: var(--tx-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.no-games {
  color: var(--tx-3);
  font-size: 13px;
  padding: 36px 20px;
  border: 1px dashed var(--bdr);
  border-radius: var(--rad-lg);
  text-align: center;
  grid-column: 1 / -1;
}

/* Beitreten-Sektion */
.join-row {
  display: flex;
  gap: 10px;
  max-width: 400px;
}

.err-msg {
  font-size: 12px;
  color: var(--err);
  margin-top: 8px;
  min-height: 20px;
}

/* ═══════════════════════════════════════════════════════════
   VIEW: WAITING ROOM
   ═══════════════════════════════════════════════════════════ */
.waiting-layout {
  flex: 1;
  max-width: 460px;
  width: 100%;
  margin: 0 auto;
  padding: 64px 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 52px;
}

/* Raum-ID Block */
.room-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.room-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tx-3);
}

.room-id {
  font-family: var(--fnt-m);
  font-size: 54px;
  font-weight: 500;
  letter-spacing: 0.28em;
  color: var(--acc);
  text-shadow: 0 0 40px rgba(238, 170, 48, 0.22);
  line-height: 1;
}

/* Spieler-Block */
.players-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.block-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tx-3);
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: var(--rad);
}

.player-row.empty { opacity: 0.42; }

.player-slot {
  font-size: 11px;
  color: var(--tx-3);
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.player-name-text {
  flex: 1;
  font-size: 14px;
}

.player-name-text.is-me   { color: var(--acc); }
.player-name-text.muted   { color: var(--tx-3); }

.player-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bdr-hi);
  flex-shrink: 0;
  transition: background 0.3s;
}

.player-status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: blink 2.2s infinite;
}

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

.waiting-status {
  font-size: 12px;
  color: var(--tx-3);
  margin-top: 4px;
}

/* Start-Button */
.start-btn {
  width: 100%;
  padding: 14px;
  font-size: 14px;
  border-radius: var(--rad);
}

/* ═══════════════════════════════════════════════════════════
   VIEW: GAME (iframe)
   ═══════════════════════════════════════════════════════════ */
#view-game { height: 100vh; overflow: hidden; }

.game-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 11px 24px;
  background: var(--surf);
  border-bottom: 1px solid var(--bdr);
  flex-shrink: 0;
  position: relative;
}

#game-iframe {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
}

/* ═══════════════════════════════════════════════════════════
   VIEW: HISTORY
   ═══════════════════════════════════════════════════════════ */
.history-layout {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hist-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Filter-Chips */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  background: var(--surf);
  border: 1px solid var(--bdr);
  color: var(--tx-2);
  font-family: var(--fnt-m);
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 100px;
  transition: all 0.15s;
  cursor: pointer;
}

.chip:hover { border-color: var(--bdr-hi); color: var(--tx); }

.chip.active {
  background: var(--acc-dim);
  border-color: rgba(238, 170, 48, 0.35);
  color: var(--acc);
}

/* Eintrags-Liste */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: var(--rad);
  transition: border-color 0.15s;
}

.history-row:hover { border-color: var(--bdr-hi); }

.history-game {
  font-family: var(--fnt-h);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--acc);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-players { font-size: 13px; }
.history-meta    { font-size: 11px; color: var(--tx-3); }

.history-winner {
  font-size: 12px;
  color: var(--ok);
  white-space: nowrap;
  text-align: right;
}

.history-empty,
.history-loading {
  color: var(--tx-3);
  font-size: 13px;
  text-align: center;
  padding: 56px 0;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surf-hi);
  border: 1px solid var(--bdr-hi);
  color: var(--tx);
  font-size: 13px;
  padding: 10px 26px;
  border-radius: 100px;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Verlassen-Confirm-Overlay ──────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 21, 0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rise 0.15s ease;
}

.overlay-box {
  background: var(--surf);
  border: 1px solid var(--bdr-hi);
  border-radius: var(--rad-lg);
  padding: 36px 40px;
  max-width: 360px;
  width: calc(100% - 48px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overlay-title {
  font-family: var(--fnt-h);
  font-size: 20px;
  font-weight: 700;
}

.overlay-sub {
  font-size: 13px;
  color: var(--tx-2);
  margin-bottom: 8px;
}

.overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

/* Verlassen-Button im Overlay: gedämpftes Rot */
.btn-leave-ok {
  background: var(--err);
  color: #fff;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--rad);
  font-size: 13px;
  transition: opacity 0.15s;
}

.btn-leave-ok:hover { opacity: 0.85; }

/* ── Rejoin-Banner ──────────────────────────────────────────── */
.rejoin-banner {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surf-hi);
  border: 1px solid var(--bdr-hi);
  border-radius: var(--rad-lg);
  padding: 14px 18px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 18px;
  white-space: nowrap;
  animation: rise 0.2s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.rejoin-info { display: flex; flex-direction: column; gap: 2px; }

.rejoin-label {
  font-size: 13px;
  color: var(--tx-2);
}

.rejoin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-rejoin {
  background: var(--acc);
  color: #080a10;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--rad);
  font-size: 13px;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-rejoin:hover { background: #f8b840; }

.rejoin-close {
  color: var(--tx-3);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}

.rejoin-close:hover { color: var(--tx); }

