/* Dark-first design — gaming night palette */
:root {
  --bg:          #0e0e1c;
  --surface:     #15152a;
  --card:        #1c1c34;
  --border:      rgba(139, 92, 246, 0.14);
  --border-2:    rgba(255, 255, 255, 0.06);
  --accent:      #8b5cf6;
  --accent-h:    #7c3aed;
  --accent-2:    #06b6d4;
  --yes:         #10b981;
  --maybe:       #f59e0b;
  --danger:      #ef4444;
  --text:        #e2e2f0;
  --muted:       #7070a0;
  --font:        'Outfit', system-ui, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:       #f2f2fa;
    --surface:  #e8e8f6;
    --card:     #ffffff;
    --border:   rgba(139, 92, 246, 0.18);
    --border-2: rgba(0, 0, 0, 0.07);
    --text:     #1a1a30;
    --muted:    #6060a0;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg:       #f2f2fa;
  --surface:  #e8e8f6;
  --card:     #ffffff;
  --border:   rgba(139, 92, 246, 0.18);
  --border-2: rgba(0, 0, 0, 0.07);
  --text:     #1a1a30;
  --muted:    #6060a0;
  color-scheme: light;
}

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

html { height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0;
}

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3 { text-wrap: balance; line-height: 1.2; margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login overlay ──────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed; inset: 0;
  z-index: 100;
  background: rgba(14, 14, 28, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-icon {
  font-size: 40px;
  text-align: center;
  line-height: 1;
}

.login-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.login-card p {
  text-align: center;
  color: var(--muted);
  margin: -12px 0 0;
  font-size: 0.9rem;
}

/* ── Upcoming dates ──────────────────────────────────────────────────────── */
.dates-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: thin;
}

.date-card {
  min-width: 120px;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 11px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.date-card:hover { border-color: var(--accent); }

.date-card--active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.12);
}

.date-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  min-height: 12px;
  line-height: 1;
}

.date-card-date {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.date-card-cd {
  font-size: 0.78rem;
  color: var(--muted);
}

.dc-summary {
  display: flex;
  gap: 7px;
  margin-top: 5px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.dc-yes   { color: var(--yes); }
.dc-maybe { color: var(--maybe); }
.dc-no    { color: var(--muted); }

.dc-topgame {
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.date-card-note {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-date-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 16px;
  min-height: 18px;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.page-inner {
  max-width: 960px;
  margin: 0 auto;
  padding-block: 32px 48px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-block: 36px 28px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 32px;
}

.site-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 500;
}

.date-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

#countdown-text {
  color: var(--muted);
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

/* ── Two-column grid ─────────────────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 640px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ── Section ─────────────────────────────────────────────────────────────── */
.section {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-2);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .count {
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}

.section-body {
  padding: 8px 0;
}

.section-form {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── RSVP list ──────────────────────────────────────────────────────────── */
.rsvp-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rsvp-list:empty::after {
  content: 'Noch keine Rückmeldungen.';
  display: block;
  padding: 16px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.rsvp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
}

.rsvp-item:not(:last-child) {
  border-bottom: 1px solid var(--border-2);
}

.rsvp-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chip {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 2px 10px;
  flex-shrink: 0;
}
.status-chip.yes    { background: rgba(16, 185, 129, 0.15); color: var(--yes); }
.status-chip.maybe  { background: rgba(245, 158, 11, 0.15); color: var(--maybe); }
.status-chip.no     { background: rgba(100, 100, 160, 0.15); color: var(--muted); }

/* ── Proposals list ──────────────────────────────────────────────────────── */
.proposals-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.proposals-list:empty::after {
  content: 'Noch keine Vorschläge.';
  display: block;
  padding: 16px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.proposal-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
}

.proposal-item:not(:last-child) {
  border-bottom: 1px solid var(--border-2);
}

.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  gap: 2px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.vote-btn:hover { border-color: var(--accent); color: var(--accent); }

.vote-btn.voted {
  background: rgba(139, 92, 246, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

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

.proposal-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.proposal-game {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proposal-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.proposal-desc {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 8px;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 13px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus {
  border-color: var(--accent);
}

input[type="date"] {
  color-scheme: inherit;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

/* ── Status select ──────────────────────────────────────────────────────── */
.status-select {
  display: flex;
  gap: 6px;
}

.status-select input[type="radio"] { display: none; }

.status-select label {
  flex: 1;
  text-align: center;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted);
  margin: 0;
  transition: all 0.15s;
  user-select: none;
}

.status-select input[value="yes"]:checked     + label { background: rgba(16,185,129,0.18); border-color: var(--yes); color: var(--yes); }
.status-select input[value="maybe"]:checked   + label { background: rgba(245,158,11,0.18); border-color: var(--maybe); color: var(--maybe); }
.status-select input[value="no"]:checked      + label { background: rgba(100,100,160,0.18); border-color: var(--muted); color: var(--muted); }
.status-select input[value="bug"]:checked     + label { background: rgba(239,68,68,0.15); border-color: #ef4444; color: #ef4444; }
.status-select input[value="feature"]:checked + label { background: rgba(139,92,246,0.15); border-color: var(--accent); color: var(--accent); }
.status-select label:hover { border-color: var(--accent); color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

/* ── Name banner ────────────────────────────────────────────────────────── */
#name-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

#name-bar span { flex: 1; color: var(--muted); }
#name-bar strong { color: var(--text); }
#name-bar .edit-name-btn {
  font-size: 0.8rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
}
#name-bar .edit-name-btn:hover { text-decoration: underline; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200;
  white-space: nowrap;
}

#toast.show { transform: translateX(-50%) translateY(0); }
#toast.ok   { color: var(--yes); border-color: rgba(16,185,129,0.3); }
#toast.err  { color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-2);
  margin: 4px 0;
}

.empty-state {
  padding: 24px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-link {
  display: block;
  text-align: center;
  margin-top: 40px;
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.5;
}

.admin-link:hover { opacity: 1; }

/* focus */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
