/* Holz oben und unten, Papier für alles, was man liest: Das Parkbüro führt ein Kassenbuch. */
:root {
  color-scheme: dark;
  --holz: #2a1a14; --holz2: #3a2619; --kante: #120b09;
  --papier: #e8dfc8; --papier2: #d9cdb0; --tinte: #2a1b22; --blass: #6d5a55;
  --kuerbis: #e9791d; --blut: #a01f2a; --moos: #5f7d33; --gift: #9fd14a;
  --nacht: #15101c; --schrift: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a0810; color: var(--papier); font: 15px/1.3 var(--schrift); touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#welt { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--kuerbis); outline-offset: 1px; }

#oben { position: fixed; top: 0; left: 0; right: 0; min-height: 46px; padding: 4px 8px; padding-top: max(4px, env(safe-area-inset-top)); display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center;
  background: repeating-linear-gradient(90deg, var(--holz) 0 120px, var(--holz2) 120px 121px, var(--holz) 121px 260px); border-bottom: 3px solid var(--kante); box-shadow: 0 3px 12px #000a; z-index: 5; }
#oben .logo { font: 26px/1 'Creepster', var(--schrift); color: var(--kuerbis); letter-spacing: 1px; text-shadow: 0 2px 0 #000; }
#oben .wert { display: flex; flex-direction: column; line-height: 1.05; min-width: 44px; }
#oben .wert b { font-size: 17px; font-variant-numeric: tabular-nums; color: #f4e9cf; }
#oben .wert small { font-size: 11px; color: #c4ad8a; }
#oben .wert b.minus { color: #ff6a55; }
#oben .tempo { margin-left: auto; display: flex; gap: 3px; }
#oben .tempo button { width: 34px; height: 32px; background: #1a100c; border: 1px solid #5a3b26; border-radius: 3px; font-weight: 800; color: #d8c4a0; }
#oben .tempo button.an { background: var(--kuerbis); color: #1a0d05; border-color: #ffb46a; }
.sterne { color: #f2b23a; letter-spacing: 1px; font-size: 14px; }

#aufgabe { position: fixed; top: calc(var(--oben, 48px) + 6px); left: 8px; z-index: 4; max-width: min(360px, 62vw); background: var(--papier); color: var(--tinte); padding: 5px 9px; font-size: 14px; line-height: 1.22; box-shadow: 0 2px 8px #0009; pointer-events: none; }
#aufgabe b { display: block; color: var(--blut); font-size: 12px; }
#ticker { position: fixed; top: calc(var(--oben, 48px) + 70px); left: 8px; right: 8px; z-index: 4; pointer-events: none; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
#ticker div { background: #150e12e6; border-left: 3px solid var(--kuerbis); padding: 3px 8px; font-size: 13px; max-width: min(520px, 92vw); pointer-events: auto; cursor: pointer; animation: rein .18s ease-out; }
#ticker div.alarm { border-left-color: #ff3b3b; background: #3c0c10ee; }
#ticker div.warnung { border-left-color: #ffc24a; }
#ticker div.gut { border-left-color: var(--gift); }
@keyframes rein { from { transform: translateX(-10px); opacity: 0; } }

#unten { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; gap: 2px; padding: 4px 6px; padding-bottom: max(4px, env(safe-area-inset-bottom)); overflow-x: auto; scrollbar-width: none;
  background: var(--holz); border-top: 3px solid var(--kante); box-shadow: 0 -3px 12px #000a; }
#unten::-webkit-scrollbar { display: none; }
#unten button { flex: 1 0 64px; max-width: 96px; padding: 3px 2px 2px; border-radius: 3px; display: flex; flex-direction: column; align-items: center; color: #d8c4a0; font-size: 12px; }
#unten button span { font-size: 21px; line-height: 1.15; }
#unten button.an { background: #5a3216; color: #ffe1b4; }

#paletten { position: fixed; left: 0; right: 0; bottom: 62px; z-index: 5; display: none; flex-direction: column; background: #1c120ef2; border-top: 2px solid #4b2f1e; max-height: 46vh; }
#paletten.an { display: flex; }
.reiter { display: flex; gap: 4px; padding: 5px 8px 3px; overflow-x: auto; scrollbar-width: none; align-items: center; }
.reiter button { flex: none; padding: 3px 10px; border-radius: 12px; color: #d8c4a0; background: #2c1c13; font-size: 13px; }
.reiter button.an { background: var(--papier); color: var(--tinte); font-weight: 700; }
.reiter .zu { margin-left: auto; font-size: 18px; background: none; }
.karten { display: flex; gap: 7px; padding: 5px 8px 9px; overflow-x: auto; scrollbar-width: thin; }
/* Jede Karte ist eine Eintrittskarte mit Lochrand */
.karte { flex: none; width: 118px; color: var(--tinte); background: var(--papier); position: relative; padding: 4px 6px 5px; text-align: left; display: flex; flex-direction: column;
  -webkit-mask: radial-gradient(circle 4px at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle 4px at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 4px at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle 4px at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat; }
.karte.an { background: #f7c98a; }
.karte.gesperrt { filter: grayscale(.9) brightness(.62); }
.karte .bild { height: 74px; display: flex; align-items: center; justify-content: center; }
.karte .bild img, .karte .bild canvas { max-width: 100%; max-height: 74px; object-fit: contain; }
.karte b { font-size: 13px; line-height: 1.1; min-height: 28px; display: block; }
.karte i { font-style: normal; font-size: 12px; color: var(--blut); font-weight: 800; }
.karte small { font-size: 11px; color: var(--blass); line-height: 1.1; }

/* Die Leiste mit dem Bauen-Knopf sitzt unten in der Mitte: Dort ist der Daumen, und die Karte bleibt frei. */
#hilfe-bau { position: fixed; left: 50%; transform: translateX(-50%); bottom: 68px; z-index: 6; width: max-content; max-width: calc(100vw - 16px); flex-wrap: wrap; justify-content: center; }
.leiste { display: flex; gap: 6px; background: #1c120ef2; border: 1px solid #5a3b26; border-radius: 4px; padding: 4px; align-items: center; color: #e6d6b6; font-size: 13px; }
.leiste { padding: 6px 8px; font-size: 15px; box-shadow: 0 3px 14px #000b; }
.leiste span { flex: 1 1 auto; padding: 0 4px; font-weight: 700; }
.leiste span.nein { color: #ff9a80; }
.leiste small { display: block; font-size: 12px; font-weight: 400; color: #c4ad8a; }
.leiste button { padding: 9px 14px; background: #3a2619; border-radius: 3px; font-weight: 700; white-space: nowrap; }
.leiste button.ja { background: var(--moos); color: #fff; padding: 9px 22px; }
.leiste button:disabled { opacity: .4; cursor: not-allowed; }

#fenster { position: fixed; inset: 0; pointer-events: none; z-index: 7; }
.blatt { position: absolute; pointer-events: auto; background: var(--papier); color: var(--tinte); width: min(370px, calc(100vw - 16px)); max-height: calc(100vh - 130px); overflow: auto; box-shadow: 0 6px 26px #000b, inset 0 0 40px #b9a67c55; right: 8px; top: calc(var(--oben, 48px) + 8px); touch-action: pan-y; user-select: text; }
.blatt.breit { width: min(620px, calc(100vw - 16px)); left: 50%; right: auto; transform: translateX(-50%); }
.blatt h2 { margin: 0; padding: 8px 34px 6px 12px; font: 25px/1.05 'Creepster', var(--schrift); letter-spacing: .6px; color: var(--blut); border-bottom: 2px solid #b6a57f; position: sticky; top: 0; background: var(--papier); z-index: 1; }
.blatt .schliessen { position: absolute; right: 6px; top: 6px; width: 28px; height: 28px; font-size: 20px; color: var(--tinte); z-index: 2; }
.blatt .inhalt { padding: 8px 12px 12px; }
.blatt p { margin: 4px 0 8px; }
.zeile { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; border-bottom: 1px dotted #b6a57f; font-variant-numeric: tabular-nums; }
.zeile b { white-space: nowrap; }
.balken { height: 8px; background: #c9bb9b; margin: 2px 0 6px; }
.balken i { display: block; height: 100%; background: var(--moos); }
.balken i.schlecht { background: var(--blut); } .balken i.mittel { background: var(--kuerbis); }
.knopf { display: inline-block; padding: 6px 12px; background: var(--tinte); color: var(--papier); font-weight: 700; margin: 3px 4px 3px 0; }
.knopf.rot { background: var(--blut); } .knopf.gruen { background: var(--moos); color: #fff; } .knopf.kuerbis { background: var(--kuerbis); color: #1a0d05; }
.knopf:disabled { opacity: .4; }
.preis { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.preis input[type=range] { flex: 1; accent-color: var(--blut); touch-action: none; }
.klein { font-size: 13px; color: var(--blass); }
.reihe { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
table.buch { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.buch td, table.buch th { padding: 2px 4px; text-align: right; border-bottom: 1px dotted #b6a57f; }
table.buch td:first-child, table.buch th:first-child { text-align: left; }
.bl-reiter { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.bl-reiter button { padding: 3px 9px; background: var(--papier2); font-size: 13px; }
.bl-reiter button.an { background: var(--tinte); color: var(--papier); }
.ziel { padding: 2px 0; } .ziel.ok { color: #49651f; font-weight: 700; }

#start { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, #2b1838ee, #070509f8); padding: 16px; }
#start.an { display: flex; }
#start .innen { max-width: 520px; text-align: center; }
#start h1 { font: clamp(58px, 13vw, 110px)/.95 'Creepster', var(--schrift); color: var(--kuerbis); margin: 0 0 6px; text-shadow: 0 4px 0 #3a1404, 0 0 40px #e9791d55; letter-spacing: 2px; }
#start p { font-size: 17px; line-height: 1.4; color: #e4d8bd; }
#start .knopf { font-size: 18px; padding: 10px 22px; }

/* Maze-Editor: der Bauplan */
#maze { position: fixed; inset: 0; z-index: 10; display: none; background: #120c18; }
#maze.an { display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: auto minmax(0, 1fr) auto; }
#maze .m-kopf { grid-column: 1 / 3; display: flex; gap: 10px; align-items: center; padding: 5px 10px; background: var(--holz); border-bottom: 3px solid var(--kante); flex-wrap: wrap; }
#maze .m-kopf .name { font: 24px/1 'Creepster', var(--schrift); color: var(--kuerbis); }
#maze .m-kopf .kasse { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
#maze .m-kopf select { background: #1a100c; color: #e8d8b8; border: 1px solid #5a3b26; padding: 4px; font: inherit; }
#maze .m-feld { position: relative; min-height: 0; min-width: 0; overflow: hidden; touch-action: none; }
#maze canvas#plan { position: absolute; inset: 0; width: 100%; height: 100%; }
#maze .m-seite { grid-row: 2 / 4; grid-column: 2; background: var(--papier); color: var(--tinte); overflow: auto; padding: 8px 10px; touch-action: pan-y; }
#maze .m-seite h3 { margin: 8px 0 3px; font: 20px/1 'Creepster', var(--schrift); color: var(--blut); }
#maze .m-werkzeug { background: #1c120e; border-top: 2px solid #4b2f1e; min-width: 0; }
#m-entwurf { position: absolute; left: 50%; transform: translateX(-50%); bottom: 8px; width: max-content; max-width: calc(100% - 16px); flex-wrap: wrap; justify-content: center; }
#m-entwurf:empty { display: none; }
#m-hinweis { position: absolute; left: 50%; transform: translateX(-50%); top: 8px; max-width: calc(100% - 16px); padding: 5px 10px; background: #150e12f0; border-left: 3px solid #ffc24a; font-size: 14px; pointer-events: none; }
#m-hinweis:empty { display: none; }
#kurve { width: 100%; height: 96px; display: block; background: #efe6cf; border: 1px solid #b6a57f; }
.note { display: flex; align-items: baseline; justify-content: space-between; }
.note b { font-size: 30px; font-family: 'Creepster', var(--schrift); color: var(--blut); }
.hinweis { font-size: 13px; padding: 3px 0 3px 8px; border-left: 3px solid var(--kuerbis); margin: 4px 0; }
.hinweis.gut { border-left-color: var(--moos); }
#durchgang { position: fixed; inset: 0; z-index: 12; display: none; background: #000; }
#durchgang.an { display: block; }
#durchgang canvas { width: 100%; height: 100%; display: block; }
#durchgang .raus { position: absolute; right: 12px; top: 12px; }
#durchgang .blitz { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }

@media (max-width: 760px), (max-height: 520px) {
  #maze.an { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
  #maze .m-kopf { grid-column: 1; }
  #maze .m-feld { grid-row: 2; grid-column: 1; }
  #maze .m-werkzeug { grid-row: 3; grid-column: 1; }
  #maze .m-seite { grid-row: 4; grid-column: 1; max-height: 20vh; }
  #maze .karte .bild { height: 44px; }
  #maze .karte .bild canvas { max-height: 44px; }
  #maze .karte b { min-height: 0; }
  #maze .karte small { display: none; }
  #oben .logo { display: none; }
  #oben .wert small { display: none; }
  #oben { gap: 2px 9px; }
  .karte { width: 104px; }
  .blatt { top: auto; bottom: 64px; left: 8px; right: 8px; width: auto; max-height: 60vh; }
  .blatt.breit { left: 8px; right: 8px; width: auto; transform: none; top: calc(var(--oben, 48px) + 6px); bottom: 64px; max-height: none; }
}
@media (prefers-reduced-motion: reduce) { #ticker div { animation: none; } }
