:root {
  --akzent: #8e2f3a; --akzent2: #5e1e26; --akzent3: #f6e8e4; --tief: #3a2c20; --panel: rgba(250, 245, 234, .9); --panel2: rgba(252, 248, 238, .97);
  --text: #2a2218; --mute: #62553f; --rand: rgba(142, 47, 58, .4); --knopf1: #f2e6cf; --knopf2: #d8c19a; --knopfText: #2a2218;
  --gruen: #2f7d32; --rot: #b3261e; --kopf: Georgia, 'Times New Roman', serif;
  --tischbild: url(img/werkbank-morgen.webp?v=1), linear-gradient(135deg, #8a5a30, #5e3a1a); --kul: url(img/kulisse-morgen.webp?v=1), linear-gradient(#6b5640, #3a2614); --kulH: url(img/kulisse-morgen-hoch.webp?v=1), linear-gradient(#6b5640, #3a2614); --schleier: rgba(255, 240, 220, .04);
  --kante1: #6a4220; --kante2: #3a230e; --zettel: #fbf3e2; --zettelText: #3a2a18; --messing: #b98a35;
}
html[data-ansicht="hell"] {
  --akzent: #2a5a8a; --akzent2: #1c3c5e; --akzent3: #e8f0f6; --tief: #e8e2d4; --panel: rgba(251, 249, 243, .9); --panel2: rgba(252, 251, 246, .97);
  --text: #222a30; --mute: #4e5a62; --rand: rgba(42, 90, 138, .4); --knopf1: #eef0e6; --knopf2: #cfd6c4; --knopfText: #222a30;
  --tischbild: url(img/werkbank-hell.webp?v=1), linear-gradient(135deg, #c09060, #8e6438); --kul: url(img/kulisse-hell.webp?v=1), linear-gradient(#e8dcc4, #b49a74); --kulH: url(img/kulisse-hell-hoch.webp?v=1), linear-gradient(#e8dcc4, #b49a74); --schleier: rgba(255, 255, 250, .04);
  --kante1: #8e6438; --kante2: #5a3a1a; --zettel: #fbfaf2; --zettelText: #222a30; --messing: #c49a48;
}
html[data-ansicht="abend"] {
  --akzent: #f0b860; --akzent2: #f6d6a0; --akzent3: #3a2412; --tief: #1a1410; --panel: rgba(36, 26, 18, .88); --panel2: rgba(42, 30, 20, .96);
  --text: #fbecd6; --mute: #e2c39a; --rand: rgba(240, 184, 96, .45); --knopf1: #6e4a2a; --knopf2: #43291a; --knopfText: #fbecd6;
  --gruen: #86efac; --rot: #fca5a5;
  --tischbild: url(img/werkbank-abend.webp?v=1), linear-gradient(135deg, #6e4622, #3e2610); --kul: url(img/kulisse-abend.webp?v=1), linear-gradient(#2a1c12, #120c08); --kulH: url(img/kulisse-abend-hoch.webp?v=1), linear-gradient(#2a1c12, #120c08); --schleier: rgba(10, 6, 2, .12);
  --kante1: #4a2e14; --kante2: #24140a; --zettel: #3a2c1e; --zettelText: #fbecd6; --messing: #e0b057;
}
body { background: var(--tief); }
#kulisse { position: fixed; inset: 0; background: var(--kul); background-position: center; background-size: cover; background-repeat: no-repeat; z-index: 0; }
#kulisse::after { content: ''; position: absolute; inset: 0; background: var(--schleier); }
body.hoch #kulisse { background: var(--kulH); background-position: center; background-size: cover; }
#buehne { z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  #kulisse::before { content: ''; position: absolute; left: 0; top: 0; width: 55%; height: 80%; pointer-events: none; mix-blend-mode: screen;
    background: radial-gradient(ellipse at 30% 30%, rgba(255, 246, 220, .22), rgba(255, 246, 220, 0) 60%); animation: licht 14s ease-in-out infinite alternate; }
  @keyframes licht { from { opacity: .55; transform: translate(0, 0); } to { opacity: 1; transform: translate(4%, 3%); } }
  html[data-ansicht="abend"] #kulisse::before { left: auto; right: 0; background: radial-gradient(ellipse at 75% 75%, rgba(255, 190, 90, .25), rgba(255, 190, 90, 0) 55%); animation: flackern 3.2s ease-in-out infinite alternate; }
  @keyframes flackern { 0% { opacity: .7; } 40% { opacity: 1; } 55% { opacity: .82; } 100% { opacity: .95; } }
}

#hud { background: var(--panel); border: 2px solid var(--messing); box-shadow: 0 10px 28px rgba(40, 20, 0, .3), inset 0 0 0 4px rgba(255, 255, 255, .06); }
#logo span, #logo b { font-family: var(--kopf); text-shadow: 0 2px 0 rgba(255, 255, 255, .5); }
#logo b { color: var(--akzent); }
html[data-ansicht="abend"] #logo span, html[data-ansicht="abend"] #logo b { text-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
#logo { font-size: 28px; letter-spacing: 1px; }
.wert { background: rgba(255, 252, 244, .55); }
.wert b { color: var(--text); font-family: var(--kopf); font-variant-numeric: lining-nums tabular-nums; }
html[data-ansicht="abend"] .wert { background: rgba(0, 0, 0, .25); }
.wert.klein b { font-size: 19px; white-space: nowrap; }
.endwert { color: var(--akzent); }
.hinweis { background: rgba(255, 250, 238, .65); color: var(--text); }
.hinweis.gut { color: var(--gruen); font-weight: 700; } .hinweis.schlecht { color: var(--rot); font-weight: 700; }
html[data-ansicht="abend"] .hinweis { background: rgba(0, 0, 0, .3); color: var(--mute); }
#banner { color: var(--akzent); font-family: var(--kopf); text-shadow: 0 2px 0 rgba(255, 250, 238, .9), 0 0 14px rgba(255, 250, 238, .9); }
#banner small { color: var(--text); }
html[data-ansicht="abend"] #banner { text-shadow: 0 2px 0 rgba(0, 0, 0, .6), 0 0 18px rgba(0, 0, 0, .5); }
#banner.zahl { display: none !important; }

#knoepfe { grid-template-columns: repeat(3, 1fr); }
#knoepfe button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: 50px; padding: 2px 0; }
#knoepfe button svg { width: 20px; height: 20px; color: var(--akzent); }
#knoepfe .kl { font: 700 11px/1.1 'Segoe UI', system-ui, sans-serif; color: var(--knopfText); white-space: nowrap; }
@media (max-height: 720px) and (min-aspect-ratio: 1/1) {
  #hud { gap: 7px; padding: 10px 14px; } #logo { font-size: 24px; padding: 2px 0 0; } .wert { padding: 4px 8px 5px; } .wert b { font-size: 24px; } .wert.klein b { font-size: 17px; }
  #knoepfe button { height: 42px; }
}

#brettbox { overflow: hidden; border-radius: 16px; touch-action: none; background: transparent; }
#brett { position: absolute; inset: 0; touch-action: none; z-index: 1; pointer-events: none; }
#tisch { position: absolute; z-index: 0; border-radius: 14px; background: var(--tischbild); background-position: center; background-size: cover; pointer-events: none;
  box-shadow: 0 26px 40px rgba(30, 14, 2, .45), 0 7px 0 3px var(--kante2), inset 0 2px 0 rgba(255, 255, 255, .35), inset 0 -18px 30px rgba(0, 0, 0, .12); }
