/* ---------- teman ---------- */

:root {
  --bg: #bfe6ff;
  --stage-bg: radial-gradient(ellipse at 50% 40%, #e3f5ff 0%, #bfe6ff 60%, #9bd4f7 100%);
  --scrim: rgba(227, 245, 255, 0.95);
  --glass: rgba(255, 255, 255, 0.94);
  --panel: #ffffff;
  --card: #f1f5fb;
  --card-hover: #e4ecf7;
  --field: #ffffff;
  --line: #d3deec;
  --line2: #8fa5c0;
  --ink: #1d2433;
  --mute: #5d6b82;
  --accent: #ff5a36;
  --accent-2: #f0431f;
  --accent-ink: #ffffff;
  --news: #1d2433;
  --news-ink: #ffffff;
  --unclaimed: #ffffff;
  --unclaimed-stroke: #1d2433;
  --map-stroke: #1d2433;
  --map-stroke-w: 1.1;
  --land-shadow: drop-shadow(0 5px 0 rgba(29, 36, 51, 0.28));
  --label: #1d2433;
  --label-halo: rgba(255, 255, 255, 0.95);
  --hover-bright: 1.08;
  --display: 'Baloo 2', 'Trebuchet MS', sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --r: 18px;
  --shadow: 0 6px 0 rgba(29, 36, 51, 0.16), 0 14px 30px rgba(29, 36, 51, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: 100dvh; }
.stage { grid-column: 1; grid-row: 1; }
.news { grid-column: 1; grid-row: 1; }
.panel { grid-column: 2; grid-row: 1; }

/* ---------- kartytan ---------- */

.stage { position: relative; overflow: hidden; min-height: 0; background: var(--stage-bg); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#map:active { cursor: grabbing; }

.kommuner { filter: var(--land-shadow); }
.kommuner path {
  stroke: var(--map-stroke); stroke-width: var(--map-stroke-w); vector-effect: non-scaling-stroke; stroke-linejoin: round;
  cursor: pointer; outline: none; transition: opacity 0.3s ease;
}
.kommuner path:not(.taken) { fill: var(--unclaimed); stroke: var(--unclaimed-stroke); }
.kommuner path:hover, .kommuner path:focus-visible { filter: brightness(var(--hover-bright)); stroke: var(--ink); stroke-width: 1.6; }
.kommuner path.sel { stroke: var(--accent); stroke-width: 3; filter: drop-shadow(0 0 6px var(--accent)); }
.kommuner path.dim { opacity: 0.16; }
.kommuner path.flash { animation: flash 1.8s ease-out; }
@keyframes flash {
  0%, 30%, 60% { filter: brightness(1.9) drop-shadow(0 0 10px var(--accent)); stroke: var(--accent); stroke-width: 3; }
  15%, 45%, 100% { filter: none; }
}

.labels text {
  font-family: var(--body); font-weight: 700; fill: var(--label); text-anchor: middle; dominant-baseline: middle;
  stroke: var(--label-halo); paint-order: stroke; stroke-linejoin: round; pointer-events: none;
}

.stage::before {
  content: ''; position: absolute; z-index: 2; top: 0; left: 0; width: 400px; height: 350px; pointer-events: none;
  background: radial-gradient(ellipse at top left, var(--scrim) 35%, transparent 72%);
}
.brand, .tools, .legend, .demo, .ticker { z-index: 3; }
.brand { position: absolute; top: 22px; left: 26px; pointer-events: none; }
.brand h1 { margin: 0; font: 700 30px/1.1 var(--display); letter-spacing: -0.01em; }
.brand p { margin: 6px 0 0; color: var(--mute); }
.crown { color: var(--accent); }

.tools { position: absolute; top: 96px; left: 26px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.search input { width: 220px; padding: 9px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--glass); }
.search input::placeholder { color: var(--mute); }

.btn {
  padding: 9px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); font-weight: 600;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--line2); background: var(--card-hover); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--glass); }
.btn.wide { width: 100%; }
.btn.gold { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: var(--accent-2); box-shadow: 0 6px 20px -8px var(--accent); }
.btn.gold:hover { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: var(--accent-2); filter: brightness(1.08); }
.btn.big { width: 100%; padding: 14px 16px; font-size: 16px; }

.seg { display: inline-flex; padding: 3px; border-radius: var(--r); border: 1px solid var(--line); background: var(--glass); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: calc(var(--r) - 3px); color: var(--mute); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--ink); color: var(--panel); }
.seg-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mute); margin-bottom: -6px; }

