/* =============================================
   Galgenmännchen Multiplayer v2
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Rajdhani:wght@400;600;700&display=swap');

:root {
  --bg:         #0d0f1a;
  --bg2:        #141728;
  --bg3:        #1a1f35;
  --bg4:        #232840;
  --accent:     #f0c040;
  --accent2:    #e05a5a;
  --accent3:    #5ae0a0;
  --text:       #e8eaf0;
  --muted:      #7a80a0;
  --border:     #2a3050;
  --border2:    #404870;
  --danger:     #e05a5a;
  --success:    #5ae0a0;
  --warning:    #f0a030;
  --pixel:      'Press Start 2P', monospace;
  --body:       'Rajdhani', sans-serif;
  --r:          6px;
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --glow:       0 0 20px rgba(240,192,64,0.25);
}

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

html, body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(ellipse at 15% 15%, rgba(240,192,64,0.04) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(90,160,224,0.04) 0%, transparent 55%);
}

/* ── Typography ──────────────────────────────────────────────────────────── */
.pixel-title {
  font-family: var(--pixel);
  color: var(--accent);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5), 0 0 24px rgba(240,192,64,0.35);
  letter-spacing: 2px;
  font-size: clamp(0.9rem, 2.5vw, 1.6rem);
}

.section-label {
  font-family: var(--pixel);
  font-size: 0.42rem;
  color: var(--muted);
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.card-title {
  font-family: var(--pixel);
  font-size: 0.6rem;
  letter-spacing: 1px;
  margin-bottom: 18px;
  color: var(--accent);
}

/* ── Layout helpers ──────────────────────────────────────────────────────── */
.flex          { display: flex; }
.items-center  { align-items: center; }
.gap-8         { gap: 8px; }
.text-center   { text-align: center; }
.text-muted    { color: var(--muted); }
.text-accent   { color: var(--accent); }
.hidden        { display: none !important; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 14px; }

/* ── Top Bar ─────────────────────────────────────────────────────────────── */
.top-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.player-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.95rem; font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px;
  font-family: var(--pixel);
  font-size: 0.55rem;
  border: 2px solid currentColor;
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  letter-spacing: 1px;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--accent); color: #0d0f1a; border-color: var(--accent);
  box-shadow: 0 4px 0 #8a6c00, var(--glow);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 2px 0 #8a6c00, var(--glow); transform: translateY(2px); }
.btn-primary:active { box-shadow: none; transform: translateY(4px); }

.btn-success {
  background: var(--success); color: #0d0f1a; border-color: var(--success);
  box-shadow: 0 4px 0 #1a7040;
}
.btn-success:hover:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #1a7040; }

.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border2); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(224,90,90,0.1); }

.btn-full { width: 100%; }
.btn-xs { padding: 6px 12px; font-size: 0.42rem; }

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--body);
  font-size: 1.05rem;
  padding: 11px 14px;
  transition: border-color 0.2s;
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

.label {
  display: block;
  font-family: var(--pixel);
  font-size: 0.42rem;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 1.5px;
}

.form-group { margin-bottom: 18px; }

.code-input {
  letter-spacing: 6px;
  font-size: 1.4rem !important;
  text-transform: uppercase;
  font-family: var(--pixel) !important;
  text-align: center;
}

.error-msg {
  background: rgba(224,90,90,0.12);
  border: 1px solid var(--danger);
  border-radius: var(--r);
  padding: 10px 14px;
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 8px;
}

/* ── Avatar ──────────────────────────────────────────────────────────────── */
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--pixel);
  font-size: 0.6rem;
  color: #0d0f1a;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Welcome / Register ──────────────────────────────────────────────────── */
