:root {
  --bg: #111827;
  --panel: rgba(255,255,255,0.14);
  --accent: #ff6b6b;
  --accent-2: #4ecdc4;
  --accent-3: #ffd166;
  --text: #f9fafb;
  --muted: #d1d5db;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #0f172a, #7c3aed 45%, #ec4899 100%);
  color: var(--text);
}

.auth-page, .admin-page, .projection-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.game-page {
  height: 100vh;
  height: 100dvh; /* accounts for mobile browser toolbars so content isn't clipped below the fold */
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

.panel, .card, .top-card, .photo-card, .status-card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.22);
}

.panel { width: min(500px, 100%); }

input, select, button {
  width: 100%;
  padding: 12px 14px;
  margin-top: 8px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  box-sizing: border-box;
}

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: bold;
  cursor: pointer;
}

button.secondary {
  background: linear-gradient(135deg, #ffffff, #fef3c7);
  color: #111827;
}

button.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.error { color: #fecaca; }
.success { color: #bbf7d0; }
.info-box { background: rgba(255,255,255,0.08); border-radius: 12px; padding: 10px 12px; }
.muted-copy { color: var(--muted); }
.landing-panel { max-width: 560px; }

.game-shell { width: 100%; max-width: 1000px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.top-card { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 10px 12px; flex: 0 0 auto; }
.top-card strong { font-size: 0.72rem; display: block; opacity: 0.85; }
.photo-card {
  flex: 0 0 auto;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.photo-card button { width: auto; margin: 0; }
#map { flex: 1 1 auto; min-height: 0; border-radius: 16px; overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  z-index: 3000; /* above Leaflet's panes/controls (max ~1000) so the photo isn't hidden under the map */
}
.modal img { width: auto; max-width: min(90vw, 720px); max-height: 85vh; border-radius: 16px; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
}
.hidden { display: none; }
.timer-label { margin-bottom: 4px; font-size: 1rem; color: var(--muted); }
.answer-summary { margin-top: 6px !important; font-weight: 700; font-size: 1.05rem; }
.menu-link { display: inline-block; margin-top: 0; color: #fef3c7; text-decoration: none; }
.finished-ranking-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0; }
.status-card {
  flex: 0 0 auto;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.status-card p { margin: 0; }
.status-card button { width: auto; margin: 0; min-width: 220px; }

.projection-shell { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; width: 100%; }
.projection-left img { width: 100%; height: 520px; object-fit: contain; border-radius: 24px; background: rgba(0,0,0,0.25); }
.projection-right .card { margin-bottom: 16px; }
.hero-banner {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-3), var(--accent));
  color: #111827;
  font-weight: bold;
  margin-bottom: 12px;
}
.projection-pill {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  margin-bottom: 12px;
}
.projection-badge {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: white;
  font-weight: 700;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(236,72,153,0.3);
}
/* Own class (not "podium-card") to avoid colliding with the top-3 podium cards' max-width:200px rule below */
.ranking-card { background: linear-gradient(135deg, rgba(255,209,102,0.24), rgba(78,205,196,0.2)); }
.funny-card { background: linear-gradient(135deg, rgba(255,107,107,0.24), rgba(255,255,255,0.12)); }
.ranking-table-wrap { max-height: 540px; overflow-y: auto; overflow-x: auto; }
.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th, .ranking-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.15); }
.ranking-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ranking-table tr.winner-highlight { background: rgba(255,209,102,0.35); }
.ranking-table tr.winner-highlight td { color: #111827; font-weight: 700; }
.ranking-panel { width: min(760px, 100%); }
.ranking-list { padding: 0; list-style: none; }
.ranking-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.2); }
.finished-panel { width: min(600px, 100%); text-align: center; }
.finished-panel button { width: auto; margin-top: 12px; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 24px 0; }
.podium-card {
  flex: 1;
  max-width: 200px;
  padding: 18px 14px;
  border-radius: 18px 18px 8px 8px;
  text-align: center;
  box-shadow: 0 14px 32px rgba(0,0,0,0.28);
  animation: podiumRise 0.5s ease both;
}
.podium-medal { font-size: 2.2rem; line-height: 1; margin-bottom: 6px; }
.podium-rank { font-weight: 700; opacity: 0.7; margin-bottom: 4px; font-size: 0.9rem; }
.podium-name { font-size: 1.1rem; font-weight: 800; margin-bottom: 6px; word-break: break-word; }
.podium-score { font-size: 1.25rem; font-weight: 900; }
.podium-1 { min-height: 230px; transform: scale(1.06); z-index: 2; animation-delay: 0.1s; }
.podium-2 { min-height: 180px; align-self: flex-end; }
.podium-3 { min-height: 150px; align-self: flex-end; }
.podium-1 { background: linear-gradient(135deg, #ffd166, #ff9f1c); color: #111827; }
.podium-2 { background: linear-gradient(135deg, #e2e8f0, #94a3b8); color: #111827; }
.podium-3 { background: linear-gradient(135deg, #fcd34d, #b45309); color: #fff; }

@keyframes podiumRise {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.admin-actions form { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-actions button { margin: 0; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
/* Panels default to content-box, so padding/border would otherwise push them past their grid track and overlap the next column */
.admin-layout > .panel { box-sizing: border-box; }
.join-panel { text-align: center; }
.admin-layout .join-panel { align-self: start; }
.join-panel h2 { margin: 0 0 10px; font-size: 1.2rem; }
.join-banner-url {
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  font-weight: 800;
  margin: 0 0 14px;
  word-break: break-word;
}
.join-banner-qr { border-radius: 12px; background: #fff; padding: 8px; }
.join-banner-code { font-size: 1.2rem; margin: 14px 0 0; }
.admin-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 16px 0 24px; }
.admin-actions-group {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  padding: 16px;
}
.admin-actions-group h3 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.secondary-link { color: #fcd34d; text-decoration: none; }

.photo-library-panel.menu-panel { width: min(1100px, 100%); text-align: left; }
.photo-library-columns { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; margin-top: 12px; }
.photo-library-add h2, .photo-library-list h2 { margin: 0 0 10px; font-size: 1rem; }
.compact-form label { font-size: 0.78rem; color: var(--muted); margin-bottom: 2px; display: block; }
.compact-form input { padding: 8px 10px; margin-top: 0; margin-bottom: 8px; font-size: 14px; }
.compact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.compact-actions { display: flex; gap: 8px; }
.compact-actions button { width: auto; margin: 0; }

.photo-compact-list { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; padding-right: 4px; }
.photo-compact-item {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 6px 10px;
}
.photo-compact-item summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
}
.photo-compact-item summary::-webkit-details-marker { display: none; }
.photo-compact-item img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.photo-compact-title { font-weight: 700; flex: 1; }
.photo-compact-meta { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.photo-compact-edit { padding: 10px 4px 4px; border-top: 1px solid rgba(255,255,255,0.12); margin-top: 6px; }

.menu-page { display: flex; min-height: 100vh; width: 100%; }
.menu-sidebar {
  width: 260px;
  flex-shrink: 0;
  padding: 28px 20px;
  background: rgba(15, 23, 42, 0.55);
  border-right: 1px solid rgba(255,255,255,0.12);
  box-sizing: border-box;
}
.menu-sidebar h2 { margin: 0 0 4px; font-size: 1.3rem; }
.sidebar-role { margin: 0 0 20px; font-size: 0.85rem; color: var(--muted); }
.sidebar-role strong { color: var(--text); }
.menu-sidebar a {
  display: block;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: white;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.15s ease, background 0.15s ease;
}
.menu-sidebar a:hover { background: rgba(255,255,255,0.18); transform: translateX(4px); }
.sidebar-logout { margin-top: 16px; background: rgba(239,68,68,0.18) !important; }
.menu-content {
  flex: 1;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  box-sizing: border-box;
}
.menu-content .join-panel { width: min(760px, 100%); }
.menu-panel { width: min(760px, 100%); text-align: center; }
.menu-panel h1 { margin-bottom: 4px; }
.players-panel { text-align: left; }
.players-panel h3 { margin: 0 0 12px; font-size: 1rem; }
.players-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; }
.players-list li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; background: rgba(255,255,255,0.06); border-radius: 10px; font-size: 0.9rem; }
.menu-subtitle { margin: 0 0 24px; color: var(--muted); }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; text-align: left; }
.menu-card {
  display: block;
  text-decoration: none;
  color: white;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.menu-card:hover {
  transform: translateY(-4px);
  background: rgba(255,255,255,0.16);
  box-shadow: 0 14px 30px rgba(0,0,0,0.25);
}
.menu-card strong { display: block; margin-bottom: 6px; font-size: 1.1rem; }
.menu-card span { color: var(--muted); font-size: 0.92rem; }
.menu-card-waiting {
  background: rgba(255,209,102,0.12);
  border: 1px dashed rgba(255,209,102,0.5);
  cursor: default;
}

.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  text-align: center;
  padding: 24px;
}
.winner-overlay.visible { display: flex; animation: pulse 1.2s ease-in-out infinite; }
.projection-page {
  overflow: hidden;
  background: radial-gradient(circle at top, rgba(255,255,255,0.18), transparent 35%), linear-gradient(135deg, #0f172a, #7c3aed 45%, #ec4899 100%);
}
.projection-shell {
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.8s ease;
}
.projection-backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 209, 102, 0.28), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(78, 205, 196, 0.24), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(236, 72, 153, 0.28), transparent 34%),
    linear-gradient(135deg, rgba(15,23,42,0.95), rgba(124,58,237,0.8));
  background-size: 200% 200%;
  animation: shiftBackground 20s ease infinite;
  z-index: 0;
}
.winner-burst {
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  font-weight: 900;
  color: #ffe066;
  text-shadow: 0 0 22px rgba(255,224,102,0.8);
}
.winner-player {
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  font-weight: 800;
  margin-top: 8px;
}
.winner-subtitle { margin-top: 8px; color: #fef3c7; }
.projection-winner { background: rgba(0,0,0,0.6); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

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

@keyframes shiftBackground {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@media (max-width: 800px) {
  .menu-page { display: block; }
  .menu-sidebar { width: 100%; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.12); }
  .menu-content { padding: 20px 16px; }
  .menu-panel { padding: 16px; }
  .menu-grid { grid-template-columns: 1fr; }
  .top-card { grid-template-columns: repeat(3, 1fr); }
  .projection-shell { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .podium { flex-direction: column; align-items: stretch; }
  .podium-card { max-width: 100%; min-height: auto !important; transform: none !important; }
  .photo-library-columns { grid-template-columns: 1fr; }

  /* Compact the game screen so it fits one mobile viewport without scrolling */
  .game-page { padding: 6px; }
  .game-shell { gap: 6px; }
  .top-card { padding: 8px 10px; gap: 6px; }
  .photo-card, .status-card { padding: 6px 10px; }
  .status-card button, .status-card p { margin: 0; }
  .status-card button { min-width: 0; width: 100%; padding: 14px; font-size: 1rem; }
}
