/* wheredoo?: färger och mått */
:root {
  --paper: #f3efe6;
  --card: #fffdf8;
  --ink: #15171c;
  --muted: #5e636b;
  --line: #d9d2c2;
  --red: #e2462c;
  --red-dark: #c23a22;
  --sun: #ffd23f;
  --night: #0e1116;
  --good: #2f8f4e;
  --mid: #d9a21b;
  --bad: #c0462f;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --top: 56px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

/* Sidhuvud: loggan, dagens fem rutor och verktygen */
.top {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 1000;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: var(--ink); color: #fff;
}
.logo {
  display: inline-flex; align-items: baseline; text-decoration: none; color: #fff;
  font-weight: 900; font-size: 22px; letter-spacing: -.02em; line-height: 1;
}
.logo b { color: var(--sun); font-weight: inherit; }
.track { display: flex; gap: 5px; margin: 0 auto; padding: 0; list-style: none; }
.track li {
  width: 34px; height: 34px; border-radius: 8px; background: #2a2e36; overflow: hidden;
  display: grid; place-items: center; font: 800 11px var(--font); color: #fff;
}
.track li.now { box-shadow: inset 0 0 0 2px var(--sun); }
.track li.g { background: var(--good); } .track li.m { background: var(--mid); }
.track li.b { background: var(--bad); } .track li.z { background: #555; }
.tools { display: flex; align-items: center; gap: 6px; }
.dayno { font: 600 13px var(--font); color: #aab0b8; margin-right: 4px; white-space: nowrap; }
.tool {
  height: 32px; min-width: 32px; padding: 0 10px; border: 0; border-radius: 99px;
  background: #2a2e36; color: #fff; font-weight: 700; font-size: 13px;
}
.tool:hover { background: #3a3f49; }

/* Kartan */
.game { position: fixed; inset: var(--top) 0 0 0; }
.map { position: absolute; inset: 0; z-index: 0; background: #0e2236; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }
.cn {
  font: 700 11px var(--font); color: rgba(255, 255, 255, .9); text-transform: uppercase;
  letter-spacing: .05em; white-space: nowrap; text-align: center; pointer-events: none;
  text-shadow: 0 0 3px #000, 0 1px 2px #000;
}
.ct {
  font: 600 11px var(--font); color: #fff; white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 3px #000, 0 1px 2px #000;
}
.ct i {
  display: inline-block; width: 6px; height: 6px; margin-right: 4px; vertical-align: 0;
  background: #fff; border: 1.5px solid var(--ink); border-radius: 50%;
}
.ct.cap { font-weight: 800; font-size: 12px; }
.ct.cap i { width: 8px; height: 8px; background: var(--sun); border-radius: 1px; }
.wt {
  font: italic 600 11px var(--font); color: #bfe3ff; white-space: nowrap; text-align: center;
  pointer-events: none; text-shadow: 0 0 3px #00182e, 0 1px 2px #00182e;
}
.wt.sea { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.pin {
  width: 22px; height: 22px; border-radius: 50%; background: var(--red);
  border: 3px solid #fff; box-shadow: 0 0 0 2px var(--ink);
}
.pin.answer { background: var(--sun); }

/* Bilden över hela ytan */
.stage {
  position: absolute; inset: 0; z-index: 950; background: var(--night); color: #fff;
  display: grid; grid-template-rows: 1fr auto;
}
.stagepic { position: relative; min-height: 0; padding: 18px 18px 0; }
.stagepic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stagepic img:not([src]) { visibility: hidden; }
.stagetext {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "count go" "task go" "q go";
  column-gap: 24px; align-items: end; padding: 18px 24px 26px; max-width: 980px; width: 100%; margin: 0 auto;
}
.count { grid-area: count; margin: 0 0 2px; font-weight: 700; font-size: 13px; color: var(--sun); }
.task { grid-area: task; margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -.02em; outline: none; }
.q { grid-area: q; margin: 6px 0 0; font-size: 17px; color: #d4d8de; }
.go {
  grid-area: go; align-self: center; min-height: 54px; padding: 0 26px; border: 0; border-radius: 99px;
  background: var(--sun); color: var(--ink); font-weight: 800; font-size: 17px; white-space: nowrap;
}
.go:hover { background: #ffe07a; }

/* Remsan på kartan */
.strip {
  position: absolute; z-index: 900; top: 12px; left: 12px; right: 64px; max-width: 560px;
  display: flex; gap: 12px; align-items: center; padding: 8px 14px 8px 8px;
  background: rgba(21, 23, 28, .88); color: #fff; border-radius: 14px;
}
.mini {
  flex: 0 0 auto; width: 64px; height: 64px; padding: 0; border: 2px solid #fff; border-radius: 10px;
  overflow: hidden; background: var(--night); cursor: zoom-in;
}
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.striptext { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.striptext b { font-size: 17px; }
.striptext span { font-size: 14px; color: #d4d8de; }
.striptext .pinland { color: var(--sun); font-weight: 600; font-size: 13px; }

/* Knapparna på kartan */
.bar {
  position: absolute; z-index: 900; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; gap: 8px; width: min(560px, calc(100% - 24px));
  padding-bottom: env(safe-area-inset-bottom);
}
.bar button { min-height: 54px; border: 0; border-radius: 99px; }
.hint {
  flex: 0 0 auto; padding: 0 18px; background: var(--card); font-weight: 800; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.hint small { font-weight: 600; font-size: 11px; color: var(--muted); }
.hint:hover:not(:disabled) { background: #fff3c4; }
.hint:disabled { background: var(--line); color: var(--muted); }
.main {
  flex: 1; background: var(--red); color: #fff; font-weight: 800; font-size: 16px; padding: 0 18px;
  border: 0; border-radius: 99px;
}
.main:hover:not(:disabled) { background: var(--red-dark); }
.main:disabled { background: var(--card); color: var(--muted); }

/* Svaret längst ned */
.sheet {
  position: absolute; z-index: 900; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(720px, 100%); max-height: 62%; overflow: auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheethead { display: flex; gap: 14px; align-items: center; }
.sheetpic { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; }
.sheetname { flex: 1; min-width: 0; }
.sheet h2 { margin: 0; font-size: 21px; line-height: 1.2; outline: none; }
.place { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.score { margin: 0; text-align: right; line-height: 1; }
.score b { display: block; font-size: 34px; font-weight: 900; letter-spacing: -.02em; }
.score small { font-size: 12px; color: var(--muted); font-weight: 600; }
.score.g b { color: var(--good); } .score.m b { color: var(--mid); } .score.b b, .score.z b { color: var(--bad); }
.fact { margin: 12px 0 8px; font-size: 15px; }
.off { margin: 0; font-weight: 700; font-size: 14px; }
.credit { margin: 8px 0 14px; font-size: 12px; color: var(--muted); }
.credit a { color: inherit; }
.wide { width: 100%; min-height: 52px; }

/* Dialoger */
.dlg {
  width: min(520px, calc(100% - 32px)); max-height: calc(100% - 48px); padding: 0;
  border: 0; border-radius: 18px; background: var(--card); color: var(--ink);
}
.dlg::backdrop, .lb::backdrop { background: rgba(14, 17, 22, .6); }
.dlghead { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 6px; }
.dlghead h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.x { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 4px; }
.tab, #done-body { padding: 8px 20px 20px; }
.how { padding-left: 20px; margin: 0 0 16px; }
.how li { margin-bottom: 8px; }

/* Bildvisaren */
.lb { padding: 0; border: 0; border-radius: 12px; background: var(--night); max-width: calc(100% - 24px); max-height: calc(100% - 24px); }
.lb img { display: block; max-width: calc(100vw - 28px); max-height: calc(100vh - 28px); object-fit: contain; }
.lb .x { position: absolute; top: 6px; right: 8px; color: #fff; text-shadow: 0 0 4px #000; }

/* Tidigare dagar */
.past { list-style: none; margin: 0; padding: 0; }
.past li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.past .pd { font-weight: 700; }
.past .pd small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.past button { border: 0; border-radius: 99px; background: var(--paper); padding: 7px 14px; font-weight: 700; font-size: 13px; }
.past button:hover { background: var(--sun); }

/* Statistik och resultat */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.stats div { background: var(--paper); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stats b { display: block; font-weight: 900; font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
.big { text-align: center; margin: 0 0 14px; }
.big b { font-weight: 900; font-size: 48px; letter-spacing: -.03em; }
.big span { font-weight: 600; font-size: 16px; color: var(--muted); }
.rounds { list-style: none; padding: 0; margin: 0 0 16px; }
.rounds li { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.rounds img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.rounds .rs { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.rounds small { display: block; color: var(--muted); font-size: 13px; }
.next { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.dot.g { background: var(--good); } .dot.m { background: var(--mid); } .dot.b { background: var(--bad); } .dot.z { background: #555; }

.toast {
  position: fixed; z-index: 2000; left: 50%; bottom: 90px; transform: translateX(-50%);
  margin: 0; padding: 10px 16px; border-radius: 99px; background: var(--ink); color: #fff; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.on { opacity: 1; }

@media (max-width: 700px) {
  :root { --top: 96px; }
  .top { flex-wrap: wrap; align-content: center; row-gap: 8px; padding: 8px 12px; }
  .logo { font-size: 20px; }
  .tools { margin-left: auto; }
  .track { order: 3; width: 100%; justify-content: center; margin: 0; }
  .track li { width: 30px; height: 30px; }
  .stagepic { padding: 10px 10px 0; }
  .stagetext { grid-template-columns: 1fr; grid-template-areas: "count" "task" "q" "go"; padding: 14px 16px 20px; }
  .task { font-size: 26px; }
  .q { font-size: 15px; }
  .go { margin-top: 14px; width: 100%; }
  .strip { right: 12px; padding: 6px 10px 6px 6px; }
  .mini { width: 52px; height: 52px; }
  .striptext b { font-size: 15px; }
  .striptext span { font-size: 13px; }
  .bar { bottom: 26px; }
  .main { font-size: 15px; }
  .sheet h2 { font-size: 18px; }
  .score b { font-size: 28px; }
  .fact { font-size: 14px; }
  .stats b { font-size: 18px; }
  .leaflet-control-zoom { display: none; }   /* nyp för att zooma */
  .cn { font-size: 9px; letter-spacing: .03em; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* Översikten när dagen är klar */
.recap {
  position: absolute; z-index: 900; top: 12px; left: 12px; right: 64px; max-width: 560px;
  display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px;
  background: rgba(21, 23, 28, .88); color: #fff; border-radius: 14px;
}
.recaptext { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.recaptext b { font-size: 17px; outline: none; }
.recaptext span { font-size: 13px; color: #d4d8de; }
.go.small { min-height: 44px; padding: 0 18px; font-size: 15px; }
.pin.nr { display: grid; place-items: center; width: 24px; height: 24px; color: #fff; font: 800 11px/1 var(--font); }
.pin.answer.nr { color: var(--ink); }
.leaflet-tooltip.svarnamn {
  padding: 2px 7px; border: 0; border-radius: 6px; background: var(--ink); color: #fff;
  font: 700 12px var(--font); box-shadow: none;
}
.leaflet-tooltip.svarnamn::before { display: none; }
.pop { display: grid; gap: 2px; width: 200px; font-family: var(--font); }
.pop img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.pop b { font-size: 15px; }
.pop span { color: var(--muted); font-size: 13px; }
.pop .ps { display: flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 700; }
.ghost { margin-top: 8px; border: 0; border-radius: 99px; background: var(--paper); color: var(--ink); font-weight: 800; font-size: 16px; }
.ghost:hover { background: var(--sun); }
@media (max-width: 640px) {
  .recap { right: 12px; padding: 8px 8px 8px 12px; }
  .recaptext span { display: none; }
}
.pasth { margin: 18px 0 4px; font-size: 16px; }

/* Textledtråden i remsan */
.striptext .clue { margin-top: 2px; color: #fff; font-style: italic; }
.striptext .clue::before { content: "Clue: "; font-style: normal; font-weight: 700; color: var(--sun); }
@media (max-width: 640px) {
  .hint { padding: 0 12px; font-size: 13px; }
  .hint small { font-size: 10px; }
}

/* Topplistan för en grupp */
.tool.grp { background: var(--sun); color: var(--ink); }
.joinform label { display: block; font-weight: 700; margin-bottom: 6px; }
.joinform input {
  width: 100%; min-height: 48px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px;
  font: inherit; background: #fff; color: var(--ink);
}
.joinform input:focus { outline: none; border-color: var(--ink); }
.err { min-height: 1.4em; margin: 6px 0 10px; color: var(--red); font-weight: 600; font-size: 14px; }
.lbh { margin: 18px 0 6px; font-size: 17px; }
.lbinfo { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.lbinfo b { color: var(--ink); }
.lbrows { list-style: none; margin: 0 0 12px; padding: 0; }
.lbrows li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.lbrows li.me { background: #fff3c4; border-radius: 8px; }
.lbrows li.tom { display: block; color: var(--muted); border: 0; }
.lbrows .pl { font-weight: 900; color: var(--muted); text-align: center; }
.lbrows .nm { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.lbrows .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.lbrows b { font-weight: 900; }
.kk { display: flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 99px; }
