/* ═══════════════════════════════════════════════════════════════════════════
     BATTLE/QUIZ PANEL (Mobile/Tablet)
     ═══════════════════════════════════════════════════════════════════════════ */
.battle-panel {
        position: fixed;
        top: 0; right: 0;
        height: 100vh;
        width: 50vw;
        max-width: 400px;
        min-width: 260px;
        background: var(--bg-card);
        border-left: 2px solid var(--border-light);
        z-index: 1001;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        box-shadow: -2px 0 12px 0 rgba(0,0,0,0.25);
}

@media (max-width: 1024px) {
    .battle-panel {
        width: 60vw;
        max-width: 420px;
        min-width: 200px;
        font-size: 13px;
        padding: 0 0 16px 0;
    }
}

@media (max-width: 767px) {
    .battle-panel {
        width: 100vw;
        max-width: 100vw;
        min-width: 0;
        left: 0; right: 0;
        border-left: none;
        border-top: 2px solid var(--border-light);
        top: auto; bottom: 0;
        height: 60vh;
        max-height: 420px;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -2px 12px 0 rgba(0,0,0,0.25);
    }
}
/* ═══════════════════════════════════════════════════════════════════════════
   ChronoRealms — Responsive UI
   Breakpoints: PC (>1024), Tablet (768-1024), Mobile (<768)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg-base: #0d0d1a;
    --bg-card: #1a1a2e;
    --bg-panel: #161628;
    --bg-input: #222244;
    --border: #2a2a4a;
    --border-light: #3a3a6a;
    --accent-purple: #6b5ce7;
    --accent-teal: #2dd4bf;
    --accent-green: #2a8a3a;
    --accent-orange: #d4842d;
    --accent-red: #cc3333;
    --text-primary: #e0e0f0;
    --text-secondary: #8080aa;
    --text-gold: #f0d060;
    --text-muted: #4a4a6a;
    --font: 'Courier New', monospace;
    --radius: 6px;
    --radius-lg: 10px;
    --device-ui-scale: 1;
}

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


html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: var(--bg-base);
    font-family: var(--font);
    color: var(--text-primary);
    /* Safe area for iOS/Android notch/home bar */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* ── Screen management ──────────────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ── Offline Badge ──────────────────────────────────────────────────────── */
#offline-badge {
    position: fixed;
    top: 4px; right: 8px;
    background: #cc6600;
    color: #fff;
    font-family: var(--font);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    z-index: 10000;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.7; }
}

/* ── Loading Screen ─────────────────────────────────────────────────────── */
#loading-screen {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #0a0a1a 0%, #1e1440 50%, #0a0a1a 100%);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000; transition: opacity 0.8s ease;
    overflow: hidden;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }

/* ── Floating particles ── */
.loading-particles { position: absolute; inset: 0; pointer-events: none; }
.loading-particles span {
    position: absolute;
    width: 4px; height: 4px;
    background: rgba(160, 208, 255, 0.4);
    border-radius: 50%;
    animation: particle-float linear infinite;
}
.loading-particles span:nth-child(1)  { left:10%; animation-duration:6s;  animation-delay:0s;   width:3px; height:3px; }
.loading-particles span:nth-child(2)  { left:20%; animation-duration:8s;  animation-delay:1s;   width:5px; height:5px; }
.loading-particles span:nth-child(3)  { left:35%; animation-duration:7s;  animation-delay:2s; }
.loading-particles span:nth-child(4)  { left:50%; animation-duration:9s;  animation-delay:0.5s; width:3px; height:3px; }
.loading-particles span:nth-child(5)  { left:65%; animation-duration:6s;  animation-delay:3s;   width:6px; height:6px; }
.loading-particles span:nth-child(6)  { left:75%; animation-duration:10s; animation-delay:1.5s; }
.loading-particles span:nth-child(7)  { left:85%; animation-duration:7s;  animation-delay:4s;   width:3px; height:3px; }
.loading-particles span:nth-child(8)  { left:5%;  animation-duration:8s;  animation-delay:2.5s; width:5px; height:5px; }
.loading-particles span:nth-child(9)  { left:45%; animation-duration:11s; animation-delay:0s; }
.loading-particles span:nth-child(10) { left:90%; animation-duration:7s;  animation-delay:3.5s; width:4px; height:4px; }