body.page-center {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.welcome-wrap { max-width: 420px; width: 100%; }
.logo-area { text-align: center; margin-bottom: 28px; }
.logo-emoji { font-size: 3rem; margin-bottom: 10px; filter: drop-shadow(0 0 16px rgba(240,192,64,0.5)); }
.logo-sub { color: var(--muted); font-size: 0.95rem; margin-top: 6px; }

.color-picker { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.color-dot {
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: white; transform: scale(1.15); box-shadow: 0 0 8px rgba(255,255,255,0.3); }

.info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px;
}
.info-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px; display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--muted);
}
.info-icon { font-size: 1.1rem; }

/* ── Menu ────────────────────────────────────────────────────────────────── */
.page-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
}
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 600px) { .menu-grid { grid-template-columns: 1fr; } }

.rules-card .card-title { color: var(--muted); }
.rules-grid { display: flex; flex-direction: column; gap: 10px; }
.rule-item { display: flex; gap: 14px; align-items: flex-start; font-size: 0.9rem; color: var(--muted); }
.rule-num {
  font-family: var(--pixel); font-size: 0.5rem; color: var(--accent);
  background: rgba(240,192,64,0.1); border: 1px solid rgba(240,192,64,0.3);
  border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.rule-item strong { color: var(--text); }

/* ── Lobby ───────────────────────────────────────────────────────────────── */
.lobby-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
@media (max-width: 700px) { .lobby-layout { grid-template-columns: 1fr; } }

.code-label { font-family: var(--pixel); font-size: 0.38rem; color: var(--muted); letter-spacing: 1px; margin-bottom: 6px; }
.room-code-display {
  font-family: var(--pixel); font-size: clamp(1.5rem, 5vw, 2.2rem);
  color: var(--accent); letter-spacing: 10px; text-align: center;
  padding: 18px; background: var(--bg2); border: 2px dashed var(--border2);
  border-radius: var(--r); cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
}
.room-code-display:hover { border-color: var(--accent); box-shadow: var(--glow); }

.players-list { list-style: none; }
.player-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r); transition: background 0.12s; margin-bottom: 3px;
}
.player-item:hover { background: var(--bg4); }
.player-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--pixel); font-size: 0.65rem; color: #0d0f1a; font-weight: 700; flex-shrink: 0;
}
.player-name { font-size: 1.05rem; font-weight: 600; }
.badge {
  font-family: var(--pixel); font-size: 0.33rem; padding: 3px 6px;
  border-radius: 3px; background: var(--accent); color: #0d0f1a; margin-left: auto;
}
.badge-you { background: var(--accent3); margin-left: 4px; }

.waiting-box {
  text-align: center; padding: 20px; color: var(--muted); font-size: 0.9rem;
}
.room-info-list { display: flex; flex-direction: column; gap: 8px; }
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.9rem; color: var(--muted); padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row span:last-child { color: var(--text); font-weight: 600; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Game Page ───────────────────────────────────────────────────────────── */
body.game-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Turn Banner */
.turn-banner {
  background: linear-gradient(135deg, rgba(240,192,64,0.15), rgba(240,192,64,0.05));
  border-bottom: 2px solid var(--accent);
  padding: 8px 16px;
  display: flex; align-items: center; gap: 16px;
  flex-shrink: 0;
}
#turn-text {
  font-family: var(--pixel); font-size: 0.55rem; color: var(--accent);
  white-space: nowrap; animation: pulse-text 1s ease-in-out infinite;
}
@keyframes pulse-text { 0%,100% { opacity:1; } 50% { opacity:0.6; } }
.timer-bar-wrap {
  flex: 1; height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden;
}
.timer-bar {
  height: 100%; background: var(--success); border-radius: 4px;
  transition: width 1s linear, background 0.5s;
}
.timer-bar.warning { background: var(--warning); }
.timer-bar.urgent  { background: var(--danger); animation: pulse-bar 0.4s ease-in-out infinite; }
@keyframes pulse-bar { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
.timer-seconds {
  font-family: var(--pixel); font-size: 0.7rem; color: var(--text);
  min-width: 28px; text-align: right;
}

/* Game Layout */
.game-layout {
  display: grid;
  grid-template-columns: 260px 1fr 240px;
  gap: 12px;
  flex: 1;
  overflow: hidden;
  padding: 12px 16px;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 900px) {
  body.game-body { overflow-y: auto; height: auto; }
  .game-layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .panel-right { height: 280px; }
}

.panel-left  { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.panel-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; position: relative; overflow: hidden;
}
.panel-right { display: flex; flex-direction: column; overflow: hidden; }

/* Hangman */
.hangman-wrap {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); border-radius: var(--r); padding: 10px;
}
#hangman-svg { width: 160px; height: 180px; }
.gallows  { stroke: var(--muted); stroke-width: 3; fill: none; stroke-linecap: round; }
.hm-part  { stroke: var(--danger); stroke-width: 4; fill: none; stroke-linecap: round; opacity: 0; transition: opacity 0.35s; }
.hm-part.visible { opacity: 1; }
.wrong-counter {
  text-align: center; margin-top: 6px;
  font-family: var(--pixel); font-size: 0.42rem; color: var(--danger);
}

