/* Pilota - Retro-Dino-Optik.
 *
 * Ein altes Jump'n'Run als Vorbild: sehr dunkler, gruenstichiger Grund,
 * Smaragd in mehreren Abstufungen als einzige Buntfarbe, harte Pixelkanten,
 * Knoepfe mit sichtbarer Bauhoehe. Rot und Bernstein bleiben den Signalen
 * vorbehalten (Pilota, Warnung) und sind die einzigen Ausreisser aus der
 * Palette - dafuer erkennt man sie sofort.
 *
 * Kein Webfont: die App laeuft offline im LAN und soll ohne Netz sofort da
 * sein. Die Pixeloptik der Wortmarke kommt aus selbst gesetzten Bitmaps
 * (src/pixel.js), Ueberschriften uebernehmen sie nur andeutungsweise ueber
 * Versalien, Sperrung und harten Schatten. Zahlen bleiben dicktengleich, das
 * Blatt spaltet damit wie ein Kontobuch.
 *
 * Kein externes Bild: die Landschaft besteht aus zwei kachelbaren SVGs als
 * data:-URI. Bewegt wird sie nur auf dem Titelbildschirm - waehrend der
 * Punkteeingabe darf nichts laufen, was den Blick zieht.
 */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
    --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* Grund und Flaechen, von tief nach hoch */
    --ink-950: #020806;
    --ink-900: #03100b;
    --ink-800: #071c14;
    --ink-700: #0c2a1f;
    --ink-600: #143d2d;

    /* Smaragd, von dunkel nach hell */
    --em-700: #0e5c3b;
    --em-600: #167a4d;
    --em-500: #1f9d63;
    --em-400: #2fc47c;
    --em-300: #55e39a;
    --em-200: #8ff5c1;

    --text: #dff3e6;
    --muted: #7fae95;
    --faint: #5c8874;

    --line: var(--ink-600);
    --line-soft: #0e2c20;
    --shadow: #020806;

    /* Signale */
    --danger: #ff4d5e;
    --danger-dim: #8f2130;
    --warn: #ffc94d;

    /* Pixelmotive faerben sich hierueber */
    --px-body: var(--em-400);
    --px-eye: var(--ink-900);
}

body {
    background: var(--ink-900);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* Schein von oben, ein feines Pixelraster darueber und am unteren Rand die
 * Andeutung derselben Landschaft wie auf dem Titelbild - alles unbewegt. */
.bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 90% 55% at 50% -10%, rgba(47, 196, 124, 0.11) 0%, transparent 65%),
        radial-gradient(ellipse 70% 50% at 50% 110%, rgba(14, 92, 59, 0.16) 0%, transparent 60%),
        repeating-linear-gradient(0deg, rgba(143, 245, 193, 0.018) 0 1px, transparent 1px 4px);
}

.bg::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 40px;
    opacity: 0.5;
    background-repeat: repeat-x;
    background-position: bottom left;
    background-size: 160px 40px;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='40' shape-rendering='crispEdges'%3E%3Cpath fill='%230a2b1e' d='M0 40V28h8V24h8V20h8V16h8V12h8V16h8V20h8V24h8V28h8V32h8V28h8V24h8V20h8V16h8V20h8V24h8V28h8V32h8V36h8V28h8V40Z'/%3E%3C/svg%3E");
}

.content {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
    padding:
        max(1.2rem, env(safe-area-inset-top))
        max(1.1rem, env(safe-area-inset-right))
        calc(3.5rem + env(safe-area-inset-bottom))
        max(1.1rem, env(safe-area-inset-left));
}

/* --- Pixelmotive --------------------------------------------------------- */

svg.px {
    display: block;
    height: auto;
    image-rendering: pixelated;
    flex: none;
}

svg.wordmark {
    color: var(--text);
    filter: drop-shadow(2px 2px 0 var(--shadow));
    --px-body: currentColor;
}

svg.dino { color: var(--em-400); --px-body: currentColor; }

/* --- Kopfzeile ---------------------------------------------------------- */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.7rem;
    border-bottom: 2px solid var(--line);
    margin-bottom: 1.3rem;
}

.title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.title-dino { width: 24px; filter: drop-shadow(2px 2px 0 var(--shadow)); }
.title-word { width: 82px; }

.target-badge {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    color: var(--em-300);
    background: var(--ink-800);
    border: 2px solid var(--line);
    padding: 0.15rem 0.4rem;
    white-space: nowrap;
}

.section-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--em-500);
    margin-bottom: 0.7rem;
}

