/* Der weiße Ton – Siegburger Steinzeug, Salzglasur, Ton.
   Kontrast: alle Texte ≥ 7:1, draußen bei Sonne lesbar. */

:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ebe6db;
  --line: #cfc7b8;
  --ink: #1d1b18;
  --ink-2: #3f3b35;
  --accent: #2c4a5c;
  --accent-ink: #ffffff;
  --clay: #7a3e20;
  --clay-soft: #f3e3d6;
  --ok: #1f5a33;
  --ok-soft: #dcefe1;
  --warn: #7a2a14;
  --warn-soft: #f7dfd6;
  --lead: #5a4a00;
  --lead-soft: #fff1b8;
  --shadow: 0 1px 0 rgba(29, 27, 24, 0.06), 0 6px 18px rgba(29, 27, 24, 0.07);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --surface-2: #2b2925;
    --line: #45413a;
    --ink: #f2eee6;
    --ink-2: #d6d0c4;
    --accent: #9cc0d6;
    --accent-ink: #10202a;
    --clay: #e3a078;
    --clay-soft: #3a2a20;
    --ok: #9fdcb0;
    --ok-soft: #1e3526;
    --warn: #f3a58c;
    --warn-soft: #3d231b;
    --lead: #ffe27a;
    --lead-soft: #3a3210;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.5 var(--sans);
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; outline: none; }
h1, h2, h3, .h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 0.4em; font-weight: 600; }
h1 { font-size: 2rem; letter-spacing: -0.01em; }
.h3 { font-size: 1.2rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); font-size: 0.95rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: 0.85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; font-weight: 600; color: var(--clay); margin-bottom: 0.3em; }
.place { color: var(--ink-2); margin-top: -0.2em; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
}
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; white-space: nowrap; }
.slots { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; justify-content: flex-end; }
.slots li {
  width: 28px; height: 32px; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 1.05rem;
  border: 1.5px dashed var(--line); border-radius: 6px 6px 9px 4px; color: var(--ink-2);
}
.slots li.got { border: 1.5px solid var(--clay); background: var(--clay-soft); color: var(--clay); }
.topbar-row { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.points { font-weight: 700; white-space: nowrap; }
.points small { font-weight: 500; color: var(--ink-2); }
.topbar-actions { display: flex; gap: 6px; }
.chip {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 0.95rem; cursor: pointer; white-space: nowrap;
}
.sim-banner { background: var(--lead-soft); color: var(--lead); text-align: center; font-weight: 700; padding: 6px; letter-spacing: 0.1em; font-size: 0.85rem; }

/* ---------- Karten ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 14px 0; box-shadow: var(--shadow);
}
.card.read { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.card.read p { font-family: var(--serif); font-size: 1.15rem; line-height: 1.55; }
.card.read.big p { font-size: 1.25rem; }
.card.info { border-left: 5px solid var(--accent); }
.card.resolve { border: 2px solid var(--clay); }
.card.tools { border: 2px dashed var(--lead); background: var(--lead-soft); }
.card.tools .h3 { color: var(--lead); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--accent); background: var(--surface); color: var(--accent);
  font-weight: 650; text-decoration: none; text-align: center; line-height: 1.2;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; min-height: 58px; font-size: 1.15rem; margin-top: 8px; }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.ghost { border-color: var(--line); color: var(--ink-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.file { position: relative; }
.linkish { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 12px 4px; cursor: pointer; font-weight: 600; display: block; margin: 4px auto; min-height: 44px; }
.icon { background: none; border: 0; font-size: 1.6rem; line-height: 1; width: 44px; height: 44px; cursor: pointer; color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions.col { flex-direction: column; }
.actions.col .btn { width: 100%; }
.actions.small .btn { min-height: 44px; padding: 8px 14px; }
:focus-visible { outline: 3px solid var(--clay); outline-offset: 2px; }
html:not(.is-ios) .ios-only { display: none; }

/* ---------- Start ---------- */
.start { padding-top: 28px; position: relative; }
.start h1 { font-size: 2.6rem; margin-bottom: 0.15em; }
.start .subtitle { font-family: var(--serif); font-size: 1.2rem; color: var(--ink-2); }
.start .facts { font-weight: 600; }
.start-shard {
  width: 88px; height: 88px; margin-bottom: 12px;
  background: linear-gradient(145deg, #fffdf8, #e2dccf);
  clip-path: polygon(8% 18%, 58% 0, 100% 30%, 86% 88%, 30% 100%, 0 62%);
  box-shadow: inset 0 0 0 2px var(--line);
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.12));
}
.gate { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.gate label { font-weight: 600; }
.gate input {
  width: 100%; min-height: 52px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1.05rem;
}
.gate input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- Navigation ---------- */
.nav { text-align: center; }
.nav .card { text-align: left; }
.compass { position: relative; width: 220px; height: 220px; margin: 18px auto 8px; }
.compass-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--line);
  background:
    radial-gradient(circle at 50% 50%, var(--surface) 0 58%, transparent 59%),
    repeating-conic-gradient(from -1deg, var(--line) 0 2deg, transparent 2deg 30deg),
    var(--surface-2);
}
.compass-ring .n { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 0.8rem; color: var(--clay); }
.arrow {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 150px;
  transform: translate(-50%, -50%) rotate(0deg);
  transition: transform 0.4s ease-out; opacity: 0.25;
}
.arrow.live { opacity: 1; }
.arrow::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 58%;
  background: var(--accent); clip-path: polygon(50% 0, 100% 100%, 50% 82%, 0 100%);
}
.arrow::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--clay);
}
.distance { font-family: var(--serif); font-size: 3rem; font-weight: 700; margin: 0; line-height: 1.1; }
.direction { color: var(--ink-2); margin-bottom: 6px; }
.gps { font-size: 0.9rem; color: var(--ink-2); margin: 0 0 8px; }
.gps.poor { color: var(--warn); font-weight: 600; }
.nav .actions { justify-content: center; }
.seg { display: inline-flex; border: 1.5px solid var(--accent); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--accent); min-height: 44px; padding: 6px 12px; font-weight: 650; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- Aufgaben ---------- */
.task-head { display: flex; align-items: flex-start; gap: 10px; }
.task-head .h3 { flex: 1; margin: 2px 0 0; }
.task-id {
  flex: none; min-width: 34px; height: 30px; padding: 0 6px; border-radius: 8px;
  display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 0.9rem;
}
.badge { flex: none; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.status-solved .badge, .status-done .badge { background: var(--ok-soft); color: var(--ok); }
.status-revealed .badge { background: var(--clay-soft); color: var(--clay); }
.status-solved, .status-done, .status-revealed { border-color: var(--line); }
.tag { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--clay-soft); color: var(--clay); vertical-align: middle; }
.task-text { margin-top: 10px; }
.answer { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.answer label { width: 100%; font-weight: 600; }
.answer input {
  flex: 1 1 180px; min-width: 0; min-height: 50px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1.05rem;
}
.answer input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.answer.two input[type="number"] { flex: 0 1 110px; }
.feedback { font-weight: 650; padding: 8px 12px; border-radius: 10px; }
.feedback.wrong { background: var(--warn-soft); color: var(--warn); }
.feedback.partial { background: var(--lead-soft); color: var(--lead); }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.hint { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; }
.solution { border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: var(--surface-2); }
.solution span { display: block; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; margin-bottom: 4px; }
.solution.solved { background: var(--ok-soft); }
.solution.solved span { color: var(--ok); }
.solution.revealed span { color: var(--clay); }
.solution p { margin: 0; }
.leader-solution { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--lead-soft); border: 1.5px dashed var(--lead); }
.leader-solution span { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; color: var(--lead); }
.leader-solution p { margin: 4px 0 0; color: var(--ink); }
.done-line { font-weight: 650; color: var(--ok); margin: 6px 0 0; }
.entries { list-style: none; padding: 0; margin: 8px 0; }
.entries li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.entries li > span:first-child { font-weight: 650; min-width: 80px; }
.entries li > span:nth-child(2) { flex: 1; }
.entries.words li > span:nth-child(2) { font-family: var(--serif); font-size: 1.1rem; }
.story { padding-left: 1.4em; margin: 8px 0; font-family: var(--serif); font-size: 1.1rem; }
.story li { margin-bottom: 6px; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chips li { padding: 6px 12px; border-radius: 999px; font-weight: 650; font-size: 0.95rem; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-bonus { background: var(--lead-soft); color: var(--lead); }
.chip-miss { background: var(--surface-2); color: var(--ink-2); text-decoration: line-through; }
.countdown { font-family: var(--mono); font-weight: 800; font-size: 2rem; text-align: center; padding: 6px; border-radius: 12px; background: var(--surface-2); margin: 10px 0; }
.countdown.big { font-size: 3.4rem; }
.countdown.urgent { color: var(--warn); }
.ranking { list-style: none; padding: 0; margin: 8px 0; }
.ranking li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 8px 10px; border-radius: 10px; }
.ranking li.best { background: var(--clay-soft); font-weight: 750; }
.ranking li.best > span:first-child::after { content: "  ★"; color: var(--clay); }
.solution-inline { margin-bottom: 6px; }

/* ---------- Buchstabe ---------- */
.letter-moment { text-align: center; padding-top: 24px; }
.letter-label { font-family: var(--serif); font-size: 1.4rem; margin: 0; }
.shard {
  width: 190px; height: 210px; margin: 18px auto 20px; display: grid; place-items: center;
  background: linear-gradient(150deg, #fffdf8 0%, #ece6d9 55%, #d9d1c1 100%);
  clip-path: polygon(14% 6%, 62% 0, 96% 22%, 88% 78%, 52% 100%, 6% 84%, 0 38%);
  filter: drop-shadow(0 10px 20px rgba(0,0,0,.18));
  animation: drop 0.7s cubic-bezier(.2,1.4,.4,1) both;
}
.shard span { font-family: var(--serif); font-size: 7rem; font-weight: 700; color: #2c4a5c; line-height: 1; }
@keyframes drop { from { transform: translateY(-60px) rotate(-18deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Ziel ---------- */
.goal { text-align: center; }
.goal .card { text-align: left; }
.word { display: flex; justify-content: center; gap: 6px; margin: 18px 0 10px; flex-wrap: nowrap; }
.pool { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tile, .slot {
  width: 44px; height: 54px; display: grid; place-items: center; border-radius: 8px 10px 12px 6px;
  font-family: var(--serif); font-size: 1.7rem; font-weight: 700; cursor: pointer;
}
.tile { background: var(--clay-soft); color: var(--clay); border: 2px solid var(--clay); }
.tile.ghost { background: transparent; border: 2px dashed var(--line); cursor: default; }
.slot.empty { border: 2px dashed var(--line); }
.slot.tile { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.word.final .slot.tile { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); cursor: default; }
.shake { animation: shake 0.5s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.bigscore { font-family: var(--serif); font-size: 2.4rem; font-weight: 700; margin: 0; }
.bigscore small { font-size: 1rem; color: var(--ink-2); }
.plain { padding-left: 1.3em; }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; max-width: 640px; margin: 0 auto;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  animation: up 0.2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 1.3rem; }
.st-list { list-style: none; padding: 0; margin: 10px 0; }
.st-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.st-link { background: none; border: 0; padding: 0; text-align: left; color: var(--accent); font-weight: 650; text-decoration: underline; cursor: pointer; min-height: 32px; }
.st-status { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; color: var(--ink-2); }
.st-erledigt .st-status, .st-gelöst .st-status { color: var(--ok); }
.st-angekommen .st-status, .st-unterwegs .st-status { color: var(--clay); }
.st-time { font-family: var(--mono); font-size: 0.85rem; color: var(--ink-2); }
.calib { list-style: none; padding: 0; }
.calib li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.calib-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.coord-status { flex: none; align-self: flex-start; font-size: 0.78rem; line-height: 1.6; font-weight: 800; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; }
.cs-geprüft { background: var(--ok-soft); color: var(--ok); }
.cs-ungefähr { background: var(--warn-soft); color: var(--warn); }
.cs-kalibriert { background: var(--lead-soft); color: var(--lead); }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px);
  font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 30;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .tile, .slot { width: 38px; height: 48px; font-size: 1.45rem; }
  .slots li { width: 24px; height: 28px; font-size: 0.95rem; }
  h1 { font-size: 1.75rem; }
}

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