@font-face {
  font-family: 'Bricolage';
  src: url('fonts/bricolage-latin-ext.woff2') format('woff2');
  font-weight: 300 800; font-stretch: 75% 100%; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Bricolage';
  src: url('fonts/bricolage-latin.woff2') format('woff2');
  font-weight: 300 800; font-stretch: 75% 100%; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Sometype';
  src: url('fonts/sometype-latin-ext.woff2') format('woff2');
  font-weight: 400 700; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Sometype';
  src: url('fonts/sometype-latin.woff2') format('woff2');
  font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --sand: #EFE3C6;
  --dune: #D9C59A;
  --dune-deep: #BFA873;
  --ink: #1E1A14;
  --ink-soft: #5B5244;
  --ochre: #B8641E;
  --ochre-deep: #8F4B12;
  --tx-black: #0C0A08;
  --phosphor: #FFB347;
  --phosphor-dim: #8A5E22;
  --fuse: #B3261E;
  --ok: #3E6B3A;
  --tabs-h: 64px;
  --pad: 20px;
  --sans: 'Bricolage', 'Segoe UI', system-ui, sans-serif;
  --mono: 'Sometype', 'Cascadia Mono', 'Consolas', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--sand); color: var(--ink);
  font-family: var(--sans); font-size: 17px; line-height: 1.45;
  font-variation-settings: 'opsz' 14;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--ochre-deep); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
h1 { font-size: 34px; font-stretch: 85%; font-variation-settings: 'opsz' 96; }
h2 { font-size: 23px; font-stretch: 90%; font-variation-settings: 'opsz' 48; }
h3 { font-size: 17px; }
p { margin: 0 0 12px; max-width: 60ch; }
.muted { color: var(--ink-soft); }
.mono { font-family: var(--mono); }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; }

.masthead {
  position: sticky; top: 0; z-index: 5; background: var(--sand);
  border-bottom: 2px solid var(--ink); padding: calc(10px + env(safe-area-inset-top)) var(--pad) 8px;
}
.masthead-row { display: flex; justify-content: space-between; align-items: baseline; max-width: 480px; margin: 0 auto; }
.masthead-title { font-weight: 700; font-stretch: 80%; font-size: 19px; }
.masthead-agent { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }

.view { max-width: 480px; margin: 0 auto; padding: 0 var(--pad) 32px; }
.view:focus { outline: none; }

section.block { padding: 22px 0; border-bottom: 1px solid var(--dune); }
section.block:last-child { border-bottom: 0; }
section.block > h2 { margin-bottom: 12px; }

/* Countdown */
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 4px; }
.countdown div { text-align: left; }
.countdown b {
  display: block; font-size: 44px; font-weight: 700; font-stretch: 75%;
  font-variation-settings: 'opsz' 96; line-height: 1; font-variant-numeric: tabular-nums;
}
.countdown span { font-size: 13px; color: var(--ink-soft); }

/* Datenzeilen (Definitionslisten statt Karten) */
.rows { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.rows dt { color: var(--ink-soft); }
.rows dd { margin: 0; }
.rows dd.mono { font-size: 15px; }

/* Flugtabelle */
.flights { width: 100%; border-collapse: collapse; font-size: 15px; }
.flights td { padding: 8px 0; border-top: 1px solid var(--dune); vertical-align: top; }
.flights tr:first-child td { border-top: 0; }
.flights .no { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); white-space: nowrap; padding-right: 10px; }
.flights .t { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border: 2px solid var(--ink); border-radius: 4px;
  background: var(--sand); color: var(--ink); font-weight: 600; cursor: pointer;
  min-height: 48px; text-decoration: none; transition: transform 80ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--sand); }
