@font-face { font-family: 'Josefin Sans'; src: url('/fonts/josefin.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'Lexend'; src: url('/fonts/lexend.woff2') format('woff2'); font-weight: 400 600; font-display: swap; }
:root {
  color-scheme: dark;
  --bg: #2e2b3b;
  --deep: #262430;
  --slot: #3a3947;
  --line: #6c6b7b;
  --tan: #80776a;
  --faint: #454254;
  --text: #f4eddb;
  --soft: #bdb7ac;
  --cream: #e9dfc4;
  --ink: #2a2833;
  --blue: #205178;
  --blue-dark: #32456c;
  --gold: #e5b94b;
  /* Schrift hat genau vier Rollen, neue Elemente nehmen eine davon:
     Titel und Reiter (Josefin, Großbuchstaben), sonst Lexend als
     Text (400), Betontes/Zwischenüberschrift (600) und Nebentext (--small). */
  --title: 700 1.2em/1.2 'Josefin Sans', 'Century Gothic', sans-serif;
  --title-space: 0.16em;
  --strong: 600;
  --small: 0.9em;
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
[hidden] { display: none !important; }
body { margin: 0; background: #191821; color: var(--text); font: 15px/1.35 Lexend, system-ui, sans-serif; }
a { color: var(--gold); }
button, input, select { font: inherit; color: inherit; background: var(--slot); border: 1px solid var(--line); border-radius: 3px; padding: 7px 9px; min-width: 0; }
option { background: var(--bg); color: var(--text); }
button { cursor: pointer; overflow-wrap: anywhere; }
button:hover:not(:disabled) { border-color: var(--cream); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary, button[aria-pressed='true'] { background: var(--cream); border-color: var(--cream); color: var(--ink); }
summary { cursor: pointer; }
b { font-weight: var(--strong); }

/* Seite: nur Rahmen um dasselbe Panel */
#app { max-width: 640px; margin: 0 auto; padding: 20px 16px; }
#app > section { background: var(--bg); border: 2px solid var(--line); outline: 1px solid var(--line); outline-offset: -7px; border-radius: 4px; padding: 16px; }
h1, .kind button, .flash b { font: var(--title); letter-spacing: var(--title-space); text-transform: uppercase; }
h1 { margin: 0; }
.kind button { font-size: 1em; }
header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -16px -16px 12px; padding: 18px 16px 14px; background: linear-gradient(var(--blue), var(--blue-dark)); border-bottom: 1px solid var(--line); }
header h1 { flex: 1; }
details { color: var(--soft); font-size: var(--small); margin-bottom: 10px; }
.notice { border: 1px solid var(--gold); color: var(--gold); border-radius: 3px; padding: 8px 10px; margin-bottom: 10px; }

/* Reiter wie im Spiel. corner-shape kennen nur neuere Chromium, sonst bleiben runde Enden. */
.kind { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 12px / 50%; corner-shape: bevel; background: linear-gradient(var(--blue), var(--blue-dark)); }
.kind button { position: relative; padding: 10px 4px 7px; border: 0; background: transparent; border-radius: 12px / 50%; corner-shape: bevel; }
.kind button:hover { background: #ffffff14; }
.kind button[aria-pressed='true'] { background: var(--cream); box-shadow: inset 0 0 0 2px var(--cream), inset 0 0 0 3px var(--ink); }
/* Raute an beiden Enden des aktiven Reiters */
.kind button[aria-pressed='true']::before, .kind button[aria-pressed='true']::after { content: ''; position: absolute; top: calc(50% - 4px); width: 8px; height: 8px; border: 1px solid var(--ink); transform: rotate(45deg); background: var(--cream); }
.kind button::before { left: 7px; }
.kind button::after { right: 7px; }

.tier { --tier: #4c4b59; }
.t1 { --tier: #667080; } .t2 { --tier: #94623f; } .t3 { --tier: #56784a; } .t4 { --tier: #3f5fa8; } .t5 { --tier: #80489a; }
.t6 { --tier: #a5333f; } .t7 { --tier: #8f6d0c; } .t8 { --tier: #37807f; } .t9 { --tier: #4b4a5c; } .t10 { --tier: #96aebe; }
.tiers .tier.t10, .what .tier.t10 { color: var(--ink); }
.grid { display: grid; gap: 4px; }
.tiers { grid-template-columns: repeat(5, 1fr); }
.tiers button { font-weight: var(--strong); padding: 8px 2px; background: var(--tier); border: 2px solid #8a7656; border-radius: 5px; corner-shape: bevel; color: #fff; }
.tiers button[aria-pressed='true'] { border-color: var(--cream); box-shadow: inset 0 0 0 1px var(--cream); }
.resources { grid-template-columns: repeat(3, 1fr); }
.amounts { grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); }
.amount { background: var(--cream); border-color: var(--cream); color: var(--ink); }
.footer { display: grid; gap: 4px; }
.custom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.custom input { background: var(--deep); border-color: var(--tan); border-radius: 5px; corner-shape: bevel; font-variant-numeric: tabular-nums; }
.custom .invalid { border-color: #d4475a; }
.resources .taken { box-shadow: inset 4px 0 0 var(--gold); }
.toolow { border-style: dashed; color: #a39fab; }
/* Feste Höhe, damit die Mengen nicht unter dem Mauszeiger wegrutschen. */
.hint { white-space: pre-line; height: 2.7em; overflow-y: auto; color: var(--gold); }
.stage { position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.stage > .board, .stage > .sheet { grid-area: 1 / 1; min-width: 0; }
.stage > .sheet { visibility: hidden; display: flex; flex-direction: column; gap: 6px; }
.editing > .sheet { visibility: visible; }
.editing > .board { visibility: hidden; }
.toasts { position: absolute; inset: auto 0 0; pointer-events: none; }
.editing > .toasts { inset: 0 0 auto; }
.message { color: #a9dc9a; background: var(--deep); border: 1px solid var(--tan); padding: 5px 8px; }
.message:empty { display: none; }
.message.warn { color: var(--gold); }
.offline { color: var(--ink); background: var(--gold); border-radius: 3px; padding: 4px 8px; }
.filters { display: grid; grid-template-columns: 1fr 70px minmax(0, 1fr) 30px; gap: 4px; margin-bottom: 6px; }
.filters > * { padding: 5px 6px; background-color: var(--deep); border-color: var(--tan); border-radius: 5px; corner-shape: bevel; }
.filters > :is(input, select):is(:hover, :focus) { border-color: var(--cream); }
::placeholder { color: #8f8a84; }
/* Pfeil im cremefarbenen Kästchen */
select { appearance: none; background-repeat: no-repeat; background-position: right 4px center; background-size: 17px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 17'%3E%3Crect width='17' height='17' rx='2' fill='%23e8dec4'/%3E%3Cpath d='M4 7l4.5 4.5L13 7' fill='none' stroke='%232a2833' stroke-width='2'/%3E%3C/svg%3E"); }
.filters select { padding-right: 24px; }
.filters .reset { padding: 0; }
.filters .reset:not(:disabled) { background-color: var(--cream); border-color: var(--cream); color: var(--ink); }
.empty { color: var(--soft); margin: 4px 0; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; align-content: start; grid-auto-rows: max-content; }
/* Oben was und wie lange, unten wer und welche Aktion; alle Zeilen gleich hoch. */
.list li { display: grid; grid-template: 1.7em 1.7em / minmax(0, 1fr); gap: 2px 6px; align-items: center; padding: 2px 4px 2px 6px; background: var(--deep); border: 1px solid var(--faint); border-left: 3px solid var(--faint); border-radius: 2px; }
.list .mine { border-left-color: var(--cream); }
.list .open { border-left-color: var(--gold); }
.list li > * { grid-row: 1; }
.list li > .who, .list li > .actions { grid-row: 2; }
.list li > .what, .list li > .who { grid-column: 1; }
.list li > .left, .list li > .actions { grid-column: 2; justify-self: end; }
.what { display: flex; gap: 6px; align-items: center; min-width: 0; font-weight: var(--strong); }
.what span:last-child, .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what .tier { flex: none; min-width: 30px; padding: 1px 3px; text-align: center; font-size: var(--small); font-weight: var(--strong); line-height: 1.2; background: var(--tier); color: #fff; border: 1px solid #8a7656; border-radius: 3px; corner-shape: bevel; }
.who { color: var(--soft); font-size: var(--small); }
.left { color: var(--soft); font-size: var(--small); font-variant-numeric: tabular-nums; white-space: nowrap; }
select.left { height: 100%; padding: 0 20px 0 5px; width: 8.2em; background-color: transparent; background-size: 13px; border-color: var(--faint); }
.actions { height: 100%; display: flex; gap: 4px; }
.actions:empty { display: none; }
.actions button { height: 100%; padding: 0 7px; font-size: var(--small); line-height: 1; white-space: nowrap; }
.take:not(.toolow) { background: var(--cream); border-color: var(--cream); color: var(--ink); }

.views { display: grid; grid-template-columns: 1fr 1.3fr 1.1fr auto; gap: 4px; margin-bottom: 4px; }
.views button { padding: 4px 2px; font-variant-numeric: tabular-nums; white-space: nowrap; border-color: var(--faint); border-radius: 5px; corner-shape: bevel; }
.views .fold { padding: 4px 2px 4px 6px; border-color: transparent; background: transparent; color: var(--soft); }
.holder { padding: 0 8px; height: 20px; line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--small); }

#chosen { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#chosen li { display: grid; grid-template-columns: 36px 1fr 36px; gap: 4px; align-items: center; background: var(--deep); border: 1px solid var(--faint); }
#chosen span { overflow-wrap: anywhere; }
#chosen button { padding: 4px 0; border: 0; background: transparent; color: var(--gold); }
#results { margin: 8px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; align-content: start; height: 240px; overflow-y: auto; scrollbar-gutter: stable; }
#results button { padding: 5px 6px; }

.delivery { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; height: 46px; padding: 4px 6px; margin-top: 4px; background: #1d4a34; border: 1px solid #3fae6d; border-radius: 5px; corner-shape: bevel; }
.delivery > div { display: grid; line-height: 1.25; }
.delivery b, .delivery div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delivery b { font-weight: var(--strong); }
.delivery div span { font-size: var(--small); }
.delivery .check { color: #6be39a; font-size: 1.6em; line-height: 1; }
.delivery button { height: 100%; padding: 0 14px; }
/* Im Formular bleibt jeder Knopf an seinem Platz, die Leiste kommt danach wieder. */
.editing ~ .delivery { display: none; }
.panel:not(.compact) .delivery { position: sticky; bottom: 8px; }
.flash { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; color: #fff; background: #157a43; border: 4px solid #7df0ab; border-radius: 0; animation: flash 6s linear both; }
.flash:hover:not(:disabled) { border-color: #7df0ab; }
.flash .check { font-size: 120px; line-height: 1; }
.flash b { font-size: 22px; letter-spacing: 0.08em; overflow-wrap: anywhere; }
.flash span:last-child { font-size: 18px; }
@keyframes flash { 0%, 8%, 16%, 92% { background-color: #157a43; opacity: 1; } 4%, 12% { background-color: #2fc877; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .flash { animation-name: flash-calm; } }
@keyframes flash-calm { from, to { opacity: 1; } }

/* Alle Dialoge beginnen an derselben Stelle oben im Fenster. */
dialog { width: min(460px, calc(100vw - 32px)); margin: 20px auto auto; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 0 16px 16px; color: var(--text); background: var(--bg); border: 2px solid var(--line); border-radius: 4px; }
dialog::backdrop { background: #0009; }
dialog h1 { margin: 0 -16px 14px; padding: 16px 16px 12px; background: linear-gradient(var(--blue), var(--blue-dark)); border-bottom: 1px solid var(--line); }
dialog .close, #name { width: 100%; }
dialog p { margin: 8px 0 12px; font-size: var(--small); color: var(--soft); }
#sound { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; margin: 0 0 10px; padding: 6px 10px 10px; border: 1px solid var(--faint); border-radius: 3px; }
#sound legend { padding: 0 4px; }
#sound label { cursor: pointer; }
#sound input { accent-color: var(--cream); }
#sound button { padding: 3px 10px; }
#sound-volume { width: 130px; padding: 0; }

.aux { height: 26px; display: grid; }
.aux .holder, .supply { height: 100%; font-size: 1em; padding: 0 8px; }
.supply { border-radius: 5px; corner-shape: bevel; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.supply:disabled, .who.ask:disabled { opacity: 1; }
.supply[data-state='online'] { background: #1d4a34; border-color: #3fae6d; }
.supply[data-state='offline'] { background: #54430f; border-color: var(--gold); }
.supply[data-state='none'] { background: #572029; border-color: #e0596b; }
.who.ask[data-state='online'] { color: #6be39a; }
.who.ask[data-state='offline'] { color: var(--gold); }
.who.ask[data-state='none'] { color: #ff8d9a; }
.able { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.able-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.able-head b { font-weight: var(--strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.able-head button { padding: 4px 10px; }
.able ul { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.able li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 3px 8px; color: var(--soft); border-bottom: 1px solid var(--faint); }
.able .head, .able .none { display: block; padding: 8px 0 4px; border: 0; }
.able .head, #sound legend { font-weight: var(--strong); color: var(--text); }
.able .dot { width: 8px; height: 8px; border: 1px solid var(--line); border-radius: 50%; }
.able .online { color: var(--text); }
.able .online .dot { background: #4fd889; border-color: #4fd889; }
.able .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.able .level { font-variant-numeric: tabular-nums; }
.who.ask { justify-self: start; max-width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.who.ask:hover:not(:disabled) { text-decoration: underline; }
/* Platz für die Lieferantenliste, auch wenn auf der Seite kaum Einträge stehen. */
.panel:not(.compact) > .stage { min-height: 380px; }

/* Overlay: die Liste bekommt allen Platz, den das Formular nicht braucht */
.overlay { font-size: 13px; height: 100vh; overflow: hidden; background: var(--bg); }
.compact { position: relative; display: flex; flex-direction: column; height: 100vh; padding: 5px; border: 1px solid var(--line); }
.compact > .stage { flex: 1; min-height: 0; }
.compact .board { display: flex; flex-direction: column; min-height: 0; }
.compact .list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.compact .sheet { min-height: 0; overflow-y: auto; gap: 4px; }
.compact .sheet > * { flex: none; }
.compact .tiers button { padding: 5px 2px; }
.tiers button:hover:not(:disabled):not([aria-pressed='true']) { border-color: #b59c74; }
.compact .resources button { padding: 4px 2px; }
/* Auch in einem kleinen Fenster bleiben die Mengen sichtbar. */
.compact .footer { position: sticky; bottom: 0; background: var(--bg); padding-top: 2px; }
.compact .custom > * { padding: 5px 10px; }
.compact .amounts button { padding: 6px 4px; }