/* Category */
.category-tag {
  display: inline-block;
  font-family: var(--pixel); font-size: 0.42rem;
  padding: 5px 12px; border-radius: 20px;
  background: rgba(240,192,64,0.1); border: 1px solid rgba(240,192,64,0.3); color: var(--accent);
  letter-spacing: 1px;
}

/* Scoreboard */
.score-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r); transition: background 0.12s; margin-bottom: 2px;
}
.score-row:hover { background: var(--bg4); }
.score-row.me { background: rgba(240,192,64,0.07); border: 1px solid rgba(240,192,64,0.2); }
.rank { font-family: var(--pixel); font-size: 0.38rem; color: var(--muted); width: 18px; text-align: center; }
.rank-1 { color: var(--accent); }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }
.score-name { font-size: 0.9rem; font-weight: 600; flex: 1; }
.score-pts { font-family: var(--pixel); font-size: 0.5rem; color: var(--accent); }

/* Guesser Info */
.guesser-info { font-size: 1rem; font-weight: 700; }
.my-turn-badge {
  font-family: var(--pixel); font-size: 0.55rem;
  color: var(--accent); background: rgba(240,192,64,0.12);
  border: 2px solid rgba(240,192,64,0.4); border-radius: var(--r);
  padding: 6px 14px; display: inline-block;
  animation: pulse-badge 1.2s ease-in-out infinite;
}
@keyframes pulse-badge { 0%,100%{ box-shadow:0 0 0 0 rgba(240,192,64,0.4); } 50%{ box-shadow:0 0 0 8px rgba(240,192,64,0); } }
.their-turn-badge {
  font-family: var(--pixel); font-size: 0.5rem; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 6px 14px; display: inline-block;
}

/* Round dots */
.round-dots-row { display: flex; gap: 5px; }
.round-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--border2);
  transition: background 0.3s;
}
.round-dot.done    { background: var(--success); }
.round-dot.current { background: var(--accent); animation: pulse-dot 1s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100%{ opacity:1; } 50%{ opacity:0.4; } }

