/* ── NEON DUNGEON Styles ──────────────────────────────────────── */

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

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

body {
    background: #050508;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    color: #ffffff;
}

#gameContainer {
    position: relative;
    width: 800px;
    height: 600px;
    border: 2px solid #1a1a3e;
    box-shadow: 0 0 30px rgba(90, 216, 255, 0.15), inset 0 0 30px rgba(0, 0, 0, 0.5);
    background: #0a0a12;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#gameCanvas    { z-index: 0; }
#effectsCanvas { z-index: 1; mix-blend-mode: screen; pointer-events: none; }
#uiCanvas      { z-index: 2; pointer-events: none; }

/* ── Overlay ── */
#overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 12, 0.85);
    backdrop-filter: blur(4px);
}

#overlay.active {
    display: flex;
}

/* ── Interact Prompt ── */
#interactPrompt {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    font-family: monospace;
    font-size: 12px;
    color: #ffcc00;
    text-shadow: 0 0 8px #ffcc00;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 12px;
    border-radius: 4px;
    display: none;
    pointer-events: none;
}

/* ── Menu Panels ── */
.menu-panel {
    text-align: center;
    padding: 30px 40px;
    max-width: 700px;
    max-height: 560px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333355 #0a0a12;
}

.neon-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 32px;
    color: #5ad8ff;
    text-shadow: 0 0 20px #5ad8ff, 0 0 40px #5ad8ff, 0 0 60px rgba(90, 216, 255, 0.3);
    margin-bottom: 10px;
    letter-spacing: 2px;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { text-shadow: 0 0 20px #5ad8ff, 0 0 40px #5ad8ff; }
    50% { text-shadow: 0 0 30px #5ad8ff, 0 0 60px #5ad8ff, 0 0 80px rgba(90, 216, 255, 0.4); }
}

.subtitle {
    color: #666688;
    font-size: 10px;
    margin-bottom: 30px;
    font-family: monospace;
}

/* ── Buttons ── */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.menu-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 12px 32px;
    background: transparent;
    color: #5ad8ff;
    border: 1px solid #5ad8ff;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 200px;
}

.menu-btn:hover {
    background: rgba(90, 216, 255, 0.15);
    box-shadow: 0 0 15px rgba(90, 216, 255, 0.3);
    transform: scale(1.02);
}

.menu-btn:active {
    transform: scale(0.98);
}

.back-btn {
    margin-top: 20px;
    font-size: 10px;
    padding: 8px 24px;
    color: #888888;
    border-color: #444444;
}

.back-btn:hover {
    color: #aaaaaa;
    border-color: #666666;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: none;
}

/* ── Character Select ── */
.char-grid {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.char-card {
    border: 1px solid #444;
    padding: 15px;
    width: 190px;
    text-align: left;
    background: rgba(20, 20, 40, 0.6);
    transition: all 0.2s;
}

.char-card:hover {
    background: rgba(30, 30, 60, 0.8);
    transform: translateY(-2px);
}

.char-card.locked {
    opacity: 0.4;
    pointer-events: none;
}

.char-card h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    margin-bottom: 8px;
}

.char-desc {
    font-size: 9px;
    color: #888;
    margin-bottom: 8px;
    font-family: monospace;
    line-height: 1.4;
}

.char-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 8px;
    font-family: monospace;
    color: #aaa;
    margin-bottom: 8px;
}

.char-stats span {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 4px;
}

.skill-desc {
    font-size: 8px;
    color: #9d7bff;
    font-family: monospace;
    margin-bottom: 8px;
    line-height: 1.3;
}

.cost-text {
    font-size: 9px;
    font-family: monospace;
    margin-bottom: 6px;
}

.char-select-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

.char-select-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.char-select-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gold-display {
    font-family: monospace;
    font-size: 12px;
    margin-bottom: 10px;
}

/* ── Upgrades ── */
.upgrades-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 15px 0;
}

.upgrade-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(20, 20, 40, 0.5);
    border: 1px solid #222244;
}

.upg-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #5ad8ff;
    min-width: 60px;
    text-align: left;
}

.upg-desc {
    font-size: 8px;
    color: #666;
    font-family: monospace;
    min-width: 80px;
}

.upg-level {
    font-size: 8px;
    color: #aaa;
    font-family: monospace;
    flex: 1;
    text-align: right;
}

.upg-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 4px 10px;
    background: transparent;
    color: #ffcc00;
    border: 1px solid #ffcc00;
    cursor: pointer;
    min-width: 60px;
    transition: all 0.2s;
}

.upg-btn:hover:not(:disabled) {
    background: rgba(255, 204, 0, 0.15);
}

.upg-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ── Settings ── */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 10px;
    font-family: monospace;
}

.setting-row label {
    color: #aaa;
}

