/* =========================================
   FOOTBALLDUEL — Główny arkusz stylów
   Estetyka: dark stadium / retro scoreboard
   ========================================= */

:root {
  --bg: #0a0e1a;
  --bg2: #111827;
  --bg3: #1a2235;
  --card: #141c2e;
  --card2: #1e2a42;
  --green: #00e676;
  --green2: #00c853;
  --yellow: #ffd600;
  --red: #ff3d57;
  --blue: #4488ff;
  --text: #e8eaf6;
  --muted: #7986a8;
  --border: rgba(255,255,255,0.08);
  --radius: 12px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  overflow-x: hidden;
}

/* ---- SCREENS ---- */
.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
}
.screen.active { display: flex; }

/* ---- HOME SCREEN ---- */
.home-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 60% 40%, #0d2a4a 0%, #0a0e1a 70%);
  z-index: 0;
}

.pitch-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,230,118,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,230,118,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: grid-drift 20s linear infinite;
}
@keyframes grid-drift {
  0% { transform: translate(0,0); }
  100% { transform: translate(60px, 60px); }
}

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  gap: 2.5rem;
}

.logo-wrap { text-align: center; }

.logo-ball {
  font-size: 60px;
  display: block;
  margin-bottom: 12px;
  animation: ball-bounce 2s ease-in-out infinite;
}
@keyframes ball-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(52px, 12vw, 96px);
  letter-spacing: 4px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 40px rgba(0,230,118,0.3);
}
.logo span { color: var(--green); }

.tagline {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 8px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.live-ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,230,118,0.08);
  border: 1px solid rgba(0,230,118,0.2);
  border-radius: 100px;
  padding: 6px 16px;
  font-size: 13px;
}
.ticker-label {
  background: var(--green);
  color: #0a0e1a;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 100px;
}

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--green);
  color: #0a0e1a;
  border: none;
  padding: 14px 32px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 2px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(0,230,118,0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,230,118,0.5);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary.full { width: 100%; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 13px 32px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 2px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-secondary:hover {
  border-color: var(--green);
  background: rgba(0,230,118,0.05);
}
.btn-secondary.full { width: 100%; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 10px;
  transition: color 0.15s;
}
.btn-ghost:hover { color: var(--text); }
.btn-ghost.small { font-size: 13px; }

/* ---- SCREEN HEADER ---- */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.screen-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 2px;
  flex: 1;
}
.back-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.back-btn:hover { background: var(--card2); }
.icon-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.3s;
}
.icon-btn:hover { background: var(--card2); transform: rotate(180deg); }

/* ---- FORM CARD ---- */
.form-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
input[type="text"], select, textarea {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input[type="text"]:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,230,118,0.1);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237986a8' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
select option { background: #1a2235; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mode-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex; flex-direction: column; gap: 4px;
}
.mode-tile:hover { border-color: rgba(255,255,255,0.2); background: var(--card2); }
.mode-tile.active { border-color: var(--green); background: rgba(0,230,118,0.08); }
.tile-icon { font-size: 22px; }
.tile-title { font-size: 13px; font-weight: 600; color: var(--text); }
.tile-sub { font-size: 11px; color: var(--muted); }

.target-row { display: flex; gap: 8px; }
.tgt {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px 4px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 1px;
  transition: all 0.15s;
}
.tgt:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }
.tgt.active { border-color: var(--green); color: var(--green); background: rgba(0,230,118,0.08); }

/* ---- ROOMS LIST ---- */
.nick-bar {
  padding: 12px 1.25rem;
  border-bottom: 1px solid var(--border);
}
.rooms-list { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 10px; }
.empty-state { text-align: center; color: var(--muted); padding: 3rem; font-size: 14px; }

.room-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.room-card:hover { border-color: var(--green); background: var(--card2); }
.room-card-info { flex: 1; min-width: 0; }
.room-card-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-card-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.room-card-badge {
  background: rgba(0,230,118,0.1);
  color: var(--green);
  border: 1px solid rgba(0,230,118,0.2);
  border-radius: 100px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- WAITING ROOM ---- */
.waiting-inner {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.code-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.code-label { font-size: 11px; letter-spacing: 2px; color: var(--muted); }
.code-val {
  font-family: var(--font-display);
  font-size: 48px;
  letter-spacing: 10px;
  color: var(--green);
}
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.15s;
}
.copy-btn:hover { border-color: var(--green); color: var(--green); }

.vs-arena {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  justify-content: center;
}
.player-slot { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; }
.avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--card2);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text);
}
.avatar.empty { border-style: dashed; color: var(--muted); }
.slot-nick { font-size: 14px; font-weight: 500; }
.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 100px;
}
.badge.host { background: rgba(255,214,0,0.15); color: var(--yellow); border: 1px solid rgba(255,214,0,0.3); }
.badge.guest { background: rgba(68,136,255,0.15); color: var(--blue); border: 1px solid rgba(68,136,255,0.3); }
.vs-label { font-family: var(--font-display); font-size: 28px; color: var(--muted); }

.game-settings-summary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  width: 100%;
}
.hint { font-size: 13px; color: var(--muted); text-align: center; }

