:root {
  --ink: #f2ead9;
  --dim: rgba(242, 234, 217, 0.72);
  --panel: rgba(11, 20, 24, 0.82);
  --brass: #c9a25a;
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1418;
  color: var(--ink);
  font: 15px/1.35 Georgia, 'Times New Roman', serif;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── HUD ── */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
#hud-place {
  position: absolute;
  top: calc(var(--sat) + 10px);
  left: calc(var(--sal) + 14px);
  font-size: 17px;
  letter-spacing: 0.04em;
}
#hud-physics {
  position: absolute;
  top: calc(var(--sat) + 34px);
  left: calc(var(--sal) + 14px);
  font: 12px/1.4 ui-monospace, Menlo, monospace;
  color: var(--dim);
  white-space: pre;
}
#hud-perf {
  position: absolute;
  top: calc(var(--sat) + 10px);
  right: calc(var(--sar) + 62px);
  font: 11px/1.4 ui-monospace, Menlo, monospace;
  color: var(--dim);
  text-align: right;
  white-space: pre;
}
#hud-toast {
  position: absolute;
  top: calc(var(--sat) + 16px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 90, 0.5);
  opacity: 0;
  transition: opacity 0.4s;
  white-space: nowrap;
}
#hud-toast.show {
  opacity: 1;
}
#btn-settings {
  position: absolute;
  top: calc(var(--sat) + 8px);
  right: calc(var(--sar) + 12px);
  width: 40px;
  height: 40px;
  pointer-events: auto;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 90, 0.6);
  background: var(--panel);
  color: var(--ink);
  font-size: 18px;
}

/* ── touch controls ── */
#controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#stick-zone {
  position: absolute;
  left: 0;
  top: 56px;
  bottom: 0;
  width: 50%;
  pointer-events: auto;
}
#stick-base {
  position: absolute;
  left: -64px;
  top: -64px;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 2px solid rgba(242, 234, 217, 0.35);
  background: rgba(11, 20, 24, 0.25);
  opacity: 0;
  transition: opacity 0.15s;
}
#stick-base.active {
  opacity: 1;
}
#stick-knob {
  position: absolute;
  left: 36px;
  top: 36px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(242, 234, 217, 0.55);
}
#actions {
  position: absolute;
  right: calc(var(--sar) + 18px);
  bottom: calc(var(--sab) + 18px);
  width: 250px;
  height: 200px;
}
.action {
  position: absolute;
  pointer-events: auto;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid rgba(201, 162, 90, 0.75);
  background: rgba(11, 20, 24, 0.5);
  color: var(--ink);
  font: 13px Georgia, serif;
  letter-spacing: 0.03em;
}
.action.big {
  width: 92px;
  height: 92px;
  font-size: 15px;
}
.action.small {
  width: 58px;
  height: 58px;
  font-size: 12px;
}
.action.down {
  background: rgba(201, 162, 90, 0.55);
  transform: scale(0.94);
}
/* Three buttons round the thumb's rest at the lower right: Jump big under
   the thumb, Dash to its left, the Hand above. */
#btn-jump {
  right: 0;
  bottom: 0;
}
#btn-dash {
  right: 104px;
  bottom: 4px;
}
#btn-interact {
  right: 14px;
  bottom: 104px;
}

/* North needle, small and out of the way, under the round buttons. */
#compass {
  position: absolute;
  top: calc(var(--sat) + 56px);
  right: calc(var(--sar) + 16px);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 90, 0.45);
  background: rgba(11, 20, 24, 0.35);
}
#compass-needle {
  position: absolute;
  inset: 3px;
  background: linear-gradient(to bottom, rgba(190, 60, 45, 0.95) 0 50%, rgba(230, 220, 200, 0.85) 50% 100%);
  clip-path: polygon(50% 0, 62% 50%, 50% 100%, 38% 50%);
}
#compass-needle span {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font: 10px Georgia, serif;
  color: var(--ink);
}
/* Wounds: one line per hurt part, short. */
#hud-wounds {
  position: absolute;
  top: calc(var(--sat) + 100px);
  left: calc(var(--sal) + 14px);
  font-size: 12px;
  line-height: 1.35;
  color: #e8b0a0;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* ── overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  background: rgba(8, 14, 18, 0.66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.overlay.hidden {
  display: none;
}
.card {
  max-width: 440px;
  max-height: 100%;
  overflow: auto;
  padding: 20px 26px;
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 90, 0.55);
  border-radius: 6px;
}
.kicker {
  margin: 0;
  color: var(--brass);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 12px;
}
h1 {
  margin: 2px 0 0;
  font-size: 44px;
  font-weight: normal;
  letter-spacing: 0.06em;
}
h2 {
  margin: 0 0 10px;
  font-weight: normal;
  font-size: 22px;
}
.sub {
  margin: 2px 0 16px;
  color: var(--dim);
}
.hint {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 13px;
}
.card button {
  padding: 10px 26px;
  border-radius: 4px;
  border: 1px solid var(--brass);
  background: rgba(201, 162, 90, 0.2);
  color: var(--ink);
  font: 17px Georgia, serif;
}
.panel {
  text-align: left;
  width: min(440px, 100%);
  -webkit-user-select: auto;
  user-select: auto;
}
.panel label {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.panel select,
.panel input {
  width: 100%;
  font: 14px Georgia, serif;
  padding: 4px;
}
.panel button {
  display: block;
  margin: 12px auto 0;
}

#rotate {
  display: none;
  z-index: 10;
  background: #0b1418;
}
@media (orientation: portrait) and (pointer: coarse) {
  #rotate {
    display: grid;
  }
}
@media (hover: hover) and (pointer: fine) {
  #actions {
    opacity: 0.55;
  }
}