#tisch[hidden] { display: none; }
#tisch .kante { position: absolute; left: 6px; right: 6px; bottom: -15px; height: 10px; border-radius: 0 0 8px 8px; background: linear-gradient(var(--kante1), var(--kante2)); }

#kopf { position: absolute; left: 12px; top: 8px; z-index: 2; height: 48px; max-width: calc(100% - 24px); padding: 4px 14px; border-radius: 6px; overflow: hidden;
  background: var(--zettel); color: var(--zettelText); border: 1px solid var(--messing); box-shadow: 0 4px 12px rgba(0, 0, 0, .25); transform: rotate(-.6deg);
  display: flex; flex-direction: column; justify-content: center; font-family: var(--kopf); pointer-events: none; }
#kopf[hidden] { display: none; }
#kopf b { font-size: 16px; line-height: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#kopf span { font-size: 14px; line-height: 18px; color: var(--mute); white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }

#meld { position: absolute; bottom: 60px; right: 12px; flex-direction: column-reverse; z-index: 10; width: min(440px, 52%); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
#meld .m { background: var(--panel2); color: var(--text); border: 1px solid var(--rand); border-left: 5px solid var(--akzent); border-radius: 10px; padding: 6px 10px;
  font-size: 14px; line-height: 1.3; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); transition: opacity .35s; }
