/* ============================================================
   F1 TIPPSPIEL PWA – Mobile-First Stylesheet
   Aesthetic: Dark cockpit / Racing telemetry / Precision
   ============================================================ */

:root {
  --red:    #E8002D;
  --red-2:  #ff1a3e;
  --accent: #FF8000;
  --gold:   #FFD700;

  --bg:     #0a0a0b;
  --bg-2:   #111114;
  --bg-3:   #1a1a1f;
  --card:   #141418;
  --border: rgba(255,255,255,0.07);
  --border-r: rgba(232,0,45,0.35);

  --text:   #f0f0f2;
  --dim:    #8a8a96;
  --muted:  #44444f;

  --fh: 'Barlow Condensed', sans-serif;
  --fb: 'Barlow', sans-serif;
  --fm: 'JetBrains Mono', monospace;

  --tab-h:  64px;
  --top-h:  52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --r:      10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--fb);
  font-size: 15px;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Login Screen ─────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.login-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.login-stripe {
  position: absolute;
  height: 2px;
  background: var(--red);
  opacity: 0.15;
  transform: rotate(-8deg);
}
.s1 { top: 25%; left: -20%; right: -20%; opacity: 0.2; }
.s2 { top: 50%; left: -20%; right: -20%; opacity: 0.1; height: 1px; }
.s3 { top: 75%; left: -20%; right: -20%; opacity: 0.15; }

.login-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo-f1 {
  font-family: var(--fh);
  font-weight: 900;
  font-size: 56px;
  color: var(--red);
  line-height: 1;
  letter-spacing: -2px;
}
.logo-f1.sm { font-size: 24px; letter-spacing: -1px; }

.logo-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.logo-tipp {
  font-family: var(--fh);
  font-weight: 900;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 1px;
  color: var(--text);
}

.logo-year {
  font-family: var(--fm);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 2px;
}

.login-desc {
  color: var(--dim);
  line-height: 1.7;
  margin-bottom: 28px;
  font-size: 15px;
}

.login-avatars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.avatar-chip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--fh);
  font-weight: 700;
  font-size: 14px;
  color: var(--dim);
}

