/* =====================================================
   Green / Red Flag — Design System
   Dark cosmic theme with glassmorphism cards.
   ===================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700;800&display=swap');

/* --- Design Tokens --- */
:root {
  /* Palette */
  --bg-base:          #0b0b1a;
  --bg-grad-from:     #0f0c29;
  --bg-grad-mid:      #1a0b2e;
  --bg-grad-to:       #0d1b3e;

  --brand-from:       #6366f1;
  --brand-to:         #ec4899;
  --green-from:       #10b981;
  --green-to:         #14b8a6;
  --red-from:         #f43f5e;
  --red-to:           #f97316;

  /* Glass card */
  --glass-bg:         rgba(255, 255, 255, 0.05);
  --glass-border:     rgba(255, 255, 255, 0.10);
  --glass-blur:       blur(20px);

  /* Text */
  --text-primary:     #f0f0ff;
  --text-muted:       rgba(240, 240, 255, 0.50);
  --text-strong:      #ffffff;

  /* Misc */
  --radius-sm:        0.625rem;
  --radius-md:        1rem;
  --radius-lg:        1.25rem;
  --radius-xl:        1.75rem;

  --shadow-card:      0 8px 32px rgba(0, 0, 0, 0.40);
  --shadow-glow-green: 0 0 24px rgba(16, 185, 129, 0.35);
  --shadow-glow-red:   0 0 24px rgba(244, 63, 94, 0.35);
  --shadow-glow-brand: 0 0 24px rgba(99, 102, 241, 0.40);

  --transition-fast:  0.18s ease;
  --transition-med:   0.30s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(99, 102, 241, 0.20) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(20, 20, 60, 0.80) 0%, var(--bg-base) 80%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* --- Typography --- */
h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h2 {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

p { font-size: 0.95rem; }

/* --- Gradient text helper --- */
.gradient-text {
  background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Glass card --- */
.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

/* --- Layout wrappers --- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem 4rem;
}

.page-narrow {
  width: 100%;
  max-width: 480px;
}

.page-wide {
  width: 100%;
  max-width: 720px;
}

/* --- Buttons --- */
button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    filter var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid var(--brand-from);
  outline-offset: 3px;
}

button:active { transform: scale(0.97); }

button.primary {
  background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  color: #fff;
  font-size: 1rem;
  padding: 0.9rem 2rem;
}

button.primary:hover {
  filter: brightness(1.12);
  box-shadow: var(--shadow-glow-brand);
}

button.ghost {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.10);
}

button.danger-ghost {
  background: transparent;
  border: 1px solid rgba(244, 63, 94, 0.40);
  color: #f43f5e;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

button.danger-ghost:hover {
  background: rgba(244, 63, 94, 0.12);
  border-color: #f43f5e;
  box-shadow: var(--shadow-glow-red);
}

/* --- Vote buttons (huge, mobile-first) --- */
.vote-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.vote-btn {
  height: 120px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: var(--radius-lg);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-med);
}

.vote-btn .vote-icon {
  font-size: 2rem;
  line-height: 1;
}

.vote-btn.green {
  background: linear-gradient(135deg, var(--green-from), var(--green-to));
}

.vote-btn.green:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-glow-green);
}

.vote-btn.red {
  background: linear-gradient(135deg, var(--red-from), var(--red-to));
}

.vote-btn.red:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-glow-red);
}

/* voted-state highlight */
.vote-btn.voted-choice {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* --- Inputs --- */
input[type="text"],
input[type="search"],
input:not([type]) {
  font: inherit;
  font-size: 1rem;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input::placeholder { color: var(--text-muted); }

input:focus {
  outline: none;
  border-color: var(--brand-from);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* --- Room code display --- */
.room-code {
  font-family: 'Space Grotesk', ui-monospace, monospace;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.35em;
  background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
  text-align: center;
}

.code {
  font-family: ui-monospace, 'Space Grotesk', monospace;
  letter-spacing: 0.08em;
}

/* --- Muted text --- */
.muted {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* --- Progress bar --- */
.progress-bar-wrap {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-from), var(--brand-to));
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 0%;
}

/* --- Result bars (reveal) --- */
.result-bar-row {
  margin: 0.5rem 0;
}

.result-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.result-bar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-bar-fill.green {
  background: linear-gradient(90deg, var(--green-from), var(--green-to));
}

.result-bar-fill.red {
  background: linear-gradient(90deg, var(--red-from), var(--red-to));
}

/* --- Player chip / vote chip --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.chip.green-chip {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.chip.red-chip {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

/* --- Vote status list (admin) --- */
.vote-status-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.vote-status-list .chip-voted {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
  animation: slideIn 0.25s ease;
}

.vote-status-list .chip-waiting {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.15);
}

/* --- Player list (admin) --- */
.player-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.player-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: fadeUp 0.2s ease;
}