/* ── story interface ── */
#bars {
  position: absolute;
  top: calc(var(--sat) + 34px);
  left: calc(var(--sal) + 14px);
  width: 170px;
}
.bar {
  height: 9px;
  margin-bottom: 3px;
  border: 1px solid rgba(242, 234, 217, 0.5);
  border-radius: 2px;
  background: rgba(11, 20, 24, 0.6);
}
.bar.xp {
  height: 5px;
  width: 120px;
}
#hp-fill {
  height: 100%;
  background: #b9412f;
  transition: width 0.2s;
}
#xp-fill {
  height: 100%;
  background: var(--brass);
  transition: width 0.3s;
}
#lvl {
  position: absolute;
  left: 128px;
  top: 9px;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}
#quest {
  position: absolute;
  top: calc(var(--sat) + 64px);
  left: calc(var(--sal) + 14px);
  max-width: 46vw;
  font-size: 14px;
  line-height: 1.25;
}
#quest-arrow {
  display: inline-block;
  margin-right: 7px;
  color: var(--brass);
  font-size: 13px;
}
#quest-dist {
  margin-left: 7px;
  color: var(--dim);
  font-size: 12px;
}
#btn-book {
  position: absolute;
  top: calc(var(--sat) + 8px);
  right: calc(var(--sar) + 60px);
  width: 40px;
  height: 40px;
  pointer-events: auto;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 90, 0.6);
  background: var(--panel);
  color: var(--ink);
  font-size: 18px;
}
#hud-perf {
  right: calc(var(--sar) + 112px);
}
#hud-toast {
  top: calc(var(--sat) + 52px);
  max-width: 70vw;
  white-space: normal;
  text-align: center;
  font-size: 14px;
}
#banner {
  position: absolute;
  top: 26%;
  left: 0;
  right: 0;
  text-align: center;
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
}
#banner.show {
  opacity: 1;
}
#banner-title {
  color: var(--brass);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 13px;
}
#banner-sub {
  font-size: 34px;
  letter-spacing: 0.05em;
}
#dialog {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + 14px);
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 2 * max(var(--sal), var(--sar)) - 24px));
  padding: 10px 16px 8px;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 90, 0.7);
  border-radius: 6px;
  z-index: 5;
}
#dialog.hidden {
  display: none;
}
#dlg-who {
  color: var(--brass);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 4px;
}
#dlg-text {
  font-size: 17px;
  line-height: 1.3;
  margin: 2px 0 4px;
}
#dlg-choices button {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 9px 12px;
  text-align: left;
  border-radius: 4px;
  border: 1px solid var(--brass);
  background: rgba(201, 162, 90, 0.16);
  color: var(--ink);
  font: 16px Georgia, serif;
}
#dlg-more {
  text-align: right;
  color: var(--dim);
  font-size: 12px;
}
#book-body {
  font-size: 14px;
  line-height: 1.35;
}
#book-body h3 {
  margin: 10px 0 3px;
  font-weight: normal;
  color: var(--brass);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#book-body p,
#book-body ul {
  margin: 2px 0;
  padding-left: 0;
  list-style: none;
}
#book-body li {
  margin: 3px 0;
}
.card button.quiet {
  font-size: 13px;
  padding: 6px 14px;
  border-color: rgba(242, 234, 217, 0.4);
  background: none;
  color: var(--dim);
}