@keyframes particle-float {
    0%   { bottom: -10px; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { bottom: 110%; opacity: 0; }
}

/* ── Content ── */
.loading-content {
    text-align: center;
    width: 90%;
    max-width: 500px;
    box-sizing: border-box;
    animation: content-fade-in 1s ease-out;
    position: relative;
    z-index: 1;
}
@keyframes content-fade-in {
    0%   { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ── Title ── */
.game-title {
    font-size: clamp(1.2rem, 6vw, 3rem);
    color: #a0d0ff;
    text-shadow: 0 0 20px rgba(100,180,255,0.5), 0 0 40px rgba(100,180,255,0.2);
    letter-spacing: clamp(0.05em, 1vw, 0.3em);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    animation: title-glow 2.5s ease-in-out infinite alternate;
}
@keyframes title-glow {
    0%   { text-shadow: 0 0 10px rgba(100,180,255,0.3), 0 0 20px rgba(100,180,255,0.1); }
    100% { text-shadow: 0 0 25px rgba(100,180,255,0.7), 0 0 50px rgba(100,180,255,0.3), 0 0 80px rgba(100,180,255,0.1); }
}

/* ── Subtitle ── */
.game-subtitle {
    font-size: clamp(0.6rem, 2.5vw, 1rem);
    color: var(--text-secondary);
    letter-spacing: clamp(0.05em, 1vw, 0.4em);
    margin-bottom: 1.5rem;
    animation: subtitle-fade 1.5s ease-out 0.3s both;
}
@keyframes subtitle-fade {
    0%   { opacity: 0; letter-spacing: 0.4em; }
    100% { opacity: 1; }
}

/* ── Spinner ── */
.loading-spinner {
    width: 48px; height: 48px;
    margin: 0 auto 1.5rem;
}
.spinner-svg {
    width: 100%; height: 100%;
    animation: spinner-rotate 1.4s linear infinite;
}
.spinner-svg circle {
    fill: none;
    stroke: #6080cf;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    animation: spinner-dash 1.4s ease-in-out infinite;
}
@keyframes spinner-rotate {
    100% { transform: rotate(360deg); }
}
@keyframes spinner-dash {
    0%   { stroke-dasharray: 1, 150;  stroke-dashoffset: 0; }
    50%  { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* ── Loading bar ── */
.loading-bar-container {
    width: 100%; max-width: 300px; height: 8px; background: #1a1a3a;
    border: 1px solid var(--border-light); border-radius: 4px;
    margin: 0 auto 1rem; overflow: hidden;
    position: relative;
}
.loading-bar {
    width: 0%; height: 100%;
    background: linear-gradient(90deg, #6060cf, #a0d0ff);
    border-radius: 4px; transition: width 0.3s ease;
    position: relative;
}
.loading-bar::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: bar-shimmer 1.5s ease-in-out infinite;
}
@keyframes bar-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.loading-text {
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    color: var(--text-muted);
    animation: text-pulse 2s ease-in-out infinite;
}
@keyframes text-pulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    font-family: var(--font); font-size: 13px;
    padding: 10px 24px; border: 1px solid var(--border-light);
    border-radius: var(--radius); cursor: pointer;
    color: var(--text-primary); background: var(--bg-card);
    transition: all 0.15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent-green); border-color: #3ab94a; }
.btn-teal { background: #1a6b5c; border-color: var(--accent-teal); color: var(--accent-teal); }
.btn-green { background: #1a5a2a; border-color: #3ab94a; color: #66ff66; }
.btn-orange { background: #5a3a1a; border-color: var(--accent-orange); color: var(--accent-orange); }
.btn-muted { background: var(--bg-panel); border-color: var(--border); color: var(--text-secondary); }
.btn-secondary { background: var(--bg-panel); border-color: var(--border); }
.btn-wide { flex: 1; min-width: 200px; }
.btn-disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-icon {
    background: none; border: none; color: var(--text-secondary);
    font-size: 20px; cursor: pointer; padding: 4px 8px;
}
.btn-icon:hover { color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════════════════════════
   MENU SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */
#menu-screen { flex-direction: row; background: var(--bg-base); }

.menu-sidebar {
    width: 200px; background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.sidebar-label {
    font-size: 11px; color: var(--text-muted);
    margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.1em;
}
.nav-btn {
    display: block; width: 100%; padding: 12px 16px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-secondary);
    font-family: var(--font); font-size: 13px;
    cursor: pointer; text-align: center; transition: all 0.15s;
}
.nav-btn:hover, .nav-btn.active {
    color: var(--text-primary); border-color: var(--border-light); background: var(--bg-input);
}

.menu-main {
    flex: 1; padding: 24px 32px;
    display: flex; flex-direction: column; align-items: center;
    overflow-y: auto;
}
.menu-header {
    text-align: center; padding: 20px 32px;
    background: var(--bg-card); border: 2px solid var(--accent-purple);
    border-radius: var(--radius-lg); margin-bottom: 24px;
    width: 100%; max-width: 600px;
}
.menu-header h1 { font-size: 1.6rem; color: #a0d0ff; letter-spacing: 0.15em; }
.menu-header .tagline { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

.era-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px; width: 100%; max-width: 600px; margin-bottom: 24px;
}
.era-card {
    background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px 12px;
    text-align: center; cursor: pointer; transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.era-card:hover:not(.locked) { border-color: var(--border-light); transform: translateY(-2px); }
.era-card.selected { border-color: var(--accent-purple); box-shadow: 0 0 12px rgba(107,92,231,0.3); }
.era-card.selected[data-era="ww2"] { border-color: var(--accent-teal); box-shadow: 0 0 12px rgba(45,212,191,0.3); }
.era-card.locked { opacity: 0.4; cursor: not-allowed; }
.era-icon {
    width: 56px; height: 56px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.era-name { font-size: 12px; color: var(--text-primary); }
.era-status { font-size: 10px; color: var(--text-secondary); }
.era-status.unlocked { color: var(--accent-teal); }

.menu-actions { display: flex; gap: 12px; width: 100%; max-width: 600px; flex-wrap: wrap; }

.menu-bottomnav {
    display: none; background: var(--bg-panel);
    border-top: 1px solid var(--border); padding: 8px; gap: 8px; justify-content: center;
}
.bnav-btn {
    flex: 1; max-width: 100px; padding: 10px 8px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-secondary);
    font-family: var(--font); font-size: 11px; cursor: pointer; text-align: center;
}
.bnav-btn.active { color: var(--text-primary); border-color: var(--border-light); }

/* ═══════════════════════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */
#game-screen { flex-direction: column; background: var(--bg-base); }

.game-hud {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 16px; background: var(--bg-panel);
    border-bottom: 1px solid var(--border); height: 40px; flex-shrink: 0;
}
.game-hud-actions { display: flex; align-items: center; gap: 8px; }
.hud-era { font-size: 13px; color: var(--text-gold); }
.hud-progress { display: flex; gap: 16px; }
.hud-hp { font-size: 12px; color: #ff6666; }
.hud-score { font-size: 12px; color: #ffcc00; }

.game-body {
    flex: 1; display: flex; flex-direction: row;
    overflow: hidden; min-height: 0; position: relative;
}
#game-container {
    flex: 1; display: flex; justify-content: center; align-items: center;
    min-width: 0; min-height: 0; overflow: hidden;
}
#game-container canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#game-screen.battle-active .game-body {
    isolation: isolate;
}

#game-screen.battle-active #game-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#game-screen.battle-active #game-container canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
}

#game-screen.battle-active .game-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    background: rgba(22, 22, 40, 0.84);
    backdrop-filter: blur(1px);
}

@media (max-height: 500px) and (orientation: landscape) {
    #game-screen.battle-active .game-sidebar {
        display: none !important;
    }
}

#game-screen.battle-active .game-controls-hint,
#game-screen.battle-active .game-tabs,
#game-screen.battle-active .game-touch-controls,
#game-screen.battle-active .touch-controls-landscape {
    display: none !important;
}

.game-sidebar {
    width: 260px; background: var(--bg-panel);
    border-left: 1px solid var(--border); padding: 8px;
    display: flex; flex-direction: column; gap: 8px;
    overflow-y: auto; flex-shrink: 0;
}
.panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px;
}
.panel h3 {
    font-size: 11px; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px;
}
.panel-minimap { border-color: var(--accent-purple); }
.panel.highlight-orange { border-color: var(--accent-orange); background: #2a1f14; }
.panel.highlight-orange p { color: var(--accent-orange); font-size: 12px; }

.stat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.hp-bar {
    --hp-scale: var(--hud-hp-scale, 3);
    position: relative;
    flex: 0 0 auto;
    width: calc(42px * var(--hp-scale));
    height: calc(11px * var(--hp-scale));
    background-image: url('/static/assets/ui/healthbar_04.png');
    background-repeat: no-repeat;
    background-size: calc(336px * var(--hp-scale)) calc(240px * var(--hp-scale));
    background-position: calc(-3px * var(--hp-scale)) calc(-67px * var(--hp-scale));
    image-rendering: pixelated;
}
.hp-bar-fill {
    position: absolute;
    left: calc(4px * var(--hp-scale));
    top: calc(3px * var(--hp-scale));
    width: calc(34px * var(--hp-scale));
    height: calc(5px * var(--hp-scale));
    background-image: url('/static/assets/ui/healthbar_04.png');
    background-repeat: no-repeat;
    background-size: calc(336px * var(--hp-scale)) calc(240px * var(--hp-scale));
    image-rendering: pixelated;
    transition: width 0.18s linear;
}
.hp-bar-player .hp-bar-fill {
    background-position: calc(-55px * var(--hp-scale)) calc(-118px * var(--hp-scale));
}
.stat-value {
    min-width: 48px;
    color: var(--text-primary);
    text-align: right;
}

#minimap-canvas { width: 100%; border-radius: 4px; background: #0a0a1a; display: block; }

.scroll-list {
    list-style: none; max-height: 100px; overflow-y: auto;
    font-size: 11px; color: var(--text-secondary);
}
.scroll-list li { padding: 3px 0; border-bottom: 1px solid #1a1a2e; }
.scroll-list .empty-msg { color: var(--text-muted); font-style: italic; }
.obj-check { margin-right: 4px; }
.obj-check.done { color: var(--accent-green); }

.game-controls-hint {
    text-align: center; padding: 6px; background: var(--bg-panel);
    border-top: 1px solid var(--border); font-size: 11px;
    color: var(--text-muted); flex-shrink: 0;
}

/* Tablet tabs */
.game-tabs {
    display: none; background: var(--bg-panel);
    border-top: 1px solid var(--border); padding: 6px 8px;
    gap: 8px; justify-content: center; flex-shrink: 0;
}
.tab-btn {
    flex: 1; max-width: 120px; padding: 8px 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-secondary);
    font-family: var(--font); font-size: 11px; cursor: pointer; text-align: center;
}
.tab-btn.active { border-color: var(--accent-purple); color: var(--text-primary); background: var(--bg-input); }

/* Tablet touch controls */
.game-touch-controls {
    display: none; background: var(--bg-panel);
    border-top: 1px solid var(--border); padding: 8px;
    gap: 8px; justify-content: center; flex-shrink: 0;
}
.ctrl-btn {
    padding: 12px 16px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-secondary); font-family: var(--font); font-size: 12px;
    cursor: pointer; min-width: 60px; text-align: center;
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.ctrl-btn:active, .ctrl-btn.pressed {
    background: var(--accent-purple); color: #fff; border-color: var(--accent-purple);
}
.ctrl-action { background: var(--bg-input); border-color: var(--accent-purple); color: var(--accent-purple); }

/* Mobile D-pad — REMOVED, replaced by landscape joystick */
.game-dpad { display: none; }

/* ── Virtual Joystick + Action Buttons (landscape mobile/tablet) ──────── */
.touch-controls-landscape {
    display: none; /* shown via media query */
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 140px; z-index: 200;
    pointer-events: none;
    padding: 0 16px 12px;
    box-sizing: border-box;
}

.joystick-zone {
    position: absolute; left: 16px; bottom: 12px;
    width: 120px; height: 120px;
    pointer-events: auto;
}
.joystick-base {
    width: 120px; height: 120px;
    background: rgba(26, 26, 46, 0.6);
    border: 2px solid rgba(100, 100, 180, 0.4);
    border-radius: 50%;
    position: relative;
    touch-action: none;
}
.joystick-thumb {
    width: 48px; height: 48px;
    background: rgba(100, 128, 207, 0.7);
    border: 2px solid rgba(160, 208, 255, 0.6);
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
    pointer-events: none;
}

.touch-action-btns {
    position: absolute; right: 16px; bottom: 12px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    pointer-events: auto;
}
.touch-btn {
    border: none; border-radius: 50%;
    font-family: var(--font); font-weight: bold;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
    transition: transform 0.1s;
}
.touch-btn:active { transform: scale(0.9); }

.touch-btn-interact {
    width: 64px; height: 64px;
    background: rgba(0, 180, 160, 0.7);
    border: 2px solid var(--accent-teal);
    color: #fff; font-size: 18px;
}
.touch-btn-row {
    display: flex; gap: 10px;
}
.touch-btn-inv, .touch-btn-map {
    width: 44px; height: 44px;
    background: rgba(40, 40, 70, 0.8);
    border: 1px solid var(--border-light);
    color: var(--text-secondary); font-size: 11px;
}

.btn-bag-icon svg,
.touch-btn-inv svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.touch-btn-inv {
    color: #f1d28b;
}

/* ── Install Button ─────────────────────────────────────────────────────── */
.btn-install {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-teal));
    color: #fff; border: none; font-weight: bold;
    padding: 12px 24px; border-radius: var(--radius);
    cursor: pointer; font-family: var(--font); font-size: 14px;
    width: 100%; max-width: 300px;
}
.btn-install:hover { filter: brightness(1.15); }

.notification-status {
    width: 100%;
    max-width: 600px;
    margin: 8px 0 0;
    color: var(--accent-teal);
    font-size: 12px;
    text-align: center;
}
.notification-status.error {
    color: #ff8888;
}
.notification-settings-status {
    margin-top: 8px;
}
.notification-settings-status.error {
    color: #ff8888;
}

/* ═══════════════════════════════════════════════════════════════════════════
   OVERLAYS (Dialogue & Quiz)
   ═══════════════════════════════════════════════════════════════════════════ */
.overlay {
    position: fixed; inset: 0; z-index: 500;
    display: flex; justify-content: center; align-items: flex-end;
}
.overlay.hidden { display: none; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }

/* ── Character Selection ────────────────────────────────────────────────── */
#charselect-overlay {
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.85);
}
.charselect-panel {
    position: relative; z-index: 1; width: 90%; max-width: 640px;
    max-height: 85vh; overflow-y: auto;
    background: var(--bg-card); border: 2px solid var(--accent-orange);
    border-radius: var(--radius-lg); padding: 24px; text-align: center;
}
.charselect-panel h2 {
    margin: 0 0 16px; font-size: 1.3rem; color: var(--accent-orange);
    font-family: var(--font-heading);
}
.charselect-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 10px; margin-bottom: 20px;
}
.char-cell {
    aspect-ratio: 1; cursor: pointer; border: 2px solid transparent;
    border-radius: var(--radius-sm); background: var(--bg-panel);
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.2s, transform 0.15s;
    image-rendering: pixelated; overflow: hidden;
}
.char-cell:hover { border-color: var(--accent-purple); transform: scale(1.1); }
.char-cell.selected { border-color: var(--accent-orange); box-shadow: 0 0 8px var(--accent-orange); transform: scale(1.15); }
.char-cell canvas {
    width: 64px; height: 64px; image-rendering: pixelated;
}
.charselect-actions { display: flex; gap: 12px; justify-content: center; }

/* Weapon Selector */
.weapon-select { margin: 16px 0; }
.weapon-select h3 { margin: 0 0 10px; font-size: 1rem; color: var(--accent-purple); font-family: var(--font-heading); }
.weapon-options { display: flex; gap: 10px; justify-content: center; }
.weapon-btn {
    padding: 8px 18px; border: 2px solid transparent; border-radius: var(--radius-sm);
    background: var(--bg-panel); color: var(--text-primary); cursor: pointer;
    font-size: 1rem; transition: border-color 0.2s, transform 0.15s;
}
.weapon-btn:hover { border-color: var(--accent-purple); transform: scale(1.05); }
.weapon-btn.selected { border-color: var(--accent-orange); box-shadow: 0 0 8px var(--accent-orange); }

/* ── Dialogue ───────────────────────────────────────────────────────────── */
.dialogue-container {
    position: relative; z-index: 1; width: 100%; max-width: 720px;
    background: var(--bg-card); border: 2px solid var(--border-light);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px; margin: 0 16px;
}
.dialogue-header { display: flex; justify-content: flex-end; gap: 12px; margin-bottom: 12px; }
.era-badge {
    padding: 4px 12px; background: #3a2000; border: 1px solid var(--accent-orange);
    border-radius: 4px; font-size: 11px; color: var(--accent-orange);
}
.score-badge {
    padding: 4px 12px; background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 4px; font-size: 11px; color: var(--text-secondary);
}
.dialogue-body { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.npc-portrait {
    width: 64px; height: 64px; background: var(--accent-purple);
    border: 2px solid #8b7cf7; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: bold; color: #fff; flex-shrink: 0;
}
.dialogue-content { flex: 1; }
.dialogue-content h3 { font-size: 14px; color: var(--text-primary); margin-bottom: 8px; }
.dialogue-content p {
    font-size: 12px; color: var(--text-secondary); line-height: 1.5;
    background: var(--bg-panel); padding: 10px; border-radius: var(--radius);
    border: 1px solid var(--border);
}
.dialogue-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Quiz ───────────────────────────────────────────────────────────────── */
.quiz-container {
    position: relative; z-index: 1; width: 100%; max-width: 520px;
    background: var(--bg-card); border: 2px solid var(--border-light);
    border-radius: var(--radius-lg); padding: 16px; margin: auto 16px;
}
.quiz-header {
    text-align: center; padding: 8px 16px;
    background: var(--accent-green); border-radius: var(--radius); margin-bottom: 12px;
}
.quiz-header span { font-size: 12px; color: #fff; letter-spacing: 0.05em; }
.quiz-question {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.quiz-question p { font-size: 13px; color: var(--text-primary); line-height: 1.4; }
.quiz-choices { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.choice-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; background: var(--bg-panel);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-primary); font-family: var(--font); font-size: 13px;
    cursor: pointer; text-align: left; transition: all 0.15s;
}
.choice-btn:hover:not(.disabled):not(.correct):not(.wrong) {
    background: var(--bg-input); border-color: var(--border-light);
}
.choice-btn.correct { background: #1a5a3a; border-color: var(--accent-teal); color: var(--accent-teal); }
.choice-btn.wrong { background: #5a1a1a; border-color: var(--accent-red); color: #ff6666; }
.choice-btn.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
.choice-letter { font-weight: bold; color: var(--text-secondary); min-width: 20px; }

.quiz-actions { display: flex; gap: 10px; margin-bottom: 10px; }
.quiz-timer {
    height: 6px; background: #1a1a3a; border-radius: 3px;
    overflow: hidden; margin-bottom: 8px;
}
.timer-bar {
    height: 100%; background: var(--accent-orange);
    transition: width 1s linear; border-radius: 3px;
}
.quiz-feedback { text-align: center; padding: 6px; }
.feedback-correct { color: #66ff66; font-size: 13px; }
.feedback-wrong { color: #ff6666; font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (768–1024)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .menu-sidebar { display: none; }
    #menu-screen { flex-direction: column; }
    .menu-main { padding: 16px; }
    .menu-bottomnav { display: flex; }

    .game-sidebar { display: none; }
    .game-controls-hint { display: none; }
    .game-tabs { display: none; }
    .game-touch-controls { display: none; }
    /* Only show touch controls when game screen is active (not on menu/loading) */
    #game-screen.active .touch-controls-landscape { display: block; }

    /* Game fills entire viewport, controls overlay on top.
       IMPORTANT: scoped to .active so it never leaks through .hidden */
    #game-screen.active {
        position: fixed !important;
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        display: flex;
        flex-direction: column;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    #game-screen.active .game-hud { flex-shrink: 0; }
    #game-screen.active .game-body {
        flex: 1;
        flex-direction: row;
        min-height: 0;
        overflow: hidden;
    }
    #game-container {
        flex: 1;
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        min-width: 0;
        min-height: 0;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden;
        position: relative;
    }
    #game-container canvas {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        display: block;
        position: absolute;
        top: 0; left: 0;
        touch-action: none;
    }

    .dialogue-container { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .dialogue-actions { justify-content: center; }
    .quiz-container { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; padding: 10px; }
    .quiz-header { padding: 4px 8px; margin-bottom: 6px; }
    .quiz-header span { font-size: 11px; }
    .quiz-question { padding: 8px 10px; margin-bottom: 6px; }
    .quiz-question p { font-size: 12px; }
    .quiz-choices { gap: 4px; margin-bottom: 6px; }
    .choice-btn { padding: 6px 10px; font-size: 12px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (<768)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .menu-sidebar { display: none; }
    #menu-screen { flex-direction: column; }
    .menu-main { padding: 12px; }
    .menu-header h1 { font-size: 1.2rem; }
    .menu-header .tagline { display: none; }
    .era-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .menu-bottomnav { display: flex; }
    .menu-actions { flex-direction: column; align-items: center; }
    .btn-wide { width: 100%; }

    .game-sidebar { display: none; }
    .game-controls-hint { display: none; }
    .game-tabs { display: none; }
    .game-touch-controls { display: none; }
    #game-screen.active .touch-controls-landscape { display: block; }
    .game-hud { height: 36px; padding: 4px 12px; flex-shrink: 0; }
    .hud-era { display: none; }

    /* Game fills entire viewport, controls overlay on top.
       IMPORTANT: scoped to .active so it never leaks through .hidden */
    #game-screen.active {
        position: fixed !important;
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        display: flex;
        flex-direction: column;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    #game-screen.active .game-body {
        flex: 1;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }
    #game-container {
        flex: 1;
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        min-width: 0;
        min-height: 0;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden;
        position: relative;
    }
    #game-container canvas {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        display: block;
        position: absolute;
        top: 0; left: 0;
        touch-action: none;
    }

    .overlay { align-items: center; }
    .charselect-grid { grid-template-columns: repeat(4, 1fr); }
    .dialogue-container { border-radius: var(--radius-lg); margin: 12px; }
    .dialogue-body { flex-direction: column; align-items: center; text-align: center; }
    .dialogue-actions { flex-direction: column; }
    .dialogue-actions .btn { width: 100%; }
    .quiz-container { border-radius: var(--radius-lg); margin: 0; padding: 8px; max-width: 100%; align-self: flex-end; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .quiz-header { padding: 4px; margin-bottom: 6px; }
    .quiz-header span { font-size: 11px; }
    .quiz-question { padding: 8px; margin-bottom: 6px; }
    .quiz-question p { font-size: 11px; }
    .quiz-choices { gap: 4px; margin-bottom: 6px; }
    .choice-btn { padding: 6px 8px; font-size: 11px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LANDSCAPE LOCK — portrait warning
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) and (orientation: portrait) {
    #rotate-device-overlay {
        display: flex !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FULLSCREEN NOTE
   The manifest uses "display": "fullscreen", so the :fullscreen pseudo-class
   matches PERMANENTLY inside the installed PWA. We do NOT use :fullscreen
   CSS rules here because they would always apply and fight with .hidden.
   The @media (max-width: 1024px) and (max-width: 767px) rules above already
   handle the mobile/tablet layout regardless of fullscreen state.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS (Knowledge Log, Settings, About)
   ═══════════════════════════════════════════════════════════════════════════ */
#auth-modal,
#eras-modal,
#knowledge-modal,
#inventory-modal,
#settings-modal,
#about-modal {
    align-items: center;
    justify-content: center;
    z-index: 600;
}
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
}
.modal-container {
    position: relative; z-index: 1;
    width: 92%; max-width: 640px;
    max-height: 85vh;
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: modal-slide-in 0.25s ease-out;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
@keyframes modal-slide-in {
    0%   { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}
.modal-header h2 {
    font-size: clamp(0.95rem, 3vw, 1.15rem);
    color: var(--accent-teal);
    margin: 0; font-family: var(--font);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-close-modal {
    background: none; border: none;
    color: var(--text-secondary); font-size: 32px;
    cursor: pointer; line-height: 1; padding: 0 6px;
    transition: color 0.15s;
    flex-shrink: 0;
    margin-left: 8px;
}
.btn-close-modal:hover { color: var(--text-primary); }

.modal-body {
    padding: 18px; overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}
.modal-footer {
    padding: 12px 18px;
    background: var(--bg-panel);
    border-top: 2px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
    flex-shrink: 0;
}

/* Knowledge Log Modal */
.knowledge-full-list {
    list-style: none; padding: 0; margin: 0;
}
.knowledge-full-list li {
    padding: 12px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.knowledge-full-list li .q-label {
    color: var(--accent-orange);
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.knowledge-full-list li .a-label {
    color: var(--accent-teal);
    font-weight: bold;
    display: block;
    margin-top: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.knowledge-full-list .empty-msg {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    border: none;
    background: none;
    padding: 48px 20px;
    font-size: 14px;
}

/* Settings Modal */
.settings-group {
    margin-bottom: 22px;
}
.settings-group:last-child {
    margin-bottom: 0;
}
.settings-group h3 {
    font-size: 0.8rem;
    color: var(--accent-purple);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.setting-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0;
    font-size: 13px; color: var(--text-primary);
    gap: 12px;
}
.setting-row:not(:last-child) {
    border-bottom: 1px solid #1a1a2e;
}

.auth-container {
    max-width: 420px;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.auth-copy {
    margin: 0 0 2px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}
.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-primary);
    font-size: 12px;
}
.auth-field small {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.4;
}
.auth-field input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text-primary);
    font: inherit;
    outline: none;
}
.auth-field input:focus {
    border-color: var(--accent-teal);
}
.password-input-wrap {
    position: relative;
    display: block;
}
.password-input-wrap input {
    padding-right: 68px;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    height: 28px;
    padding: 0 9px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus {
    color: var(--text-primary);
    border-color: var(--accent-teal);
    outline: none;
}
.auth-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
}
.auth-remember input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-teal);
}
.auth-error {
    margin: 0;
    color: #ff8888;
    font-size: 12px;
    line-height: 1.4;
}
.auth-footer {
    justify-content: space-between;
}

.era-history-list {
    display: grid;
    gap: 12px;
}
.era-history-entry {
    padding: 12px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.era-history-entry h3 {
    margin: 0 0 8px;
    color: var(--accent-teal);
    font-size: 14px;
}
.era-history-entry p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.55;
}
.setting-row-stack {
    align-items: flex-end;
    padding-bottom: 6px;
    border-bottom: none;
}
.setting-block {
    padding: 10px 0 14px;
    border-bottom: 1px solid #1a1a2e;
    margin-bottom: 8px;
}
.setting-block input[type="range"] {
    width: 100%;
    accent-color: var(--accent-purple);
    margin-bottom: 10px;
}
.setting-value {
    color: var(--text-gold);
    font-weight: bold;
}
.setting-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px; height: 26px;
    display: inline-block;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 26px;
    cursor: pointer; transition: all 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    left: 2px; top: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-green);
    border-color: #3ab94a;
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: #fff;
}

/* Buttons */
.btn-small {
    padding: 6px 14px;
    font-size: 12px;
}
.btn-danger {
    background: #5a1a1a;
    border-color: var(--accent-red);
    color: #ff6666;
}
.btn-danger:hover {
    background: #6a2a2a;
}

/* About Modal */
.about-section {
    margin-bottom: 22px;
}
.about-section:last-child {
    margin-bottom: 0;
}
.about-section h3 {
    font-size: 0.9rem;
    color: var(--accent-teal);
    margin-bottom: 8px;
    font-family: var(--font);
}
.about-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 6px 0;
}
.about-section a {
    color: var(--accent-purple);
    text-decoration: none;
    transition: color 0.15s;
    word-break: break-word;
}
.about-section a:hover {
    color: var(--accent-teal);
}
.about-list {
    list-style: none; padding: 0; margin: 0;
}
.about-list li {
    padding: 6px 0 6px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    margin-bottom: 4px;
}
.about-list li::before {
    content: '\2022';
    position: absolute;
    left: 6px;
    color: var(--accent-purple);
}
.about-list li strong {
    color: var(--text-primary);
}

/* ── Modal Responsive — Tablet (≤1024px) ─────────────────────────────── */
@media (max-width: 1024px) {
    .modal-container {
        width: 90%;
        max-height: 80vh;
    }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 10px 16px; }
}