.tip {
  position: absolute; top: 0; left: 0; z-index: 6; pointer-events: none; white-space: nowrap;
  display: flex; flex-direction: column; gap: 2px; padding: 8px 11px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line2); font-size: 13px; box-shadow: var(--shadow);
}
.tip strong { font: 700 16px var(--display); }
.tip span { display: flex; align-items: center; gap: 6px; }
.tip .free { color: var(--mute); }
.dot { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18); }

.legend { position: absolute; right: 16px; bottom: 78px; display: flex; align-items: center; gap: 8px; color: var(--mute); font-size: 12.5px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; margin-left: 6px; }
.legend .sw:first-child { margin-left: 0; }
.legend .ramp { width: 130px; height: 8px; border-radius: 4px; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); font: 500 18px var(--display); }
.demo { position: absolute; right: 16px; bottom: 44px; padding: 4px 10px; border-radius: 999px; border: 1px dashed var(--line2); color: var(--mute); font-size: 12px; background: var(--glass); }

/* ---------- Tronnytt ---------- */

.news {
  align-self: end; justify-self: start; z-index: 4; width: 380px; margin: 0 0 46px 22px;
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
}
.news-head { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; background: var(--news); color: var(--news-ink); }
.news-logo { font: 800 15px/1 var(--display); letter-spacing: 0.08em; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; background: rgba(0, 0, 0, 0.3); color: #fff; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #b9c0cc; }
.news.is-live .badge { background: #fff; color: #c41218; }
.news.is-live .badge::before { background: #e5383b; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }
.news-head .sp { flex: 1; }
.news-head button { border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.18); color: inherit; border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 600; }
.news-head button[aria-pressed='true'] { background: #fff; color: #1d2433; border-color: #fff; }

.news-body { display: flex; gap: 12px; padding: 12px 12px 10px; align-items: flex-start; }
.news-text { flex: 1; min-width: 0; }
.news-who { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--mute); }
#news-line { margin: 3px 0 0; min-height: 5.6em; font-size: 14px; line-height: 1.4; }
#news-line::after { content: '▍'; opacity: 0; }
.news.talking #news-line::after { opacity: 0.7; }

.third { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; border-top: 1px solid var(--line); background: var(--card); padding: 8px 12px; text-align: left; }
.third:hover { background: var(--card-hover); }
.third i { width: 6px; align-self: stretch; border-radius: 3px; background: var(--accent); }
.third-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.third b { font: 700 17px/1.2 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.third-main span { font-size: 12.5px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.third em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--mute); white-space: nowrap; }

.ticker { position: absolute; left: 0; right: 0; bottom: 0; height: 32px; display: flex; align-items: center; background: var(--panel); border-top: 1px solid var(--line2); overflow: hidden; font-size: 13px; }
.ticker-tag { flex: none; align-self: stretch; display: flex; align-items: center; padding: 0 12px; background: var(--news); color: var(--news-ink); font-weight: 700; font-size: 11.5px; letter-spacing: 0.09em; z-index: 1; }
.ticker-track { display: flex; white-space: nowrap; animation: ticker 70s linear infinite; }
.ticker-track span { padding: 0 18px; }
.ticker-track span::before { content: '◆'; color: var(--accent); margin-right: 18px; font-size: 9px; vertical-align: middle; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- panelen ---------- */

.panel { background: var(--panel); border-left: 1px solid var(--line); padding: 22px 22px 40px; overflow-y: auto; min-height: 0; }
.panel h2 { margin: 26px 0 8px; font: 600 12px/1 var(--body); letter-spacing: 0.09em; text-transform: uppercase; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: #2fb85a; animation: pulse 1.8s infinite; }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(47, 184, 90, 0.6); } to { box-shadow: 0 0 0 9px rgba(47, 184, 90, 0); } }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats div { padding: 14px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; }
.stats b { font: 700 26px/1.1 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; }
.stats span { color: var(--mute); font-size: 12.5px; margin-top: 4px; }
.how { margin: 14px 2px 0; }
.hint { margin: 0 0 8px; color: var(--mute); font-size: 13px; }

.list { list-style: none; margin: 0; padding: 0; }
.row { width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 8px; border: 0; border-radius: var(--r); background: none; text-align: left; }
button.row:hover, .row.active { background: var(--card); }
.history .row { cursor: default; }
.history .row:hover { background: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--mute); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-right { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }

.freebox { margin-top: 26px; padding: 14px; border-radius: var(--r); border: 1px dashed var(--line2); display: flex; align-items: center; gap: 12px; }
.freebox div { flex: 1; display: flex; flex-direction: column; }
.freebox span { color: var(--mute); font-size: 13px; }

.back { border: 0; background: none; color: var(--mute); padding: 4px 0; font-weight: 600; }
.back:hover { color: var(--ink); }
.kommun-head { margin: 10px 0 16px; }
.panel .kommun-name { margin: 0; font: 700 38px/1.05 var(--display); letter-spacing: -0.015em; text-transform: none; color: var(--ink); display: block; overflow-wrap: anywhere; }
.kommun-head span { color: var(--mute); }

.regent {
  position: relative; padding: 18px 18px 16px; border-radius: var(--r); overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 26%, var(--card)), var(--card) 70%);
  border: 1px solid color-mix(in srgb, var(--c) 55%, var(--line));
}
.regent::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--c); }
.regent-top { display: flex; align-items: baseline; gap: 9px; font: 700 24px/1.15 var(--display); }
.regent-top .crown { font-size: 22px; }
.regent-name { overflow-wrap: anywhere; }
.regent-of { color: var(--mute); margin-top: 2px; }
.regent blockquote { margin: 12px 0 0; font: 500 17px/1.4 var(--display); font-style: italic; overflow-wrap: anywhere; }
.regent-meta { margin-top: 12px; color: var(--mute); font-size: 12.5px; }