.player-list-item .player-name {
  font-weight: 600;
  font-size: 0.95rem;
}

/* --- Result vote chips --- */
.result-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

/* --- Dividers & spacing --- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.5rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: 0.75rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

/* --- Section label --- */
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.20);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
}

/* --- Separator --- */
.sep {
  height: 1px;
  background: var(--glass-border);
  margin: 1rem 0;
}

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

/* --- Animations --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.animate-in {
  animation: fadeUp 0.35s ease both;
}

.pulsing {
  animation: pulse 2s ease-in-out infinite;
}

/* =====================================================
   PAGE: index.html
   ===================================================== */

.landing-hero {
  text-align: center;
  padding: 3rem 0 2rem;
  animation: fadeUp 0.5s ease both;
}

.landing-hero .tagline {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: 0.5rem;
}

.landing-actions {
  display: grid;
  gap: 1rem;
  width: 100%;
  margin-top: 1.5rem;
}

.landing-actions .card {
  animation: fadeUp 0.4s ease both;
}

.landing-actions .card:nth-child(2) {
  animation-delay: 0.08s;
}

.landing-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.landing-card-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.join-input-group {
  display: flex;
  gap: 0.5rem;
}

.join-input-group input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.join-input-group button {
  white-space: nowrap;
  flex-shrink: 0;
}

/* =====================================================
   PAGE: admin.html
   ===================================================== */

.admin-header {
  text-align: center;
  padding: 2rem 0 1rem;
  width: 100%;
  animation: fadeUp 0.4s ease both;
}

.admin-header .subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 0.25rem;
}

.code-display-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.copy-btn.copied {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

.join-url-text {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: ui-monospace, monospace;
  word-break: break-all;
}

.admin-grid {
  display: grid;
  gap: 1rem;
  width: 100%;
}

.question-text-big {
  font-size: clamp(1.2rem, 4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.3;
  margin: 0.5rem 0 1rem;
  color: var(--text-strong);
}

.voted-summary {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.voted-summary span {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ended-state {
  text-align: center;
  padding: 2rem 0;
}

.ended-state h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

/* =====================================================
   PAGE: player.html
   ===================================================== */

.player-header {
  text-align: center;
  padding: 2rem 0 1rem;
  animation: fadeUp 0.4s ease both;
}

.player-header .room-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.join-form-card {
  animation: fadeUp 0.35s ease both;
}

.lobby-status {
  text-align: center;
  padding: 1.5rem;
}

.lobby-status .pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-from);
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
  margin-right: 0.4rem;
}

.voted-state {
  text-align: center;
  padding: 1.5rem;
}

.voted-state .voted-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.voted-state h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.voted-choice-display {
  margin-top: 1rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
}

.voted-choice-display.green {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.40);
  color: #6ee7b7;
}

.voted-choice-display.red {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.40);
  color: #fda4af;
}

/* =====================================================
   PAGE: report.html
   ===================================================== */

.report-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
  animation: fadeUp 0.4s ease both;
}

.report-header h1 {
  font-size: clamp(1.6rem, 5vw, 2.5rem);
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.80rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
}

.report-players-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
}

.question-card {
  animation: fadeUp 0.35s ease both;
}

.question-number {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.question-card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.report-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.home-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: background var(--transition-fast);
}

.home-link:hover {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-primary);
}

/* --- Responsive tweaks --- */
@media (min-width: 600px) {
  .landing-actions {
    grid-template-columns: 1fr 1fr;
  }

  .admin-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .vote-buttons {
    gap: 1.25rem;
  }
}

@media (max-width: 400px) {
  .vote-buttons {
    grid-template-columns: 1fr;
  }

  .vote-btn {
    height: 90px;
  }
}
