/* ---------------------------------------------------------------------------
   BE FREAKY - gemeinsames Stylesheet
   Gilt fuer alle Seiten (Login, Startseite, Galerie, Benutzerverwaltung)
   und die Rechner (/pharma, /mischung, /anmischen).
   Keine externen Schriften, kein JavaScript.
   --------------------------------------------------------------------------- */

:root {
    --fg: #1d1d1f;
    --fg-muted: #5b5b60;
    --bg: #ffffff;
    --bg-soft: #f4f4f2;
    --bg-header: #f7f7f5;
    --border: #d5d5d0;
    --border-strong: #b9b9b2;
    --accent: #2f5d45;
    --accent-soft: #e8efea;
    --error: #a01b1b;
    --error-bg: #fdf3f3;
    --ok: #1f6b3a;
    --ok-bg: #f1f8f3;
    --radius: 4px;
    --max-width: 1000px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

/* --- Kopfzeile ------------------------------------------------------------ */

.site-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
}

/* Ab Tablet-Breite bleibt die Kopfzeile beim Scrollen oben stehen.
   Auf dem Handy bricht das Menue um und wuerde zu viel Platz kosten - dort
   scrollt sie wie bisher mit. */
@media (min-width: 601px) {
    .site-header {
        position: sticky;
        top: 0;
        z-index: 10;
    }
}

.site-nav {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.site-nav .brand {
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
    margin-right: 4px;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

/* Dropdown im Menue: <details>/<summary> - funktioniert ohne JavaScript. */
.nav-menu {
    position: relative;
}

.nav-menu > summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.nav-menu > summary::-webkit-details-marker {
    display: none;
}

.nav-menu > summary::after {
    content: "\25BE"; /* kleines Dreieck */
    font-size: 10px;
    color: var(--fg-muted);
}

.nav-menu[open] > summary::after {
    content: "\25B4";
}

.nav-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    padding: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.nav-menu-panel a {
    display: block;
    padding: 5px 8px;
    border-radius: var(--radius);
    white-space: nowrap;
}

.nav-menu-panel a:hover,
.nav-menu-panel a:focus {
    background: var(--accent-soft);
    text-decoration: none;
}

.nav-user {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-muted);
    font-size: 14px;
}

.nav-form {
    display: inline;
}

.nav-form button {
    padding: 3px 10px;
    font-size: 13px;
}

/* --- Inhalt --------------------------------------------------------------- */

.site-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.site-footer {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px;
    border-top: 1px solid var(--border);
    color: var(--fg-muted);
}

/* --- Typografie ----------------------------------------------------------- */

h1 {
    font-size: 24px;
    margin: 0 0 16px;
}

h2 {
    font-size: 18px;
    margin: 28px 0 10px;
}

p {
    margin: 0 0 12px;
}

a {
    color: var(--accent);
}

a:hover {
    text-decoration: none;
}

small,
.hint,
.meta {
    color: var(--fg-muted);
    font-size: 13px;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 22px 0;
}

code {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 4px;
    font-size: 13px;
}

/* --- Hinweise und Meldungen ---------------------------------------------- */

.flash,
.notice {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: var(--bg-soft);
}

.flash-success {
    border-left-color: var(--ok);
    background: var(--ok-bg);
}

.flash-error,
.notice-error {
    border-left-color: var(--error);
    background: var(--error-bg);
    color: #4a0f0f;
}

/* --- Formulare ----------------------------------------------------------- */

form p {
    margin: 0 0 14px;
}

label {
    display: inline-block;
    margin-bottom: 3px;
    font-size: 14px;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="file"],
select {
    padding: 5px 7px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--fg);
    font: inherit;
    font-size: 15px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: 2px solid var(--accent-soft);
    border-color: var(--accent);
}

button {
    padding: 6px 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
}

button:hover {
    background: var(--accent);
    color: #fff;
}

/* --- Tabellen ------------------------------------------------------------ */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 16px;
    font-size: 15px;
}

th,
td {
    padding: 7px 9px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--bg-soft);
    font-weight: 600;
    white-space: nowrap;
}

table td input[type="password"],
table td input[type="text"] {
    width: 100%;
    min-width: 120px;
}

/* --- Galerie ------------------------------------------------------------- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin: 0 0 20px;
}

.gallery-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    background: #fff;
}

.gallery-item img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}

.gallery-item .file-meta {
    display: block;
    color: var(--fg-muted);
    font-size: 12px;
    margin: 6px 0;
}

.link-input {
    width: 100%;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
    padding: 3px 5px;
    margin-bottom: 6px;
}

/* Aktionen unter dem Link-Feld: "löschen" und "kopieren" nebeneinander */
.gallery-item .file-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* "kopieren" sieht aus wie ein Link, ist aber ein Button (kein Sprungziel) */
button.copy-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

button.copy-link:hover,
button.copy-link:focus {
    background: none;
    color: var(--fg);
}

button.copy-link.copy-failed {
    color: var(--error);
}

/* Hilfsfeld für den Kopier-Fallback (unsichtbar, aber fokussierbar) */
.copy-helper {
    position: fixed;
    top: -1000px;
    left: -1000px;
    opacity: 0;
}