/* --- Flächen ------------------------------------------------------------ */

/* Abgeschraegte Ecken statt Radius - der Rahmen soll aus Pixeln bestehen und
 * nicht rund sein. clip-path schneidet den Rahmen an den Ecken mit ab, genau
 * das ergibt die Stufe. */
.panel {
    position: relative;
    background: var(--ink-800);
    border: 2px solid var(--line);
    padding: 1.1rem 1rem;
    margin-bottom: 1.1rem;
    clip-path: polygon(
        6px 0, calc(100% - 6px) 0, 100% 6px,
        100% calc(100% - 6px), calc(100% - 6px) 100%,
        6px 100%, 0 calc(100% - 6px), 0 6px
    );
}

/* --- Blatt -------------------------------------------------------------- */

.sheet-wrap { overflow-x: auto; }

table.sheet {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.92rem;
}

table.sheet th, table.sheet td {
    padding: 0.5rem 0.35rem;
    text-align: right;
    white-space: nowrap;
    vertical-align: top;
}

table.sheet th.rnd, table.sheet td.rnd {
    text-align: left;
    color: var(--faint);
    font-size: 0.7rem;
    font-weight: 400;
    padding-left: 0;
    width: 1.4rem;
}

table.sheet thead th {
    font-family: var(--sans);
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    border-bottom: 2px solid var(--line);
    padding-bottom: 0.55rem;
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

table.sheet thead th.active {
    color: var(--em-300);
    text-shadow: 1px 1px 0 var(--shadow);
}

table.sheet tbody td {
    color: #bcd9c8;
    border-bottom: 1px solid var(--line-soft);
}

td .pilota {
    color: var(--danger);
    font-weight: 700;
    animation: pilota-flash 0.5s steps(5) 1;
}

td .push { color: var(--em-400); }
td .blank { color: #17352a; }

td .penalty {
    display: block;
    font-size: 0.66rem;
    margin-top: 0.15rem;
    color: var(--danger);
}

/* Doppelstrich ueber der Summe - wie im Kontobuch. */
tr.totals td, tr.totals th {
    border-top: 3px double var(--em-700);
    padding-top: 0.6rem;
    color: var(--em-300);
    font-size: 1.15rem;
    text-shadow: 2px 2px 0 var(--shadow);
}

tr.totals th.rnd { color: var(--faint); font-size: 0.8rem; text-shadow: none; }

tr.pilotas td, tr.pilotas th {
    font-size: 0.6rem;
    color: var(--danger);
    padding: 0.35rem 0.35rem 0;
    letter-spacing: 0.15em;
}

/* Quittung fuer den letzten Eintrag: die Zelle blitzt einmal auf. Ausgeloest
 * wird das allein dadurch, dass Preact sie bei geaendertem Wert austauscht. */
tr.totals td.pop { animation: total-pop 0.45s steps(6) 1; }
tr.pilotas td.pop { animation: pilota-flash 0.5s steps(5) 1; }

@keyframes total-pop {
    from { color: var(--em-200); text-shadow: 0 0 10px var(--em-400), 2px 2px 0 var(--shadow); }
    to   { color: var(--em-300); text-shadow: 2px 2px 0 var(--shadow); }
}

@keyframes pilota-flash {
    from { color: #fff0f1; text-shadow: 0 0 10px var(--danger); }
    to   { color: var(--danger); text-shadow: none; }
}

.empty-sheet {
    color: var(--faint);
    font-size: 0.8rem;
    text-align: center;
    padding: 1.1rem 0 0.3rem;
}

/* --- Laufender Zug ------------------------------------------------------ */

.turn-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    animation: turn-in 0.22s steps(3) 1;
}

@keyframes turn-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: none; }
}

.turn-player {
    font-size: 1.25rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-shadow: 2px 2px 0 var(--shadow);
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    min-width: 0;
}

.turn-player .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-player .at { color: var(--em-400); font-size: 0.8em; flex: none; }

.turn-total {
    font-family: var(--mono);
    font-size: 1.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    flex: none;
    color: var(--em-200);
    text-shadow: 2px 2px 0 var(--shadow);
}

.turn-meta {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem 0.9rem;
    margin-bottom: 1.1rem;
    letter-spacing: 0.02em;
}

.turn-meta .warn { color: var(--warn); }
.turn-meta .carried { color: var(--em-400); }

/* --- Punkteeingabe ------------------------------------------------------ */

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
    margin-bottom: 0.7rem;
}