/* Word Display */
.word-display { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.letter-box {
  width: 36px; height: 48px;
  border-bottom: 3px solid var(--border2);
  display: flex; align-items: flex-end; justify-content: center;
  font-family: var(--pixel); font-size: 1rem; color: var(--text);
  padding-bottom: 4px; transition: border-color 0.25s;
}
.letter-box.space { width: 14px; border-bottom: none; }
.letter-box.revealed { border-color: var(--success); color: var(--success); animation: pop 0.25s ease; }
.letter-box.revealed-wrong { color: var(--danger); border-color: var(--danger); }
@keyframes pop { 0%{transform:scale(1)} 50%{transform:scale(1.3)} 100%{transform:scale(1)} }

/* Keyboard */
.keyboard { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; max-width: 380px; }
.key-btn {
  width: 40px; height: 40px;
  background: var(--bg3); border: 2px solid var(--border2); border-radius: var(--r);
  color: var(--text); font-family: var(--pixel); font-size: 0.5rem;
  cursor: pointer; transition: all 0.1s; display: flex; align-items: center; justify-content: center;
}
.key-btn:hover:not(:disabled) {
  background: var(--bg4); border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 8px rgba(240,192,64,0.25);
}
.key-btn:active:not(:disabled) { transform: scale(0.9); }
.key-btn.guessed { background: rgba(90,90,90,0.2); border-color: var(--border); color: var(--border2); }
.key-btn:disabled { cursor: not-allowed; }

/* Wait Overlay (inside panel-center) */
.wait-overlay {
  position: absolute; inset: 0;
  background: rgba(13,15,26,0.85);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r);
  backdrop-filter: blur(2px);
  z-index: 10;
}
.wait-inner { text-align: center; padding: 24px; }
.wait-icon { font-size: 2.5rem; margin-bottom: 12px; }
.wait-name { font-family: var(--pixel); font-size: 0.65rem; color: var(--accent); margin-bottom: 6px; }
.wait-sub { color: var(--muted); font-size: 0.9rem; }

/* Chat */
.chat-card { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.chat-box {
  flex: 1; overflow-y: auto; padding: 6px;
  display: flex; flex-direction: column; gap: 5px;
  scroll-behavior: smooth;
}
.chat-box::-webkit-scrollbar { width: 3px; }
.chat-box::-webkit-scrollbar-track { background: var(--bg2); }
.chat-box::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.chat-msg { padding: 6px 10px; background: var(--bg2); border-radius: var(--r); font-size: 0.88rem; }
.chat-msg .sender { font-weight: 700; font-size: 0.8rem; margin-bottom: 2px; }
.chat-msg.system {
  background: transparent; color: var(--muted);
  font-size: 0.8rem; font-style: italic; text-align: center;
  padding: 3px 8px;
}
.chat-input-area { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input-area .input { font-size: 0.88rem; padding: 8px 12px; }
.chat-send-btn {
  background: var(--bg4); border: 2px solid var(--border2); border-radius: var(--r);
  color: var(--accent); cursor: pointer; padding: 8px 13px; font-size: 1.1rem;
  transition: border-color 0.12s, background 0.12s; flex-shrink: 0;
}
.chat-send-btn:hover { border-color: var(--accent); background: var(--bg3); }

/* Overlays */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(5px);
}
.overlay-card {
  background: var(--bg3); border: 2px solid var(--accent); border-radius: var(--r);
  padding: 40px 36px; text-align: center; max-width: 420px; width: 90%;
  box-shadow: 0 0 60px rgba(240,192,64,0.2);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from{ transform:translateY(-16px) scale(0.96); opacity:0; } to{ transform:none; opacity:1; } }
.overlay-title { font-family: var(--pixel); font-size: 0.9rem; color: var(--accent); margin-bottom: 8px; }
.overlay-word { font-family: var(--pixel); font-size: 1.3rem; color: var(--text); letter-spacing: 5px; margin: 12px 0; }

/* Round Badge */
.round-badge {
  font-family: var(--pixel); font-size: 0.42rem; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 4px 10px;
}

/* Toast */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 7px; z-index: 300;
}
.toast {
  background: var(--bg3); border: 1px solid var(--border2); border-left: 4px solid var(--accent);
  border-radius: var(--r); padding: 11px 16px; font-size: 0.9rem; min-width: 210px;
  box-shadow: var(--shadow); transition: opacity 0.3s; animation: toastIn 0.25s ease;
}
.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes toastIn { from{ transform:translateX(16px); opacity:0; } to{ transform:none; opacity:1; } }

/* Responsive game */
@media (max-width: 600px) {
  .key-btn { width: 34px; height: 34px; font-size: 0.42rem; }
  .letter-box { width: 28px; height: 40px; font-size: 0.8rem; }
  .game-layout { padding: 8px; gap: 8px; }
}