/* ---- GAME SCREEN ---- */
.scorebar {
  display: flex;
  align-items: stretch;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 70px;
}
.score-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 14px;
  gap: 4px;
}
.score-half.right { align-items: flex-end; }
.sn { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.sv { font-family: var(--font-display); font-size: 36px; color: var(--green); line-height: 1; }
.progress-bar { height: 3px; background: var(--border); border-radius: 3px; width: 100%; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 3px; width: 0%; transition: width 0.5s; }
.progress-fill.right { margin-left: auto; }
.score-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}
.round-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--muted);
  white-space: nowrap;
}
.round-badge span { color: var(--text); font-size: 18px; }

.club-banner {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 1.25rem;
  display: flex;
  align-items: center;
  gap: 14px;
}
.club-badge { font-size: 32px; }
.club-info { flex: 1; }
.club-name { font-family: var(--font-display); font-size: 26px; letter-spacing: 2px; color: #fff; }
.club-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.new-club-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
}
.new-club-btn:hover { border-color: var(--green); color: var(--green); transform: rotate(180deg); }

.turn-bar {
  background: rgba(0,230,118,0.06);
  border-bottom: 1px solid rgba(0,230,118,0.15);
  padding: 8px 1.25rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--green);
  text-align: center;
}

.game-log-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 12px 1rem;
}
.game-log { display: flex; flex-direction: column-reverse; gap: 6px; }

.log-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  animation: slide-in 0.2s ease;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.log-entry.success { border-color: rgba(0,230,118,0.3); background: rgba(0,230,118,0.04); }
.log-entry.error { border-color: rgba(255,61,87,0.3); background: rgba(255,61,87,0.04); }
.log-entry.new-club { border-color: rgba(255,214,0,0.3); background: rgba(255,214,0,0.04); justify-content: center; }
.log-player { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 80px; }
.log-name { flex: 1; font-size: 14px; font-weight: 500; }
.log-pts { font-family: var(--font-display); font-size: 18px; color: var(--green); }
.log-pts.red { color: var(--red); }
.log-icon { font-size: 16px; }

.input-area {
  display: flex;
  gap: 8px;
  padding: 10px 1rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.ac-wrap { flex: 1; position: relative; }
.ac-list {
  position: absolute;
  bottom: 100%; left: 0; right: 0;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}
.ac-item {
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.selected { background: rgba(0,230,118,0.1); }
.ac-flag { font-size: 16px; flex-shrink: 0; }
.ac-name { flex: 1; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-meta { font-size: 11px; color: var(--muted); text-align: right; flex-shrink: 0; display: flex; flex-direction: column; gap: 1px; align-items: flex-end; }
.ac-apps { color: var(--green); font-size: 11px; }

.confirm-btn {
  background: var(--green);
  color: #0a0e1a;
  border: none;
  width: 48px; height: 48px;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.confirm-btn:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(0,230,118,0.4); }

.opponent-turn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 1.5rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
}
.dot-loader { display: flex; gap: 4px; }
.dot-loader span {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: dot-pulse 1.2s infinite;
}
.dot-loader span:nth-child(2) { animation-delay: 0.2s; }
.dot-loader span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* ---- RESULT SCREEN ---- */
.result-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem;
  gap: 1.5rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.trophy-anim {
  font-size: 72px;
  animation: trophy-pop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes trophy-pop {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.winner-label {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 3px;
  text-align: center;
  color: var(--green);
}
.final-board {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  width: 100%;
  display: flex;
  justify-content: space-around;
}
.final-player { text-align: center; }
.fp-nick { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.fp-score { font-family: var(--font-display); font-size: 48px; color: var(--green); }
.fp-score.loser { color: var(--muted); }

.full-log-wrap { width: 100%; }
.full-log-wrap h3 { font-family: var(--font-display); font-size: 18px; letter-spacing: 2px; margin-bottom: 10px; color: var(--muted); }
.result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table th { text-align: left; padding: 6px 8px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.result-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); }
.result-table tr:hover td { background: var(--card); }

.result-btns { display: flex; gap: 12px; width: 100%; flex-wrap: wrap; }
.result-btns .btn-primary, .result-btns .btn-secondary { flex: 1; font-size: 16px; padding: 14px; text-align: center; }

/* ---- RULES ---- */
.rules-wrap { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; max-width: 480px; margin: 0 auto; }
.rule-row { display: flex; gap: 1rem; align-items: flex-start; }
.rule-n { font-family: var(--font-display); font-size: 48px; color: var(--border); line-height: 1; flex-shrink: 0; width: 48px; }
.rule-body h3 { font-family: var(--font-display); font-size: 20px; letter-spacing: 1px; margin-bottom: 6px; }
.rule-body p { font-size: 14px; color: var(--muted); line-height: 1.7; }
.rule-body strong { color: var(--text); }

/* ---- TOAST ---- */
#toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
  min-width: 200px;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 20px;
  font-size: 14px;
  text-align: center;
  animation: toast-in 0.3s ease;
  pointer-events: none;
}
.toast.success { border-color: rgba(0,230,118,0.4); color: var(--green); }
.toast.error { border-color: rgba(255,61,87,0.4); color: var(--red); }
.toast.info { border-color: rgba(68,136,255,0.3); color: var(--blue); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- CONFETTI ---- */
#confetti-zone {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  from { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ---- RESPONSIVE ---- */
@media (min-width: 600px) {
  .form-card, .waiting-inner, .result-inner, .rules-wrap { padding: 2rem; }
  .logo { font-size: 100px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
