/* schnappifuchs – ein Stylesheet, keine externen Ressourcen (Schriften, CDNs):
   so geht keine Besucher-IP an Dritte. */

:root {
    --bg:        #fbf6f0;
    --surface:   #ffffff;
    --ink:       #211a15;
    --muted:     #6f645b;
    --line:      #ecdfd2;
    --accent:    #e2601a;   /* Fuchs-Orange */
    --accent-ink:#ffffff;
    --accent-soft:#fdeadd;
    --chip:      #f3ebe3;
    --shadow:    0 1px 2px rgb(60 30 10 / 6%), 0 8px 24px rgb(60 30 10 / 7%);
    --radius:    14px;
    --font:      system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:        #15110e;
        --surface:   #201a16;
        --ink:       #f4ece4;
        --muted:     #a89b8f;
        --line:      #372d26;
        --accent:    #ff8a3d;
        --accent-ink:#1b120c;
        --accent-soft:#3a2416;
        --chip:      #2c241f;
        --shadow:    0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.55 var(--font);
}

a { color: inherit; }

[hidden] { display: none !important; }

.wrap {
    width: 100%;
    max-width: 1060px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Kopf ---------- */

.masthead { border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }

.masthead-inner {
    display: flex;
    align-items: center;
    min-height: 60px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 750;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.brand-mark { font-size: 1.6rem; line-height: 1; }

main.wrap { padding-top: 26px; padding-bottom: 16px; }

/* ---------- Einleitung ---------- */

.intro h1 {
    margin: 0 0 18px;
    font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.intro p { margin: 8px 0 20px; max-width: 40em; color: var(--muted); }

/* ---------- Spiel ---------- */

.game {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 22px;
    padding: 12px 18px;
    font-size: 0.98rem;
    font-variant-numeric: tabular-nums;
}

.hud strong { font-size: 1.15rem; }

.hud-hp { display: inline-flex; align-items: center; gap: 6px; }

.hpbar {
    display: inline-block;
    width: 90px;
    height: 10px;
    border-radius: 5px;
    background: var(--chip);
    overflow: hidden;
}

.hpbar span {
    display: block;
    height: 100%;
    background: #3fae4f;
    transform-origin: left center;
    transition: transform 0.15s ease, background-color 0.3s;
}

.hpbar span.is-mid { background: #e8b72d; }
.hpbar span.is-low { background: #d9364a; }
.hud-time { margin-left: auto; }

.hud-fs {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: -6px -8px -6px -8px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.hud-fs:hover { background: var(--chip); }
.hud-fs:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.hud-fs svg { width: 20px; height: 20px; }
.hud-fs .icon-exit { display: none; }

/* Ton-Knopf: je nach Modus ein anderes Symbol */
.hud-sound svg { display: none; }
.hud-sound[data-mode="all"] .icon-sound-all,
.hud-sound[data-mode="sfx"] .icon-sound-sfx,
.hud-sound[data-mode="off"] .icon-sound-off { display: block; }
.game.is-fullscreen .hud-fs .icon-enter { display: none; }
.game.is-fullscreen .hud-fs .icon-exit { display: block; }

/* Vollbild: nur Anzeige und Spielfeld, über die ganze Fläche
   (echtes Vollbild oder – wo der Browser das nicht kann – per CSS). */
.game.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.game.is-fullscreen .hud { padding-top: max(10px, env(safe-area-inset-top)); }
.game.is-fullscreen .stage { flex: 1; aspect-ratio: auto; min-height: 0; max-height: none; }
html.sf-fullscreen, html.sf-fullscreen body { overflow: hidden; }

/* Handy-Vollbild: keine Leiste über dem Spielfeld – Leben, Powerups, Fänge, Level und Zeit
   zeichnet das Spiel ins Spielfeld, Ton- und Vollbild-Knopf schweben oben rechts. */
.game.is-compact .hud {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 5;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 0;
    background: transparent;
}

.game.is-compact .hud-item,
.game.is-compact .timebar { display: none; }

.game.is-compact .hud-fs {
    width: 40px;
    height: 40px;
    margin: 0;
    border-radius: 50%;
    background: rgb(20 20 20 / 45%);
    color: #ffffff;
}

.timebar { height: 5px; background: var(--chip); }

.timebar span {
    display: block;
    height: 100%;
    background: var(--accent);
    transform-origin: left center;
    transition: background-color 0.3s;
}

.timebar span.is-low { background: #d9364a; }

.stage {
    position: relative;
    aspect-ratio: 16 / 10;
    min-height: 320px;
    max-height: 80vh;
    max-height: 80svh;
    width: 100%;
    background: #7fbf5c;
    user-select: none;
    -webkit-user-select: none;
}

.stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
    touch-action: none;   /* Tippen/Wischen auf dem Spielfeld scrollt nicht die Seite */
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-y: auto;     /* passt die Karte nicht aufs Spielfeld, lässt sie sich scrollen statt abgeschnitten zu werden */
    padding: 16px;
    background: rgb(20 40 10 / 28%);
    backdrop-filter: blur(1.5px);
}

.overlay-card {
    width: min(420px, 100%);
    margin: auto;
    padding: 24px 24px 22px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.overlay-card h2 { margin: 0 0 6px; font-size: 1.5rem; letter-spacing: -0.015em; }
#overlay-start .overlay-card h2 { margin-bottom: 16px; }

/* Unter dem Spielfeld nur am Handy: kurzer Hinweis zur Finger-Steuerung */
.controls { display: none; flex-direction: column; align-items: center; gap: 6px; margin-top: 12px; padding: 0 8px; }
.controls-touch { margin: 0; color: var(--muted); font-size: 0.92rem; text-align: center; }

@media (hover: none) and (pointer: coarse) {
    .controls { display: flex; }
}
.overlay-card p { margin: 0 0 16px; color: var(--muted); }
.overlay-mark { display: block; font-size: 3rem; line-height: 1.1; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.1s ease;
}

.button:hover { transform: translateY(-1px); filter: brightness(1.05); }
.button:disabled { opacity: 0.55; cursor: default; transform: none; }
.button-secondary { background: var(--chip); color: var(--ink); margin-top: 6px; }

.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.end-actions .button-secondary { margin-top: 0; }
.button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.score-form { margin: 4px 0 8px; text-align: left; }
.score-form label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 600; }

.score-form-row { display: flex; flex-wrap: wrap; gap: 8px; }
.score-form-row .button { flex: 1 0 auto; }

.score-form input {
    flex: 999 1 150px;   /* nimmt den Platz; wird es zu eng, rutscht der Knopf in die nächste Zeile */
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
}

.form-msg { min-height: 1.5em; margin: 8px 0 0 !important; font-size: 0.9rem; }

/* ---------- Bestenlisten ---------- */

.boards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 26px;
}

.boards > .notice { grid-column: 1 / -1; }

.board {
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.board h2 { margin: 0 0 8px; font-size: 1.05rem; }

.board-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: rank;
}

.board-list li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    counter-increment: rank;
    font-variant-numeric: tabular-nums;
}

.board-list li + li { border-top: 1px solid var(--line); }

.board-list li::before {
    content: counter(rank) ".";
    min-width: 1.8em;
    color: var(--muted);
    font-size: 0.9rem;
}

.board-list li:nth-child(1)::before { content: "🥇"; }
.board-list li:nth-child(2)::before { content: "🥈"; }
.board-list li:nth-child(3)::before { content: "🥉"; }

.board-list li.is-me { background: var(--accent-soft); border-radius: 8px; padding-left: 6px; padding-right: 6px; }

.board-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.board-score { color: var(--muted); white-space: nowrap; }
.board-empty { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- Hinweise & Fuß ---------- */

.notice {
    margin: 0;
    padding: 14px 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
}

.foot {
    margin-top: 40px;
    padding-top: 18px;
    padding-bottom: 36px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.84rem;
}

.foot p { margin: 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px !important; }
.foot-links a { color: var(--muted); }
.foot-links a:hover { color: var(--ink); }

/* ---------- Impressum & Datenschutz ---------- */

.legal { max-width: 42em; }
.legal h1 { margin: 0 0 16px; font-size: 1.8rem; letter-spacing: -0.015em; }
.legal h2 { margin: 26px 0 6px; font-size: 1.05rem; }
.legal p { margin: 0 0 10px; }
.legal a { color: var(--accent); }

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 620px) {
    .wrap { padding: 0 8px; }
    main.wrap { padding-top: 18px; }
    .intro { padding: 0 4px; }
    .stage { aspect-ratio: 2 / 3; max-height: 74vh; max-height: 74svh; }
    .overlay { padding: 10px; }
    .overlay-card { padding: 18px 16px 16px; }
    .overlay-card h2 { font-size: 1.3rem; }
    .overlay-mark { font-size: 2.4rem; }
    .hud { padding: 10px 14px; gap: 4px 14px; font-size: 0.92rem; }
    .hpbar { width: 60px; }
    .boards { grid-template-columns: 1fr; }
}