.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #5865F2;
  color: white;
  text-decoration: none;
  border-radius: var(--r);
  padding: 16px 32px;
  font-family: var(--fh);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  width: 100%;
  justify-content: center;
}
.btn-discord:active { transform: scale(0.97); background: #4752d9; }

.login-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

/* ── App Shell ────────────────────────────────────────────── */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ── Top Bar ──────────────────────────────────────────────── */

.topbar {
  height: var(--top-h);
  background: rgba(10,10,11,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  opacity: 0.4;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-title {
  font-family: var(--fh);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  color: var(--dim);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: blink 2s ease-in-out infinite;
}
.connection-dot.stale { background: var(--accent); animation: none; }
.connection-dot.offline { background: var(--red); animation: none; }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

.topbar-user {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--fm);
}

/* ── Content ──────────────────────────────────────────────── */

.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Tab Bar ──────────────────────────────────────────────── */

.tabbar {
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(10,10,11,0.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.tab.active { color: var(--red); }

.tab.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--red);
  border-radius: 0 0 2px 2px;
}

.tab-icon { font-size: 20px; line-height: 1; }
.tab-label {
  font-family: var(--fh);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Loading ──────────────────────────────────────────────── */

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Feed Tab ─────────────────────────────────────────────── */

.feed-header {
  padding: 16px 16px 8px;
}

.next-race-card {
  margin: 0 16px 16px;
  background: var(--card);
  border: 1px solid var(--border-r);
  border-radius: var(--r);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.next-race-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--red);
}
.next-race-label {
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 4px;
}
.next-race-name {
  font-family: var(--fh);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.countdown-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.cd-unit {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
  min-width: 52px;
}
.cd-val {
  font-family: var(--fm);
  font-weight: 600;
  font-size: 22px;
  color: var(--red);
  line-height: 1;
  display: block;
}
.cd-lbl {
  font-family: var(--fh);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}
.my-tip-preview {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tip-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-family: var(--fm);
  font-size: 12px;
}
.driver-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tip-pos-label { font-size: 9px; color: var(--muted); font-family: var(--fh); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }

/* Bonus Banner */
.bonus-banner {
  margin: 0 16px 12px;
  background: linear-gradient(135deg, rgba(255,128,0,0.08), rgba(255,128,0,0.03));
  border: 1px solid rgba(255,128,0,0.25);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}
.bonus-banner-left { flex: 1; }
.bonus-banner-tag {
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}
.bonus-banner-q { font-size: 14px; color: var(--text); line-height: 1.4; }
.bonus-banner-cta {
  background: var(--accent);
  color: #000;
  font-family: var(--fh);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Feed Messages */
.feed-section-label {
  padding: 4px 16px 8px;
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.msg {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  position: relative;
}
.msg.bot { background: rgba(232,0,45,0.03); }
.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-author {
  font-family: var(--fh);
  font-weight: 700;
  font-size: 14px;
  color: var(--dim);
}
.msg-author.bot-author { color: var(--red); }
.msg-time {
  font-family: var(--fm);
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}
.msg-channel-tag {
  font-family: var(--fh);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255,128,0,0.1);
  color: var(--accent);
  border: 1px solid rgba(255,128,0,0.2);
}
.msg-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-content a { color: var(--accent); }

/* Embeds */
.embed {
  background: var(--bg-2);
  border-left: 3px solid var(--red);
  border-radius: 0 6px 6px 0;
  padding: 12px;
  margin-top: 8px;
}
.embed-title {
  font-family: var(--fh);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
  color: var(--text);
}
.embed-field { margin-bottom: 6px; }
.embed-field-name {
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.embed-field-value { font-size: 13px; color: var(--dim); line-height: 1.5; }

.load-more-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--dim);
  font-family: var(--fh);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  text-align: center;
}
.load-more-btn:active { background: var(--bg-3); }

/* ── Chat Tab ─────────────────────────────────────────────── */

.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}
.chat-input-wrap {
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(10,10,11,0.95);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-family: var(--fb);
  font-size: 15px;
  resize: none;
  max-height: 120px;
  outline: none;
  line-height: 1.4;
}
.chat-input:focus { border-color: var(--red); }
.chat-send {
  width: 42px;
  height: 42px;
  background: var(--red);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.chat-send:active { transform: scale(0.9); }

/* ── Standings Tab ────────────────────────────────────────── */

.standings-wrap { padding: 16px; }

.my-position-card {
  background: linear-gradient(135deg, rgba(232,0,45,0.1), rgba(232,0,45,0.03));
  border: 1px solid var(--border-r);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.my-position-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--red);
}
.my-pos-label {
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 4px;
}
.my-pos-name {
  font-family: var(--fh);
  font-weight: 900;
  font-size: 28px;
  margin-bottom: 2px;
}
.my-pos-pts {
  font-family: var(--fm);
  font-size: 40px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}
.my-pos-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.standings-list { display: flex; flex-direction: column; gap: 8px; }

.standing-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s;
}
.standing-row.is-me { border-color: var(--border-r); }
.standing-row:first-child .sr-name { color: var(--gold); }

.sr-rank { font-family: var(--fm); font-size: 12px; color: var(--muted); width: 20px; text-align: center; }
.sr-medal { font-size: 20px; width: 24px; text-align: center; }
.sr-name { font-family: var(--fh); font-weight: 700; font-size: 20px; flex: 1; }
.sr-badges { font-size: 14px; }
.sr-pts { font-family: var(--fm); font-weight: 600; font-size: 20px; }

/* ── Profile/Me Tab ───────────────────────────────────────── */

.me-wrap { padding: 16px; }

.profile-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--border-r);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fh);
  font-weight: 900;
  font-size: 24px;
  color: var(--red);
}
.profile-name { font-family: var(--fh); font-weight: 900; font-size: 24px; }
.profile-discord { font-size: 12px; color: var(--muted); font-family: var(--fm); }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  text-align: center;
}
.stat-val {
  font-family: var(--fm);
  font-weight: 600;
  font-size: 32px;
  color: var(--text);
  line-height: 1;
  display: block;
}
.stat-val.gold { color: var(--gold); }
.stat-val.red { color: var(--red); }
.stat-lbl {
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
  display: block;
}

.section-title {
  font-family: var(--fh);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.badge-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.badge-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--dim);
}

/* History */
.history-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }
.history-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.hr-race { flex: 1; font-family: var(--fh); font-weight: 700; font-size: 15px; }
.hr-icons { display: flex; gap: 6px; }
.hr-icon { font-size: 12px; }
.hr-pts {
  font-family: var(--fm);
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  min-width: 36px;
  text-align: right;
}
.hr-pts.high { color: var(--gold); }

/* No-link logout */
.logout-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--muted);
  font-family: var(--fh);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 32px;
}

/* ── Bonus Modal ──────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 999;
  display: flex;
  align-items: flex-end;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r) var(--r) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-tag {
  font-family: var(--fh);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-body { padding: 20px; }
.bonus-question-text {
  font-family: var(--fh);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.3;
  margin-bottom: 20px;
}
.bonus-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bonus-option {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 15px;
  font-family: var(--fb);
  color: var(--text);
  width: 100%;
  text-align: left;
}
.bonus-option:active { transform: scale(0.98); }
.bonus-option.selected {
  background: rgba(255,128,0,0.1);
  border-color: rgba(255,128,0,0.4);
  color: var(--accent);
}
.bonus-opt-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fm);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.bonus-option.selected .bonus-opt-letter {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* ── Empty States ─────────────────────────────────────────── */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-family: var(--fh); font-weight: 700; font-size: 16px; }
