:root {
  --bg: #f4efe4;
  --card: #fffdf8;
  --ink: #1f2a2e;
  --muted: #6b7275;
  --line: #ddd4c2;
  --accent: #1d6b5f;
  --accent-soft: #e2efe9;
  --accent-ink: #ffffff;
  --warn: #b0452f;
  --land: #e7e0cf;
  --cand: #9cc9bd;
  --target: #1d6b5f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b1d;
    --card: #1f2629;
    --ink: #ebe6db;
    --muted: #9aa2a5;
    --line: #34403f;
    --accent: #4fb3a1;
    --accent-soft: #1d3833;
    --accent-ink: #0d1517;
    --warn: #e07a62;
    --land: #2b3436;
    --cand: #2f6d62;
    --target: #6fd6c3;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: .04em; }
h2 { margin: 0 0 .6rem; font-size: 1.15rem; }
h3 { margin: 1rem 0 .4rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.top {
  max-width: 1040px; margin: 0 auto; padding: 16px;
  display: flex; justify-content: space-between; align-items: flex-end;
}
.brand { display: flex; gap: .6rem; align-items: baseline; }
.budget { font-family: Georgia, serif; font-size: 1.8rem; font-variant-numeric: tabular-nums; text-align: right; line-height: 1.1; }
.budget-label { font: .75rem system-ui, sans-serif; letter-spacing: .03em; }
.budget.low #points { color: var(--warn); }

/* Layout: links Rätsel + Tipp, rechts der Laden (T1-3). Schmal: untereinander. */
.layout { max-width: 1040px; margin: 0 auto; padding: 0 16px 48px; display: grid; gap: 0 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto 1fr; grid-template-areas: "main shop" "extra shop"; }
  .col-main { grid-area: main; }
  .col-extra { grid-area: extra; }
  .shop-col { grid-area: shop; position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow: auto; }
}

.card, .shelf {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.shelf h2 { margin-bottom: .1rem; }
.shelf-sub { margin: 0 0 .7rem; }
.shelf.compare { border: 2px solid var(--accent); background: var(--accent-soft); }

.clues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.clues li { padding: 8px 10px; border-radius: 8px; background: var(--bg); }
.clues .row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.clues li .k { color: var(--muted); }
.clues li .v { font-weight: 600; text-align: right; }
.clues li .v-line { font-weight: 600; margin-top: 2px; }
.clues li.start { border-left: 3px solid var(--accent); }
.clues li.guess { background: transparent; border: 1px dashed var(--line); }
.clues li.compare { border-left: 3px solid var(--warn); }
.clues li .cost { color: var(--muted); font-size: .75rem; margin-left: .5rem; font-weight: 400; padding: 1px 6px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.clues svg.outline { width: 120px; height: 120px; }
.clues .flag-big { font-size: 3rem; line-height: 1; }
.swatch { display: inline-block; width: .9em; height: .9em; border-radius: 3px; border: 1px solid var(--line); vertical-align: -1px; margin-right: 3px; }

.guess-row { display: flex; gap: 8px; }
.guess-row .ac { flex: 1; }
.guess-row .primary { width: auto; padding: 10px 18px; }
.ac { position: relative; }
input[type=text] {
  width: 100%; padding: 10px 12px; font-size: 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.ac-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; max-height: 240px; overflow: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.ac-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.ac-list li.active, .ac-list li:hover { background: var(--bg); }
.ac-list li.used { color: var(--muted); text-decoration: line-through; cursor: default; }
.feedback { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); border-left: 3px solid var(--accent); font-size: .92rem; }

button { font: inherit; cursor: pointer; }
button.primary {
  width: 100%; padding: 11px; border-radius: 8px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
button.primary:disabled { opacity: .45; cursor: default; }

/* Laden: kompakte Liste */
.shop { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.shop .row-line { display: flex; gap: 4px; align-items: stretch; }
.shop button.buy {
  flex: 1; min-height: 44px; display: flex; gap: 8px; align-items: center; text-align: left;
  padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-size: .9rem; min-width: 0;
}
.shop li > button.buy { width: 100%; }
.shelf.compare button.buy { background: var(--card); }
.shop .ico { width: 1.3em; text-align: center; flex: none; }
.shop .lbl { flex: 1; min-width: 0; }
.shop .price { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .85rem; display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.shop .price .pts b, .pts b { font-weight: 700; }
.shop .price::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: var(--line); }
.shop .price.t-small::before { background: #5aa469; }
.shop .price.t-medium::before { background: #d9b23c; }
.shop .price.t-high::before { background: #e08a3c; }
.shop .price.t-big::before { background: #c4553f; }
.shop .price.t-escape::before { background: #555; }
.shelf.compare .price::before { display: none; }
.shop .tier { display: block; font-size: .72rem; color: var(--muted); }
.shop button.buy:disabled { opacity: .45; cursor: default; }
.shop button.buy:not(:disabled):hover { border-color: var(--accent); }
.shop li.bought .price { color: var(--accent); border-color: var(--accent); }
.shop li.bought .price::before { display: none; }
.shop li.used .desc { opacity: .5; }
.shop .desc { color: var(--muted); margin: 2px 4px 6px 2.1em; line-height: 1.35; }
.shop .tag { display: block; font-size: .72rem; color: var(--muted); }

.info-btn {
  flex: none; width: 1.55em; height: 1.55em; align-self: center; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: italic 600 .78rem/1 Georgia, serif; padding: 0; display: inline-grid; place-items: center; vertical-align: 1px;
}
.info-btn.on, .info-btn:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.info { margin: 6px 0 4px; padding: 8px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-weight: 400; text-align: left; }
.info p { margin: .2rem 0; }
.clues .info { background: var(--card); }

details summary { cursor: pointer; }

#result h2 { font-size: 1.4rem; }
#result .answer { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
#result .answer .flag-big { font-size: 3.4rem; line-height: 1; }
#result svg.map { width: 100%; height: auto; border-radius: 8px; background: var(--bg); display: block; }
.map .bg { fill: var(--land); opacity: .55; stroke: var(--card); stroke-width: .5; vector-effect: non-scaling-stroke; }
.map .c { fill: var(--land); stroke: var(--card); stroke-width: .8; vector-effect: non-scaling-stroke; }
.map .c.hl { stroke: var(--ink); stroke-width: 1.6; }
.map .c.cand { fill: var(--cand); }
.map .c.target { fill: var(--target); }
.map circle.cand { fill: var(--cand); stroke: var(--card); vector-effect: non-scaling-stroke; }
.map circle.target { fill: var(--target); stroke: var(--card); vector-effect: non-scaling-stroke; }
.map text.lbl { font: 600 11px system-ui, sans-serif; font-size: calc(11px / var(--k, 1)); fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--card); stroke-width: calc(3px / var(--k, 1)); stroke-linejoin: round; pointer-events: none; }
.map text.lbl.target { font-size: calc(13px / var(--k, 1)); }
.map.no-names text.lbl { display: none; }

/* Zoombare Auflösungskarte (T4-2) */
.map-wrap { position: relative; }
.map-wrap svg.map { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.map-wrap.zoomed svg.map { touch-action: none; }
.map-wrap svg.map.dragging { cursor: grabbing; }
.map-tools { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; }
.map-tools button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 1.05rem; line-height: 1; padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.map-tools button[data-z="names"] { font: 600 .78rem Georgia, serif; }
.map-tools button[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.map-tools button:disabled { opacity: .4; cursor: default; }
.map-caption { margin: 6px 2px 0; min-height: 1.3em; }

.giveup-row { margin-top: 10px; text-align: right; }
button.link { background: none; border: 0; padding: 2px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
button.link:hover { color: var(--warn); }
button.link.confirm { color: var(--warn); font-weight: 600; }
.journey { padding-left: 1.1rem; margin: .6rem 0; }
.journey li { margin-bottom: .35rem; }
.share-box { white-space: pre; font-family: ui-monospace, Menlo, monospace; background: var(--bg); padding: 10px; border-radius: 8px; margin: 10px 0; }

.dev { font-size: .9rem; }
.dev-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 10px 0; }
.dev-row button { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
#stats { border-collapse: collapse; width: 100%; }
#stats td, #stats th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
#stats td.num, #stats th.num { text-align: right; font-variant-numeric: tabular-nums; }
#guess-cost { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 400; margin-left: .3rem; }

/* Verlängerung (T4-3) */
.budget.ot #points { color: var(--muted); }
.clues li.overtime { background: transparent; border: 1px solid var(--warn); color: var(--ink); font-size: .9rem; }
button.refresh { width: 100%; margin-top: 8px; padding: 9px; border-radius: 8px; border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
button.refresh:disabled { opacity: .5; cursor: default; }

/* Par (T4-4) */
.par-box { margin: -4px 0 12px; }
.par-line { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; font-size: 1.05rem; }
.par-line b { font-family: Georgia, serif; font-size: 1.25rem; }
.par-box details { margin-top: 6px; }

/* v0.7: Erklärung, Hilfe-Knopf, eigene Bilanz, Fußzeile */
.help-btn { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: 600 .8rem system-ui, sans-serif; cursor: pointer; align-self: center; }
.help-btn:hover { color: var(--ink); border-color: var(--muted); }
.intro { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 24, 26, .55); }
.intro[hidden] { display: none; }
.intro-card { background: var(--card); color: var(--ink); border-radius: 14px; padding: 22px 22px 18px; max-width: 420px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.intro-card p { margin: 0 0 .5rem; }
.intro-card ul { padding-left: 1.1rem; margin: .4rem 0 .8rem; }
.intro-card li { margin: .35rem 0; }
.intro-card .primary { width: 100%; margin-top: .5rem; }
.me-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; }
.me-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.me-box p { margin: 6px 0 0; }
.foot { max-width: 1040px; margin: -24px auto 0; padding: 0 16px 28px; }

/* v0.8: Vergleich mit Freunden */
.brand { flex-wrap: wrap; }
.group-btn { height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 500 .8rem system-ui, sans-serif; cursor: pointer; align-self: center; }
.group-btn:hover { border-color: var(--muted); }
.nick-label { display: block; margin: .6rem 0 .3rem; font-weight: 600; font-size: .9rem; }
.nick-input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.nick-row { display: flex; gap: 8px; }
.nick-row button { padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.board-box { margin-bottom: 6px; }
.board { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.board li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto 3.2rem; gap: 8px; align-items: center; padding: 7px 10px; border-top: 1px solid var(--line); font-size: .92rem; }
.board li:first-child { border-top: 0; }
.board li.me { background: var(--accent-soft); }
.board .rk { color: var(--muted); font-variant-numeric: tabular-nums; }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .mk { font-size: .8rem; letter-spacing: -.05em; white-space: nowrap; overflow: hidden; max-width: 10rem; text-overflow: ellipsis; }
.board .sc { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .board .mk { max-width: 5.5rem; } }
