/* =======================================================================
 * FoulPlay.io – Styles
 * Sauber, modern, farbenfroh. Dark-UI mit kräftigen Akzenten.
 * ===================================================================== */

:root {
  --bg:        #0e1320;
  --bg-2:      #161d2e;
  --panel:     #1c2436;
  --panel-2:   #232c41;
  --line:      #2e3a55;
  --text:      #e8edf7;
  --muted:     #8b97b3;

  --blue:      #3b82f6;
  --blue-soft: #1e3a8a;
  --red:       #ef4444;
  --red-soft:  #7f1d1d;
  --green:     #22c55e;
  --accent:    #ffd23f;

  --radius:    14px;
  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --font:      'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  height: 100%;
  background: radial-gradient(1200px 700px at 50% -10%, #1b2742 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 2px 6px;
  margin: 0 1px;
  font-size: .8em;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--text);
}

/* ---------------------- Screens ---------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.screen.active { display: flex; }

/* ---------------------- Buttons ---------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  color: #fff;
  transition: transform .06s ease, filter .15s ease, background .15s ease;
  user-select: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-primary   { background: linear-gradient(180deg, #ffd23f, #f5a623); color: #2a1c00; }
.btn-secondary { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.btn-ghost     { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn-tiny      { padding: 4px 10px; font-size: .8rem; background: var(--panel-2); border: 1px solid var(--line); }

/* ---------------------- Inputs ---------------------- */
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }

input[type="text"], select {
  font: inherit;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  outline: none;
  transition: border-color .15s ease;
}
input[type="text"]:focus, select:focus { border-color: var(--accent); }
select { cursor: pointer; }

.error-msg { color: var(--red); font-size: .9rem; min-height: 1.2em; font-weight: 600; }

/* ====================== HOME ====================== */
.home-card {
  width: min(440px, 96vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.logo {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}
.logo span { color: var(--accent); }
.logo small { font-size: 1rem; color: var(--muted); font-weight: 600; vertical-align: super; }
.tagline { color: var(--muted); margin-top: -8px; }

.home-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 3px; font-weight: 700; text-align: center; }

.controls-hint {
  margin-top: 6px;
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
}
.controls-hint strong { width: 100%; color: var(--text); }

/* ====================== LOBBY ====================== */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.lobby-grid {
  width: min(1000px, 98vw);
  height: min(620px, 92vh);
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}
.lobby-main { display: flex; flex-direction: column; min-height: 0; }
.lobby-head { display: flex; justify-content: space-between; align-items: flex-start; }
.lobby-head h2 { font-size: 1.4rem; }
.code-box {
  margin-top: 6px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.code-box span {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 1.1rem;
}

.teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
  flex: 1;
  min-height: 0;
}
.team-col {
  background: var(--bg-2);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  overflow: auto;
}
.team-col h3 { font-size: 1rem; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.team-blue h3 { color: #93c5fd; }
.team-red h3  { color: #fca5a5; }
.count {
  font-size: .75rem;
  background: var(--panel-2);
  padding: 1px 8px;
  border-radius: 20px;
  color: var(--muted);
}
.player-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.player-list li {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.player-list li .host-badge {
  margin-left: auto;
  font-size: .68rem;
  background: var(--accent);
  color: #2a1c00;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 800;
}
.player-list li .you-badge {
  font-size: .68rem;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 0 6px;
  border-radius: 20px;
}

.hint { color: var(--muted); font-size: .82rem; margin-top: 12px; text-align: center; }

.host-settings {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.guest-wait {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* Chat */
.lobby-chat { display: flex; flex-direction: column; min-height: 0; }
.lobby-chat h3 { margin-bottom: 10px; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .88rem;
  min-height: 0;
}
.chat-messages .msg .who { font-weight: 700; margin-right: 6px; }
.chat-messages .msg .who.blue { color: #93c5fd; }
.chat-messages .msg .who.red  { color: #fca5a5; }
.chat-messages .msg.system { color: var(--muted); font-style: italic; font-size: .82rem; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.chat-form input { flex: 1 1 auto; min-width: 0; }      /* darf schrumpfen, kein Overflow */
.chat-form .btn { flex: 0 0 auto; padding: 12px 16px; } /* feste Breite, bricht nicht um */

/* ====================== GAME ====================== */
.game-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.hud {
  width: min(1280px, 96vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 22px;
  box-shadow: var(--shadow);
}
.hud-side { display: flex; align-items: center; gap: 12px; }
.hud-team { font-weight: 800; letter-spacing: 1px; }
.hud-side.blue .hud-team { color: #93c5fd; }
.hud-side.red  .hud-team { color: #fca5a5; }
.hud-score {
  font-size: 2rem;
  font-weight: 800;
  min-width: 42px;
  text-align: center;
}
.hud-side.blue .hud-score { color: var(--blue); }
.hud-side.red  .hud-score { color: var(--red); }
.hud-center { text-align: center; display: flex; flex-direction: column; }
.hud-time { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-half { font-size: .78rem; color: var(--muted); }

.canvas-holder {
  position: relative;
  width: min(1280px, 96vw);
  aspect-ratio: 1280 / 720;
  max-height: 76vh;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid var(--line);
}
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #2f7d3a;
}

.overlay-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(8, 12, 22, .5);
  pointer-events: none;
  /* Hintergrund blendet einmalig sanft ein und bleibt dann konstant. */
  animation: overlay-fade .25s ease;
}
.overlay-message.hidden { display: none; }

/* Nur der Inhalt pulsiert bei Änderung (z.B. Countdown 3 -> 2 -> 1). */
.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 6px 24px rgba(0,0,0,.6);
}
.overlay-inner .sub { font-size: .4em; color: var(--accent); margin-top: 8px; font-weight: 700; }
.overlay-inner.pulse { animation: pop .45s cubic-bezier(.2,1.4,.4,1); }

@keyframes overlay-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.45); opacity: .2; } to { transform: scale(1); opacity: 1; } }

.ping-badge {
  position: absolute;
  top: 8px; right: 10px;
  background: rgba(8,12,22,.6);
  color: var(--muted);
  font-size: .72rem;
  padding: 3px 9px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

.game-foot { color: var(--muted); font-size: .8rem; text-align: center; }

/* ====================== GAME OVER ====================== */
.gameover-card {
  width: min(640px, 96vw);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gameover-card h2 { font-size: 1.8rem; }
.go-score { font-size: 3rem; font-weight: 800; display: flex; justify-content: center; gap: 14px; }
.go-score .blue { color: var(--blue); }
.go-score .red  { color: var(--red); }
.go-score .sep  { color: var(--muted); }

.stats-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.stats-table th, .stats-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.stats-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; }
.stats-table td:first-child, .stats-table th:first-child { text-align: left; }
.stats-table .pill { padding: 2px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; }
.stats-table .pill.blue { background: var(--blue-soft); color: #bfdbfe; }
.stats-table .pill.red  { background: var(--red-soft);  color: #fecaca; }

.gameover-actions { display: flex; justify-content: center; gap: 12px; }

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

/* ---------------------- Responsive ---------------------- */
@media (max-width: 820px) {
  .lobby-grid { grid-template-columns: 1fr; height: auto; max-height: 94vh; overflow: auto; }
  .lobby-chat { height: 240px; }
}
