/* === Navly — Huvudstylesheet === */

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

:root {
  --bg:       #0f172a;
  --bg2:      #1e293b;
  --bg3:      #334155;
  --accent:   #3b82f6;
  --accent2:  #2563eb;
  --gron:     #22c55e;
  --rod:      #ef4444;
  --orange:   #f59e0b;
  --text:     #f1f5f9;
  --text2:    #94a3b8;
  --radius:   12px;
  --shadow:   0 4px 24px rgba(0,0,0,0.5);
}

html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  overflow: hidden;
}

/* === Vyer === */
.vy { display: none; position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; }
.vy.aktiv { display: flex; flex-direction: column; }

/* Kartvyer använder visibility istället för display:none så att Leaflet
   aldrig förlorar container-storleken — fixar svart karta i Safari. */
#vy-spectate, #vy-spel {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}
#vy-spectate.aktiv, #vy-spel.aktiv {
  visibility: visible;
  pointer-events: auto;
}

/* === Topbar === */
.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--bg3);
  flex-shrink: 0;
}
.topbar h2 { font-size: 1.1rem; font-weight: 600; }
.btn-back {
  background: none; border: none; color: var(--text);
  font-size: 1.4rem; cursor: pointer; padding: .25rem .5rem;
  line-height: 1;
}

/* === Knappar === */
.btn {
  display: block; width: 100%; padding: .85rem 1.5rem;
  border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  text-align: center; transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-prim { background: var(--accent); color: #fff; }
.btn-prim:hover { background: var(--accent2); }
.btn-sek { background: var(--bg3); color: var(--text); }
.btn-danger { background: var(--rod); color: #fff; }
.btn-prim:disabled { opacity: .4; cursor: not-allowed; }

/* === Startvy === */
#vy-start { justify-content: center; align-items: center; }
.start-inner {
  width: min(420px, 92vw);
  display: flex; flex-direction: column; gap: 1rem;
}
.logo {
  font-size: 3.5rem; font-weight: 800; text-align: center;
  letter-spacing: -.02em; user-select: none;
}
.logo-n { color: var(--accent); }
.logo-liten {
  font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em;
}
.logo-liten::first-letter { color: var(--accent); }
.tagline { text-align: center; color: var(--text2); font-size: .95rem; margin-bottom: .5rem; }
.separator { text-align: center; color: var(--text2); font-size: .85rem; position: relative; }
.separator::before, .separator::after {
  content: ''; position: absolute; top: 50%; width: 40%;
  height: 1px; background: var(--bg3);
}
.separator::before { left: 0; }
.separator::after { right: 0; }
.anslut-form { display: flex; flex-direction: column; gap: .6rem; }

/* === Inputs === */
input[type="text"], input[type="number"], .inp-text {
  width: 100%; padding: .75rem 1rem;
  background: var(--bg2); border: 1px solid var(--bg3);
  border-radius: var(--radius); color: var(--text);
  font-size: 1rem; outline: none; transition: border-color .15s;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--text2); }

/* === Regler & Info-vy === */
.regler-scroll {
  flex: 1; overflow-y: auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1rem;
  max-width: 560px; margin: 0 auto; width: 100%;
}
.regler-intro {
  color: var(--text2); font-size: .9rem; line-height: 1.6;
  padding: .75rem 1rem;
  background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.2);
  border-radius: var(--radius);
}
.regler-sektion {
  background: var(--bg2); border-radius: var(--radius);
  padding: 1rem 1rem 1rem 1.25rem;
  border-left: 3px solid var(--sek-farg, var(--accent));
}
.regler-rubrik {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem;
}
.regler-ikon { font-size: 1.2rem; line-height: 1; }
.regler-rubrik > span:last-child {
  font-weight: 700; font-size: .95rem;
  color: var(--sek-farg, var(--accent));
}
.regler-sektion ul { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.regler-sektion li {
  font-size: .875rem; line-height: 1.55; color: var(--text2);
  padding-left: 1rem; position: relative;
}
.regler-sektion li::before {
  content: '–'; position: absolute; left: 0;
  color: var(--sek-farg, var(--accent));
}
.regler-sektion li strong { color: var(--text); }
.regler-footer {
  padding: 1rem 1.25rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  background: var(--bg2); border-top: 1px solid var(--bg3);
  flex-shrink: 0;
}

/* === Setup-vy === */
.setup-content {
  padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem;
  max-width: 560px; margin: 0 auto; width: 100%;
}
.setup-label { font-size: .85rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.transport-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem;
}
.transport-btn {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .75rem .5rem; background: var(--bg2);
  border: 2px solid var(--bg3); border-radius: var(--radius);
  color: var(--text); cursor: pointer; transition: all .15s;
}
.transport-btn.aktiv { border-color: var(--accent); background: rgba(59,130,246,.15); }
.transport-ikon { font-size: 1.5rem; line-height: 1; display: flex; align-items: center; justify-content: center; }
.transport-namn { font-size: .8rem; font-weight: 600; }

.slider-row {
  display: flex; align-items: center; gap: 1rem;
}
.slider-row input[type=range] {
  flex: 1; accent-color: var(--accent);
  height: 4px; background: var(--bg3); border: none; padding: 0;
}
.slider-row span { min-width: 4rem; text-align: right; font-weight: 600; color: var(--accent); }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-tog {
  position: absolute; inset: 0; background: var(--bg3);
  border-radius: 26px; cursor: pointer; transition: .2s;
}
.slider-tog::before {
  content: ''; position: absolute;
  width: 20px; height: 20px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .2s;
}
input:checked + .slider-tog { background: var(--accent); }
input:checked + .slider-tog::before { transform: translateX(22px); }

.avancerat-toggle {
  color: var(--text2); font-size: .85rem; cursor: pointer; user-select: none;
}
#avancerat-panel { display: flex; flex-direction: column; gap: .75rem; }

#setup-karta-container {
  position: relative; width: 100%; height: 260px;
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg2);
}
#setup-karta { width: 100%; height: 100%; }
#setup-karta-overlay {
  position: absolute; inset: 0; background: rgba(15,23,42,.8);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
}