/* Minimap Modal */
.modal-minimap .modal-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
#minimap-modal-canvas {
    width: 100%;
    max-width: 400px;
    height: auto;
    aspect-ratio: 4 / 3;
    background: #0a0a1a;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    image-rendering: pixelated;
    display: block;
}
.minimap-legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.dot-player { background: #ffffff; border: 1px solid #aaa; }
.dot-npc { background: #4488ff; }
.dot-mob { background: #ff4444; }

/* Inventory Modal */
.inventory-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}
.inventory-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
    animation: inventory-bob 3s ease-in-out infinite;
}
@keyframes inventory-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.inventory-placeholder p {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.inventory-hint {
    font-size: 12px !important;
    color: var(--text-muted) !important;
}

.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inventory-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    background: rgba(24, 37, 52, 0.9);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.inventory-summary > div {
    min-width: 0;
}

.inventory-summary-label {
    display: block;
    margin-bottom: 3px;
    font-size: 10px;
    color: var(--text-muted);
}

.inventory-summary strong {
    display: block;
    font-size: 12px;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.inventory-item {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.inventory-item.equipped {
    border-color: var(--accent-teal);
}

.inventory-consumables,
.inventory-era-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inventory-filter-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.inventory-filter-btn {
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 11px;
    cursor: pointer;
}

.inventory-filter-btn.active {
    border-color: var(--accent-teal);
    color: var(--text-primary);
    background: rgba(45, 212, 191, 0.13);
}

.inventory-section-title {
    margin: 4px 0 0;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.inventory-item.consumable {
    border-color: rgba(126, 231, 135, 0.35);
}

.inventory-item.disabled {
    opacity: 0.55;
}

.inventory-empty-category {
    padding: 24px 12px;
}

.inventory-item-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    image-rendering: pixelated;
}

.inventory-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-primary);
}

.inventory-item-era,
.inventory-item-stats {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
}

.power-pill {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    border: 1px solid currentColor;
}

.full-power .power-pill { color: #7ee787; }
.reduced-power .power-pill { color: #ffcf70; }

.item-pickup-toast {
    position: fixed;
    left: 50%;
    top: 74px;
    transform: translate(-50%, -12px);
    z-index: 1200;
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: min(320px, calc(100vw - 32px));
    padding: 10px 12px;
    background: rgba(12, 18, 28, 0.94);
    border: 1px solid var(--accent-teal);
    border-radius: var(--radius);
    color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.item-pickup-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.item-pickup-toast img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    image-rendering: pixelated;
}

.item-pickup-toast strong,
.item-pickup-toast span {
    display: block;
    font-size: 12px;
}

.item-pickup-toast span {
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Modal Responsive — Mobile (≤767px) ──────────────────────────────── */
@media (max-width: 767px) {
    #auth-modal,
    #eras-modal,
    #knowledge-modal,
    #inventory-modal,
    #settings-modal,
    #about-modal {
        align-items: flex-end;
    }
    .modal-container {
        width: 100%;
        max-width: none;
        max-height: 92vh;
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border: none;
        border-top: 2px solid var(--border-light);
        animation: modal-slide-up 0.25s ease-out;
    }
    @keyframes modal-slide-up {
        0%   { opacity: 0; transform: translateY(100%); }
        100% { opacity: 1; transform: translateY(0); }
    }
    .modal-header { padding: 12px 14px; }
    .modal-header h2 { font-size: 0.95rem; }
    .modal-body { padding: 14px; }
    .modal-footer { padding: 10px 14px; }
    .btn-close-modal { font-size: 28px; }

    .knowledge-full-list li { padding: 10px 12px; font-size: 12px; }
    .setting-row { font-size: 12px; }
    .about-section p { font-size: 12px; }
    .about-list li { font-size: 12px; }
    .auth-footer { flex-direction: column-reverse; }
    .auth-footer .btn { width: 100%; }
}

/* ── Modal Responsive — Small Mobile (≤480px) ────────────────────────── */
  @media (max-width: 480px) {
    .modal-container {
          max-height: 95vh;
      }
      .inventory-summary {
          grid-template-columns: 1fr;
      }
    .modal-header { padding: 10px 12px; }
    .modal-header h2 { font-size: 0.85rem; }
    .modal-body { padding: 12px; }
    .modal-footer { padding: 8px 12px; }
    .btn-close-modal { font-size: 24px; }

    .knowledge-full-list li { padding: 8px 10px; font-size: 11px; margin-bottom: 8px; }
    .knowledge-full-list li .q-label,
    .knowledge-full-list li .a-label { font-size: 10px; }
    .setting-row { font-size: 11px; padding: 8px 0; }
    .toggle-switch { width: 42px; height: 22px; }
    .toggle-slider::before { width: 16px; height: 16px; }
    .toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
    .btn-small { padding: 5px 10px; font-size: 11px; }
    .about-section p { font-size: 11px; }
    .about-list li { font-size: 11px; }
}