.empty { padding: 22px 18px; border-radius: var(--r); border: 1px dashed var(--line2); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.empty .crown { font-size: 30px; opacity: 0.45; }
.empty b { font: 700 20px var(--display); }
.empty span:last-child { color: var(--mute); }
.panel .btn.big { margin-top: 14px; }
.panel .btn.wide { margin-top: 8px; }

/* ---------- kröningsdialogen ---------- */

.claim {
  width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line2); border-radius: calc(var(--r) + 6px);
  background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.claim::backdrop { background: rgba(4, 8, 16, 0.66); backdrop-filter: blur(3px); }
.claim form, .paying { padding: 24px; display: flex; flex-direction: column; }
.claim h2 { margin: 0 28px 4px 0; font: 700 26px/1.15 var(--display); }
.claim .x { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--card); font-size: 20px; line-height: 1; }
.label { display: flex; justify-content: space-between; margin: 16px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--mute); }
.preview-wrap .label { margin-top: 10px; }
.count { font-weight: 500; letter-spacing: 0; }
.claim input[type='text'], .claim input[type='number'] { width: 100%; padding: 11px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--field); }
.claim input::placeholder { color: var(--mute); opacity: 0.7; }

.radios { display: flex; flex-wrap: wrap; gap: 8px; }
.radios input { position: absolute; opacity: 0; pointer-events: none; }
.radios.title span { display: block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; }
.radios.title input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.swatch { display: block; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--panel); }
.radios input:checked + .swatch { border-color: var(--ink); }
.radios input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.amount { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.amount input { flex: 1 1 110px; width: auto !important; font: 700 20px var(--display); font-variant-numeric: tabular-nums; }
.chip { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 13px; }
.chip:hover { border-color: var(--line2); }
.claim .hint { margin: 6px 0 0; }
.claim .btn.big { margin-top: 18px; }
.err { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--r); background: #5c1a1f; border: 1px solid #a13a42; color: #ffe1e3; }
.fine { margin: 10px 0 0; color: var(--mute); font-size: 12.5px; text-align: center; }

.paying { align-items: center; text-align: center; padding: 44px 24px; }
.paying p { margin: 4px 0 0; }
.spinner { width: 46px; height: 46px; margin-bottom: 18px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 52px; transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: var(--shadow);
}

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti i { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.4s cubic-bezier(0.2, 0.6, 0.4, 1) forwards; }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: 0.9; } }

/* ---------- mobil ---------- */

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 64dvh auto auto; min-height: 100dvh; }
  .stage { grid-row: 1; }
  .news { grid-row: 2; width: auto; justify-self: stretch; margin: 12px 12px 0; }
  .panel { grid-column: 1; grid-row: 3; border-left: 0; overflow: visible; padding: 18px 16px 40px; }
  .stage::before { width: 100%; height: 230px; background: linear-gradient(var(--scrim) 60%, transparent); }
  .brand { top: 14px; left: 16px; }
  .brand h1 { font-size: 23px; }
  .brand p { font-size: 13px; margin-top: 2px; }
  .tools { top: 72px; left: 16px; right: 16px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .search { flex: 1 1 130px; }
  .search input { width: 100%; }
  .seg-label { display: none; }
  .legend { right: auto; left: 12px; bottom: 40px; }
  .demo { display: none; }
  .panel .kommun-name { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