#meld .m.gut { border-left-color: var(--gruen); } #meld .m.schlecht { border-left-color: var(--rot); }
#meld .m.weg { opacity: 0; }
#meld.eine .m:not(:last-child) { display: none; }

#zeile { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2; width: min(640px, calc(100% - 24px)); height: 38px; padding: 0 14px;
  display: flex; align-items: center; justify-content: center; text-align: center; border-radius: 8px; overflow: hidden;
  background: var(--zettel); color: var(--zettelText); border: 1px solid var(--messing); font: 14px/1.25 var(--kopf); box-shadow: 0 4px 12px rgba(0, 0, 0, .2); pointer-events: none; }
#zeile:empty { display: none; }
#zeile.erkl { border-color: var(--akzent); }


#knoepfe button.an { outline: 3px solid var(--akzent); background: linear-gradient(#ffe7a6, #e8b84a); }
#knoepfe button.gesperrt { opacity: .5; border-style: dashed; }
#knoepfe button.mahnt { outline: 3px solid var(--rot); }
@media (prefers-reduced-motion: no-preference) { #knoepfe button.mahnt { animation: mahnt 1s ease-in-out infinite alternate; } }
@keyframes mahnt { from { transform: scale(1); } to { transform: scale(1.06); } }
.wert.knapp b { color: var(--rot); }

#tafel { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(20, 10, 0, .28); }
#tafel[hidden] { display: none; }
#tafel .schild { position: relative; width: min(420px, calc(100% - 28px)); max-height: calc(100% - 24px); overflow: auto; padding: 14px 18px 16px; border-radius: 10px; background: var(--zettel); color: var(--zettelText);
  border: 2px solid var(--messing); box-shadow: 0 14px 40px rgba(0, 0, 0, .45); display: grid; gap: 8px; font-family: var(--kopf); scrollbar-width: thin; scrollbar-color: var(--akzent) transparent; }
#tafel .schild.gut { border-top: 6px solid var(--gruen); } #tafel .schild.schlecht { border-top: 6px solid var(--rot); }
#tafel .zu { position: sticky; top: 0; justify-self: end; margin: -6px -10px -34px 0; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--messing);
  background: var(--knopf1); color: var(--knopfText); font: 700 20px/1 var(--kopf); cursor: pointer; z-index: 1; }
#tafel b { font-size: 21px; color: var(--akzent); padding-right: 40px; } #tafel span { font-size: 14px; color: var(--mute); }
#tafel table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: lining-nums tabular-nums; }
#tafel td { padding: 3px 2px; border-bottom: 1px dotted var(--rand); } #tafel td:last-child { text-align: right; white-space: nowrap; }
#tafel tr.summe td { font-weight: 700; border-top: 2px solid var(--akzent); border-bottom: 0; }
#tafel .lohn { margin: 0; padding: 6px 10px; border-left: 4px solid var(--messing); background: rgba(185, 138, 53, .14); font-size: 14px; }
#tafel .wz { font: 600 13px/1.2 'Segoe UI', system-ui, sans-serif; color: var(--mute); }
#tafel .weiter { min-height: 44px; border-radius: 10px; border: 2px solid var(--rand); background: linear-gradient(var(--knopf1), var(--knopf2)); color: var(--knopfText); font: 700 17px var(--kopf); cursor: pointer; }

