/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — Desktop (> 900px)
   Alle mobilen Elemente explizit ausblenden
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
    .mobile-toolbar     { display: none !important; }
    .mobile-bottom-nav  { display: none !important; }
    .mobile-more-panel  { display: none !important; }
    .mobile-seed-display { display: none !important; }
    .app-container { padding-bottom: 0 !important; }

    .stats-modal {
        max-width: 700px;
        max-height: 85vh;
    }

    .achievement-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    /* Mobile Numpad-Styles werden per JS in show() zurückgesetzt, kein CSS-Reset nötig */
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (601px – 900px)
   Toolbar bleibt oben, wird aber kompakter. Kein Bottom Nav.
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 601px) and (max-width: 899px) {
    .app-container {
        border-left: none;
        border-right: none;
    }

    header {
        padding: 8px 16px 7px;
        gap: 12px;
    }

    header h1 { font-size: 1.6em; letter-spacing: 5px; }
    .subtitle { font-size: 0.7em; letter-spacing: 2px; }

    .toolbar {
        padding: 8px 14px 7px;
    }

    .toolbar-grid {
        grid-template-columns: max-content 16px max-content 45px auto;
        row-gap: 8px;
    }

    .toolbar-actions { gap: 7px; padding-top: 10px; }
    .toolbar-icons   { gap: 4px; }
    .toolbar-controls { gap: 10px; }

    .control-group label,
    .control-label-row label { font-size: 0.7em; }

    .custom-select-btn { font-size: 0.82em; padding: 4px 7px; }
    .btn-primary       { font-size: 0.82em; padding: 5px 10px; }
    .btn-ghost         { font-size: 0.82em; padding: 5px 10px; }
    .btn-pencil        { width: 28px; height: 28px; font-size: 0.82em; }

    #seed-input { font-size: 0.75em; width: 100px; }
    #btn-load-seed { width: 26px; }

    /* Footer auf Tablet kleiner */
    .footer { font-size: 0.72em; padding: 5px 14px; }

    /* Mobile-spezifische Elemente ausblenden */
    .mobile-bottom-nav  { display: none !important; }
    .mobile-more-panel  { display: none !important; }
    .mobile-toolbar     { display: none !important; }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 600px)
   Kompakte Top-Toolbar + Bottom Nav, Desktop-Toolbar ausgeblendet
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    /* App-Container: Ränder weg, footer weg */
    .app-container {
        border-left: none;
        border-right: none;
    }

    /* Body-Hintergrund auf accent damit kein beiger Streifen bei Navigationsleiste */
    body {
        background: var(--accent);
    }

    /* Header: kompakter */
    header {
        padding: 9px 12px 8px;
        padding-top: calc(9px + env(safe-area-inset-top));
        gap: 8px;
    }

    header h1       { font-size: 1.35em; letter-spacing: 4px; }
    .subtitle       { display: none; }

    /* Header-Icons kleiner */
    .btn-settings   { width: 30px; height: 30px; }
    .btn-settings svg { width: 15px; height: 15px; }

    /* Desktop-Toolbar: komplett ausblenden */
    .toolbar        { display: none; }

    /* ── Mobile Compact Toolbar ────────────────────────────────────── */
    .mobile-toolbar {
        display: block;
        flex-shrink: 0;
        background: var(--bg-toolbar);
        border-bottom: 1px solid var(--border-main);
        padding: 7px 10px;
    }

    .mobile-toolbar-row {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .mobile-select {
        flex: 1;
        padding: 7px 5px;
        border: 1px solid var(--border-input);
        border-radius: 7px;
        font-size: 0.78em;
        background: var(--bg-input);
        color: var(--text-primary);
        min-width: 0;
        -webkit-appearance: none;
        appearance: none;
        text-align: center;
    }

    .mobile-seed-btn {
        height: 34px;
        border: 1px solid var(--border-input);
        background: var(--bg-input);
        border-radius: 7px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--text-muted);
        cursor: pointer;
        flex-shrink: 0;
        padding: 0 10px;
        font-size: 0.78em;
        font-family: system-ui, 'Segoe UI', sans-serif;
    }

    .mobile-btn-new {
        padding: 7px 18px;
        background: var(--accent);
        color: #fff;
        border: none;
        border-radius: 7px;
        font-size: 0.88em;
        font-family: system-ui, 'Segoe UI', sans-serif;
        font-weight: 600;
        cursor: pointer;
        white-space: nowrap;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-btn-new:active { opacity: 0.8; }

    /* Footer: auf Mobile ausblenden (Tastaturkürzel irrelevant) */
    .footer         { display: none; }

    /* Käfig-Labels: 40% größer auf Mobile, bleibt proportional zur Schriftgröße-Einstellung */
    .cage-label {
        font-size: calc(var(--cage-label-size) * 1.4) !important;
    }

    /* Notizen: 40% größer auf Mobile */
    .note {
        font-size: calc(var(--note-size) * 1.4) !important;
    }

    /* Status-Zeile kleiner */
    #status         { font-size: 0.8em; padding: 4px 12px; min-height: 0; }

    /* Rätsel-ID über dem Board, linksbündig neben Timer */
    .mobile-seed-display {
        display: flex;
        align-items: center;
        gap: 2px;
        position: absolute;
        top: 10px;
        left: 10px;
        font-family: monospace;
        font-size: 0.72em;
        letter-spacing: 1px;
        color: var(--text-primary);
        opacity: 0.4;
        z-index: 10;
    }
    .mobile-seed-copy-btn {
        background: none;
        border: none;
        padding: 2px 3px;
        margin-left: 3px;
        cursor: pointer;
        color: inherit;
        opacity: 0.8;
        line-height: 1;
    }

    /* Musikplayer im Header ausblenden (wird per JS gesteuert) */
    #music-player { display: none; }

    /* Console: Header-Icons enger zusammen (Musik-Button + 4 Icons würden sonst überlaufen) */
    [data-theme="console"] .header-right { gap: 6px; }

    /* Stats-Modal: Bottom-Nav nicht überlagern */
    .stats-modal {
        max-height: calc(100svh - var(--mobile-nav-height) - env(safe-area-inset-bottom) - 16px);
    }

    /* ── Mobile More Panel ─────────────────────────────────────────── */
    .mobile-more-panel {
        position: fixed;
        bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
        left: 0;
        right: 0;
        z-index: 9000;
        background: var(--bg-toolbar);
        border-top: 1px solid var(--border-main);
        border-radius: 12px 12px 0 0;
        padding: 12px 12px;
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
    }

    .mobile-more-btn {
        display: flex;
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 4px;
        border: 1px solid var(--border-light);
        border-radius: 8px;
        background: var(--bg-input);
        color: var(--text-primary);
        font-size: 0.65em;
        font-family: system-ui, 'Segoe UI', sans-serif;
        cursor: pointer;
        white-space: nowrap;
    }

    .mobile-more-btn svg {
        flex-shrink: 0;
    }

    .mobile-more-btn:active {
        opacity: 0.7;
    }

    .mobile-more-btn.active {
        background: var(--select-bg);
        border-color: var(--select-border);
        color: var(--select-text);
    }

    /* ── Mobile Bottom Nav ─────────────────────────────────────────── */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        justify-content: space-around;
        align-items: center;
        background: var(--accent);
        border-top: 2px solid var(--accent-dark);
        padding: 10px 0 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        z-index: 200;
    }

    /* Platz für die fixe Bottom Nav + Android-Leiste */
    .app-container {
        padding-bottom: calc(68px + env(safe-area-inset-bottom));
        background: var(--accent);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: rgba(255,255,255,0.45);
        font-size: 0.65em;
        font-family: system-ui, 'Segoe UI', sans-serif;
        letter-spacing: 0.3px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 6px 10px;
        border-radius: 8px;
        min-width: 56px;
        transition: color 0.12s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-item svg {
        stroke: currentColor;
    }

    .mobile-nav-item:active,
    .mobile-nav-item.active {
        color: #fff;
    }

    /* Numpad-Styles wurden in klassenbasierte Regeln ausgelagert (.numpad-overlay--mobile),
       da CSS-Viewport in Electron/HiDPI nicht mit window.innerWidth übereinstimmt. */
}

/* ══════════════════════════════════════════════════════════════════
   NATIVE / CAPACITOR (APK) – Mobile Layout erzwingen
   Tablets mit großen Bildschirmen bekommen sonst die Desktop-Ansicht,
   weil die Viewport-Breite über dem Mobile-Breakpoint liegt.
   ══════════════════════════════════════════════════════════════════ */
.is-native .toolbar            { display: none !important; }
.is-native .footer             { display: none !important; }
.is-native .subtitle           { display: none !important; }
.is-native #music-player       { display: none !important; }

.is-native .mobile-toolbar     { display: block !important; }
.is-native .mobile-bottom-nav  { display: flex  !important; }
.is-native .mobile-seed-display { display: flex  !important; }

.is-native.app-container {
    border-left: none !important;
    border-right: none !important;
    padding-bottom: calc(68px + env(safe-area-inset-bottom)) !important;
}