.setup-filter-info {
  font-size: .82rem; color: var(--text2); text-align: center;
  padding: .3rem 0;
}
.transport-epa-info { display: none; }
.setup-btns { display: flex; flex-direction: column; gap: .6rem; padding-bottom: 2rem; }
.setup-generera-fel {
  color: var(--rod); font-size: .85rem; text-align: center;
  padding: .25rem 0; font-weight: 500;
}
.fairness-info {
  background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3);
  border-radius: var(--radius); padding: .75rem 1rem;
  font-size: .9rem; color: var(--accent);
}

/* === Lobby-vy === */
.lobby-content {
  padding: 1.25rem; display: flex; flex-direction: column; gap: 1.25rem;
  max-width: 560px; margin: 0 auto; width: 100%;
}
.spelkod-display {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  background: var(--bg2); border-radius: var(--radius); padding: 1.25rem;
}
#lobby-spelkod {
  font-size: 2.2rem; font-weight: 800; letter-spacing: .1em; color: var(--accent);
}
.btn-dela {
  background: var(--bg3); border: none; border-radius: 8px;
  padding: .5rem .75rem; color: var(--text); font-size: 1.1rem; cursor: pointer;
}
.lobby-sub { text-align: center; color: var(--text2); font-size: .9rem; }
.spelare-lista-label {
  font-size: .85rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em;
}
.spelare-lista { display: flex; flex-direction: column; gap: .5rem; }
.spelare-item {
  display: flex; align-items: center; gap: .75rem;
  background: var(--bg2); border-radius: var(--radius); padding: .75rem 1rem;
}
.spelare-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
}
.spelare-navn { font-weight: 600; }
.spelare-badge {
  margin-left: auto; font-size: .75rem; color: var(--text2);
  background: var(--bg3); padding: .2rem .5rem; border-radius: 6px;
}
#lobby-oversikt-karta { height: 300px; border-radius: var(--radius); overflow: hidden; }
.lobby-bana-notis {
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  font-size: .88rem;
  line-height: 1.55;
  color: var(--text);
}
.lobby-cp-lista { display: flex; flex-direction: column; gap: 1rem; }
.cpl-nr-cirkel.lobby { background: var(--accent); }
.cpl-card-header.lobby { background: rgba(59,130,246,.12); border-bottom: 1px solid rgba(59,130,246,.2); }
.countdown {
  text-align: center; background: var(--bg2); border-radius: var(--radius); padding: 1.5rem;
}
#countdown-siffra {
  font-size: 4rem; font-weight: 800; color: var(--accent); line-height: 1;
}