#wahl { position: absolute; inset: 0; z-index: 3; overflow: auto; padding: 16px; background: var(--panel2); border-radius: 16px; scrollbar-width: thin; scrollbar-color: var(--akzent) rgba(0, 0, 0, .12); }
#wahl[hidden] { display: none; }
#wahl::-webkit-scrollbar { width: 8px; } #wahl::-webkit-scrollbar-thumb { background: var(--akzent); border-radius: 4px; } #wahl::-webkit-scrollbar-track { background: rgba(0, 0, 0, .12); }
#wahl h2 { margin: 0 0 4px; text-align: center; font: 800 24px/1.2 var(--kopf); color: var(--akzent); }
#wahl h2 small { font-size: 15px; color: var(--mute); font-weight: 600; margin-left: 6px; }
#wahl .legende { margin: 0 0 10px; text-align: center; font: 13px var(--kopf); color: var(--mute); }
#wahl h3 { margin: 10px 0 6px; font: 700 17px/1.2 var(--kopf); color: var(--akzent2); } #wahl h3 small { font: 600 12px 'Segoe UI', system-ui, sans-serif; color: var(--mute); margin-left: 6px; }
.buch section { border: 2px solid var(--rand); border-radius: 12px; padding: 6px 10px 10px; margin-bottom: 10px; background: rgba(255, 255, 255, .25); }
html[data-ansicht="abend"] .buch section { background: rgba(0, 0, 0, .2); }
.seiten { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.seite { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 4px 4px; border-radius: 10px; border: 2px solid var(--rand); background: rgba(255, 252, 244, .7); color: var(--text); cursor: pointer; }
html[data-ansicht="abend"] .seite { background: rgba(0, 0, 0, .25); }
.seite:hover, .seite.an { border-color: var(--akzent); }
.seite canvas { width: 64px; height: 72px; object-fit: contain; image-rendering: pixelated; background: #f4ead0; border-radius: 4px; }
.seite b { position: absolute; left: 6px; top: 4px; font: 800 14px var(--kopf); color: var(--akzent); }
.seite em { font: 600 12px/1.15 var(--kopf); font-style: normal; text-align: center; }
.seite i { display: inline-flex; gap: 1px; }
.seite .st { width: 13px; height: 13px; fill: rgba(0, 0, 0, .2); stroke: var(--mute); stroke-width: 1.2; }
.seite .st.an { fill: #e8b030; stroke: #a8780c; }
.seite .rek { font: 600 11px/1.2 'Segoe UI', system-ui, sans-serif; color: var(--mute); padding: 1px 6px; border-radius: 8px; border: 1px solid transparent; font-variant-numeric: tabular-nums; white-space: nowrap; }
.seite .rek.m-gold { border-color: #d4a017; background: rgba(232, 176, 48, .18); color: var(--text); }
.seite .rek.m-silber { border-color: #9aa3ad; background: rgba(170, 178, 188, .2); color: var(--text); }
.seite .rek.m-bronze { border-color: #b0703a; background: rgba(176, 112, 58, .16); color: var(--text); }

.kach { display: block; width: 48px; height: 48px; border-radius: 10px; background: center / cover no-repeat; flex: none; border: 1px solid var(--rand); }
.k-aus { background-image: var(--k-aus); } .k-wartet { background-image: var(--k-wartet); } .k-ein { background-image: var(--k-ein); } .k-dreh { background-image: var(--k-dreh); } .k-eisen { background-image: var(--k-eisen); } .k-wz { background-image: var(--k-wz); }
.kurz { padding: 10px 12px; border-radius: 10px; background: rgba(142, 47, 58, .08); border-left: 4px solid var(--akzent); margin-bottom: 10px; }

body.hoch #hud { grid-template-columns: minmax(0, .95fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, .9fr) minmax(0, 1fr); grid-template-areas: 'zeit punkte e1 e2 e3 e4' 'kn kn kn kn kn kn'; gap: 4px; padding: 6px; }
body.hoch #logo, body.hoch #modus, body.hoch #info { display: none; }
body.hoch #eigen .wert:nth-child(3) { display: block; grid-area: e3; } body.hoch #eigen .wert:nth-child(4) { display: block; grid-area: e4; }
body.hoch #eigen .wert:nth-child(n+5) { display: none; }
body.hoch .wert { padding: 2px 1px 3px; min-width: 0; } body.hoch .wert b, body.hoch .wert.klein b { font-size: 14px; line-height: 18px; white-space: nowrap; overflow: hidden; }
body.hoch .wert span { font-size: 11px; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; }
body.hoch #knoepfe { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
body.hoch #knoepfe button { width: auto; height: 46px; min-width: 0; } body.hoch #knoepfe .kl { font-size: 11px; letter-spacing: -.2px; }
body.hoch #brettbox { border-radius: 12px; }
body.hoch #kopf { height: 38px; top: 4px; left: 8px; padding: 2px 10px; } body.hoch #kopf b { font-size: 14px; line-height: 18px; } body.hoch #kopf span { font-size: 12px; line-height: 14px; }
body.hoch #tafel { place-items: end center; padding-bottom: 8px; background: linear-gradient(rgba(20, 10, 0, 0) 30%, rgba(20, 10, 0, .35)); }
body.hoch #tafel .schild { max-height: 62%; }
#tafel .weiter { position: sticky; bottom: 0; box-shadow: 0 -8px 12px var(--zettel); }
body.hoch #meld { top: 42px; bottom: auto; right: 8px; left: 8px; width: auto; flex-direction: column; }
body.hoch #meld .m:not(:last-child) { display: none; }
body.hoch #zeile { height: 52px; font-size: 14px; line-height: 1.12; bottom: 6px; }
@media (pointer: coarse) { #knoepfe button { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { #banner { animation: none !important; } }

.modus:not(.tag) { position: relative; background: linear-gradient(#6a4424, #3a2210); border-color: #b98a35; color: #fff6e6; overflow: hidden; }
.modus:not(.tag)::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 7px;
  background: linear-gradient(90deg, #c8323a 0 20%, #2a5fc0 20% 40%, #e8b030 40% 60%, #2f9a52 60% 80%, #8a4fc0 80%); }
.modus:not(.tag) svg { color: #f2c66a; }
.modus:not(.tag) span { color: #f4e8d2; }
.modus b { overflow-wrap: anywhere; }
body.hoch .menue .schildkopf { font-size: 30px; letter-spacing: 0; }
body.hoch .modus b { font-size: 18px; }
body.hoch .modus em { font-size: 16px; }

@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  #buehne { grid-template-columns: 212px 1fr; gap: 6px; padding: 6px; }
  #hud { padding: 6px; gap: 4px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; }
  #logo, #modus, #info, #hud .bestwert { display: none !important; }
  #eigen { display: contents; }
  #eigen .wert[data-w="Teil"] { display: none; }
  #hud .wert { padding: 2px 3px; min-width: 0; }
  #hud .wert b, .wert.klein b { font-size: 15px; line-height: 18px; white-space: nowrap; }
  #hud .wert span { font-size: 11px; line-height: 13px; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; display: block; }
  #knoepfe { grid-column: 1 / -1; margin-top: 2px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  #knoepfe button { height: 40px; min-width: 0; width: auto; flex-direction: row; gap: 5px; } #knoepfe button svg { width: 16px; height: 16px; } #knoepfe .kl { font-size: 12px; }
}
body.flach #kopf { height: 32px; top: 4px; padding: 0 10px; flex-direction: row; align-items: center; gap: 8px; max-width: calc(100% - 24px); }
body.flach #kopf b { font-size: 14px; line-height: 18px; } body.flach #kopf span { font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; }
body.flach #zeile { height: 42px; bottom: 3px; font-size: 14px; line-height: 1.12; }
body.flach #meld .m:not(:last-child) { display: none; }