/* ── language choice on the start card ── */
#langs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: -6px 0 14px;
}
#langs button {
  padding: 5px 12px;
  font-size: 13px;
  border-color: rgba(242, 234, 217, 0.35);
  background: none;
  color: var(--dim);
}
#langs button.on {
  border-color: var(--brass);
  background: rgba(201, 162, 90, 0.2);
  color: var(--ink);
}

/* Links to imprint, privacy and sources on the start screen and in the settings. */
.legal-links a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* No fights any more (docs/Umbauplan.md, phase 3): no health bar, no wounds, no levels. */
#bars,
#hud-wounds {
  display: none;
}

/* The inked town map in the notebook: tall like the old town, scrolls with the page. */
#book-map {
  display: block;
  width: min(320px, 100%);
  height: auto;
  margin: 6px auto 12px;
  border: 1px solid rgba(201, 162, 90, 0.7);
  border-radius: 3px;
}

/* One line on the start screen that says what the game is about. */
.teaser {
  max-width: 34em;
  margin: 6px auto 14px;
  font-style: italic;
  line-height: 1.4;
}

/* A jump through time: the picture goes white, the next town fades in. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: #f4efe2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease-in;
  z-index: 50;
}
body.jumping::after {
  opacity: 1;
}

/* Start: a new game is the normal way (the game is in the making). */
#start-choice {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0 2px;
}
.card button.primary {
  background: rgba(201, 162, 90, 0.55);
  font-weight: bold;
}
.card button.quiet:disabled {
  opacity: 0.4;
}

/* The coach: a short hint at the top, the element to use pulses in gold. */
#coach {
  position: fixed;
  left: 50%;
  top: calc(var(--sat) + 64px);
  transform: translateX(-50%);
  width: min(440px, calc(100% - 32px));
  padding: 10px 40px 10px 14px;
  background: var(--panel);
  border: 2px solid #f2c14e;
  border-radius: 6px;
  color: var(--ink);
  font: 15px/1.4 Georgia, serif;
  z-index: 30;
  pointer-events: auto;
}
#coach.hidden {
  display: none;
}
#coach-text {
  margin: 0;
}
#coach-skip {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 20px Georgia, serif;
}
.coach-hl {
  outline: 4px solid #ffd34d;
  outline-offset: 4px;
  box-shadow: 0 0 0 8px rgba(255, 211, 77, 0.35), 0 0 24px 8px rgba(255, 211, 77, 0.6);
  animation: coach-pulse 0.9s ease-in-out infinite;
  z-index: 25;
}
canvas.coach-hl {
  outline-offset: -8px;
  box-shadow: none;
  animation: coach-frame 0.9s ease-in-out infinite;
}
/* Buttons also swell a little; the stick is placed by a transform of its own. */
button.coach-hl {
  animation-name: coach-swell;
}
@keyframes coach-pulse {
  50% {
    outline-color: rgba(255, 211, 77, 0.3);
    box-shadow: 0 0 0 14px rgba(255, 211, 77, 0.15), 0 0 30px 12px rgba(255, 211, 77, 0.3);
  }
}
@keyframes coach-swell {
  50% {
    outline-color: rgba(255, 211, 77, 0.3);
    box-shadow: 0 0 0 14px rgba(255, 211, 77, 0.15), 0 0 30px 12px rgba(255, 211, 77, 0.3);
    transform: scale(1.1);
  }
}
@keyframes coach-frame {
  50% {
    outline-color: rgba(255, 211, 77, 0.25);
  }
}

/* Coordinates for placing things precisely (settings: Koordinaten). */
#coords {
  position: absolute;
  left: calc(var(--sal) + 10px);
  bottom: calc(var(--sab) + 150px);
  max-width: min(420px, calc(100% - 20px));
  padding: 6px 8px;
  background: rgba(8, 14, 18, 0.72);
  border: 1px solid rgba(201, 162, 90, 0.55);
  border-radius: 4px;
  color: #f2e6c8;
  font: 12px/1.45 ui-monospace, Menlo, monospace;
  white-space: pre;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  z-index: 20;
}
#coords.hidden {
  display: none;
}

/* While a new game is prepared after "Neu starten" (src/boot.js): no buttons. */
#start.fresh #start-choice,
#start.fresh #start-saved {
  display: none;
}
#start-status:not(:empty) {
  color: var(--brass);
  font-size: 15px;
}
.card button:disabled {
  opacity: 0.45;
}