.quick {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--em-300);
    background: var(--ink-700);
    border: 2px solid var(--em-700);
    min-height: 48px;
    padding: 0.6rem 0.2rem;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--ink-950);
    transition: background 0.1s, color 0.1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.quick:active {
    background: var(--em-700);
    color: var(--em-200);
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--ink-950);
}

.entry {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.6rem;
}

.entry input.inp { flex: 1; }

input.inp.points {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: right;
    color: var(--em-200);
    padding: 0.5rem 0.7rem;
    letter-spacing: 0.02em;
}

/* Spinner-Pfeile weg - auf dem Handy stoeren sie nur. */
input.inp.points::-webkit-outer-spin-button,
input.inp.points::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.inp.points { -moz-appearance: textfield; }

.preview {
    font-family: var(--mono);
    font-size: 0.74rem;
    color: var(--muted);
    margin-bottom: 0.8rem;
    letter-spacing: 0.02em;
}

.preview.over { color: var(--warn); }
.preview.win { color: var(--em-300); }

/* --- Knöpfe ------------------------------------------------------------- */

.actions { display: grid; gap: 0.55rem; }
.actions.two { grid-template-columns: 1fr 1fr; gap: 0.6rem; }

/* Chunky: sichtbare Bauhoehe ueber einen harten Schatten, beim Druecken faellt
 * der Knopf darauf zusammen. */
button.btn {
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text);
    background: var(--ink-700);
    border: 2px solid var(--line);
    min-height: 44px;
    padding: 0.7rem 0.8rem;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--ink-950);
    transition: background 0.1s, color 0.1s, border-color 0.1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button.btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--ink-950);
}

button.btn:disabled {
    opacity: 0.34;
    cursor: default;
    transform: none;
    box-shadow: 0 4px 0 var(--ink-950);
}

button.btn.primary {
    background: var(--em-500);
    border-color: var(--em-300);
    color: #03170e;
    text-shadow: 1px 1px 0 rgba(143, 245, 193, 0.45);
    box-shadow: 0 4px 0 var(--em-700);
}

button.btn.primary:active { background: var(--em-400); box-shadow: 0 1px 0 var(--em-700); }
button.btn.primary:disabled { box-shadow: 0 4px 0 var(--em-700); }

button.btn.big { font-size: 0.95rem; min-height: 54px; letter-spacing: 0.12em; }

button.btn.ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0.03em;
    font-weight: 600;
}

button.btn.ghost:active { transform: none; box-shadow: none; color: var(--em-300); }
button.btn.ghost:disabled { box-shadow: none; }

button.btn.danger {
    color: var(--danger);
    border-color: var(--danger-dim);
    box-shadow: 0 4px 0 #1a0709;
}

button.btn.danger:active { background: var(--danger-dim); color: #fff0f1; box-shadow: 0 1px 0 #1a0709; }

button.btn.small {
    min-height: 44px;
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
}

/* Scharf gestellt: der Knopf hat gefragt und wartet auf den zweiten Druck.
 * Muss nach .ghost und .danger stehen, sonst gewinnen deren Farben. */
button.btn.armed {
    background: var(--danger-dim);
    border-color: var(--danger);
    color: #fff0f1;
    box-shadow: 0 4px 0 #1a0709;
}

button.btn.ghost.armed { box-shadow: none; }

/* Die zwei Wahlknöpfe: Angebot des Vorgängers annehmen oder nicht. */
button.btn.bank-btn {
    font-family: var(--mono);
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.86rem;
    font-weight: 400;
    line-height: 1.5;
    padding: 0.8rem 0.5rem;
    min-height: 68px;
    color: var(--text);
}

button.btn.bank-btn b { color: var(--em-300); font-weight: 700; font-size: 1.25em; }

.bar { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* --- Titelbildschirm ---------------------------------------------------- */

.title-screen { padding-top: 0.4rem; }

.scene {
    position: relative;
    height: 232px;
    margin-bottom: 1.4rem;
    overflow: hidden;
    border: 2px solid var(--line);
    background: linear-gradient(180deg, #04140e 0%, #062117 55%, #08301f 100%);
    clip-path: polygon(
        6px 0, calc(100% - 6px) 0, 100% 6px,
        100% calc(100% - 6px), calc(100% - 6px) 100%,
        6px 100%, 0 calc(100% - 6px), 0 6px
    );
}

/* Sterne: ein paar einzelne Pixel, fest an ihrem Platz. */
.scene::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 18px 26px, var(--em-200), transparent),
        radial-gradient(1px 1px at 74% 18px, var(--em-300), transparent),
        radial-gradient(1px 1px at 52% 44px, var(--em-200), transparent),
        radial-gradient(1px 1px at 88% 58px, var(--em-300), transparent),
        radial-gradient(1px 1px at 30% 12px, var(--em-200), transparent);
    opacity: 0.55;
}

/* CRT-Andeutung, sehr zurueckhaltend. */
.scene::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.14) 0 1px, transparent 1px 3px);
}