.btn-oracle { background: var(--ochre); border-color: var(--ochre-deep); color: #fff; width: 100%; font-size: 19px; min-height: 60px; }
.btn-quiet { border-color: var(--dune-deep); color: var(--ink-soft); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn-row .btn { flex: 1 1 auto; }

/* Formularfelder */
.field { margin: 12px 0; }
.field label { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 15px; }
.field select, .field input[type=text] {
  width: 100%; padding: 10px 12px; border: 2px solid var(--dune-deep); border-radius: 4px; background: #fff8e8;
}
.field input[type=range] { width: 100%; accent-color: var(--ochre); }
.radius-out { font-family: var(--mono); font-size: 15px; }

/* Orakel-Ausgabe */
.oracle-out { margin-top: 20px; }
.coord {
  font-family: var(--mono); font-size: 24px; font-weight: 700; letter-spacing: 0.02em;
  padding: 14px 0; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  font-variant-numeric: tabular-nums; white-space: pre; overflow-x: auto;
}
.coord.rolling { color: var(--ochre); }
.nav-grid { display: grid; grid-template-columns: 1fr 140px; gap: 16px; align-items: center; margin: 16px 0; }
.nav-grid .big { font-size: 40px; font-weight: 700; font-stretch: 75%; line-height: 1; font-variation-settings: 'opsz' 96; }
.nav-grid .sub { color: var(--ink-soft); font-size: 14px; }
.compass { width: 140px; height: 140px; }
.compass .needle { transform-origin: 70px 70px; transition: transform 300ms ease-out; }
.compass .ring { transform-origin: 70px 70px; transition: transform 300ms ease-out; }
.arrived { background: var(--ok); color: #fff; padding: 12px 14px; border-radius: 4px; font-weight: 600; }
.hint { font-size: 14px; color: var(--ink-soft); margin-top: 8px; }

/* Missionen */
.mission { padding: 14px 0; border-top: 1px solid var(--dune); position: relative; }
.mission:first-of-type { border-top: 0; }
.mission .kind { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }
.mission .text { margin: 6px 0 10px; }
.mission .target { font-family: var(--mono); font-size: 14px; }
.mission.done { color: var(--ink-soft); }
.stamp {
  position: absolute; right: 4px; top: 10px; transform: rotate(-12deg);
  border: 3px solid var(--fuse); color: var(--fuse); padding: 2px 10px; border-radius: 4px;
  font-weight: 800; font-stretch: 75%; letter-spacing: 0.08em; font-size: 15px; opacity: 0.85;
}
.stamp.ok { border-color: var(--ok); color: var(--ok); }
.empty { padding: 24px 0; color: var(--ink-soft); }

/* Rang */
.rank { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.rank b { font-size: 28px; font-stretch: 80%; font-weight: 700; }
.rankbar { height: 6px; background: var(--dune); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.rankbar i { display: block; height: 100%; background: var(--ochre); }

/* Phrasen */
.phrases { width: 100%; border-collapse: collapse; }
.phrases td { padding: 7px 0; border-top: 1px solid var(--dune); vertical-align: top; }
.phrases tr:first-child td { border-top: 0; }
.phrases .ar { font-size: 20px; text-align: right; direction: rtl; }
.phrases .tr { font-family: var(--mono); font-size: 14px; color: var(--ink-soft); }
ul.plain { padding-left: 18px; margin: 0; }
ul.plain li { margin: 6px 0; }

/* Log */
.log-entry { padding: 12px 0; border-top: 1px solid var(--dune); }
.log-entry:first-child { border-top: 0; }
.log-entry time { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); display: block; }
.log-entry .pts { float: right; font-weight: 700; }

/* Tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--sand); border-top: 2px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
.tabs a {
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  color: var(--ink-soft); font-weight: 600; font-size: 15px; border-right: 1px solid var(--dune);
}
.tabs a:last-child { border-right: 0; }
.tabs a.active { color: var(--ink); box-shadow: inset 0 -4px 0 var(--ochre); }

/* Transmission (Vollbild, dunkel, Bernstein) */
.transmission {
  position: fixed; inset: 0; z-index: 20; background: var(--tx-black); color: var(--phosphor);
  font-family: var(--mono); padding: calc(24px + env(safe-area-inset-top)) 22px 24px;
  overflow-y: auto; display: flex; flex-direction: column;
}
.transmission[hidden] { display: none; }
.transmission::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,179,71,0.05) 0 1px, transparent 1px 3px);
}
.transmission::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.6));
}
.tx-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--phosphor-dim); margin-bottom: 28px; }
.tx-body { font-size: 18px; line-height: 1.55; white-space: pre-wrap; flex: 1; min-height: 40vh; }
.tx-body .cursor { display: inline-block; width: 0.6em; height: 1.1em; background: var(--phosphor); vertical-align: -0.15em; animation: blink 0.9s steps(1) infinite; }
.tx-body .w { display: inline-block; }
.tx-body .ch { display: inline-block; }
.tx-body .ch.burn { animation: burn 1.3s ease-in forwards; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes burn {
  0% { color: var(--phosphor); transform: none; opacity: 1; }
  30% { color: #ff6a3d; }
  60% { color: var(--fuse); opacity: 0.9; }
  100% { color: #000; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}
.tx-countdown { font-size: 15px; color: var(--phosphor-dim); margin: 16px 0 4px; min-height: 1.5em; }
.tx-countdown b { color: var(--fuse); font-size: 26px; }
.tx-actions { display: flex; gap: 10px; margin-top: 16px; }
.tx-actions .btn { flex: 1; background: transparent; border-color: var(--phosphor); color: var(--phosphor); }
.tx-actions .btn-primary { background: var(--phosphor); color: var(--tx-black); }
.tx-static { position: absolute; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}
.tx-static.on { animation: static 1.2s steps(8) forwards; }
@keyframes static { 0% { opacity: 0.9; } 100% { opacity: 0; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--sand); padding: 10px 16px; border-radius: 4px; z-index: 30; max-width: 90vw; font-size: 15px;
}

/* Ziffernrollen beim Orakel */
.rolling .d { display: inline-block; animation: roll 90ms steps(1) infinite; }
@keyframes roll { 0% { opacity: 1; } 50% { opacity: 0.4; } }

@media (prefers-reduced-motion: reduce) {
  .tx-body .cursor { animation: none; }
  .tx-body .ch.burn { animation-duration: 0.3s; }
  .compass .needle, .compass .ring { transition: none; }
}
