        :root {
            --parchment: #2a1f0e;
            --parchment-lt: #3d2c12;
            --parchment-md: #4e3a1a;
            --wood: #1e1208;
            --gold: #d4a017;
            --gold-bright: #f5c842;
            --gold-dim: #7a5c0a;
            --red-blood: #8b1a1a;
            --red-bright: #cc2222;
            --green-moss: #2d5a1b;
            --green-bright: #4a8c2a;
            --blue-magic: #1a3a6b;
            --blue-bright: #3a7abf;
            --teal: #1a6b5a;
            --teal-bright: #2aaa8a;
            --ink: #d4c4a0;
            --ink-dim: #b8a882;
            --ink-bright: #f0e0c0;
            --rune: #8b6914;
            --shadow: rgba(0, 0, 0, 0.7);
        }

        @font-face {
            font-family: 'PixelMedieval';
            src: local('Press Start 2P');
        }

        * {
            box-sizing: border-box;
            image-rendering: pixelated;
        }

        body {
            font-family: 'IM Fell English', Georgia, serif;
            background-color: #0d0905;
            background-image:
                repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.15) 2px, rgba(0, 0, 0, 0.15) 4px),
                repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0, 0, 0, 0.08) 2px, rgba(0, 0, 0, 0.08) 4px);
            color: var(--ink);
            text-align: center;
            margin: 0;
            padding: 0;
            min-height: 100vh;
        }

        /* Scanline overlay */
        body::before {
            content: '';
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 9999;
            background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.03) 0px, rgba(0, 0, 0, 0.03) 1px, transparent 1px, transparent 3px);
        }

        /* ── GAME CONTAINER ── */
        #game-container {
            max-width: none;
            margin: 0;
            background-color: var(--parchment);
            background-image:
                radial-gradient(ellipse at 20% 20%, rgba(212, 160, 23, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(139, 26, 26, 0.06) 0%, transparent 50%);
            border: 4px solid var(--gold-dim);
            outline: 2px solid #0d0905;
            outline-offset: 3px;
            padding: 24px;
            box-shadow: 0 0 0 6px #0d0905, 0 0 40px rgba(0, 0, 0, 0.9), inset 0 0 60px rgba(0, 0, 0, 0.4);
            position: relative;
        }

        /* Corner runes */
        #game-container::before,
        #game-container::after {
            content: '✦';
            position: absolute;
            font-size: 1.2em;
            color: var(--gold);
            line-height: 1;
        }

        #game-container::before {
            top: 6px;
            left: 10px;
        }

        #game-container::after {
            top: 6px;
            right: 10px;
        }

        h1 {
            font-family: 'UnifrakturMaguntia', cursive;
            font-size: 2.8em;
            color: var(--gold-bright);
            text-shadow: 0 0 20px rgba(212, 160, 23, 0.5), 2px 2px 0 #000, -1px -1px 0 rgba(0, 0, 0, 0.8);
            margin: 0 0 16px 0;
            letter-spacing: 4px;
        }

        h2 {
            font-family: 'UnifrakturMaguntia', cursive;
            font-size: 1.6em;
            color: var(--gold);
            text-shadow: 1px 1px 0 #000, 0 0 10px rgba(212, 160, 23, 0.3);
            margin: 0 0 14px 0;
            border-bottom: 2px solid var(--gold-dim);
            padding-bottom: 8px;
            letter-spacing: 2px;
        }

        h3 {
            font-family: 'IM Fell English', serif;
            font-size: 1.1em;
            color: var(--gold-bright);
            text-shadow: 1px 1px 0 #000;
            letter-spacing: 1px;
        }

        /* ── HEADER / STATUS BAR ── */
        .header {
            background: linear-gradient(135deg, var(--wood) 0%, var(--parchment-lt) 50%, var(--wood) 100%);
            padding: 12px 20px;
            margin-bottom: 20px;
            border: 2px solid var(--gold-dim);
            border-top: 3px solid var(--gold);
            border-bottom: 3px solid var(--gold);
            color: var(--gold-bright);
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-wrap: wrap;
            gap: 4px;
        }

        .header::before,
        .header::after {
            content: '⚜';
            color: var(--gold);
            font-size: 1.1em;
            margin: 0 8px;
        }

        .header span {
            margin: 0 10px;
            font-size: 1em;
            font-family: 'Press Start 2P', monospace;
            font-size: 0.7em;
            text-shadow: 1px 1px 0 #000;
        }

        .header b {
            color: var(--gold-bright);
        }

        /* ── PANELS ── */
        .panels {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            gap: 16px;
        }

        .panel {
            flex: 1;
            min-width: 300px;
            background: linear-gradient(180deg, var(--parchment-lt) 0%, var(--parchment) 100%);
            padding: 16px;
            border: 2px solid var(--gold-dim);
            box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4), 2px 2px 8px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            position: relative;
        }

        /* Wooden frame corners */
        .panel::before {
            content: '';
            position: absolute;
            inset: 3px;
            border: 1px solid rgba(212, 160, 23, 0.15);
            pointer-events: none;
        }

        /* ── TABS ── */
        .tabs {
            display: flex;
            gap: 3px;
            margin-bottom: 14px;
            border-bottom: 3px solid var(--gold-dim);
            padding-bottom: 0;
        }

        .tab-btn {
            flex: 1;
            background: linear-gradient(180deg, var(--parchment-md) 0%, var(--wood) 100%);
            color: var(--ink);
            border: 2px solid var(--gold-dim);
            border-bottom: none;
            padding: 7px 4px;
            cursor: pointer;
            font-family: 'Press Start 2P', monospace;
            font-size: 0.5em;
            letter-spacing: 0.5px;
            transition: all 0.1s;
            position: relative;
            bottom: -3px;
        }

        .tab-btn:hover:not(.active) {
            background: linear-gradient(180deg, var(--parchment-md) 0%, var(--parchment-lt) 100%);
            color: var(--ink-bright);
        }

        .tab-btn.active {
            background: linear-gradient(180deg, var(--parchment-md) 0%, var(--parchment-lt) 100%);
            color: var(--gold-bright);
            border-color: var(--gold);
            border-bottom: 3px solid var(--parchment-lt);
            z-index: 1;
        }

        /* ── BUTTONS ── */
        button {
            background: linear-gradient(180deg, var(--parchment-md) 0%, var(--wood) 100%);
            color: var(--ink-bright);
            border: 2px solid var(--gold-dim);
            padding: 9px 12px;
            cursor: pointer;
            font-family: 'IM Fell English', serif;
            font-size: 0.95em;
            margin: 4px 0;
            width: 100%;
            position: relative;
            text-shadow: 1px 1px 0 #000;
            transition: all 0.08s;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.5);
        }

        button:hover:not(:disabled) {
            background: linear-gradient(180deg, var(--parchment-lt) 0%, var(--parchment-md) 100%);
            border-color: var(--gold);
            color: var(--gold-bright);
            box-shadow: 0 0 8px rgba(212, 160, 23, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
        }

        button:active:not(:disabled) {
            transform: translateY(1px);
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
        }

        .btn-stop {
            background: linear-gradient(180deg, #5c1010 0%, #2d0808 100%);
            border-color: #8b2222;
            color: #ffaaaa;
        }

        .btn-stop:hover:not(:disabled) {
            background: linear-gradient(180deg, #7a1515 0%, #4a0a0a 100%);
            border-color: var(--red-bright);
            color: #ffcccc;
            box-shadow: 0 0 10px rgba(200, 30, 30, 0.4);
        }

        /* ── PROGRESS BARS ── */
        .bar-bg {
            width: 100%;
            background: var(--wood);
            border: 2px solid var(--gold-dim);
            height: 20px;
            position: relative;
            margin-bottom: 6px;
            overflow: hidden;
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
        }

        .bar-bg::before {
            content: '';
            position: absolute;
            inset: 0;
            background: repeating-linear-gradient(90deg, transparent, transparent 8px, rgba(0, 0, 0, 0.1) 8px, rgba(0, 0, 0, 0.1) 9px);
            z-index: 1;
            pointer-events: none;
        }

        .bar-fill {
            height: 100%;
            width: 100%;
            transition: width 0.1s linear;
            position: relative;
        }

        .bar-fill::after {
            content: '';
            position: absolute;
            right: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: rgba(255, 255, 255, 0.3);
        }

        .hp-bar {
            background: linear-gradient(180deg, #cc3333 0%, #881111 100%);
        }

        .attack-bar {
            background: linear-gradient(180deg, #3a8fd4 0%, #1a5a9a 100%);
            width: 0%;
        }

        .wood-bar {
            background: linear-gradient(180deg, #5cb85c 0%, #3a7a3a 100%);
            width: 0%;
        }

        .cook-bar {
            background: linear-gradient(180deg, #e8a020 0%, #a06010 100%);
            width: 0%;
        }

        .fish-bar {
            background: linear-gradient(180deg, #20b8c8 0%, #107080 100%);
            width: 0%;
        }

        .mine-bar {
            background: linear-gradient(180deg, #a0a0b8 0%, #606080 100%);
            width: 0%;
        }

        .bar-text {
            position: absolute;
            width: 100%;
            text-align: center;
            top: 0;
            left: 0;
            z-index: 2;
            font-family: 'Press Start 2P', monospace;
            font-size: 9px;
            font-weight: bold;
            line-height: 20px;
            color: white;
            text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
        }

        /* ── ACTION LOG ── */
        #action-log {
            height: 150px;
            flex-shrink: 0;
            background: var(--wood);
            color: var(--ink);
            font-family: 'Press Start 2P', monospace;
            font-size: 9px;
            overflow-y: auto;
            text-align: left;
            padding: 8px 10px;
            border: 2px solid var(--gold-dim);
            margin-top: auto;
            line-height: 1.8;
            box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
        }

        #action-log>div {
            padding: 1px 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.03);
        }

        #action-log::-webkit-scrollbar {
            width: 8px;
        }

        #action-log::-webkit-scrollbar-track {
            background: #0d0905;
        }

        #action-log::-webkit-scrollbar-thumb {
            background: var(--gold-dim);
        }

        #action-log::-webkit-scrollbar-thumb:hover {
            background: var(--gold);
        }

        .log-hit {
            color: #ff7070;
        }

        .log-crit {
            color: var(--gold-bright);
            text-shadow: 0 0 6px rgba(245, 200, 66, 0.6);
        }

        .log-kill {
            color: #70e070;
            text-shadow: 0 0 6px rgba(80, 200, 80, 0.4);
        }

        .log-loot {
            color: #70e8ff;
            text-shadow: 0 0 6px rgba(80, 200, 255, 0.4);
        }

        .log-warn {
            color: #ffaa44;
        }

        /* ── STAT ROWS ── */
        .stat-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
            background: rgba(0, 0, 0, 0.3);
            padding: 8px 10px;
            border: 1px solid rgba(212, 160, 23, 0.2);
            border-left: 3px solid var(--gold-dim);
        }

        .stat-row button {
            width: auto;
            padding: 5px 12px;
            margin: 0;
            font-size: 0.8em;
        }

        .stat-row span {
            font-size: 0.95em;
        }

        .stat-row b {
            color: var(--gold-bright);
        }

        /* ── INVENTORY ── */
        .inventory-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 5px;
            margin-top: 10px;
        }

        .inv-slot {
            background: linear-gradient(135deg, var(--wood) 0%, #150d05 100%);
            border: 2px solid var(--gold-dim);
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            cursor: pointer;
            font-size: 1.5em;
            user-select: none;
            box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
            transition: all 0.08s;
        }

        .inv-slot:hover {
            border-color: var(--gold-bright);
            background: linear-gradient(135deg, var(--parchment-md) 0%, var(--wood) 100%);
            box-shadow: 0 0 8px rgba(212, 160, 23, 0.4), inset 0 0 6px rgba(0, 0, 0, 0.3);
        }

        .inv-qty {
            position: absolute;
            bottom: 1px;
            right: 3px;
            font-family: 'Press Start 2P', monospace;
            font-size: 8px;
            color: var(--gold-bright);
            text-shadow: 1px 1px 0 #000;
        }

        /* ── EQUIP AREA ── */
        .equip-area {
            border-top: 2px solid var(--gold-dim);
            margin-top: 14px;
            padding-top: 12px;
        }

        .equip-box {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
            background: rgba(0, 0, 0, 0.3);
            padding: 8px;
            border: 1px solid rgba(212, 160, 23, 0.2);
            cursor: pointer;
            transition: border-color 0.1s, background 0.1s;
        }

        .equip-box:hover {
            border-color: rgba(212, 160, 23, 0.5);
            background: rgba(0, 0, 0, 0.45);
        }

        .equip-slot {
            width: 42px;
            height: 42px;
            min-width: 42px;
            background: linear-gradient(135deg, var(--wood) 0%, #0d0702 100%);
            border: 2px solid var(--gold-dim);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.4em;
            cursor: pointer;
            user-select: none;
            box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.7);
            transition: all 0.08s;
        }

        .equip-slot:hover {
            border-color: var(--red-bright);
            box-shadow: 0 0 10px rgba(200, 30, 30, 0.4), inset 0 0 6px rgba(0, 0, 0, 0.5);
        }

        /* ── SMALL DETAILS ── */
        small {
            color: var(--ink);
            font-style: italic;
        }

        p {
            color: var(--ink);
            line-height: 1.6;
        }

        .hidden {
            display: none !important;
        }

        /* Pixel divider */
        .pixel-divider {
            height: 4px;
            background: repeating-linear-gradient(90deg, var(--gold-dim) 0px, var(--gold-dim) 4px, transparent 4px, transparent 8px);
            margin: 10px 0;
            opacity: 0.5;
        }

        /* Enemy cards */
        #enemy-cards>div {
            border-left: 3px solid var(--gold-dim) !important;
        }

        #enemy-cards>div:hover {
            border-left-color: var(--gold-bright) !important;
        }

        /* ── LAYOUT ── */
        body {
            display: flex;
            align-items: stretch;
            min-height: 100vh;
        }

        /* ── PERMANENT SIDEBAR ── */
        #nav-drawer {
            position: sticky;
            top: 0;
            width: 200px;
            min-width: 200px;
            height: 100vh;
            background: linear-gradient(180deg, var(--wood) 0%, #0d0905 100%);
            border-right: 3px solid var(--gold-dim);
            display: flex;
            flex-direction: column;
            padding: 20px 0;
            box-shadow: 4px 0 20px rgba(0, 0, 0, 0.8);
            flex-shrink: 0;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: var(--gold-dim) transparent;
        }
        #nav-drawer::-webkit-scrollbar { width: 4px; }
        #nav-drawer::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }

        .drawer-title {
            font-family: 'UnifrakturMaguntia', cursive;
            color: var(--gold);
            font-size: 1.2em;
            text-align: center;
            padding: 0 16px 14px 16px;
            border-bottom: 1px solid var(--gold-dim);
            margin-bottom: 10px;
            letter-spacing: 2px;
        }

        .nav-item {
            display: flex;
            align-items: center;
            gap: 10px;
            position: relative;
            padding: 12px 20px;
            font-family: 'IM Fell English', serif;
            font-size: 1em;
            color: var(--ink);
            cursor: pointer;
            border-left: 3px solid transparent;
            border-bottom: 1px solid rgba(212, 160, 23, 0.07);
            border-right: none;
            border-top: none;
            transition: all 0.1s;
            background: none;
            width: 100%;
            text-align: left;
            text-shadow: 1px 1px 0 #000;
            margin: 0;
        }

        .nav-item:hover {
            color: var(--ink-bright);
            border-left-color: var(--gold-dim);
            background: rgba(212, 160, 23, 0.06);
        }

        .nav-item.active {
            color: var(--gold-bright);
            border-left-color: var(--gold);
            background: rgba(212, 160, 23, 0.1);
            text-shadow: 0 0 8px rgba(212, 160, 23, 0.3), 1px 1px 0 #000;
        }

        .nav-group {
            border-bottom: 1px solid rgba(212, 160, 23, 0.1);
        }
        .nav-group-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            background: none;
            border: none;
            padding: 12px 20px;
            font-family: 'IM Fell English', serif;
            font-size: 1.05em;
            color: var(--ink-bright);
            cursor: pointer;
            text-align: left;
            text-shadow: 1px 1px 0 #000;
            margin: 0;
        }
        .nav-group-header:hover {
            background: rgba(212, 160, 23, 0.06);
        }
        .nav-group-header .nav-icon {
            font-size: 1.1em;
            width: 22px;
            text-align: center;
            margin-right: 10px;
        }
        .nav-group-arrow {
            font-size: 0.7em;
            transition: transform 0.2s ease-in-out;
        }
        .nav-group-content {
            max-height: 600px; /* A large enough value to show all items */
            overflow: hidden;
            transition: max-height 0.3s ease-in-out;
            background: rgba(0,0,0,0.15);
        }
        .nav-group.collapsed .nav-group-content {
            max-height: 0;
        }
        .nav-group.collapsed .nav-group-arrow {
            transform: rotate(-90deg);
        }

        

        .nav-dot {
            position: absolute;
            top: 8px;
            right: 10px;
            width: 9px;
            height: 9px;
            background: #e03030;
            border-radius: 50%;
            box-shadow: 0 0 6px rgba(220, 50, 50, 0.9);
            animation: navdot-pulse 1.4s ease-in-out infinite;
            pointer-events: none;
        }
        .nav-group-dot {
            position: static;
            display: inline-block;
            vertical-align: middle;
            margin-left: 8px;
            margin-bottom: 2px;
        }
        .nav-dot[data-color="orange"] {
            background: #e07820;
            box-shadow: 0 0 6px rgba(220, 130, 30, 0.9);
        }
        .nav-dot[data-color="green"] {
            background: #28c040;
            box-shadow: 0 0 6px rgba(40, 192, 64, 0.9);
        }
        @keyframes navdot-pulse {
            0%, 100% { transform: scale(1);   opacity: 1; }
            50%       { transform: scale(1.35); opacity: 0.7; }
        }

        .nav-item .nav-icon {
            font-size: 1.1em;
            width: 22px;
            text-align: center;
        }

        .nav-divider {
            height: 1px;
            background: rgba(212, 160, 23, 0.2);
            margin: 6px 12px;
        }

        .nav-group-content .nav-item {
            padding-left: 32px;
            font-size: 0.9em;
        }
        .nav-divider-sub {
            height: 1px;
            background: rgba(212, 160, 23, 0.15);
            margin: 4px 20px;
        }

        .nav-save {
            color: #7ecb7e !important;
        }

        .nav-save:hover {
            color: #a8e6a8 !important;
            background: rgba(94, 175, 94, 0.08) !important;
            border-left-color: #5eaf5e !important;
        }

        .nav-delete {
            color: #c97070 !important;
        }

        .nav-delete:hover {
            color: #e09090 !important;
            background: rgba(180, 80, 80, 0.08) !important;
            border-left-color: #b45050 !important;
        }

        /* ── MAIN CONTENT ── */
        #main-content {
            flex: 1;
            padding: 10px;
            overflow-y: auto;
            text-align: center;
        }

        #game-container {
            max-width: none;
            margin: 0;
        }

        #current-tab-label {
            font-family: 'UnifrakturMaguntia', cursive;
            font-size: 1.4em;
            color: var(--gold);
            text-shadow: 1px 1px 0 #000;
            margin: 0 0 12px 0;
            padding-bottom: 8px;
            border-bottom: 2px solid var(--gold-dim);
            letter-spacing: 1px;
        }

        /* Hamburger Menu */
        #hamburger-btn {
            display: none;
            background: none;
            border: none;
            color: var(--gold-bright);
            font-size: 1.8em;
            cursor: pointer;
            padding: 0 12px;
            line-height: 1;
            min-height: unset;
            width: auto;
            margin: 0;
        }

        #nav-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.6);
            z-index: 1999;
        }
        #nav-overlay.visible {
            display: block;
        }

        /* ── QUESTS ── */
        .quest-card {
            background: linear-gradient(135deg, var(--parchment-lt) 0%, var(--parchment) 100%);
            border: 1px solid var(--gold-dim);
            padding: 10px;
            margin-bottom: 8px;
            text-align: left;
            position: relative;
            box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
        }

        .quest-card h4 {
            margin: 0 0 5px 0;
            color: var(--gold-bright);
            font-family: 'IM Fell English', serif;
            font-size: 1.1em;
        }

        .quest-rewards {
            font-size: 0.8em;
            color: var(--ink-bright);
            border-top: 1px dashed var(--gold-dim);
            padding-top: 5px;
            margin-top: 5px;
        }

        .quest-progress-text {
            font-family: 'Press Start 2P', monospace;
            font-size: 0.65em;
            color: var(--gold);
            text-align: right;
            margin-bottom: 4px;
        }

        .quest-progress-text {
            font-family: 'Press Start 2P', monospace;
            font-size: 0.65em;
            color: var(--gold);
            text-align: right;
            margin-bottom: 4px;
        }

        .quest-card {
            background: linear-gradient(135deg, var(--parchment-lt) 0%, var(--parchment) 100%);
            border: 1px solid var(--gold-dim);
            padding: 10px;
            margin-bottom: 8px;
            text-align: left;
            position: relative;
            box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
        }

        /* Mobile HP bar: always hidden on desktop */
        #mobile-hp-bar {
            display: none;
        }

        /* Mobile-only nav tabs: hidden on desktop */
        #nav-character, #nav-inventory {
            display: none;
        }

        /* Cooking touch controls: hidden on desktop */
        #cooking-touch-controls { display: none; }
        .cooking-dpad {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            width: 156px;
            margin: 8px auto 4px;
            gap: 4px;
        }
        .cooking-dpad button {
            font-size: 1.4em;
            background: rgba(0,0,0,0.5);
            border: 2px solid var(--gold-dim);
            color: #fff;
            border-radius: 8px;
            cursor: pointer;
            line-height: 1;
        }
        .cooking-dpad-center {
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.4em;
        }

        /* City tab: hidden until unlocked via JS */
        #nav-city {
            display: none;
        }

        /* ── MOBILE RESPONSIVE ── */
        @media (max-width: 768px) {
            body {
                flex-direction: column;
                padding-bottom: 0;
            }

            #hamburger-btn {
                display: block;
                z-index: 2001;
            }

            #nav-overlay.visible {
                display: block;
            }

            #nav-drawer {
                position: fixed;
                top: 0;
                left: 0;
                width: 220px;
                height: 100vh;
                transform: translateX(-100%);
                transition: transform 0.3s ease-in-out;
                z-index: 2000;
                flex-direction: column;
                overflow-y: auto;
                padding: 20px 0;
                border-right: 3px solid var(--gold-dim);
                box-shadow: 4px 0 20px rgba(0, 0, 0, 0.8);
                scrollbar-width: thin;
                scrollbar-color: var(--gold-dim) transparent;
            }
            #nav-drawer::-webkit-scrollbar { width: 4px; }
            #nav-drawer::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }

            #nav-drawer.mobile-open {
                transform: translateX(0);
            }

            .drawer-title, .nav-divider { display: block; }

            .nav-item {
                flex-direction: row;
                padding: 12px 20px;
                border-left: 3px solid transparent;
                border-bottom: 1px solid rgba(212, 160, 23, 0.07);
                font-size: 1em;
                gap: 10px;
                width: 100%;
                text-align: left;
            }

            .nav-item.active {
                color: var(--gold-bright);
                border-left-color: var(--gold);
                background: rgba(212, 160, 23, 0.12);
                text-shadow: 0 0 8px rgba(212, 160, 23, 0.3), 1px 1px 0 #000;
                border-top-color: transparent;
            }

            .nav-label { display: inline; }

            #nav-character { display: flex; }
            #nav-inventory { display: flex; }

            #main-content { padding: 4px; padding-top: 38px; overflow-y: auto; }

            #game-container { padding: 10px 8px; }

            h1 { font-size: 1.6em; letter-spacing: 1px; margin-bottom: 6px; }

            .panels { flex-direction: column; gap: 8px; }

            .panel { min-width: unset; }

            #mobile-hp-bar {
                display: flex;
                align-items: center;
                gap: 8px;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                z-index: 200;
                background: var(--wood);
                border-bottom: 2px solid var(--gold-dim);
                padding: 5px 10px;
            }

            #character { display: none; }
            #character.mobile-visible { display: flex; }
            #inventory-panel { display: flex; }

            button:not(.nav-item) { min-height: 44px; padding: 10px 12px; font-size: 0.92em; }
            .stat-row button { min-height: 36px; padding: 5px 10px; }

            .inv-slot { height: 52px; }

            .header { padding: 7px 8px; gap: 2px; }
            .header span { margin: 0 4px; font-size: 0.62em; }

            #action-log { height: 110px; }

            #auth-status-text { font-size: 0.55em; padding: 2px 4px; white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; max-width: 100px; word-break: normal !important; }
            #auth-open-btn, #auth-logout-btn { min-width: 56px; padding: 5px 4px; }
            #auth-modal input { font-size: 16px !important; }

            #cooking-touch-controls { display: block; }
            .cooking-dpad button { min-height: 52px; min-width: 52px; }

            #cooking-minigame-container { width: 180px; height: 180px; }

            /* Skill-Buttons: intern scrollbar statt seitlicher Seitenüberlauf */
            #active-skill-btns, #dungeon-skill-btns {
                overflow-x: auto;
                flex-wrap: nowrap;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
                gap: 4px;
                min-width: 0;
            }
            #active-skill-btns::-webkit-scrollbar, #dungeon-skill-btns::-webkit-scrollbar { display: none; }
            #active-skill-btns button, #dungeon-skill-btns button {
                flex-shrink: 0;
                width: auto;
                min-height: 38px;
                font-size: 0.62em;
                padding: 6px 8px;
                white-space: nowrap;
                margin: 0;
            }
        }

        @media (max-width: 420px) {
            .inventory-grid { grid-template-columns: repeat(4, 1fr); }
        }

        /* ── CHAT ── */
        #chat-panel {
            position: fixed;
            bottom: 0;
            right: 20px;
            width: 290px;
            z-index: 600;
            background: var(--wood);
            border: 2px solid var(--gold-dim);
            border-bottom: none;
            border-radius: 8px 8px 0 0;
            box-shadow: -4px -4px 24px rgba(0,0,0,0.7);
            font-family: 'IM Fell English', serif;
        }

        #chat-header {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 7px 12px;
            cursor: pointer;
            background: linear-gradient(180deg, var(--parchment-md) 0%, var(--wood) 100%);
            border-radius: 6px 6px 0 0;
            border-bottom: 1px solid var(--gold-dim);
            color: var(--gold-bright);
            font-size: 0.82em;
            user-select: none;
        }

        #chat-badge {
            background: #c0392b;
            color: #fff;
            border-radius: 10px;
            padding: 1px 6px;
            font-size: 0.75em;
            font-family: 'Press Start 2P', monospace;
        }

        #chat-arrow { margin-left: auto; font-size: 0.8em; }

        #chat-body {
            display: none;
            flex-direction: column;
            height: 270px;
        }

        #chat-panel.chat-open #chat-body { display: flex; }

        #chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 8px 10px;
            display: flex;
            flex-direction: column;
            gap: 5px;
            scrollbar-width: thin;
            scrollbar-color: var(--gold-dim) transparent;
        }

        #chat-messages::-webkit-scrollbar { width: 4px; }
        #chat-messages::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }

        .chat-msg { font-size: 0.8em; line-height: 1.35; word-break: break-word; text-align: left; }
        .chat-msg-me { text-align: right; }

        .chat-nick { color: var(--ink-dim); font-weight: bold; margin-right: 4px; }
        .chat-nick-me { color: var(--gold); }

        .chat-time { color: #555; font-size: 0.78em; }
        .chat-text { color: var(--ink-bright); margin-top: 1px; }

        #chat-login-note {
            padding: 10px;
            color: var(--ink-dim);
            font-size: 0.78em;
            text-align: center;
            border-top: 1px solid var(--gold-dim);
        }
        #chat-login-note a { color: var(--gold); }

        #chat-input-area {
            gap: 4px;
            padding: 6px 8px;
            border-top: 1px solid var(--gold-dim);
            align-items: center;
        }

        #chat-input {
            flex: 1;
            background: rgba(0,0,0,0.4);
            border: 1px solid var(--gold-dim);
            color: var(--ink-bright);
            padding: 6px 8px;
            font-family: 'IM Fell English', serif;
            font-size: 0.88em;
            border-radius: 3px;
            min-height: unset;
            width: auto;
            margin: 0;
        }
        #chat-input:focus { outline: none; border-color: var(--gold); }

        #chat-input-area button {
            width: auto;
            min-height: unset;
            padding: 6px 10px;
            margin: 0;
            font-size: 0.9em;
        }

        @media (max-width: 768px) {
            #chat-panel {
                right: 0;
                left: 0;
                width: 100%;
                border-radius: 8px 8px 0 0;
                bottom: 0;
            }
            #chat-body { height: 230px; }
            #chat-input { font-size: 16px; } /* kein Auto-Zoom auf iOS */
        }

        /* ── RANGLISTE ── */
        .lb-row {
            display: grid;
            grid-template-columns: 36px 1fr auto auto;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            border-bottom: 1px solid rgba(212,160,23,0.15);
            font-size: 0.85em;
        }
        .lb-row:nth-child(odd) { background: rgba(0,0,0,0.15); }
        .lb-row-me { background: rgba(212,160,23,0.12) !important; border-left: 3px solid var(--gold); }

        .lb-rank { font-family: 'Press Start 2P', monospace; font-size: 0.75em; text-align: center; }
        .lb-name { color: var(--ink-bright); font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .lb-level { color: var(--ink-dim); font-size: 0.85em; white-space: nowrap; }
        .lb-power { color: var(--gold); font-family: 'Press Start 2P', monospace; font-size: 0.7em; white-space: nowrap; }
