/* Botchbridge – UI „Werkstatt am Berg“ (docs/ui/kritik-1.md, Abschnitt 3):
   Papier für Karten und Zettel, Holz für Leiste und Kopf, Messing als Akzent, Moos = hält, Rost = Gefahr.
   Schriften lokal (public/schrift/): Bree Serif für Titel, Nunito für alles andere. */
@font-face { font-family: 'Bree Serif'; src: url(schrift/bree-serif.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(schrift/nunito-var.woff2) format('woff2'); font-weight: 200 1000; font-display: swap; }

:root {
  --papier: #efe3c8;
  --papier-hell: #f8efdb;
  --papier-dunkel: #d9c7a2;
  --holz: #5d3f27;
  --holz-hell: #7d5734;
  --holz-dunkel: #2f2014;
  --tafel: #23201bf0;          /* Text über dem Bild */
  --tinte: #2f2418;
  --tinte-weich: #6e5b44;
  --kreide: #f6eedb;
  --kreide-weich: #cfc2a6;
  --messing: #d6a94a;
  --messing-hell: #f0cf7f;
  --moos: #6f9a52;
  --moos-hell: #a9cf86;
  --rost: #c4553a;
  --rost-hell: #f1a088;
  --radius: 10px;
  --schatten: 0 3px 0 var(--holz-dunkel), 0 10px 22px #1a120a66;
  --titel: 'Bree Serif', Georgia, serif;
  --text: 'Nunito', system-ui, sans-serif;
  /* alte Namen, die noch im JS stehen könnten */
  --akzent: var(--messing-hell);
  --gut: var(--moos-hell);
  --schlecht: var(--rost-hell);
  --gedaempft: var(--kreide-weich);
  --linie: #6b5238;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1e1913; color: var(--kreide); font: 500 15px/1.35 var(--text); }
body { display: flex; flex-direction: column; overflow: hidden; user-select: none; }

/* Holzmaserung als wiederverwendbarer Hintergrund */
header, #inventar, #werkzeug {
  background:
    repeating-linear-gradient(176deg, #ffffff07 0 2px, transparent 2px 9px, #0000000d 9px 11px, transparent 11px 23px),
    linear-gradient(180deg, var(--holz-hell), var(--holz) 55%, #4d3420);
}

header {
  z-index: 2;
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.15vw, 30px);
  min-height: 62px;
  padding: 7px 16px;
  border-bottom: 3px solid var(--holz-dunkel);
  box-shadow: inset 0 -2px 0 #e0b35c55, 0 4px 14px #1a120a66;
}
body:is([data-ansicht="start"], [data-ansicht="raum"]) header { display: none; }
.titel {
  display: flex;
  align-items: center;
  gap: 9px;
  font: 400 24px/1 var(--titel);
  color: var(--messing-hell);
  text-shadow: 0 2px 0 var(--holz-dunkel);
}
.titel::before {
  content: '';
  width: 26px;
  height: 20px;
  background: currentColor;
  clip-path: polygon(0 18%, 100% 18%, 100% 28%, 90% 28%, 75% 80%, 25% 80%, 10% 28%, 0 28%, 0 18%, 21% 28%, 30% 64%, 44% 28%, 56% 28%, 70% 64%, 79% 28%, 64% 28%, 72% 53%, 64% 70%, 50% 35%, 36% 70%, 64% 70%, 72% 53%, 64% 28%, 56% 28%, 44% 28%, 21% 28%);
}
/* Werte in der Kopfzeile: kleine Papierschilder */
.info {
  color: var(--tinte-weich);
  white-space: nowrap;
  font-size: 13px;
  padding: 4px 11px 5px;
  background: var(--papier);
  border-radius: 7px;
  box-shadow: 0 2px 0 var(--holz-dunkel);
  line-height: 1.15;
}
.info:empty { display: none; }
.info b { color: var(--tinte); font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.info small { margin-left: 6px; color: var(--tinte-weich); font-size: 11px; font-weight: 700; }
.info > span, .uhr::before {
  display: block;
  color: var(--tinte-weich);
  font-size: 11px;
  font-weight: 700;
}
/* Uhr als Messingschild */
.uhr {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  font-size: 21px;
  color: var(--tinte);
  background: linear-gradient(180deg, var(--messing-hell), var(--messing));
  text-align: center;
  min-width: 78px;
}
.uhr::before { content: 'Bauzeit'; color: #5b4423; }
html:lang(en) .uhr::before { content: 'Build time'; }
.uhr.knapp { color: #fff; background: linear-gradient(180deg, #d96a4c, var(--rost)); animation: uhrPuls 1s ease-in-out infinite; }
.uhr.knapp::before { color: #ffe0d4; }
@keyframes uhrPuls { 50% { transform: scale(1.07); } }
#fahrbahnInfo b { color: var(--rost); }
#fahrbahnInfo:not(.bereit):not(:empty) {
  background: var(--rost);
  box-shadow: 0 2px 0 var(--holz-dunkel), 0 0 0 0 #f1a08866;
  animation: fahrbahnPuls 1.4s ease-in-out infinite;
}
#fahrbahnInfo:not(.bereit) > span { color: #ffe0d4; }
#fahrbahnInfo:not(.bereit) b { color: #fff; }
@keyframes fahrbahnPuls { 50% { box-shadow: 0 2px 0 var(--holz-dunkel), 0 0 0 5px #f1a08844; } }
#fahrbahnInfo.bereit b { color: #4d7a35; }
#fahrbahnInfo b::before { content: ''; display: inline-block; width: 7px; height: 7px; margin: 0 6px 2px 0; border-radius: 50%; background: currentColor; }
#mpInfo { font-weight: 700; }
.knoepfe { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.karte .knoepfe { margin: 20px 0 0; justify-content: center; flex-wrap: wrap; }

/* ---------- Knöpfe: Papier mit Holzrand, Haupt = Messing, Gefahr = Rost ---------- */
button {
  font: 800 14px/1.25 var(--text);
  padding: 8px 15px;
  min-height: 38px;
  border-radius: 9px;
  border: 2px solid var(--holz-dunkel);
  background: var(--papier);
  color: var(--tinte);
  box-shadow: 0 3px 0 var(--holz-dunkel);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .06s, box-shadow .06s, background .12s;
}
button:hover:not(:disabled) { background: var(--papier-hell); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--holz-dunkel); }
button:focus-visible { outline: 3px solid var(--messing-hell); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
button.haupt { background: linear-gradient(180deg, var(--messing-hell), var(--messing)); color: var(--tinte); }
button.haupt:hover:not(:disabled) { background: linear-gradient(180deg, #f8dd98, #e1b65a); }
button[aria-disabled="true"] { background: var(--papier-dunkel); color: var(--tinte-weich); box-shadow: 0 3px 0 #2f201488; }
button.gefahr { color: #fff; background: var(--rost); }
button.gefahr:hover:not(:disabled) { background: #d4654a; }
button.rund { width: 38px; padding: 0; font-size: 17px; }
.taste { display: inline-block; min-width: 18px; padding: 0 4px; margin-left: 4px; border-radius: 4px; background: #2f201422; color: var(--tinte-weich); font-size: 11px; line-height: 17px; text-align: center; }

#mitte { flex: 1; min-height: 0; display: flex; }
main { position: relative; flex: 1; min-width: 0; min-height: 0; }
canvas { display: block; width: 100%; height: 100%; }

/* Hilfe: Tafel über dem Bild, blendet aus, kommt mit ? oder H wieder */
#hilfe {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  width: max-content;
  color: var(--kreide);
  background: var(--tafel);
  border: 2px solid #00000055;
  border-radius: var(--radius);
  box-shadow: 0 6px 18px #1a120a66;
  font-size: 13px;
  padding: 8px 14px;
  pointer-events: none;
  opacity: 0;
}
#hilfe.offen { animation: hilfeAus 1.2s ease 8s forwards; opacity: 1; }
#hilfe span { white-space: nowrap; }
#hilfe b { color: var(--messing-hell); font-weight: 800; }
@keyframes hilfeAus { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #hilfe.offen { animation-timing-function: steps(1, end); } .uhr.knapp { animation: none; } }

#meldung {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  color: var(--kreide);
  background: var(--tafel);
  border: 2px solid #00000055;
  box-shadow: 0 6px 18px #1a120a66;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  pointer-events: none;
  z-index: 3;
}

body[data-modus="test"] :is(#inventar, .bau-knopf),
body[data-modus="ergebnis"] :is(#inventar, .bau-knopf),
body[data-modus="wiedergabe"] .bau-knopf { display: none; }
.fahrt-kopf :is(#uhr, #duebelInfo, #fahrbahnInfo, #mpInfo) { display: none; }
.fahrt-kopf #fahrtModus { margin-left: auto; }
.fahrt-kopf .knoepfe { margin-left: 0; }
#fahrtModus b { color: var(--tinte); }

#fahrtAnzeige {
  display: grid;
  flex: 1 1 416px;
  grid-template-columns: 80px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 11px;
  max-width: 430px;
  min-width: 312px;
  min-height: 52px;
  padding: 4px 10px 4px 4px;
  margin-inline: auto;
  color: var(--tinte);
  background: var(--papier);
  border-radius: 9px;
  box-shadow: 0 3px 0 var(--holz-dunkel);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#fahrtBild { max-height: 45px; }
body[data-modus="test"] #fahrtModus { margin-left: 0; }
@media (min-width: 571px) and (max-width: 950px) {
  body[data-modus="test"] :is(#levelInfo, #fahrtModus) { display: none; }
}
#fahrtBild, #ergebnisBild {
  height: auto;
  background: radial-gradient(ellipse at 50% 74%, #ffffff55, transparent 75%), #c9d6d0;
  border: 2px solid var(--holz-dunkel);
  border-radius: 6px;
}
.fahrt-zeile { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
#fahrtName { color: var(--tinte); font: 400 20px/1.05 var(--titel); white-space: nowrap; }
#fahrtMasse { color: var(--tinte-weich); font-size: 12px; font-weight: 800; white-space: nowrap; }
.fahrt-status { margin: 4px 0 7px; color: var(--tinte-weich); font-size: 12px; font-weight: 700; line-height: 1; white-space: nowrap; }
#fahrtFortschritt { height: 4px; border-radius: 2px; overflow: hidden; background: var(--papier-dunkel); }
#fahrtFortschritt i, #fahrtLast i::after {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left;
  transform: scaleX(var(--anteil, 0));
  border-radius: inherit;
  background: var(--messing);
}
#fahrtLast {
  display: grid;
  gap: 1px;
  padding-left: 10px;
  border-left: 2px solid var(--papier-dunkel);
  color: var(--tinte-weich);
  font-size: 10px;
  font-weight: 700;
}
#fahrtLast b { font-size: 17px; color: var(--tinte); line-height: 1.25; white-space: nowrap; }
#fahrtLast i { height: 4px; margin-top: 3px; border-radius: 2px; background: var(--papier-dunkel); }
#fahrtLast i::after { content: ''; background: var(--lastfarbe, var(--moos)); }
#fahrtAnzeige[data-zustand="bruch"] { background: #f6d6c8; }
#fahrtAnzeige[data-zustand="bruch"] #fahrtPhase { color: var(--rost); }
#fahrtAnzeige[data-zustand="ziel"] #fahrtPhase { color: #4d7a35; }

/* Ergebnis im Einzelspiel: Papierstreifen über dem unteren Bildrand (verkleinert das Feld nicht) */
#ergebnis {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 980px);
  max-height: 45vh;
  overflow: auto;
  z-index: 4;
  color: var(--tinte);
  background: var(--papier);
  border: 2px solid var(--holz-dunkel);
  border-radius: 12px;
  box-shadow: var(--schatten);
  animation: hochkommen .35s cubic-bezier(.2, 1.4, .4, 1);
}
body[data-modus="ergebnis"]:not(.schmal) #inventar { display: none; }
#ergebnis .ergebnis-karte {
  --signal: #4d7a35;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px 22px;
  width: 100%;
  margin: 0;
  padding: 12px 18px 14px;
  background: transparent;
  border: 0;
  box-shadow: none;
  text-align: left;
  color: var(--tinte);
  animation: none;
}
#ergebnis:is([data-ausgang="offen"], [data-ausgang="teilerfolg"]) .ergebnis-karte { --signal: #9a6a1c; }
#ergebnis[data-ausgang="abbruch"] .ergebnis-karte { --signal: var(--rost); }
#ergebnisEtikett { color: var(--signal); font-weight: 900; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
#ergebnisTitel { margin: 1px 0 2px; color: var(--tinte); font: 400 clamp(21px, 3.8vw, 28px)/1.1 var(--titel); }
#ergebnisText { font-size: 13px; line-height: 1.35; color: var(--tinte-weich); }
.ergebnis-daten { display: flex; gap: 9px; align-items: center; border-left: 2px solid var(--papier-dunkel); padding-left: 12px; }
#ergebnisBild { width: 82px; }
.ergebnis-daten div { display: grid; gap: 3px; }
#ergebnisStufe { color: var(--signal); font-size: 14px; font-weight: 900; white-space: nowrap; }
#ergebnisBrueche { color: var(--tinte-weich); font-size: 12px; white-space: nowrap; }
.ergebnis-karte .knoepfe { margin: 0; justify-content: end; }
@media (max-width: 800px) {
  #ergebnis .ergebnis-karte { grid-template-columns: minmax(0, 1fr) auto; }
  .ergebnis-karte .knoepfe { grid-column: 1 / -1; padding-top: 8px; border-top: 2px solid var(--papier-dunkel); }
}
@keyframes hochkommen { from { transform: translate(-50%, 30px); opacity: 0; } }

/* ---------- Karten (Dialoge): Papier mit Holzrand ---------- */
.karte {
  position: relative;
  color: var(--tinte);
  background:
    radial-gradient(circle at 12px 12px, var(--messing) 3px, #0000 4px),
    radial-gradient(circle at calc(100% - 12px) 12px, var(--messing) 3px, #0000 4px),
    radial-gradient(circle at 12px calc(100% - 12px), var(--messing) 3px, #0000 4px),
    radial-gradient(circle at calc(100% - 12px) calc(100% - 12px), var(--messing) 3px, #0000 4px),
    linear-gradient(180deg, var(--papier-hell), var(--papier));
  border: 3px solid var(--holz-dunkel);
  padding: 24px 30px;
  border-radius: 14px;
  width: min(100%, 440px);
  text-align: center;
  box-shadow: var(--schatten);
  animation: aufklappen .3s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes aufklappen { from { transform: translateY(14px) scale(.97); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .karte, #ergebnis { animation: none; } }
.karte h2 { margin: 0 0 8px; color: var(--tinte); font: 400 30px/1.15 var(--titel); }
.karte p { margin: 0; color: var(--tinte-weich); line-height: 1.5; }

/* ---------- Teileleiste: Werkbank mit Zetteln ---------- */
#inventar {
  width: 204px;
  display: flex;
  flex-direction: column;
  border-right: 3px solid var(--holz-dunkel);
  box-shadow: inset -2px 0 0 #e0b35c33;
}
.inventar-kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 11px 10px;
}
#inventar h2 { margin: 0; font: 400 17px/1 var(--titel); color: var(--messing-hell); text-shadow: 0 2px 0 var(--holz-dunkel); white-space: nowrap; }
#inventarZaehler { margin-left: 3px; color: var(--kreide-weich); font: 800 12px var(--text); text-shadow: none; }
#inventarStatus { color: var(--messing-hell); font-size: 11px; font-weight: 800; white-space: nowrap; }
#leiste {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  padding: 2px 10px 12px;
  overflow-y: auto;
  scrollbar-color: var(--holz-hell) var(--holz-dunkel);
}
.teilkarte {
  position: relative;
  min-width: 0;
  min-height: 80px;
  padding: 6px 3px 5px 3px;
  border-radius: 6px 6px 8px 8px;
  background: linear-gradient(180deg, var(--papier-hell), var(--papier));
  box-shadow: 0 3px 0 var(--holz-dunkel), 0 5px 8px #1a120a55;
  cursor: grab;
  text-align: center;
  transition: transform .08s;
}
.teilkarte:nth-child(odd) { transform: rotate(-.6deg); }
.teilkarte:nth-child(even) { transform: rotate(.5deg); }
.teilkarte:hover { background: #fff7e6; transform: translateY(-2px); }
/* Material als farbiger Streifen oben */
.teilkarte::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; border-radius: 6px 6px 0 0; background: var(--materialfarbe, var(--messing)); }
.teilkarte[data-material="holz"] { --materialfarbe: #a8743f; }
.teilkarte[data-material="stahl"] { --materialfarbe: #7e8c96; }
.teilkarte[data-material="seil"] { --materialfarbe: #c9a66b; }
.teilkarte[data-material="beton"] { --materialfarbe: #a7a39a; }
.teilkarte.gehalten {
  cursor: grabbing;
  background: #fff3d2;
  box-shadow: inset 0 0 0 3px var(--messing), 0 3px 0 var(--holz-dunkel);
  transform: none;
}
.teilkarte canvas { height: 50px; }
.teilkarte div {
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--tinte);
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.teilkarte div small { display: block; font-size: 10px; font-weight: 700; color: var(--tinte-weich); }
/* Verbaute Teile bleiben im Inventar erkennbar. */
.teilkarte.benutzt, .teilkarte.benutzt:hover {
  cursor: default;
  background: #a8916c;
  box-shadow: inset 0 2px 5px #0004, 0 1px 0 var(--holz-dunkel);
  transform: none;
}
.teilkarte.benutzt > :is(canvas, img, div) { opacity: .55; filter: saturate(.5); }
.teilkarte.benutzt::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: #fff;
  background: var(--moos);
  box-shadow: 0 1px 0 var(--holz-dunkel);
  font: 900 11px/17px var(--text);
}
.material-icon {
  position: absolute; left: 3px; top: 7px; width: 18px; height: 18px;
  pointer-events: none; opacity: .9;
}
.leer { color: var(--kreide-weich); }

.versteckt { display: none !important; }
#werkzeug {
  position: absolute;
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 2px solid var(--holz-dunkel);
  border-radius: 12px;
  box-shadow: var(--schatten);
}
#werkzeug button { min-height: 36px; padding: 5px 10px; font-size: 13px; }
/* Touch: Bild und Werkzeug nehmen Gesten selbst, Leiste wischt nur waagrecht (hochziehen holt ein Teil heraus) */
#feld, #werkzeug { touch-action: none; }
.teilkarte { touch-action: pan-x; -webkit-touch-callout: none; }
body[data-zeiger="finger"] #werkzeug button { min-height: 44px; padding-inline: 12px; }
body[data-zeiger="finger"] #werkzeug .taste { display: none; }

/* ---------- Mehrspieler (mehrspieler.js) ---------- */
#mp { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 55%, #1a120a22, #1a120a88); z-index: 5; padding: 12px; overflow: auto; }
body:is([data-ansicht="start"], [data-ansicht="raum"]) #mp { background: radial-gradient(ellipse at 50% 60%, transparent 30%, #1a120a66); }
#mp.durchsichtig { background: transparent; pointer-events: none; align-items: start; justify-items: end; padding: 10px 12px; }
#mp.durchsichtig .karte { pointer-events: auto; width: max-content; padding: 0; background: none; border: 0; box-shadow: none; animation: none; }
#mpKarte { width: min(100%, 520px); }
#mpKarte .zeile { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
#mpKarte label { display: block; margin: 16px 0 5px; color: var(--tinte-weich); font-size: 13px; font-weight: 800; text-align: left; }
#mpKarte input {
  font: 800 17px var(--text); padding: 9px 12px; border-radius: 9px;
  border: 2px solid var(--holz-dunkel); background: #fffaf0; color: var(--tinte);
  box-shadow: inset 0 2px 0 #2f201418; max-width: 100%; width: 100%;
}
#mpKarte input::placeholder { color: #b5a283; font-weight: 700; }
#mpKarte input:focus-visible { outline: 3px solid var(--messing); outline-offset: 1px; }
#mpKarte input.code { width: 120px; text-transform: uppercase; letter-spacing: 5px; text-align: center; }
#mpKarte .trenner { display: flex; align-items: center; gap: 10px; margin: 20px 0 2px; color: var(--tinte-weich); font-size: 13px; font-weight: 800; }
#mpKarte .trenner::before, #mpKarte .trenner::after { content: ''; flex: 1; height: 2px; background: var(--papier-dunkel); }
#mpKarte .klein { font-size: 13px; color: var(--tinte-weich); margin-top: 14px; font-weight: 700; }
#mpKarte .raumcode {
  display: inline-block; margin: 6px 0 2px; padding: 4px 18px 6px 26px;
  font: 400 46px/1 var(--titel); letter-spacing: 10px; color: var(--kreide);
  background: var(--holz); border: 3px solid var(--holz-dunkel); border-radius: 10px;
  box-shadow: inset 0 2px 0 #ffffff22, 0 3px 0 var(--holz-dunkel); text-shadow: 0 2px 0 var(--holz-dunkel);
}
#mpKarte .fehler { color: var(--rost); font-weight: 800; margin-top: 10px; min-height: 1.3em; }
#mpKarte .fehler:empty { margin: 0; min-height: 0; }
#mpKarte .unterzeile { margin: -2px 0 0; font-weight: 700; }
#mpKarte .gross { min-height: 48px; font-size: 16px; padding-inline: 22px; }

/* Startseite: Wortmarke als Holzschild */
.start-karte { padding-top: 0 !important; }
.schild {
  position: relative;
  margin: -58px auto 14px;
  width: max-content;
  max-width: 100%;
  padding: 12px 30px 14px;
  font: 400 clamp(34px, 9vw, 52px)/1 var(--titel);
  color: var(--messing-hell);
  text-shadow: 0 3px 0 var(--holz-dunkel);
  background:
    repeating-linear-gradient(178deg, #ffffff08 0 2px, transparent 2px 8px, #00000012 8px 10px, transparent 10px 19px),
    linear-gradient(180deg, var(--holz-hell), var(--holz));
  border: 3px solid var(--holz-dunkel);
  border-radius: 10px;
  box-shadow: 0 4px 0 var(--holz-dunkel), 0 14px 26px #1a120a77;
  transform: rotate(-1.5deg);
}
.schild small { display: block; margin-top: 6px; font: 800 13px var(--text); color: var(--kreide-weich); text-shadow: none; letter-spacing: .02em; }
.start-wege { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; text-align: left; }
.start-wege > div { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 10px; background: #2f20140d; }
.start-wege h3 { margin: 0; font: 400 17px/1.1 var(--titel); color: var(--tinte); }
.start-wege p { font-size: 12px; line-height: 1.35; flex: 1; }
.start-wege button { width: 100%; }
.start-wege .code-zeile { display: flex; gap: 8px; }
.start-wege .code-zeile input.code { width: 100%; min-width: 0; letter-spacing: 3px; }
.start-wege .code-zeile button { width: auto; }
@media (max-width: 420px) { .start-wege { grid-template-columns: 1fr; } }

/* Spielerfarbe als Wimpel */
.wimpel { width: 16px; height: 18px; flex: 0 0 auto; clip-path: polygon(0 0, 100% 50%, 0 100%); border-left: 3px solid var(--holz-dunkel); display: inline-block; vertical-align: -3px; }
.spielerliste { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; display: grid; gap: 4px; }
.spielerliste li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; background: #2f20140d; font-weight: 800; }
.spielerliste li.ich { background: #d6a94a40; }
.spielerliste li.weg { opacity: 0.45; }
.spielerliste li.frei { color: #b5a283; font-weight: 700; background: none; border: 2px dashed var(--papier-dunkel); padding: 5px 10px; }
.spielerliste .rechts { margin-left: auto; color: var(--tinte-weich); font-size: 12px; font-variant-numeric: tabular-nums; }
.spielerliste .klein-knopf { padding: 2px 8px; min-height: 0; font-size: 12px; line-height: 1.4; }
.ersteller { color: var(--messing); }
.einstellungen { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.einstellungen span { padding: 3px 10px; border-radius: 20px; background: #2f201414; font-size: 12px; font-weight: 800; color: var(--tinte-weich); }
.einstellungen .stellbar { display: inline-flex; align-items: center; gap: 6px; padding: 2px 3px; }
.einstellungen .stell { width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%; font-size: 15px; line-height: 1; }
.einstellungen .stell:disabled { opacity: 0.35; cursor: default; }

/* Wertung */
.wertung { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; text-align: left; font-variant-numeric: tabular-nums; }
.wertung li {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 9px; background: #2f20140d;
  animation: reinrutschen .35s backwards; animation-delay: calc(var(--i, 0) * 90ms + 100ms);
}
.wertung li.ich { background: #d6a94a40; box-shadow: inset 0 0 0 2px var(--messing); }
.wertung .rang { font: 400 20px/1 var(--titel); color: var(--tinte-weich); text-align: center; }
.wertung li[data-rang="1"] .rang { color: #fff; background: var(--messing); border-radius: 50%; width: 30px; height: 30px; line-height: 30px; box-shadow: 0 2px 0 var(--holz-dunkel); }
.wertung .wer { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 800; }
.wertung .wer > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wertung .was { font-size: 12px; font-weight: 700; color: var(--tinte-weich); text-align: right; white-space: nowrap; }
.wertung .was.raus { color: var(--rost); }
.wertung .pkt { min-width: 64px; text-align: right; font-weight: 900; font-size: 18px; color: var(--tinte); }
.wertung .pkt small { display: block; font-size: 12px; color: #4d7a35; font-weight: 900; animation: plus .6s backwards; animation-delay: calc(var(--i, 0) * 90ms + 500ms); }
@keyframes reinrutschen { from { transform: translateX(-16px); opacity: 0; } }
@keyframes plus { from { transform: translateY(6px) scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .wertung li, .wertung .pkt small { animation: none; } }

/* Podest am Ende */
.podest { display: flex; justify-content: center; align-items: end; gap: 8px; margin: 16px 0 4px; }
.podest > div { display: flex; flex-direction: column; align-items: center; width: 31%; min-width: 0; }
.podest .name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; font-size: 14px; margin: 6px 0 4px; }
.podest .stufe {
  width: 100%; display: grid; place-items: center; color: var(--kreide); font: 400 28px/1 var(--titel);
  background: linear-gradient(180deg, var(--holz-hell), var(--holz)); border: 3px solid var(--holz-dunkel); border-bottom: 0;
  border-radius: 8px 8px 0 0; text-shadow: 0 2px 0 var(--holz-dunkel);
  animation: wachsen .6s cubic-bezier(.2, 1.3, .4, 1) backwards;
}
.podest .stufe small { font: 800 12px var(--text); color: var(--kreide-weich); text-shadow: none; }
.podest .p1 .stufe { height: 108px; background: linear-gradient(180deg, var(--messing-hell), var(--messing)); color: var(--tinte); text-shadow: none; animation-delay: .5s; }
.podest .p1 .stufe small { color: #5b4423; }
.podest .p2 .stufe { height: 78px; animation-delay: .25s; }
.podest .p3 .stufe { height: 56px; }
.podest .wimpel { width: 22px; height: 26px; }
.podest .p1 .wimpel { width: 28px; height: 32px; }
.krone { font-size: 22px; line-height: 1; margin-bottom: 2px; }
@keyframes wachsen { from { transform: scaleY(0); transform-origin: bottom; } }
.podest-boden { height: 8px; margin: 0 -8px; background: var(--holz-dunkel); border-radius: 3px; }

.knoepfe button { white-space: nowrap; }

@media (max-width: 850px) {
  header { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .titel { font-size: 20px; }
  #inventar { width: 164px; }
}
@media (min-width: 571px) and (max-width: 850px) {
  #hilfe {
    bottom: 8px;
    display: grid;
    grid-template-columns: repeat(2, auto);
    padding: 4px 10px;
    gap: 2px 12px;
    font-size: 12px;
    line-height: 1.2;
  }
}
@media (max-width: 570px) {
  header { gap: 5px 6px; min-height: 0; padding: 6px 8px; }
  .titel { width: 100%; font-size: 18px; gap: 6px; }
  .titel::before { width: 20px; height: 16px; }
  header .info { font-size: 11px; padding: 2px 7px 3px; }
  header .info b { font-size: 13px; }
  header .info > span, header .uhr::before { font-size: 9px; }
  header .info small { display: none; }
  header .uhr { font-size: 15px; min-width: 0; }
  header .knoepfe { margin-left: 0; }
  header button { padding: 5px 9px; font-size: 13px; min-height: 34px; }
  #mitte { flex-direction: column; }
  #inventar { order: 1; flex: none; width: 100%; border: 0; border-top: 3px solid var(--holz-dunkel); }
  .inventar-kopf { padding: 5px 8px 3px; }
  #inventar h2 { font-size: 14px; }
  #inventarStatus { font-size: 10px; }
  #leiste {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 76px;
    grid-auto-rows: 62px;
    gap: 6px;
    padding: 2px 8px 8px;
    overflow: auto hidden;
  }
  .teilkarte { min-height: 0; padding: 5px 2px 3px; }
  .teilkarte canvas { height: 32px; }
  .teilkarte div { font-size: 11px; }
  .teilkarte div small { display: none; }
  .material-icon { width: 14px; height: 14px; left: 2px; top: 6px; }
  #hilfe, #knopfHilfe { display: none; }
  .fahrt-kopf { min-height: 50px; padding: 6px 9px; align-content: center; }
  .fahrt-kopf .titel { width: auto; font-size: 17px; }
  .fahrt-kopf #levelInfo { display: none; }
  body[data-modus="test"] header { display: grid; grid-template-columns: 1fr auto auto; gap: 5px 8px; }
  #fahrtAnzeige { grid-area: 2 / 1 / 3 / 4; grid-template-columns: 64px minmax(0, 1fr) 58px; gap: 8px; min-width: 0; width: 100%; min-height: 47px; padding: 4px 8px 4px 4px; }
  .fahrt-status { margin-block: 3px 4px; }
  #fahrtName { font-size: clamp(16px, 5.25vw, 21px); }
  #fahrtMasse { font-size: 11px; }
  #fahrtLast { padding-left: 5px; }
  #fahrtLast b { font-size: 15px; }
  #ergebnis { bottom: 8px; }
  #ergebnis .ergebnis-karte { gap: 6px 9px; padding: 9px 11px; }
  .ergebnis-daten { flex-direction: column; align-items: start; padding-left: 8px; gap: 3px; }
  #ergebnisBild { width: 54px; }
  .ergebnis-karte .knoepfe { padding-top: 6px; }
  .karte { padding: 20px 16px; }
  #mpKarte .raumcode { font-size: 38px; }
  .wertung li { grid-template-columns: 26px minmax(0, 1fr) auto; }
}

@media (max-width: 350px) {
  #fahrtAnzeige { grid-template-columns: 47px minmax(0, 1fr) 55px; gap: 6px; }
  .fahrt-status { font-size: 10px; }
}
button.gefahr .taste { background: #00000030; color: #ffe0d4; }
#mpKarte .code-zeile input.code { width: auto; flex: 1; min-width: 0; letter-spacing: 3px; }
/* Mittlere Breiten: Wortmarke nur als Zeichen, damit Werte und Knöpfe in eine Zeile passen */
@media (min-width: 851px) and (max-width: 1220px) {
  header { gap: 10px; }
  body:is([data-modus="bauen"], [data-modus="schwerkraft"], [data-modus="warten"]) .titel { font-size: 0; gap: 0; }
  header .info { padding-inline: 9px; }
}

/* Runde 2 (docs/ui/kritik-2.md) */
.start-wege { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.start-wege > div { min-width: 0; }
#mp > .karte { max-width: 100%; min-width: 0; }
.teilkarte div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.teilkarte div small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wertung .was { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.wertung .fz { width: 44px; height: 25px; object-fit: contain; }
@media (max-width: 570px) { .wertung .was { display: none; } } /* nach der Grundregel, sonst bricht die Zeile */
@media (max-width: 420px) { .start-wege { grid-template-columns: minmax(0, 1fr); } }

/* Gemalte Flächen (tools/grafik/gen_ui.py → public/grafik/ui/) */
header, #inventar, #werkzeug {
  background: linear-gradient(180deg, #ffffff14, #0000 40%, #00000026), url(grafik/ui/holz.webp) 0 0 / 384px 384px;
}
.karte {
  background:
    radial-gradient(circle at 12px 12px, var(--messing) 3px, #0000 4px),
    radial-gradient(circle at calc(100% - 12px) 12px, var(--messing) 3px, #0000 4px),
    radial-gradient(circle at 12px calc(100% - 12px), var(--messing) 3px, #0000 4px),
    radial-gradient(circle at calc(100% - 12px) calc(100% - 12px), var(--messing) 3px, #0000 4px),
    url(grafik/ui/papier.webp) 0 0 / 384px 384px, var(--papier);
}
.teilkarte, .info:not(.uhr), #fahrtAnzeige, #ergebnis { background-image: url(grafik/ui/papier.webp); background-size: 384px 384px; }
.teilkarte:hover { background-image: linear-gradient(#ffffff40, #ffffff40), url(grafik/ui/papier.webp); }
#fahrbahnInfo:not(.bereit):not(:empty) { background-image: none; }
.teilkarte.benutzt, .teilkarte.benutzt:hover { background-image: linear-gradient(#7d5a3488, #7d5a3488), url(grafik/ui/papier.webp); }
.schild {
  background: url(grafik/ui/schild.webp) center / 100% 100% no-repeat;
  border: 0; box-shadow: none; filter: drop-shadow(0 12px 14px #1a120a77);
  padding: 26px 54px 30px; transform: rotate(-1deg);
}
.icon { width: 22px; height: 22px; vertical-align: -6px; margin-right: 5px; pointer-events: none; }
#werkzeug .icon { width: 20px; height: 20px; }
.krone-bild { width: 44px; height: auto; margin-bottom: -4px; filter: drop-shadow(0 2px 0 #2f2014); }

.podest-bild { position: relative; margin: 92px auto 4px; width: min(100%, 420px); }
.podest-bild > img { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 8px #1a120a55); animation: aufklappen .5s .15s backwards; }
.podest-bild .platz { position: absolute; bottom: 0; }
.podest-bild .oben { position: absolute; bottom: 100%; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; padding-bottom: 2px; animation: reinfallen .5s cubic-bezier(.3, 1.5, .5, 1) backwards; }
.podest-bild .p1 .oben { animation-delay: .9s; } .podest-bild .p2 .oben { animation-delay: .6s; } .podest-bild .p3 .oben { animation-delay: .35s; }
.podest-bild .name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; font-size: 14px; }
.podest-bild .wimpel { width: 22px; height: 26px; }
.podest-bild .p1 .wimpel { width: 28px; height: 32px; }
.podest-bild .front { position: absolute; top: 18%; left: 12%; right: 12%; display: grid; place-items: center; color: #f8e6c6; text-shadow: 0 2px 0 #3a1d10; }
.podest-bild .front b { font: 400 clamp(28px, 8vw, 46px)/1 var(--titel); }
.podest-bild .p1 .front b { color: var(--messing-hell); }
.podest-bild .front small { font-weight: 900; font-size: 12px; }
@keyframes reinfallen { from { transform: translateY(-30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .podest-bild .oben, .podest-bild > img { animation: none; } }
/* Holz etwas dunkler und weniger rot, damit Papierschilder und Text davor stehen */
header, #inventar, #werkzeug { background-color: #7a5a3c; background-blend-mode: normal, multiply; }
@media (max-width: 420px) { .schild { padding: 20px 30px 24px; } .schild small { font-size: 11px; } }

/* Runde 3 (docs/ui/kritik-3.md) */
.wertung .pkt b { display: block; font-size: 20px; color: #4d7a35; animation: plus .6s backwards; animation-delay: calc(var(--i, 0) * 90ms + 400ms); }
.wertung .pkt small { color: var(--tinte-weich); font-size: 12px; font-weight: 800; animation: none; }
.podest-bild .oben { flex-direction: row; justify-content: center; gap: 4px; }
.podest-bild .person { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; }
.podest-bild .mehrere .person { max-width: 50%; }
.podest-bild .mehrere .name { font-size: 12px; }
.podest-bild { overflow: visible; }
.konfetti {
  position: absolute; left: var(--x); top: -110px; width: 24px; height: 24px; pointer-events: none;
  background: url(grafik/ui/konfetti_atlas.webp) calc(var(--n) * -24px) 0 / 504px 24px no-repeat;
  opacity: 0; animation: konfetti var(--v) ease-in var(--d) 2 both;
}
@keyframes konfetti {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(300px) rotate(var(--r)); }
}
@media (prefers-reduced-motion: reduce) { .konfetti { display: none; } }

#werkzeug { max-width: calc(100vw - 16px); }
body[data-zeiger="finger"] #werkzeug .wz-text { display: none; }
body[data-zeiger="finger"] #werkzeug button { min-width: 46px; }
body[data-zeiger="finger"] #werkzeug .icon { margin-right: 0; width: 24px; height: 24px; }
body[data-zeiger="finger"] #werkzeug svg { width: 20px; height: 20px; }
.finger-hilfe { display: none; }
body[data-zeiger="finger"] .maus-hilfe { display: none; }
body[data-zeiger="finger"] .finger-hilfe { display: flex; align-items: center; gap: 8px; }
.finger-hilfe img { width: 30px; height: 30px; object-fit: contain; }
@media (max-width: 570px) {
  #knopfHilfe { display: inline-block; }
  #knopfHilfe.versteckt { display: none; }
  #hilfe.offen { display: grid; grid-template-columns: 1fr; gap: 6px; bottom: 8px; width: calc(100% - 16px); font-size: 13px; }
  #hilfe.offen.versteckt { display: none; }
}

/* Runde 4 (docs/ui/kritik-4.md) */
@media (max-width: 570px) {
  /* Mehrere auf einem Block: untereinander statt nebeneinander, sonst werden die Namen abgeschnitten */
  .podest-bild .mehrere .oben { flex-direction: column; align-items: center; gap: 2px; left: -25%; right: -25%; }
  .podest-bild .mehrere .person { flex-direction: row; gap: 4px; max-width: 100%; }
  .podest-bild .mehrere .krone-bild { width: 28px; margin: 0; }
  .podest-bild .mehrere .wimpel { width: 16px; height: 19px; }
}
.podest-bild .front small { font-size: 13px; }
/* Handy: Überspringen unten rechts, oben steht das Fahrzeugschild */
@media (max-width: 570px) { #mp.durchsichtig { align-items: end; padding-bottom: 14px; } }
/* Startbühne: so sieht das Spiel aus (grafik/ui/buehne.webp) */
.start-karte .buehne { display: block; width: calc(100% + 24px); height: auto; margin: -6px -12px 6px; filter: drop-shadow(0 5px 4px #1a120a40); animation: aufklappen .6s .2s backwards; }
@media (max-height: 760px) and (min-width: 571px) { .start-karte .buehne { width: 80%; margin-inline: auto; } }
/* Verbaute Karten ans Ende der Leiste, vorne liegt, was noch zu haben ist */
.teilkarte.benutzt { order: 1; }
/* Handy beim Bauen: Wortmarke nur als Zeichen, dann passen die Werte daneben -> zwei Reihen statt drei */
@media (max-width: 570px) {
  body:is([data-modus="bauen"], [data-modus="schwerkraft"], [data-modus="warten"]) header .titel { width: auto; font-size: 0; gap: 0; }
}
@media (max-width: 570px) {
  /* Mehrspieler: Raum-Chip passt mit in die Knopfreihe, Schwerkraft-Test dafür nur als Lot (im Test steht „Test beenden“) */
  body[data-modus="bauen"] #knopfSchwerkraft { font-size: 0; padding-inline: 8px; }
  body[data-modus="bauen"] #knopfSchwerkraft .icon { margin-right: 0; width: 24px; height: 24px; }
  #mpInfo:not(:empty) { font-size: 12px; }
}
@media (max-width: 570px) { .wertung li > span:empty { display: none; } } /* Endwertung-Rest: Punkte in derselben Zeile */

/* Tutorial (?tutorial=1, tutorial.js) */
#tutorial {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  color: var(--kreide);
  background: var(--tafel);
  border: 2px solid var(--messing);
  box-shadow: 0 6px 18px #1a120a66;
  padding: 10px 16px 12px;
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 3;
}
#tutorial.versteckt { display: none; }
#tutorial.wichtig { border-color: var(--rost-hell); }
#tutorial.neu { animation: tutNeu .45s ease-out; }
@keyframes tutNeu { from { transform: translate(-50%, 10px); opacity: 0; } }
#tutorial .tut-kopf { display: flex; gap: 10px; align-items: baseline; font-family: var(--titel); font-size: 18px; color: var(--akzent); }
#tutorial.wichtig .tut-kopf { color: var(--schlecht); }
#tutorial .tut-nr { font-family: var(--text); font-size: 13px; font-weight: 800; color: var(--kreide-weich); }
#tutorial p { margin: 4px 0 0; font-weight: 700; line-height: 1.35; }
#tutorial small { display: block; margin-top: 4px; color: var(--kreide-weich); }
body[data-modus="bauen"]:has(#tutorial:not(.versteckt)) #hilfe { display: none; }

/* ---------- Audio-Menü: immer oben rechts, auch über Startkarte, Lobby und Wiedergabe ---------- */
#audioMenue {
  --audio-rechts: max(16px, env(safe-area-inset-right));
  --audio-oben: max(12px, env(safe-area-inset-top));
  position: fixed; top: var(--audio-oben); right: var(--audio-rechts); z-index: 20;
}
header { padding-right: calc(16px + 38px + 14px); } /* Platz für den Knopf */
#audioKnopf { display: grid; place-items: center; }
#audioMenue:has(:popover-open) #audioKnopf { background: var(--papier-hell); }
#audioMenue:not([data-stumm]) .audio-stumm, #audioMenue[data-stumm] .audio-wellen { display: none; }
#audioRegler {
  position: fixed; inset: calc(var(--audio-oben) + 48px) var(--audio-rechts) auto auto;
  margin: 0; padding: 14px 16px 16px; width: min(260px, calc(100% - 2 * var(--audio-rechts)));
  background: var(--papier) url(grafik/ui/papier.webp); background-size: 384px 384px;
  color: var(--tinte); border: 2px solid var(--holz-dunkel); border-radius: var(--radius); box-shadow: var(--schatten);
}
#audioRegler h2 { margin: 0 0 10px; font: 400 18px/1.1 var(--titel); }
#audioRegler label { display: grid; grid-template-columns: minmax(0, 1fr) 4ch; align-items: center; gap: 0 8px; margin-bottom: 8px; font-weight: 700; }
#audioRegler input { grid-row: 2; width: 100%; min-width: 0; margin: 0; height: 28px; accent-color: var(--holz-hell); }
#audioRegler label span:last-child { grid-row: 2; text-align: right; font-variant-numeric: tabular-nums; color: var(--tinte-weich); }
#stummKnopf { width: 100%; margin-top: 4px; }
#stummKnopf[aria-pressed="true"] { background: var(--rost); color: #fff; }
@media (max-width: 570px) {
  #audioMenue { --audio-rechts: max(8px, env(safe-area-inset-right)); --audio-oben: max(5px, env(safe-area-inset-top)); }
  #audioKnopf { width: 34px; min-height: 34px; }
  header { padding-right: 8px; }
  header .titel { padding-right: 44px; }
}

/* Zuschauer (Regelwerk Abschnitt 13): bauen nicht, schalten unten zwischen den Spielern um */
.augen { white-space: nowrap; }
body.zuschauer .bau-knopf { display: none; }
#blick {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 6px; padding: 6px; max-width: calc(100% - 24px);
  border: 2px solid var(--holz-dunkel); border-radius: 12px; box-shadow: var(--schatten);
  background: linear-gradient(180deg, var(--holz-hell), var(--holz) 55%, #4d3420);
}
#blick button { min-height: 40px; min-width: 44px; padding: 4px 10px; font-size: 16px; }
#blick .wer { display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--kreide); font-weight: 800; white-space: nowrap; min-width: 0; }
#blick .wer b { overflow: hidden; text-overflow: ellipsis; }
#blick .wer small { color: var(--messing-hell); font-variant-numeric: tabular-nums; }
#blick .haken { color: #8fe08f; }