.pager {
    display: flex;
    gap: 14px;
    align-items: center;
    margin: 18px 0;
}

/* --- Pharmakokinetik-Rechner --------------------------------------------- */

.calc-form label {
    display: block;
    margin: 10px 0 3px;
}

.calc-form input[type="text"] {
    width: 8em;
}

.chart {
    margin: 20px 0;
}

.chart img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}

.copy-field {
    width: 100%;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
    padding: 4px 6px;
    margin: 4px 0 6px;
}

@media (max-width: 600px) {
    .site-nav {
        gap: 10px;
    }

    .nav-user {
        margin-left: 0;
    }

    /* Panel nach links oeffnen, damit es nicht aus dem Bild laeuft. */
    .nav-menu-panel {
        left: auto;
        right: 0;
    }

    h1 {
        font-size: 21px;
    }
}

/* --- Shoutbox ------------------------------------------------------------ */

.shout-form {
    margin-bottom: 18px;
}

.shout-form textarea {
    width: 100%;
    max-width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--fg);
    font: inherit;
    font-size: 15px;
    resize: vertical;
}

.shout-form textarea:focus {
    outline: 2px solid var(--accent-soft);
    border-color: var(--accent);
}

.shout-list {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}

.shout-item {
    margin: 0 0 10px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.shout-head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0 0 4px;
}

.shout-head small {
    color: var(--fg-muted);
    font-size: 12px;
}

.shout-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.shout-delete {
    margin: 7px 0 0;
}

.shout-delete button {
    padding: 2px 9px;
    font-size: 12px;
}

.shout-empty {
    color: var(--fg-muted);
    font-size: 14px;
}

#shout-status {
    min-height: 1.3em;
}

/* --- Avatare ------------------------------------------------------------- */

.avatar {
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-soft);
    object-fit: cover;
}

/* Avatare werden nie vergroessert: max-width/max-height statt fester Groesse.
   Ein 15-px-Bild bleibt also 15 px (scharf), ein grosses wird heruntergerechnet. */
.avatar-nav {
    width: auto;
    height: auto;
    max-width: 24px;
    max-height: 24px;
}

.avatar-shout {
    flex: 0 0 auto;
    width: auto;
    height: auto;
    max-width: 32px;
    max-height: 32px;
}

.avatar-preview {
    display: block;
    width: auto;
    height: auto;
    max-width: 128px;
    max-height: 128px;
    margin: 0 0 10px;
}

/* --- Übersicht (Startseite) ---------------------------------------------- */

.dashboard-hello {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px;
}

.avatar-dashboard {
    width: auto;
    height: auto;
    max-width: 48px;
    max-height: 48px;
}

/* Verweise unter der Begrüßung ("Chat", später ggf. mehr) */
.link-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
}

.link-list a {
    display: inline-block;
    padding: 5px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-soft);
    text-decoration: none;
}

.link-list a:hover,
.link-list a:focus {
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* --- Wordle (Spielplatz) -------------------------------------------------- */
/* Nachbau des alten Canvas-Looks: graue Flaeche, 45-px-Kaestchen mit schwarzem
   Rahmen (gruen/gelb/grau), Tastatur 50 px, rote Enter/Del-Tasten. */

.wordle-board {
    width: 640px;
    max-width: 100%;
    margin: 0 auto;
    padding: 14px 12px;
    background: #dddddd;
    border: 1px solid #000000;
    font-family: Arial, Helvetica, sans-serif;
}

.wordle-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.wordle-grid {
    display: grid;
    grid-template-columns: repeat(5, 45px);
    gap: 5px;
}

.wordle-cell {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #000000;
    color: #000000;
    font-size: 24px;
    line-height: 1;
}

.wordle-cell.is-1,
.wordle-key.is-1 {
    background: #00ff00;
}

.wordle-cell.is-2,
.wordle-key.is-2 {
    background: #ffff00;
}

.wordle-cell.is-3,
.wordle-key.is-3 {
    background: #bbbbbb;
}

.wordle-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wordle-label {
    font-size: 14px;
    color: var(--fg-muted);
}

.wordle-input {
    width: 160px;
    padding: 4px 6px;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    font-family: inherit;
    font-size: 20px;
    text-transform: uppercase;
}

.wordle-keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 18px;
}

.wordle-keyrow {
    display: flex;
}

.wordle-key {
    width: 50px;
    height: 50px;
    padding: 0;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    font-family: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.wordle-key:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 1px;
}

/* Enter und Del - im alten Spiel rote Knoepfe rechts neben dem Raster. */
.wordle-key-wide {
    width: 160px;
    height: 40px;
    background: #ff0000;
    font-size: 20px;
}

.wordle-status {
    margin: 16px 0 0;
    text-align: center;
    font-size: 20px;
    line-height: 1.4;
}