.setting-row input[type="range"] {
    width: 150px;
    accent-color: #5ad8ff;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle input { display: none; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #333;
    border-radius: 20px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 2px; bottom: 2px;
    background: #888;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: #5ad8ff;
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

/* ── Inventory ── */
.inventory-panel {
    text-align: left;
    max-width: 600px;
}

.inventory-panel h2 {
    text-align: center;
    font-size: 14px;
    margin-bottom: 15px;
    color: #5ad8ff;
    font-family: 'Press Start 2P', monospace;
}

.inventory-panel h3 {
    font-size: 10px;
    color: #888;
    margin-bottom: 8px;
    font-family: monospace;
}

.equip-grid {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.equip-slot {
    border: 1px solid #333355;
    padding: 6px 10px;
    min-width: 120px;
    background: rgba(15, 15, 30, 0.5);
    font-size: 8px;
    font-family: monospace;
}

.slot-label {
    color: #666;
    font-size: 7px;
    margin-bottom: 3px;
}

.slot-item {
    font-size: 9px;
    margin-bottom: 3px;
}

.unequip-btn {
    font-size: 7px;
    padding: 2px 6px;
    background: transparent;
    color: #ff4757;
    border: 1px solid #ff4757;
    cursor: pointer;
    font-family: monospace;
}

.unequip-btn:hover {
    background: rgba(255, 71, 87, 0.15);
}

.inv-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.inv-slot {
    border: 1px solid #222244;
    padding: 6px;
    min-height: 50px;
    background: rgba(10, 10, 20, 0.5);
    font-size: 8px;
    font-family: monospace;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.inv-slot.has-item {
    background: rgba(20, 20, 45, 0.6);
}

.empty-slot {
    color: #333;
    text-align: center;
    line-height: 38px;
}

.inv-item-name {
    font-size: 8px;
    margin-bottom: 4px;
    line-height: 1.2;
}

.inv-item-actions {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.inv-btn {
    font-size: 7px;
    padding: 2px 5px;
    background: transparent;
    border: 1px solid;
    cursor: pointer;
    font-family: monospace;
    transition: all 0.15s;
}

.equip-btn { color: #39ff9f; border-color: #39ff9f; }
.equip-btn:hover { background: rgba(57, 255, 159, 0.15); }

.use-btn { color: #5ad8ff; border-color: #5ad8ff; }
.use-btn:hover { background: rgba(90, 216, 255, 0.15); }

.drop-btn { color: #666; border-color: #444; }
.drop-btn:hover { background: rgba(255, 255, 255, 0.05); color: #ff4757; border-color: #ff4757; }

.player-stats-summary {
    font-size: 9px;
    color: #888;
    font-family: monospace;
    text-align: center;
    padding: 8px;
    border-top: 1px solid #222244;
    margin-top: 10px;
}

/* ── Game Over / Victory ── */
.gameover-panel .neon-title,
.victory-panel .neon-title {
    font-size: 28px;
    margin-bottom: 20px;
}

.results {
    text-align: left;
    display: inline-block;
    margin: 15px 0;
    font-size: 10px;
    font-family: monospace;
    line-height: 2;
}

.results p {
    color: #888;
}

.gameover-panel .menu-btn,
.victory-panel .menu-btn {
    margin-top: 15px;
}

/* ── Scrollbar ── */
.menu-panel::-webkit-scrollbar {
    width: 4px;
}

.menu-panel::-webkit-scrollbar-track {
    background: #0a0a12;
}

.menu-panel::-webkit-scrollbar-thumb {
    background: #333355;
    border-radius: 2px;
}

/* ── Pause ── */
.pause-panel h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    color: #5ad8ff;
    margin-bottom: 25px;
}

/* ── Touch Controls (mobile) ───────────────────────────────────── */
#touch-controls {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    display: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.tc-dpad, .tc-actions {
    position: absolute;
    bottom: 14px;
    display: grid;
    gap: 6px;
    pointer-events: none;
}

.tc-dpad {
    left: 14px;
    width: 168px;
    height: 168px;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.tc-dpad .tc-up    { grid-area: 1 / 2 / 2 / 3; }
.tc-dpad .tc-left  { grid-area: 2 / 1 / 3 / 2; }
.tc-dpad .tc-right { grid-area: 2 / 3 / 3 / 4; }
.tc-dpad .tc-down  { grid-area: 3 / 2 / 4 / 3; }

.tc-actions {
    right: 14px;
    grid-template-columns: repeat(3, 56px);
    grid-auto-rows: 56px;
    justify-content: end;
}

.tc-btn {
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #e0e0f0;
    background: rgba(10, 10, 20, 0.55);
    border: 2px solid rgba(90, 216, 255, 0.55);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.08s, transform 0.08s;
}

.tc-btn:active {
    background: rgba(90, 216, 255, 0.35);
    transform: scale(0.94);
}

.tc-act {
    min-width: 56px;
    min-height: 56px;
    font-size: 12px;
}

.tc-attack   { border-color: rgba(255, 71, 87, 0.7);  color: #ff4757; }
.tc-skill    { border-color: rgba(157, 123, 255, 0.7); color: #9d7bff; }
.tc-dash     { border-color: rgba(57, 255, 159, 0.7);  color: #39ff9f; }
.tc-interact { border-color: rgba(255, 204, 0, 0.7);   color: #ffcc00; }
.tc-inv, .tc-pause { font-size: 10px; border-color: rgba(255,255,255,0.35); color: #bbb; }

/* Show controls on touch devices. Desktop keeps the keyboard-only layout. */
@media (pointer: coarse) {
    #touch-controls { display: block; }
}

/* Mobile viewport — scale the fixed 800x600 container to fit */
@media (max-width: 900px), (max-height: 700px) {
    html, body { overflow: hidden; }
    body { align-items: center; padding: 0; }
    #gameContainer {
        width: min(100vw, calc(100vh * 4 / 3));
        height: min(100vh, calc(100vw * 3 / 4));
        border-width: 1px;
    }
    #gameCanvas, #effectsCanvas, #uiCanvas {
        width: 100%;
        height: 100%;
    }
    .tc-dpad {
        width: 44vw;
        max-width: 168px;
        height: 44vw;
        max-height: 168px;
    }
    .tc-actions {
        grid-template-columns: repeat(3, 14vw);
        grid-auto-rows: 14vw;
    }
    .tc-act {
        min-width: 0;
        min-height: 0;
    }
}