/* === Spelvy === */
#spel-karta { position: absolute; inset: 0; }
#spel-karta .leaflet-container { background: #e8e0d8; }

.hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: .75rem 1rem;
  display: flex; align-items: center; gap: .75rem;
  background: linear-gradient(to bottom, rgba(15,23,42,.9) 0%, transparent 100%);
  pointer-events: none;
  z-index: 800;
}
.hud-hastighet {
  display: flex; align-items: baseline; gap: .2rem;
}
#hud-kmh { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.hud-enhet { font-size: .85rem; color: var(--text2); }
.hud-grans { font-size: .85rem; color: var(--text2); }
.hud-grans.over-grans { color: var(--rod); font-weight: 700; }
.hud-cp { margin-left: auto; font-size: .9rem; font-weight: 600; }
.hud-tid { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-penalty { font-size: .8rem; font-weight: 700; color: var(--rod); font-variant-numeric: tabular-nums; }
.hud-bonus { font-size: .8rem; font-weight: 700; color: var(--gron); font-variant-numeric: tabular-nums; }
.hud-bonus-countdown {
  font-size: .8rem; font-weight: 700; color: var(--orange);
  font-variant-numeric: tabular-nums;
  animation: puls-orange 1.5s ease-in-out infinite;
}
.hud-bonus-countdown.varning { color: var(--rod); animation: puls-rod 0.8s ease-in-out infinite; }
@keyframes puls-orange { 0%,100%{opacity:1} 50%{opacity:.65} }
.hud-cp-btn {
  pointer-events: all; background: rgba(30,41,59,.9); border: none;
  border-radius: 8px; padding: .4rem .6rem; color: var(--text);
  font-size: 1rem; cursor: pointer;
}

.violation-varning {
  position: absolute; bottom: .5rem; left: 50%; transform: translateX(-50%);
  background: rgba(239,68,68,.9); color: white;
  padding: .35rem .85rem; border-radius: 20px; font-size: .85rem; font-weight: 700;
  pointer-events: none;
}

.speed-border {
  position: absolute; inset: 0; z-index: 700; pointer-events: none;
  border: 4px solid var(--rod);
  animation: puls-rod 0.8s ease-in-out infinite;
}
@keyframes puls-rod {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.cp-notis {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(34,197,94,.95); color: white;
  padding: 1.25rem 2rem; border-radius: var(--radius);
  text-align: center; font-size: 1.1rem; font-weight: 700;
  z-index: 900; max-width: 80vw;
}

.host-toast {
  position: absolute; top: 4.5rem; left: 50%; transform: translateX(-50%);
  background: rgba(30,41,59,.95); border: 1px solid var(--bg3);
  padding: .75rem 1.25rem; border-radius: var(--radius);
  font-size: .9rem; max-width: 80vw; text-align: center;
  z-index: 900;
}

/* === Centrera-knapp (spelvy) === */
.btn-centrera {
  position: absolute; bottom: 3rem; right: 1rem; z-index: 800;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(30,41,59,.92); border: 2px solid var(--bg3);
  color: var(--text); font-size: 1.35rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
  transition: border-color .2s, background .2s, color .2s;
  pointer-events: all;
}
.btn-centrera.aktiv {
  border-color: var(--accent);
  background: rgba(59,130,246,.2);
  color: var(--accent);
}

/* === Checkpoint-lista === */
#cp-oversikt-karta {
  height: 280px; width: 100%; flex-shrink: 0; background: #1a2433;
}
.cpl-oversikt-ikon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800; color: white;
  border: 2px solid rgba(255,255,255,.8);
  box-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.cpl-start-ikon {
  background: white; color: #0f172a;
  padding: .2rem .5rem; border-radius: 4px;
  font-size: .7rem; font-weight: 800; letter-spacing: .04em;
  border: 2px solid #0f172a; white-space: nowrap;
  box-shadow: 0 1px 6px rgba(0,0,0,.5);
}

.cp-bilder-lista { padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }

.cpl-kort {
  background: var(--bg2); border-radius: var(--radius);
  border: 1px solid var(--bg3); overflow: hidden;
}
.cpl-kort.nadd  { border-color: rgba(34,197,94,.5); }
.cpl-kort.nasta { border-color: rgba(245,158,11,.6); }

.cpl-card-header {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem;
  background: rgba(0,0,0,.2); border-bottom: 1px solid var(--bg3);
}
.cpl-nr-cirkel {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
  background: var(--accent); color: white;
}
.cpl-nr-cirkel.nadd  { background: var(--gron);   color: #000; }
.cpl-nr-cirkel.nasta { background: var(--orange); color: #000; }
.cpl-nr-cirkel.last  { background: var(--bg3); }
.cpl-card-titel { flex: 1; font-size: 1rem; font-weight: 700; }
.cpl-badge {
  font-size: .75rem; font-weight: 600;
  padding: .25rem .65rem; border-radius: 20px;
  background: rgba(148,163,184,.15); color: var(--text2); flex-shrink: 0;
}
.cpl-badge.nadd  { background: rgba(34,197,94,.2);  color: var(--gron); }
.cpl-badge.nasta { background: rgba(245,158,11,.2); color: var(--orange); }

.cpl-karta { width: 100%; height: 200px; background: #1a2433; display: block; }

.cpl-bild-wrap { position: relative; cursor: pointer; }
.cpl-bild { width: 100%; height: 160px; object-fit: cover; display: block; }
.cpl-bild-fs-btn {
  position: absolute; bottom: .5rem; right: .5rem;
  background: rgba(0,0,0,.7); color: white; border: none;
  border-radius: 6px; padding: .3rem .6rem; font-size: .8rem; cursor: pointer;
}

.cpl-info {
  padding: .75rem 1rem; display: flex; flex-direction: column; gap: .45rem;
  border-top: 1px solid var(--bg3);
}
.cpl-info-rad { display: flex; align-items: baseline; gap: .5rem; font-size: .85rem; }
.cpl-info-ikon { flex-shrink: 0; }
.cpl-info-text { color: var(--text2); }


/* === Checkpoint-detaljvy === */
#vy-cp-detalj { overflow: hidden; }

.cp-detalj-scroll {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}

.cp-detalj-karta {
  width: 100%; height: 300px; flex-shrink: 0;
  background: var(--bg2);
}
.cp-detalj-karta.stor { height: 400px; }

.cp-detalj-bild-wrap {
  position: relative; flex-shrink: 0;
}
.cp-detalj-bild {
  width: 100%; display: block; max-height: 260px; object-fit: cover;
}
.cp-detalj-bild-fullscreen {
  position: absolute; bottom: .5rem; right: .5rem;
  background: rgba(0,0,0,.7); color: white; border: none;
  border-radius: 6px; padding: .3rem .7rem; font-size: .8rem; cursor: pointer;
}

.cp-detalj-fakta {
  padding: 1rem; display: flex; flex-direction: column; gap: .75rem;
  background: var(--bg2); margin: .75rem; border-radius: var(--radius);
}
.cp-fakta-rad { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.cp-fakta-etikett { font-size: .8rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; flex-shrink: 0; }
.cp-fakta-varde { font-size: .9rem; font-weight: 600; text-align: right; }
.cp-fakta-varde.mono { font-family: monospace; font-size: .85rem; }

.cp-detalj-badge {
  margin-left: auto; font-size: .75rem; font-weight: 600;
  padding: .2rem .6rem; border-radius: 20px;
}
.cp-detalj-badge.nadd  { background: rgba(34,197,94,.2);  color: var(--gron); }
.cp-detalj-badge.nasta { background: rgba(245,158,11,.2); color: var(--orange); }
.cp-detalj-badge.kvar  { background: rgba(148,163,184,.15); color: var(--text2); }

.cp-fullscreen {
  position: fixed; inset: 0; background: #000; z-index: 1000;
  display: flex; flex-direction: column;
}
.cp-fs-stang {
  position: absolute; top: 1rem; right: 1rem; z-index: 1001;
  background: rgba(0,0,0,.7); border: none; color: white;
  font-size: 1.5rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
#cp-fs-innehall { flex: 1; }
#cp-fs-innehall iframe { width: 100%; height: 100%; border: none; }
#cp-fs-innehall img { width: 100%; height: 100%; object-fit: contain; }

/* === Resultatvy === */
.resultat-tabell {
  width: 100%; border-collapse: collapse; margin: 1rem;
  font-size: .85rem;
}
.resultat-tabell th {
  background: var(--bg2); padding: .6rem; text-align: left;
  color: var(--text2); font-size: .75rem; text-transform: uppercase;
}
.resultat-tabell td { padding: .6rem; border-bottom: 1px solid var(--bg2); }
.resultat-tabell tr:nth-child(1) td { font-weight: 700; }

.podium {
  display: flex; align-items: flex-end; justify-content: center; gap: 1rem;
  padding: 1.5rem 1rem 0;
}
.podium-plats {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  flex: 1; max-width: 100px;
}
.podium-ikon { font-size: 1.5rem; }
.podium-namn { font-size: .8rem; font-weight: 600; text-align: center; word-break: break-word; }
.podium-tid { font-size: .75rem; color: var(--text2); }
.podium-steg {
  width: 100%; background: var(--bg2); border-radius: 8px 8px 0 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800;
}
.podium-plats:nth-child(1) .podium-steg { height: 80px; background: rgba(251,191,36,.3); }
.podium-plats:nth-child(2) .podium-steg { height: 60px; }
.podium-plats:nth-child(3) .podium-steg { height: 45px; }

/* === Violations-vy === */
#violations-karta-container {
  height: 200px; margin: 0;
}
#violations-karta { width: 100%; height: 100%; }
.violations-lista { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.violation-item {
  background: var(--bg2); border-radius: var(--radius); padding: .75rem 1rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.violation-header { display: flex; justify-content: space-between; align-items: center; }
.violation-kmh { font-weight: 700; color: var(--rod); }
.violation-penalty { font-weight: 700; color: var(--orange); }
.violation-meta { font-size: .8rem; color: var(--text2); }
.violation-status { font-size: .75rem; }
.violation-status.none {}
.violation-status.requested { color: var(--orange); }
.violation-status.approved { color: var(--gron); }
.violation-status.rejected { color: var(--rod); }
.btn-bestrid {
  background: none; border: 1px solid var(--bg3); border-radius: 6px;
  color: var(--text2); padding: .3rem .75rem; font-size: .8rem; cursor: pointer; margin-top: .25rem; align-self: flex-start;
}

/* === Host-panel === */
.host-panel-content { padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.host-section-label { font-size: .85rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.host-msg-row { display: flex; gap: .5rem; }
.host-msg-row .inp-text { flex: 1; }
.host-msg-row .btn { width: auto; padding: .75rem 1.25rem; }
.bestridande-item {
  background: var(--bg2); border-radius: var(--radius); padding: .75rem 1rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.bestridande-btns { display: flex; gap: .5rem; }
.bestridande-btns .btn { width: auto; padding: .5rem 1rem; font-size: .85rem; }
.abort-trigger {
  background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: .8rem; padding: .5rem 0;
  text-align: left; margin-top: 1rem;
  transition: color .15s;
}
.abort-trigger:hover { color: var(--rod); }

/* === Dialog === */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.dialog {
  background: var(--bg2); border-radius: var(--radius);
  padding: 1.5rem; width: min(380px, 92vw);
  display: flex; flex-direction: column; gap: .85rem;
  max-height: 90vh; overflow-y: auto;
}
.dialog h3 { font-size: 1.1rem; }
.dialog p { color: var(--text2); font-size: .9rem; }
.dialog-lista {
  margin: 0; padding-left: 1.25rem;
  color: var(--text2); font-size: .85rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.dialog-label { font-size: .82rem; color: var(--text2); font-weight: 500; }
.abort-confirm-input { font-family: monospace; letter-spacing: .05em; }
.dialog-btns { display: flex; gap: .5rem; }
.dialog-btns .btn { flex: 1; }

/* === Abort-overlay === */
.abort-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000;
}
.abort-overlay-box {
  text-align: center; padding: 2rem;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.abort-overlay-ikon { font-size: 3rem; }
.abort-overlay-msg { font-size: 1.1rem; font-weight: 600; max-width: 280px; line-height: 1.4; }
.abort-overlay-sub { font-size: .9rem; color: var(--text2); }

/* === Resultat-banner === */
.resultat-banner {
  background: rgba(245,158,11,.12); border-bottom: 1px solid rgba(245,158,11,.3);
  padding: .75rem 1.25rem; font-size: .9rem; color: var(--orange); text-align: center;
}
.resultat-dnf { color: var(--text2); font-style: italic; }

/* === Leaflet overrides === */
.leaflet-control-attribution { display: none !important; }
.leaflet-control-zoom { display: none; }

.leaflet-grab {
  cursor: grab;
}

/* Spelarmarkör */
.spelare-marker {
  border-radius: 50%; border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.spelare-marker.pulserar {
  animation: pulsera 1.5s ease-out infinite;
}
@keyframes pulsera {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,.5); }
  70% { box-shadow: 0 0 0 12px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* Checkpoint-ikon */
.cp-ikon {
  background: var(--accent); color: white;
  border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
  border: 3px solid white; box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.cp-ikon.nasta {
  background: var(--orange); width: 44px; height: 44px;
  font-size: 1rem; animation: pulsera 1.5s ease-out infinite;
}

/* === Live-rankningspanel === */
.live-ranking-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 850;
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.live-ranking-panel.kollapsad { transform: translateY(calc(100% - 40px)); }

.lr-tab {
  height: 40px;
  background: rgba(15,23,42,.92);
  border-top: 1px solid var(--bg3);
  display: flex; align-items: center; gap: .5rem;
  padding: 0 1rem;
  cursor: pointer;
  user-select: none;
  pointer-events: all;
}
.lr-tab-ikon { font-size: 1rem; color: var(--text2); }
.lr-tab-text { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text2); flex: 1; }
.lr-tab-chevron { font-size: .7rem; color: var(--text2); transition: transform .3s; }
.live-ranking-panel:not(.kollapsad) .lr-tab-chevron { transform: rotate(180deg); }

.lr-content {
  background: rgba(15,23,42,.95);
  border-top: 1px solid var(--bg3);
  max-height: 40vh; overflow-y: auto;
  pointer-events: all;
}
.lr-lista { padding: .4rem 0; }
.lr-rad {
  display: grid;
  grid-template-columns: 20px 14px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: .82rem;
}
.lr-rad.lr-jeg {
  background: rgba(59,130,246,.15);
  border-left: 3px solid #3b82f6;
  padding-left: 5px;
}
.lr-rang { font-weight: 700; font-size: .75rem; color: var(--text2); text-align: right; }
.lr-dot { width: 10px; height: 10px; border-radius: 50%; }
.lr-navn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-cp-count { font-size: .7rem; color: var(--text2); font-weight: 400; margin-left: .3rem; }
.lr-tid-blok { text-align: right; }
.lr-tid-main { font-size: .82rem; font-weight: 600; display: block; }
.lr-tid-main.lr-leder { color: var(--gron); }
.lr-gap-text { font-size: .7rem; color: var(--text2); display: block; }
.lr-tillagg { font-size: .7rem; margin-top: .1rem; }
.lr-straff { color: var(--orange); }
.lr-bonus-tid { color: var(--gron); margin-left: .2rem; }
.spectate-bonus-timer { font-size: .72rem; font-weight: 700; color: var(--orange); margin-left: .3rem; font-variant-numeric: tabular-nums; }
.spectate-bonus-timer.varning { color: var(--rod); }

/* === Bonus-overlay === */
.bonus-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 2500;
}
.bonus-box {
  background: var(--bg2);
  border: 2px solid var(--orange);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
  width: min(320px, 90vw);
  animation: bonus-in .35s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes bonus-in {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.bonus-ikon { font-size: 2.5rem; animation: puls-rod 1s ease-in-out infinite; }
.bonus-titel { font-size: 1.15rem; font-weight: 800; color: var(--orange); letter-spacing: .03em; }
.bonus-info { font-size: .95rem; color: var(--text2); }
.bonus-info strong { color: var(--orange); font-size: 1.1rem; }
.bonus-btns { display: flex; gap: .75rem; width: 100%; margin-top: .25rem; }
.bonus-btns .btn { flex: 1; }

/* === Bonus-claim-knapp === */
.btn-bonus-claim {
  position: absolute;
  bottom: 5.5rem; left: 50%; transform: translateX(-50%);
  z-index: 900;
  background: var(--orange); color: #000;
  border: none; border-radius: var(--radius);
  padding: .75rem 1.5rem; font-size: 1rem; font-weight: 800;
  cursor: pointer; pointer-events: all;
  box-shadow: 0 4px 20px rgba(245,158,11,.5);
  animation: bonus-pulse 1.2s ease-in-out infinite;
}
@keyframes bonus-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(245,158,11,.5); }
  50%       { box-shadow: 0 4px 30px rgba(245,158,11,.9); }
}

/* === Race-overlay === */
.race-overlay {
  position: absolute; top: 5rem; left: 50%; transform: translateX(-50%);
  z-index: 950; pointer-events: none;
}
.race-box {
  background: rgba(30,41,59,.95);
  border: 2px solid #a855f7;
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  display: flex; align-items: center; gap: .65rem;
  min-width: 220px; max-width: 80vw;
}
.race-ikon { font-size: 1.3rem; }
.race-msg { font-size: .9rem; font-weight: 700; color: #c084fc; }

/* === Host-panel-knapp === */
.btn-host-panel {
  position: absolute; bottom: 7rem; right: 1rem;
  z-index: 800;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(30,41,59,.92); border: 2px solid var(--bg3);
  color: var(--text); font-size: 1.3rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
  pointer-events: all;
}
.btn-host-panel:hover { border-color: var(--accent); }

/* === Bonus-lista i host-panel === */
.host-bonus-info {
  font-size: .82rem; color: var(--text2); line-height: 1.5;
}
.host-bonus-lista {
  display: flex; flex-direction: column; gap: .4rem; margin-top: .25rem;
}
.bonus-cp-rad {
  display: flex; align-items: center; gap: .75rem;
  background: var(--bg2); border-radius: 8px;
  padding: .55rem .9rem;
}
.bonus-cp-nr {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg3); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 800; flex-shrink: 0;
}
.bonus-cp-nr.race { background: rgba(168,85,247,.3); border: 1px solid #a855f7; }
.bonus-cp-nr.aktiv { background: var(--orange); color: #000; }
.bonus-cp-info { flex: 1; font-size: .8rem; color: var(--text2); }
.bonus-cp-btn {
  background: var(--bg3); border: 1px solid var(--bg3); color: var(--text);
  border-radius: 6px; padding: .3rem .75rem; font-size: .78rem; cursor: pointer;
  transition: all .15s; flex-shrink: 0;
}
.bonus-cp-btn:hover { border-color: var(--orange); color: var(--orange); }
.bonus-cp-btn:disabled { opacity: .4; cursor: not-allowed; }
.bonus-cp-btn.aktiv { background: rgba(245,158,11,.15); border-color: var(--orange); color: var(--orange); }
.host-bonus-aktiv { font-size: .85rem; color: var(--orange); padding: .5rem 0; }

/* === Hjälpklasser === */
.dold { display: none !important; }

/* === Spinner === */
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--bg3); border-top-color: var(--accent);
  animation: snurra .8s linear infinite;
}
@keyframes snurra { to { transform: rotate(360deg); } }

/* === Responsivt === */
@media (min-width: 600px) {
  .setup-content, .lobby-content { padding: 1.5rem 2rem; }
}

/* === Race/bonus CP-markör-pulsering === */
.cp-ikon.bonus-aktiv {
  animation: puls-bonus 0.9s ease-in-out infinite !important;
  border-color: var(--orange) !important;
}
@keyframes puls-bonus {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,.7); }
  50%       { box-shadow: 0 0 0 10px rgba(245,158,11,0); }
}
.cp-ikon.race-prox {
  animation: puls-race 0.75s ease-in-out infinite !important;
  border-color: #a855f7 !important;
}
@keyframes puls-race {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,85,247,.7); }
  50%       { box-shadow: 0 0 0 10px rgba(168,85,247,0); }
}

/* === Lobby race-info === */
.lobby-race-info {
  text-align: center; color: #a855f7;
  font-size: .9rem; font-weight: 700;
  background: rgba(168,85,247,.1); border: 1px solid rgba(168,85,247,.3);
  border-radius: var(--radius); padding: .6rem 1rem; margin: .5rem 0 0;
}

/* === Åskådarvy === */
.btn-spectate {
  background: rgba(168,85,247,.2); color: #c084fc;
  border: 1px solid rgba(168,85,247,.4); border-radius: var(--radius);
  padding: .75rem 1.5rem; font-size: 1rem; font-weight: 600; cursor: pointer;
  width: 100%; transition: background .15s;
}
.btn-spectate:hover { background: rgba(168,85,247,.3); }

.spectate-spelkod-badge {
  margin-left: auto; background: var(--bg3); color: var(--text2);
  font-size: .78rem; font-weight: 700; padding: .25rem .6rem;
  border-radius: 6px; letter-spacing: .05em;
}

#spectate-karta {
  width: 100%; flex: 1; min-height: 0;
}

.spectate-ranking-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 850;
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.spectate-ranking-panel.kollapsad { transform: translateY(calc(100% - 40px)); }
.spectate-ranking-panel:not(.kollapsad) .lr-tab-chevron { transform: rotate(180deg); }

.spectate-ranking-content {
  background: rgba(15,23,42,.95);
  border-top: 1px solid var(--bg3);
  max-height: 40vh; overflow-y: auto;
}

.spectate-panel {
  background: var(--bg2);
  border-top: 1px solid var(--bg3);
  padding: .75rem 1rem;
}

.spectate-panel-rubrik {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text2); margin-bottom: .4rem;
}

.spectate-feed {
  display: flex; flex-direction: column; gap: .3rem;
  max-height: 200px; overflow-y: auto;
}

.spectate-feed-rad {
  font-size: .82rem; color: var(--text); padding: .3rem 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.spectate-feed-rad:last-child { border-bottom: none; }

.spectate-feed-tid {
  font-size: .72rem; color: var(--text2); margin-right: .4rem;
}

/* === iPhone PWA / standalone safe-area === */
@media (display-mode: standalone) {
  .hud {
    padding-top: env(safe-area-inset-top);
  }
  .topbar {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }
  .host-toast {
    top: calc(4.5rem + env(safe-area-inset-top));
  }
  .btn-centrera {
    bottom: calc(3rem + env(safe-area-inset-bottom));
  }
  .btn-hinder {
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }
  .btn-host-panel {
    bottom: calc(7rem + env(safe-area-inset-bottom));
  }
  .btn-bonus-claim {
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }
  .live-ranking-panel {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* === Host-roll-toggle === */
.host-roll-toggle {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.host-roll-toggle-rad {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .95rem;
}
.toggle-label {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-label input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg3);
  border-radius: 12px;
  transition: background .2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-label input:checked + .toggle-slider { background: var(--accent); }
.toggle-label input:checked + .toggle-slider::before { transform: translateX(20px); }
#roll-text { font-weight: 600; }
.roll-beskrivning { font-size: .82rem; color: var(--text2); margin: 0; transition: opacity .3s ease; }

/* === Landskapsläge-blockering (endast mobil i PWA-läge) === */
#landscape-overlay { display: none; }

@media (orientation: landscape) and (display-mode: standalone) and (max-width: 768px) {
  body::before {
    content: "Vrid telefonen till stående läge";
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #0f172a;
    color: white;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
  }
}