.scene-far, .scene-near {
    position: absolute;
    left: 0;
    right: 0;
    background-repeat: repeat-x;
    image-rendering: pixelated;
}

.scene-far {
    bottom: 46px;
    height: 40px;
    background-size: 160px 40px;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='40' shape-rendering='crispEdges'%3E%3Cpath fill='%230a2b1e' d='M0 40V28h8V24h8V20h8V16h8V12h8V16h8V20h8V24h8V28h8V32h8V28h8V24h8V20h8V16h8V20h8V24h8V28h8V32h8V36h8V28h8V40Z'/%3E%3C/svg%3E");
    animation: scroll-far 46s linear infinite;
}

.scene-near {
    bottom: 40px;
    height: 32px;
    background-size: 136px 32px;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='136' height='32' shape-rendering='crispEdges'%3E%3Cpath fill='%2310422d' d='M0 32V22h8V18h8V14h8V10h8V14h8V18h8V14h8V10h8V6h8V10h8V14h8V18h8V22h8V26h8V22h8V18h8V22h8V32Z'/%3E%3C/svg%3E");
    animation: scroll-near 21s linear infinite;
}

@keyframes scroll-far  { to { background-position-x: -160px; } }
@keyframes scroll-near { to { background-position-x: -136px; } }

.scene-ground {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 42px;
    background:
        repeating-linear-gradient(90deg, transparent 0 7px, rgba(47, 196, 124, 0.13) 7px 9px),
        #0c2f21;
    border-top: 2px solid var(--em-600);
}

.scene-mascot {
    position: absolute;
    left: 13%;
    bottom: 34px;
    width: 62px;
    filter: drop-shadow(3px 3px 0 rgba(2, 8, 6, 0.6));
    animation: idle 0.9s steps(2) infinite;
}

.scene-deco {
    position: absolute;
    right: 16%;
    bottom: 34px;
    width: 26px;
    color: var(--em-600);
    --px-body: currentColor;
}

@keyframes idle {
    0%, 49%  { transform: translateY(0); }
    50%, 100% { transform: translateY(-2px); }
}

.scene-word {
    position: absolute;
    top: 22px;
    left: 0;
    right: 0;
    text-align: center;
}

.hero-word {
    width: min(62%, 232px);
    margin: 0 auto;
    color: var(--em-200);
    filter: drop-shadow(4px 4px 0 var(--shadow));
}

.hero-sub {
    margin-top: 0.7rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--em-500);
}

.ready {
    margin-top: 1.1rem;
    text-align: center;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--em-600);
}

.ready .caret { animation: blink 1.1s steps(1) infinite; }

@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* --- Setup -------------------------------------------------------------- */

.field { margin-bottom: 1.3rem; }
.field:last-child { margin-bottom: 0; }

label.lbl {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--em-500);
    margin-bottom: 0.6rem;
}

input.inp {
    width: 100%;
    background: var(--ink-900);
    border: 2px solid var(--line);
    border-radius: 0;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    min-height: 44px;
    padding: 0.6rem 0.7rem;
    outline: none;
    transition: border-color 0.1s;
}

input.inp:focus { border-color: var(--em-400); }
input.inp::placeholder { color: var(--faint); }

.player-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; align-items: center; }

.player-row .idx {
    font-family: var(--mono);
    color: var(--em-600);
    font-size: 0.8rem;
    font-weight: 700;
    width: 1rem;
    flex: none;
}

.player-row button { flex: none; }

.presets { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }

.preset {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--ink-700);
    border: 2px solid var(--line);
    min-height: 44px;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    flex: 1;
    box-shadow: 0 3px 0 var(--ink-950);
    transition: color 0.1s, border-color 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.preset:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink-950); }
.preset.on { background: var(--em-700); border-color: var(--em-400); color: var(--em-200); }

.hint { font-size: 0.72rem; color: var(--faint); margin-top: 0.6rem; line-height: 1.55; }

.err {
    font-size: 0.75rem;
    color: var(--warn);
    margin-top: 0.7rem;
    border-left: 3px solid var(--warn);
    padding-left: 0.5rem;
}

