/* ==================================================================
   Beerbusinessgame – Grundlayout. Farben zentral als Variablen,
   damit du sie leicht anpassen kannst.
   ================================================================== */
:root {
    --bier:      #c8860d;   /* Akzentfarbe */
    --dunkel:    #3b2a1a;
    --hell:      #fbf7f0;
    --karte:     #ffffff;
    --rand:      #e6dccb;
    --ok:        #2e7d32;
    --fehler:    #c62828;
    --link:      #9a5c00;   /* Links: dunkleres Bernstein, gut lesbar auf hellem Grund */
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--hell);
    color: var(--dunkel);
}

/* Links: Akzentfarbe statt Standard-Blau, feine Unterstreichung,
   die beim Darüberfahren kräftiger wird */
a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: .2em;
    text-decoration-color: rgba(154, 92, 0, .35);
    transition: color .15s, text-decoration-color .15s;
}
a:hover { color: var(--dunkel); text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--bier); outline-offset: 2px; border-radius: 2px; }

/* Kopfzeile */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: .5rem;
    padding: .75rem 1rem;
    background: var(--dunkel); color: #fff;
}
.topbar .logo { font-weight: 700; font-size: 1.2rem; }
.topbar a { color: var(--bier); text-decoration: none; }
.topbar a:hover { color: #f3e3c3; text-decoration: underline; }

.content { max-width: 1000px; margin: 0 auto; padding: 1rem; }
h1 { margin-top: .5rem; }
.sub { margin-top: -.5rem; color: #7a6a58; }

/* Karten und Raster */
.card {
    background: var(--karte); border: 1px solid var(--rand); border-radius: 8px;
    padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.narrow { max-width: 360px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
/* Rasterzellen dürfen schmaler werden als ihr Inhalt – sonst ragen breite
   Tabellen in die Nachbarkarte. Zu breite Tabellen scrollen in .table-scroll. */
.grid > * { min-width: 0; }

/* Formulare */
label { display: block; margin-bottom: .75rem; font-size: .9rem; }
input, select {
    display: block; width: 100%; margin-top: .25rem; padding: .5rem;
    border: 1px solid var(--rand); border-radius: 4px; font-size: 1rem;
}
button {
    background: var(--bier); color: #fff; border: 0; border-radius: 4px;
    padding: .6rem 1.2rem; font-size: 1rem; cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .4rem .5rem; border-bottom: 1px solid var(--rand); text-align: left; }
td.num { text-align: right; white-space: nowrap; }
th.num { text-align: right; }   /* Überschrift steht über den Zahlen (rechtsbündig) */
tr.sum td { font-weight: 700; border-top: 2px solid var(--dunkel); }
tr.detail td { font-size: .85rem; color: #7a6a58; border-bottom: 0; }   /* Unterzeilen */
tr.detail td:first-child { padding-left: 1.5rem; }

/* Eingabetabelle (Ausgangslage) */
.table-scroll { overflow-x: auto; margin-bottom: 1rem; }  /* auf dem Handy seitlich scrollen */
.input-table input { margin-top: 0; min-width: 90px; }
.hint { font-size: .85rem; color: #7a6a58; }
input:disabled { background: #f1ece3; }

/* Buttons: zweite Variante und Link, der wie ein Button aussieht */
button.secondary { background: #fff; color: var(--dunkel); border: 1px solid var(--rand); }
a.button {
    display: inline-block; margin-left: .5rem; padding: .4rem .9rem; border-radius: 4px;
    background: var(--bier); color: #fff; text-decoration: none;
}
a.button:hover { background: #b0760b; color: #fff; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Checkbox mit Text daneben statt darunter */
label.check { display: flex; align-items: center; gap: .5rem; }
label.check input, td.center input { width: auto; margin: 0; }
td.center { text-align: center; }

/* Hinweiskasten im Dashboard */
.callout {
    background: #fff8e6; border: 1px solid var(--bier); border-radius: 8px;
    padding: .75rem 1rem; margin-bottom: 1rem;
}

/* Status-Etiketten */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 10px; font-size: .85rem; background: #eee; }
.badge-setup    { background: #fff3cd; }
.badge-running  { background: #e8f5e9; color: var(--ok); }
.badge-finished { background: #e3e3e3; }

/* Ampel: rot = noch nichts, gelb = Entwurf, grün = abgegeben */
.light {
    display: inline-block; width: 12px; height: 12px; border-radius: 50%;
    vertical-align: middle; margin-right: .3rem; box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.light-open      { background: #d93025; }
.light-draft     { background: #f2b600; }
.light-submitted { background: #2e9d43; }
ul.players { list-style: none; padding: 0; margin: 0 0 .5rem; }
ul.players li { padding: .35rem 0; border-bottom: 1px solid var(--rand); }
ul.players .hint { margin-left: .3rem; }

/* Kleine Buttons in Tabellenzeilen, Gefahrenzone (Reset) */
button.small { padding: .25rem .6rem; font-size: .85rem; }
.row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.card.danger { border-color: var(--fehler); }

/* Kleines Formular in einer Tabellenzeile (z.B. Passwort ändern) */
.inline-form { display: flex; gap: .4rem; align-items: center; margin: 0; }
.inline-form input { margin: 0; width: 9rem; padding: .3rem .4rem; font-size: .9rem; }
tr.highlight td { background: #e8f5e9; }   /* gerade geänderte Zeile */

/* Spam-Falle im Solo-Formular: aus dem sichtbaren Bereich geschoben */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Kennzeichen für Computer-Gegner */
.bot { font-size: .8rem; color: #7a6a58; }
button.danger { background: var(--fehler); }

.neg { color: var(--fehler); }
.small { font-size: .8rem; }

/* ⓘ-Knopf mit Erklärtext (erscheint bei Hover, Fokus oder per JS-Klasse .open) */
.info {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%; margin-left: .25rem;
    background: var(--bier); color: #fff; font: italic 700 12px/1 Georgia, serif;
    cursor: help; vertical-align: middle; flex-shrink: 0;
}
.info .tip {
    display: none; position: absolute; z-index: 10; top: 24px; left: 50%; transform: translateX(-50%);
    width: 260px; max-width: 80vw; padding: .6rem .75rem; border-radius: 6px;
    background: var(--dunkel); color: #fff; font: 400 .85rem/1.4 system-ui, sans-serif;
    text-align: left; white-space: normal; box-shadow: 0 4px 12px rgba(0,0,0,.2);
    pointer-events: none;   /* Text fängt keine Klicks ab und verdeckt so keine Bedienelemente */
}
.info:hover .tip, .info:focus .tip, .info.open .tip { display: block; }
th .info .tip { font-weight: 400; }

/* Gekaufte Marktinformationen */
.infobox { border-left: 4px solid var(--bier); }
.infobox h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
.infobox h3:first-of-type { margin-top: 0; }

/* Aufklappbare Vorschau (<details>) beim Moderator */
details.preview summary { cursor: pointer; list-style: none; }
details.preview summary::-webkit-details-marker { display: none; }
details.preview summary h2 { display: inline; }
details.preview summary::before { content: '▸ '; color: var(--bier); }
details.preview[open] summary::before { content: '▾ '; }
details.preview h3 { font-size: .95rem; margin: 1rem 0 .4rem; }

/* Kennzahlen-Kacheln */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--karte); border-left: 4px solid var(--bier); border-radius: 6px; padding: .75rem .85rem; min-width: 0; }
.kpi > span { display: block; font-size: .85rem; color: #7a6a58; }
.kpi strong { font-size: 1.3rem; white-space: nowrap; }   /* Beträge nie umbrechen */

/* Meldungen */
.msg { padding: .75rem 1rem; border-radius: 6px; }
.msg.ok { background: #e8f5e9; color: var(--ok); }
.msg.error { background: #ffebee; color: var(--fehler); }
code { background: #f1ece3; padding: .1rem .35rem; border-radius: 3px; font-size: 1rem; }

/* Positive Werte (z.B. Attraktivitätsbeiträge) */
.pos { color: var(--ok); }

/* ==================================================================
   Navigationsleiste der Spieler (app/player.php, player_nav())
   Bleibt beim Scrollen oben stehen; auf schmalen Bildschirmen
   seitlich wischbar statt umzubrechen.
   ================================================================== */
.tabs {
    position: sticky; top: 0; z-index: 20;
    background: #fff; border-bottom: 1px solid var(--rand);
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.tabs-wrap {
    max-width: 1000px; margin: 0 auto; padding: 0 1rem;
    display: flex; align-items: stretch;
}
.tabs-links {
    display: flex; gap: .25rem; min-width: 0;
    overflow-x: auto; white-space: nowrap;
    scrollbar-width: none;                 /* Firefox: keine Scrollleiste */
    -webkit-overflow-scrolling: touch;
}
.tabs-links::-webkit-scrollbar { display: none; }
.tabs-game {
    display: flex; align-items: center; flex-shrink: 0;
    padding-right: .75rem; margin-right: .25rem;
    border-right: 1px solid var(--rand); font-weight: 700; font-size: .9rem;
    max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tabs a {
    display: flex; align-items: center; gap: .35rem;
    padding: .75rem .7rem; color: var(--dunkel); text-decoration: none; font-size: .95rem;
    border-bottom: 3px solid transparent;
}
.tabs a:hover { background: var(--hell); }
.tabs a.active { border-bottom-color: var(--bier); font-weight: 700; }
.tabs .dot { width: 8px; height: 8px; border-radius: 50%; background: #d93025; display: inline-block; }

/* Hinweis "neu ab Qx" auf der Seite Spielregeln & Kosten */
.badge-new { background: #fff3cd; color: #8a5a00; font-size: .75rem; vertical-align: middle; }

/* Hilfe: aufklappbare Abschnitte */
details.help summary { cursor: pointer; list-style: none; }
details.help summary::-webkit-details-marker { display: none; }
details.help summary h2 { display: inline; }
details.help summary::before { content: '▸ '; color: var(--bier); }
details.help[open] summary::before { content: '▾ '; }
details.help[open] summary { margin-bottom: .5rem; }
dl dt { font-weight: 700; margin-top: .6rem; }
dl dd { margin: .15rem 0 0 0; }
p.callout { margin-top: 0; }

/* Nur auf dem Handy / nur auf größeren Bildschirmen zeigen */
.show-sm { display: none; }
@media (max-width: 600px) {
    .card { padding: .85rem .75rem; }
    th, td { padding: .4rem .3rem; }
    .hide-sm { display: none; }
    span.show-sm { display: inline; }
    p.show-sm { display: block; }
}

@media (max-width: 600px) {
    .tabs-wrap { display: block; padding: 0; }
    .tabs-game {
        display: block; max-width: none; border-right: 0; margin: 0;
        padding: .4rem 1rem 0; font-size: .8rem; color: #7a6a58;
    }
    .tabs-links { padding: 0 .5rem; }
    .tabs a { padding: .55rem .55rem .65rem; font-size: .9rem; }
}

/* ==================================================================
   Historie: Quartale als Spalten, erste Spalte bleibt beim Wischen stehen
   ================================================================== */
.htable th, .htable td { white-space: nowrap; }
.htable th.num { text-align: right; }
.htable tr > th:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--karte); text-align: left; font-weight: 400;
    box-shadow: 1px 0 0 var(--rand);
}
.htable tr:first-child th { font-weight: 700; }
.htable tr.group th, .htable tr.group td {
    background: var(--hell); font-weight: 700; font-size: .8rem;
    text-transform: uppercase; letter-spacing: .03em; color: #7a6a58; padding-top: .7rem;
}
@media (max-width: 600px) {
    /* Beschriftungsspalte schmal halten und umbrechen, damit Platz für Zahlen bleibt */
    .htable tr > th:first-child {
        white-space: normal; min-width: 9.5rem; max-width: 9.5rem; font-size: .85rem; line-height: 1.25;
        hyphens: manual; overflow-wrap: break-word;   /* Trennstellen setzt hist_label() */
    }
    .htable td { font-size: .9rem; }
}
.htable td.empty { color: #c9bca8; }
.htable tbody tr:hover td { background: #fdf9f2; }

/* Umschalter für Biersorten */
.seg { display: inline-flex; border: 1px solid var(--rand); border-radius: 6px; overflow: hidden; margin-bottom: .75rem; }
.seg-btn {
    background: #fff; color: var(--dunkel); border: 0; border-radius: 0;
    padding: .45rem .9rem; font-size: .95rem;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--rand); }
.seg-btn.active { background: var(--bier); color: #fff; }
.beer-panel h3 { font-size: .95rem; margin: .25rem 0 .5rem; }

/* Frühere Marktinformationen */
details.infohist { border-top: 1px solid var(--rand); padding: .5rem 0; }
details.infohist summary { cursor: pointer; font-weight: 700; }
details.infohist[open] summary { margin-bottom: .4rem; }
/* "hidden" muss auch gegen display-Regeln oben gewinnen (z.B. .seg) */
[hidden] { display: none !important; }

/* ==================================================================
   Diagramme (app/charts.php, js/charts.js)
   ================================================================== */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem 1.5rem; }
.charts > * { min-width: 0; }
figure.chart { margin: 0 0 .5rem; }
figure.chart figcaption { font-weight: 700; font-size: .95rem; margin-bottom: .4rem; }
.chart-box { position: relative; height: 220px; }
figure.chart .hint { margin: .3rem 0 0; }
@media (max-width: 600px) {
    .charts { grid-template-columns: 1fr; }
    .chart-box { height: 200px; }
}

/* Historie: Beschriftung + kleiner Diagramm-Knopf je Tabellenzeile */
.htable .lbl { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
button.row-chart {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; border-radius: 5px;
    background: transparent; border: 1px solid var(--rand); color: var(--bier); cursor: pointer;
}
button.row-chart svg { fill: currentColor; }
button.row-chart:hover, button.row-chart:focus-visible { background: var(--bier); color: #fff; border-color: var(--bier); }

/* Diagramm-Fenster */
dialog.chart-dialog {
    width: min(640px, 94vw); padding: 1rem 1.25rem; border: 0; border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.25); color: var(--dunkel);
}
dialog.chart-dialog::backdrop { background: rgba(59,42,26,.45); }
.cd-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.cd-close {
    background: transparent; color: var(--dunkel); font-size: 1.6rem; line-height: 1;
    padding: .1rem .5rem; border-radius: 6px;
}
.cd-close:hover { background: var(--hell); }
.cd-box { height: 280px; }
dialog.chart-dialog .hint { margin: .5rem 0 0; }
@media (max-width: 600px) { .cd-box { height: 240px; } dialog.chart-dialog { padding: .85rem; } }

/* Einwilligung Bestenliste am Spielende */
.board-consent { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; font-size: .9rem; }

/* Startseite: Einleitung und "Über das Spiel" */
p.lead { font-size: 1.05rem; max-width: 46rem; margin-top: -.25rem; }
.about h3 { font-size: 1rem; margin: .25rem 0 .4rem; }
.about p, .about li { font-size: .95rem; }
ul.compact { padding-left: 1.1rem; margin: 0; }
ul.compact li { margin-bottom: .35rem; }

/* Fußzeile */
.footer { max-width: 1000px; margin: 1rem auto 2rem; padding: 0 1rem; font-size: .85rem; color: #7a6a58; text-align: center; }
.footer a { color: inherit; }

/* Moderator-Hilfe */
nav.toc { display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: baseline; font-size: .95rem; }
ol.steps li { margin-bottom: .5rem; }
p.formula, span.formula {
    font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem;
    background: var(--hell); border-left: 3px solid var(--bier); padding: .4rem .7rem; border-radius: 4px;
}
span.formula { padding: .1rem .4rem; border-left-width: 2px; }
#modell h3 { font-size: 1rem; margin: 1.25rem 0 .4rem; }
/* "Über das Spiel": immer 2 × 2 statt 3 + 1 */
.grid.about { grid-template-columns: repeat(2, 1fr); gap: 1rem 2rem; }
@media (max-width: 700px) { .grid.about { grid-template-columns: 1fr; } }

/* AGB / Datenschutz / Impressum als Fenster */
dialog.legal-dialog {
    width: min(720px, 94vw); max-height: 85vh; padding: 0; border: 0; border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.25); color: var(--dunkel);
}
dialog.legal-dialog[open] { display: flex; flex-direction: column; }
dialog.legal-dialog::backdrop { background: rgba(59,42,26,.45); }
dialog.legal-dialog .cd-head { padding: .9rem 1.25rem; margin: 0; border-bottom: 1px solid var(--rand); }
dialog.legal-dialog .cd-head h2 { margin: 0; font-size: 1.15rem; }
.legal-body { padding: .5rem 1.25rem 1.25rem; overflow-y: auto; }
.legal-body h3, .legal-page h3 { font-size: 1rem; margin: 1rem 0 .3rem; }
.legal-body p, .legal-page p { line-height: 1.5; }

/* Bestenliste: kompakte, feste Spalten statt weit auseinandergezogener Zahlen */
table.board { width: auto; min-width: 100%; max-width: 640px; }
table.board th:nth-child(1), table.board td:nth-child(1) { width: 2.5rem; }        /* Platz */
table.board th:nth-child(3), table.board td:nth-child(3) { width: 9rem; }          /* Gesamtgewinn */
table.board th:nth-child(4), table.board td:nth-child(4) { width: 6rem; }          /* Quartale */
table.board th:nth-child(5), table.board td:nth-child(5) { width: 7rem; padding-left: 1.25rem; }  /* Datum */
table.board .anon { color: #7a6a58; font-style: italic; }
@media (max-width: 600px) {
    table.board th, table.board td { width: auto !important; }
    table.board th:nth-child(4), table.board td:nth-child(4) { display: none; }   /* Quartale am Handy weglassen */
    table.board th:nth-child(5), table.board td:nth-child(5) { padding-left: .5rem; }
}

/* ==================================================================
   KI-Regel, Bestätigung, Hinweise (app/ki.php)
   ================================================================== */
.ki-rule { border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem; font-size: .95rem; }
.ki-rule p { margin: 0; }
.ki-rule p + p { margin-top: .45rem; }
.ki-yes  { background: #f3f7f3; border: 1px solid #cfe3d1; }
.ki-mode { background: #eef3fb; border: 1px solid #c4d5ef; }
.ki-no   { background: #fff4f2; border: 1px solid #f0c4bc; border-left: 4px solid var(--fehler); }
/* Offener Hinweis für KI-Assistenten: für alle sichtbar, bewusst nüchtern */
.ki-note { font-size: .88rem; color: #5a4a3a; }
.ki-pledge { border-left: 4px solid var(--bier); }
.ki-pledge label.check { font-size: 1rem; margin: .75rem 0; }
.msg.ki-hint { background: #fff8e6; color: var(--dunkel); border: 1px solid var(--bier); }

/* Solo-Start: Haken "selbst" / "mit KI" */
.ki-choice { margin-bottom: .25rem; }
.again-form { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; margin-top: .5rem; }
.again-form .ki-choice label { margin-bottom: .25rem; font-size: .9rem; }

/* Moderator: Einstellung erlaubt / nicht erlaubt */
fieldset.ki-setting { border: 1px solid var(--rand); border-radius: 6px; padding: .4rem .75rem .1rem; margin: 0 0 .5rem; }
fieldset.ki-setting legend { font-size: .9rem; padding: 0 .3rem; }
fieldset.ki-setting label.check { display: inline-flex; margin-right: 1.25rem; }

/* Eingabe-Ampel: Punkt + Text (Farbe nie allein) */
.ai-badge {
    display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
    font-size: .82rem; padding: .05rem .45rem; border-radius: 10px; background: #f4f1ec;
}
.ai-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.ai-0 .ai-dot { background: #2e9d43; }
.ai-1 .ai-dot { background: #f2b600; }
.ai-1 { background: #fff6d6; }
.ai-2 .ai-dot { background: #d93025; }
.ai-2 { background: #fde4e1; font-weight: 700; }
.ai-none { color: #7a6a58; background: transparent; }
table.ki-matrix td, table.ki-matrix th { white-space: nowrap; }
.badge-ai { background: #e4ecf8; color: #1f4f8f; }
