@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

html, body {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

body {
    background: #0a0a0f;
    color: #c8c8d0;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    position: relative;
    width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#canvas-container {
    position: relative;
    width: 960px;
    height: 640px;
}

#canvas-container canvas:not(#minimap-canvas) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: none;
}

#ui-canvas {
    pointer-events: none;
    z-index: 1;
}

#world-canvas {
    z-index: 0;
}

#minimap-canvas {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 160px;
    height: 160px;
    border: 1px solid rgba(200, 200, 208, 0.25);
    border-radius: 4px;
    background: rgba(10, 10, 15, 0.85);
    z-index: 15;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: pointer;
}

#minimap-canvas.hidden { display: none; }

#top-bar {
    width: 960px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

#hud {
    display: flex;
    gap: 16px;
    font-size: 7px;
    letter-spacing: 0.5px;
}

#hud span {
    white-space: nowrap;
}

#controls {
    display: flex;
    gap: 8px;
}

#controls button {
    background: rgba(10, 10, 15, 0.85);
    color: #c8c8d0;
    border: 1px solid rgba(200, 200, 208, 0.2);
    border-radius: 4px;
    padding: 6px 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

#controls button:hover {
    background: rgba(30, 30, 45, 0.9);
    border-color: rgba(200, 200, 208, 0.4);
}

#controls button:active {
    background: rgba(40, 40, 60, 0.95);
    border-color: rgba(200, 200, 208, 0.5);
}

#btn-sound, #btn-auto {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

#btn-sound svg, #btn-auto svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

#btn-sound.unmuted-hint {
    background: rgba(200, 60, 60, 0.3);
    border-color: rgba(220, 80, 80, 0.6);
    color: #f0a0a0;
}

#btn-sound.unmuted-hint:hover {
    background: rgba(200, 60, 60, 0.45);
    border-color: rgba(220, 80, 80, 0.8);
    color: #ffb8b8;
}

#btn-sound.unmuted-hint:active {
    background: rgba(200, 60, 60, 0.55);
}

#dashboard {
    position: absolute;
    top: 32px;
    right: 8px;
    width: 300px;
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
    scrollbar-width: thin;
    scrollbar-color: rgba(200,200,208,0.2) transparent;
}

#dashboard.hidden { display: none; }

#dash-close {
    position: sticky;
    top: 0;
    float: right;
    background: none;
    border: none;
    color: rgba(200,200,208,0.4);
    font-size: 8px;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    z-index: 1;
    padding: 2px 4px;
    margin: -4px -4px 2px 0;
}

#dash-close:hover {
    color: rgba(200,200,208,0.8);
}

.dash-panel {
    background: rgba(10, 10, 15, 0.92);
    border: 1px solid rgba(200, 200, 208, 0.12);
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.dash-panel:hover {
    border-color: rgba(200, 200, 208, 0.3);
}

#panel-auraMap {
    cursor: default;
}

.dash-panel h3 {
    font-size: 6px;
    color: rgba(200, 200, 208, 0.6);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dash-panel canvas {
    width: 100%;
    display: block;
    image-rendering: pixelated;
}

#chart-auraMap {
    cursor: pointer;
}

.dash-panel h3 .hint {
    font-size: 5px;
    opacity: 0.35;
    text-transform: none;
    letter-spacing: 0;
}

.dash-panel h3 .expand-btn {
    float: right;
    cursor: pointer;
    opacity: 0.3;
    font-size: 7px;
    transition: opacity 0.15s;
}

.dash-panel h3 .expand-btn:hover {
    opacity: 0.8;
}

/* ---- Chart Expand Overlay ---- */
#chart-expand {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.88);
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
}

#chart-expand.hidden { display: none; }

#chart-expand-title {
    font-size: 7px;
    color: rgba(200, 200, 208, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#chart-expand-canvas {
    background: rgba(10, 10, 15, 0.97);
    border: 1px solid rgba(200, 200, 208, 0.2);
    border-radius: 6px;
    cursor: default;
    image-rendering: pixelated;
}

/* ---- Info Overlay ---- */
#info-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.85);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

#info-overlay.hidden { display: none; }

#info-modal {
    background: rgba(10, 10, 15, 0.97);
    border: 1px solid rgba(200, 200, 208, 0.2);
    border-radius: 6px;
    padding: 20px 24px;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(200,200,208,0.2) transparent;
}

#info-modal h2 {
    font-size: 11px;
    margin-bottom: 14px;
    color: #e8e8f0;
    letter-spacing: 1px;
}

#info-content p {
    font-size: 7px;
    line-height: 2;
    margin-bottom: 8px;
    color: rgba(200, 200, 208, 0.75);
}

#info-content strong {
    color: #e8e8f0;
    font-size: 7px;
}

#info-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 10px;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
}

#info-close:hover {
    color: #ccc;
}

#inspector {
    position: absolute;
    bottom: 48px;
    left: 12px;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid rgba(200, 200, 208, 0.2);
    border-radius: 4px;
    padding: 10px;
    min-width: 180px;
    z-index: 20;
    font-size: 7px;
    line-height: 1.8;
}

#inspector.hidden { display: none; }

#inspector h3 {
    font-size: 7px;
    margin-bottom: 6px;
    color: #e8e8f0;
}

#inspector-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #888;
    font-size: 10px;
    cursor: pointer;
}

#inspector-content div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

#inspector-content .label { color: rgba(200,200,208,0.5); }
#inspector-content .value { color: #e8e8f0; }

/* ---- Tablet ---- */
@media (max-width: 1000px) {
    #canvas-container { width: 768px; height: 512px; }
    #top-bar { width: 768px; }
}

/* ---- Small tablet / large phone landscape ---- */
@media (max-width: 800px) {
    #canvas-container {
        width: min(100vw, calc((100dvh - 36px) * 1.5));
        height: min(calc(100dvh - 36px), calc(100vw / 1.5));
    }
    #top-bar { width: 100vw; padding: 6px 10px; }
    #hud { gap: 10px; font-size: 6px; }
    #controls { gap: 6px; }
    #controls button { font-size: 7px; padding: 5px 8px; }
    #minimap-canvas { width: 100px; height: 100px; bottom: 6px; right: 6px; }
    #dashboard { width: 240px; top: 36px; }
    #inspector { bottom: 40px; left: 8px; min-width: 160px; }
}

/* ---- Phone portrait ---- */
@media (max-width: 480px) {
    #top-bar {
        flex-direction: column;
        gap: 4px;
        padding: 4px 8px;
    }
    #hud { gap: 6px; font-size: 5px; flex-wrap: wrap; justify-content: center; }
    #controls { gap: 4px; }
    #controls button { font-size: 6px; padding: 5px 7px; }
    #canvas-container {
        width: min(100vw, calc((100dvh - 56px) * 1.5));
        height: min(calc(100dvh - 56px), calc(100vw / 1.5));
    }
    #minimap-canvas { width: 80px; height: 80px; bottom: 4px; right: 4px; }
    #dashboard {
        width: calc(100vw - 16px);
        left: 8px;
        right: 8px;
        top: 56px;
        max-height: calc(100dvh - 70px);
    }
    #inspector {
        bottom: auto;
        top: 60px;
        left: 8px;
        right: 8px;
        min-width: 0;
    }
    #info-modal {
        max-width: calc(100vw - 32px);
        padding: 16px;
    }
    #chart-expand-canvas {
        max-width: calc(100vw - 32px);
        max-height: calc(100dvh - 80px);
    }
}