/* --- Sieg --------------------------------------------------------------- */

.win { text-align: center; padding: 1.4rem 0.5rem 1.4rem; overflow: hidden; }

.win-art {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.win-mascot {
    width: 52px;
    animation: hop 0.7s steps(2) 6;
    filter: drop-shadow(3px 3px 0 var(--shadow));
}

.win-cup {
    width: 40px;
    color: var(--warn);
    --px-body: currentColor;
    filter: drop-shadow(3px 3px 0 var(--shadow));
}

@keyframes hop {
    0%, 49%   { transform: translateY(0); }
    50%, 100% { transform: translateY(-8px); }
}

.win .who {
    font-size: 1.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--em-200);
    text-shadow: 3px 3px 0 var(--shadow);
    margin-bottom: 0.4rem;
    word-break: break-word;
}

.win .sub {
    font-family: var(--mono);
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    margin-bottom: 1.4rem;
}

/* Konfetti aus Pixeln: faellt einmal durch und bleibt dann weg. */
.confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti i {
    position: absolute;
    top: -10px;
    left: calc(var(--n) * 7% + 2%);
    width: 5px;
    height: 5px;
    background: var(--em-300);
    animation: fall 1.9s steps(12) 1 both;
    animation-delay: calc(var(--n) * 0.07s);
}

.confetti i:nth-child(3n)   { background: var(--em-200); width: 4px; height: 4px; }
.confetti i:nth-child(4n+1) { background: var(--warn); }
.confetti i:nth-child(7n+3) { background: var(--em-500); width: 6px; height: 6px; }

@keyframes fall {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(280px); opacity: 0; }
}

/* --- Historie ----------------------------------------------------------- */

.hist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    background: var(--ink-800);
    border: 2px solid var(--line);
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.55rem;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--ink-950);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.hist-item:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink-950); }

.hist-item .when { font-family: var(--mono); font-size: 0.66rem; color: var(--faint); }

.hist-item .who {
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--em-300);
    text-shadow: 2px 2px 0 var(--shadow);
    margin-top: 0.15rem;
}

.hist-item .names { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }

.hist-item .score {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--faint);
}

/* --- Regelspickzettel --------------------------------------------------- */

details.rules { margin-top: 1.6rem; }

details.rules summary {
    cursor: pointer;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--em-500);
    list-style: none;
    padding: 0.7rem 0;
    border-top: 2px solid var(--line-soft);
}

details.rules summary::-webkit-details-marker { display: none; }
details.rules summary::before { content: '▸ '; }
details.rules[open] summary::before { content: '▾ '; }

details.rules table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.74rem;
    margin-bottom: 0.9rem;
}

details.rules td {
    padding: 0.32rem 0;
    color: var(--muted);
    border-bottom: 1px solid var(--line-soft);
    line-height: 1.4;
}

details.rules td:last-child {
    text-align: right;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    color: var(--em-400);
    white-space: nowrap;
    padding-left: 0.8rem;
}

@media (min-width: 560px) {
    .content { padding-top: 2.2rem; padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
    .title-dino { width: 28px; }
    .title-word { width: 96px; }
    .scene { height: 268px; }
    .scene-mascot { width: 74px; }
}

/* Wer es ruhig will, bekommt dasselbe Bild - nur still. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* --- Würfel -------------------------------------------------------------- */
/* Die Augen sind Pixelmotive aus core/pixel.js, hier bekommen sie nur ihren
 * Zustand. Umgefaerbt wird ueber --px-body, nicht ueber ein zweites Bitmap. */

.dice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin: 0.9rem 0;
}

.dice-row.empty {
    min-height: 52px;
    align-items: center;
    color: var(--faint);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.die-btn {
    display: block;
    width: 46px;
    height: 46px;
    padding: 3px;
    background: var(--ink-700);
    border: 2px solid var(--line);
    cursor: pointer;
    box-shadow: 0 3px 0 var(--ink-950);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    --px-body: var(--em-300);
    --px-eye: var(--ink-900);
}

.die-btn.static { cursor: default; box-shadow: none; }
.die-btn:not(.static):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink-950); }

/* Ausgewaehlt bzw. gehalten: heller Rand, hellere Augen. */
.die-btn.held {
    border-color: var(--em-400);
    background: var(--ink-600);
    --px-body: var(--em-200);
}

/* Zaehlt in diesem Wurf - dezent hervorgehoben, damit man sieht, was ueberhaupt
 * antippbar ist. */