@media (max-width: 660px) {
    .wordle-grid {
        grid-template-columns: repeat(5, 36px);
    }

    .wordle-cell {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .wordle-key {
        width: 32px;
        height: 36px;
        font-size: 15px;
    }

    .wordle-key-wide,
    .wordle-input {
        width: 104px;
        height: 34px;
        font-size: 15px;
    }

    .wordle-status {
        font-size: 16px;
    }
}

/* --- Spielerliste --------------------------------------------------------- */

.avatar-list {
    width: auto;
    height: auto;
    max-width: 32px;
    max-height: 32px;
}

/* Kein Avatar vorhanden: Kreis mit dem ersten Buchstaben des Namens. */
.avatar-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 15px;
    font-weight: 700;
    color: var(--fg-muted);
    text-transform: uppercase;
}

.player-table .player-avatar {
    width: 48px;
}

.player-table .player-score {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.player-table tr.is-self {
    background: var(--accent-soft);
}


/* --- MediStar (Spielplatz) ------------------------------------------------ */
/* Ein Bildschirm, alle Aktionen sichtbar: Statusleiste, Ortsleiste,
   Aktionskarten. Alles DOM (kein Canvas), damit es auch auf dem Handy passt. */

.medistar {
    max-width: 780px;
}

.medistar.is-busy {
    opacity: 0.6;
}

.ms-status,
.ms-rooms,
.ms-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-soft);
    padding: 10px 12px;
    margin: 0 0 12px;
}

.ms-status-line {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0 0 8px;
    font-size: 15px;
}

.ms-bar {
    position: relative;
    height: 20px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #fff;
    overflow: hidden;
}

.ms-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--ok);
}

.ms-bar-fill.is-mid {
    background: #b8860b;
}

.ms-bar-fill.is-high {
    background: var(--error);
}

.ms-bar-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.ms-warn {
    margin: 8px 0 0;
    color: var(--error);
    font-size: 14px;
}

.ms-room-list,
.ms-tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.ms-tiles .ms-btn {
    min-height: 40px;
    padding: 6px 4px;
    font-size: 14px;
}

/* Die Ortsleiste braucht keine Ueberschrift - Platz sparen */
.ms-rooms {
    padding: 8px;
}

@media (max-width: 600px) {
    .ms-tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ms-toast {
    margin: 0 0 12px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    background: var(--bg-soft);
    font-size: 15px;
    font-weight: 600;
}

.ms-toast.is-error {
    border-left-color: var(--error);
    background: var(--error-bg);
    color: var(--error);
}

/* Endabrechnung: Bargeld, Bankguthaben, Summe */
.ms-sum {
    display: grid;
    gap: 4px;
    margin: 0 0 14px;
}

.ms-sum-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-soft);
}

.ms-sum-row strong {
    font-weight: 700;
}

.ms-btn.is-current {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    cursor: default;
}

.ms-btn.is-primary {
    font-weight: 600;
}

.ms-btn.is-risky {
    border-color: #8a5a00;
    background: #fdf5e6;
    color: #8a5a00;
}

.ms-btn.is-sell {
    border-color: #1f4a6b;
    background: #eaf1f7;
    color: #1f4a6b;
}

.ms-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.ms-panel h3 {
    margin: 0 0 8px;
    font-size: 15px;
}

.ms-row {
    border-top: 1px solid var(--border);
    padding: 8px 0;
}

.ms-row:first-of-type {
    border-top: 0;
}

.ms-row-head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
    margin-bottom: 6px;
}

.ms-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ms-actions .ms-btn {
    padding: 5px 10px;
    font-size: 14px;
    min-height: 34px;
}

/* Gruppenbeschriftung innerhalb einer Aktionszeile ("kaufen", "klauen 75 %") */
.ms-group {
    align-self: stretch;
    display: flex;
    align-items: center;
    padding-left: 10px;
    border-left: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Die erste Gruppe einer Zeile beginnt ohne Trennlinie */
.ms-group:first-child {
    padding-left: 0;
    border-left: 0;
}

.ms-muted {
    color: var(--fg-muted);
    font-size: 14px;
}

.ms-list {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
}

.ms-list li {
    margin: 0 0 3px;
}

.ms-log .ms-list li {
    color: var(--fg-muted);
}

.medistar-rules {
    font-size: 14px;
    color: var(--fg-muted);
}

@media (max-width: 600px) {
    .ms-actions .ms-btn {
        min-height: 44px;
    }

    .ms-status-line {
        gap: 8px;
        font-size: 14px;
    }
}


/* --- Passwortfeld (Einstellungen) ----------------------------------------- */
/* Die Regeln stehen als Liste unter dem Feld; password.js setzt is-ok/is-bad,
   damit man ohne Absenden sieht, was noch fehlt. */

.password-rules {
    list-style: none;
    padding-left: 0;
    margin: 0 0 12px;
}

.password-rules li::before {
    content: '• ';
    color: var(--fg-muted);
}

.password-rules li.is-ok::before {
    content: '✓ ';
    color: var(--ok);
}

.password-rules li.is-bad::before {
    content: '✗ ';
    color: var(--error);
}

.password-rules li.is-bad {
    color: var(--error);
}


/* --- Links in der Shoutbox ------------------------------------------------ */
/* Nur Optik: lange Adressen duerfen das Layout nicht sprengen. */

.shout-text a {
    word-break: break-word;
    overflow-wrap: anywhere;
}