.die-btn.scoring { border-color: var(--em-600); }

/* Zaehlt nicht: sichtbar stumpf und nicht antippbar. */
.die-btn.dead {
    --px-body: var(--faint);
    opacity: 0.55;
    cursor: default;
    box-shadow: none;
}

.die-btn svg.px { width: 100%; height: 100%; display: block; }

/* --- Augen eintippen ---------------------------------------------------- */
/* Fuer eigene Wuerfel: die Ziffern der Reihe nach antippen. Schneller als
 * Stepper und mit einer Hand bedienbar - am Tisch zaehlt genau das. */

.face-entry { margin-top: 0.6rem; }

.face-entry .slots {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    margin: 0.6rem 0 0.9rem;
}

.face-entry .slot {
    width: 40px;
    height: 40px;
    border: 2px dashed var(--line);
    background: var(--ink-900);
}

.face-entry .slot.filled {
    border-style: solid;
    border-color: var(--em-600);
    background: var(--ink-700);
    padding: 3px;
    --px-body: var(--em-300);
    --px-eye: var(--ink-900);
}

.face-entry .slot.filled svg.px { width: 100%; height: 100%; display: block; }

.face-entry .pad {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.35rem;
}

.pad-key {
    aspect-ratio: 1;
    min-height: 44px;
    padding: 4px;
    background: var(--ink-700);
    border: 2px solid var(--line);
    cursor: pointer;
    box-shadow: 0 3px 0 var(--ink-950);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    --px-body: var(--em-400);
    --px-eye: var(--ink-900);
}

.pad-key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink-950); }
.pad-key svg.px { width: 100%; height: 100%; display: block; }

/* --- Modus-Wahl und Schalter -------------------------------------------- */

.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.mode {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
    padding: 0.7rem;
    min-height: 44px;
    background: var(--ink-700);
    border: 2px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    box-shadow: 0 3px 0 var(--ink-950);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mode.on { border-color: var(--em-400); color: var(--text); background: var(--ink-600); }
.mode:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink-950); }

.mode-name {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.mode-sub { font-size: 0.72rem; color: var(--faint); }
.mode.on .mode-sub { color: var(--muted); }

.toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    width: 100%;
    text-align: left;
    padding: 0.7rem;
    min-height: 44px;
    background: var(--ink-700);
    border: 2px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.toggle.on { border-color: var(--em-400); color: var(--text); }

.toggle-box {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border: 2px solid var(--line);
    background: var(--ink-900);
    color: var(--em-300);
    font-size: 0.8rem;
    line-height: 16px;
    text-align: center;
}

.toggle.on .toggle-box { border-color: var(--em-400); }
.toggle-name { display: block; font-size: 0.8rem; font-weight: 700; }
.toggle-sub { display: block; font-size: 0.72rem; color: var(--faint); margin-top: 0.15rem; }

/* --- Lobby -------------------------------------------------------------- */

.game-list { display: grid; gap: 0.7rem; margin: 1.2rem 0; }

.game-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
    padding: 0.9rem 1rem;
    background: var(--ink-800);
    border: 2px solid var(--line);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 4px 0 var(--ink-950);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    clip-path: polygon(
        6px 0, calc(100% - 6px) 0, 100% 6px,
        100% calc(100% - 6px), calc(100% - 6px) 100%,
        6px 100%, 0 calc(100% - 6px), 0 6px
    );
}

.game-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink-950); }

.gc-head { display: flex; align-items: center; gap: 0.6rem; }

.gc-name {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--em-300);
}

.gc-open {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-900);
    background: var(--em-400);
    padding: 0.1rem 0.4rem;
}

.gc-blurb { font-size: 0.8rem; color: var(--muted); }
.gc-rules { font-size: 0.75rem; color: var(--faint); line-height: 1.5; }
.gc-meta {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--em-600);
    margin-top: 0.2rem;
}

/* --- Kleinteile --------------------------------------------------------- */

.err.banner { margin-bottom: 0.9rem; }
.turn-meta .good { color: var(--em-300); }
.turn-meta .faint { color: var(--faint); }

input.inp.tiny {
    width: 4.5rem;
    min-height: 36px;
    padding: 0.3rem 0.45rem;
    text-align: right;
}

/* Trennlinie zwischen oberer und unterer Haelfte im Kniffel-Blatt. */
table.sheet tr.section-break td,
table.sheet tr.section-break th { border-top: 2px solid var(--line); }
