:root {
    --bg-color: #0d0d12;
    --room-bg: rgba(20, 24, 35, 0.4);
    --room-border: rgba(90, 100, 150, 0.2);
    --primary: #5c85ff;
    --neon-yellow: #facc15;
    --neon-blue: #3b82f6;
    --neon-red: #ef4444;
    --neon-green: #22c55e;
    --neon-teal: #14b8a6;
    --neon-orange: #f97316;
    --neon-uncolored: #94a3b8;
    --font-ui: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --scale: 1;
}

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

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 50% 50%, #1a1e2b 0%, #050508 100%);
    color: white;
    font-family: var(--font-ui);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    touch-action: none;
    -webkit-touch-callout: none;
}

#game-wrapper {
    position: relative;
    width: 1400px;
    height: 980px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.05);
    background: repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 20px),
                repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 20px);
    transform-origin: center center;
    transform: scale(var(--scale));
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* Rooms */
.room {
    position: absolute;
    background: var(--room-bg);
    border: 2px solid var(--room-border);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    transform: scale(0.95);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
    display: none;
}

.room.revealed {
    opacity: 1;
    transform: scale(1);
    display: block;
}

.room-title {
    font-family: var(--font-heading);
    color: rgba(255,255,255,0.3);
    font-size: 1.2rem;
    position: absolute;
    top: 10px;
    width: 100%;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 4px;
    z-index: 10;
}

/* Hardcoded room dimensions based on index.html data attributes */
#room-main { left: 560px; top: 70px; width: 280px; height: 840px; }
#room-1 { left: 140px; top: 70px; width: 420px; height: 280px; }
#room-2 { left: 840px; top: 70px; width: 420px; height: 280px; }
#room-3 { left: 140px; top: 350px; width: 420px; height: 280px; }
#room-4 { left: 840px; top: 350px; width: 420px; height: 280px; }
#room-5 { left: 140px; top: 630px; width: 420px; height: 280px; }
#room-6 { left: 840px; top: 630px; width: 280px; height: 280px; }
#room-f1 { left: 1120px; top: 630px; width: 140px; height: 280px; }

/* Doors */
.door {
    position: absolute;
    background: #555;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: all 0.5s ease;
    z-index: 20;
}
.door.unlocked {
    pointer-events: none;
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.08);
    opacity: 0.7;
    animation: doorPulse 2s ease-in-out infinite alternate;
}
@keyframes doorPulse {
    0% { border-color: rgba(255, 255, 255, 0.15); }
    100% { border-color: rgba(255, 255, 255, 0.35); }
}

.pad-mini { position: absolute; top: -15px; left: 10px; font-size: 10px; font-family: monospace; color: cyan; background: black; padding: 2px; border: 1px solid cyan; }
.exit-sign { position: absolute; top: 0px; left: 10px; font-size: 12px; font-family: var(--font-heading); color: var(--neon-green); font-weight: bold; }

/* Player */
#player {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    left: 0;
    top: 0;
    z-index: 100;
    transition: opacity 0.3s;
}
.player-core {
    width: 100%; height: 100%; border-radius: 50%;
    background: #fff; box-shadow: 0 0 15px #fff;
    position: relative; z-index: 2;
}
.player-glow {
    position: absolute; width: 40px; height: 40px; border-radius: 50%; left: -8px; top: -8px;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 70%);
    z-index: 1; animation: pulse 2s infinite alternate;
}

@keyframes pulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.2); opacity: 0.8; } }

/* Items */
.item { position: absolute; animation: hover 2s ease-in-out infinite alternate; }
@keyframes hover { from { transform: translateY(0px) rotate(45deg); } to { transform: translateY(-5px) rotate(45deg); } }

.item.picked { display: none; }
.item-key {
    width: 24px; height: 24px; background-color: #fff;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.65 10C11.83 7.67 8.98 6.5 6.65 7.32c-2.33.82-3.5 3.67-2.68 6 1.13 3.2 5.17 3.5 6.68.8l4.35 4.35V20h2v-2h2v-2h-2v-3.35L12.65 10zm-3.65 2c-.83 0-1.5-.67-1.5-1.5S8.17 9 9 9s1.5.67 1.5 1.5S9.83 12 9 12z"/></svg>') center/contain no-repeat;
    mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.65 10C11.83 7.67 8.98 6.5 6.65 7.32c-2.33.82-3.5 3.67-2.68 6 1.13 3.2 5.17 3.5 6.68.8l4.35 4.35V20h2v-2h2v-2h-2v-3.35L12.65 10zm-3.65 2c-.83 0-1.5-.67-1.5-1.5S8.17 9 9 9s1.5.67 1.5 1.5S9.83 12 9 12z"/></svg>') center/contain no-repeat;
}
.item-lever {
    width: 14px; height: 26px; background-color: #fff;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="4" r="4"/><rect x="10" y="8" width="4" height="16"/></svg>') center/contain no-repeat;
    mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="4" r="4"/><rect x="10" y="8" width="4" height="16"/></svg>') center/contain no-repeat;
}

.bg-yellow { background-color: var(--neon-yellow) !important; filter: drop-shadow(0 0 6px var(--neon-yellow)); }
.bg-blue { background-color: var(--neon-blue) !important; filter: drop-shadow(0 0 6px var(--neon-blue)); }
.bg-red { background-color: var(--neon-red) !important; filter: drop-shadow(0 0 6px var(--neon-red)); }
.bg-green { background-color: var(--neon-green) !important; filter: drop-shadow(0 0 6px var(--neon-green)); }
.bg-teal { background-color: var(--neon-teal) !important; filter: drop-shadow(0 0 6px var(--neon-teal)); }
.bg-orange { background-color: var(--neon-orange) !important; filter: drop-shadow(0 0 6px var(--neon-orange)); }
.bg-white { background-color: #fff !important; filter: drop-shadow(0 0 6px #fff); }
.bg-uncolored { background-color: #eee !important; filter: drop-shadow(0 0 6px #eee); }

/* Key Fragments */
.item-key.frag { border-radius: 0; }
.item-key.half-left { 
    -webkit-mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 10C11.83 7.67 8.98 6.5 6.65 7.32c-2.33.82-3.5 3.67-2.68 6 1.13 3.2 5.17 3.5 6.68.8l1.35 1.35V20h-0.5z"/></svg>') center/contain no-repeat; 
    mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 10C11.83 7.67 8.98 6.5 6.65 7.32c-2.33.82-3.5 3.67-2.68 6 1.13 3.2 5.17 3.5 6.68.8l1.35 1.35V20h-0.5z"/></svg>') center/contain no-repeat; 
}
.item-key.half-right { 
    -webkit-mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 10v7h2v-2h2v-2h-2v-3.35L12 10z"/></svg>') center/contain no-repeat; 
    mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 10v7h2v-2h2v-2h-2v-3.35L12 10z"/></svg>') center/contain no-repeat; 
}

/* Vents */
.vent {
    position: absolute;
    width: 42px; height: 42px;
    background: repeating-linear-gradient(0deg, #333 0px, #333 4px, #111 4px, #111 8px);
    border: 2px solid #555;
    box-shadow: inset 0 0 10px #000;
}
#vent-shelf { right: 14px; top: 168px; }
#vent-switch { left: 14px; bottom: 14px; }

/* Shelves Clue */
.shelf-rack {
    position: absolute; right: 56px; top: 49px; width: 84px; height: 217px;
    background: rgba(0,0,0,0.5); border: 2px solid #444; display: flex; flex-direction: column; justify-content: space-around; padding: 5px;
}
.shelf { width: 100%; height: 2px; background: #555; position: relative; display: flex; align-items: flex-end; justify-content: flex-start; gap: 2px; margin-bottom: 25px;}
.book { width: 6px; height: 18px; background: #888; margin-bottom: 2px; border-radius: 1px; }

/* Control switches */
.switch-panel { position: absolute; top: 56px; left: 56px; width: 168px; height: 80px; background: #222; border-radius: 5px; border: 2px solid #555; display: flex; justify-content: space-around; align-items: center; padding: 5px; }
.toggle-switch { width: 56px; height: 60px; background: #111; border: 1px solid #444; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; position: relative; padding: 2px 0; }
.sw-name { font-size: 10px; color: #888; font-weight: bold; }
.sw-state { font-size: 10px; margin-top: auto; margin-bottom:2px; color: var(--neon-red);}
.toggle-switch.on .sw-state { color: var(--neon-green); }

.slot { width: 6px; height: 16px; background: #000; position: absolute; top: 12px; border-radius: 2px; }
.lever-handle { width: 8px; height: 14px; background: #aaa; border: 1px solid #fff; border-radius: 2px; position: absolute; top: 6px; left: -1px; transform: scaleY(1); transition: 0.3s; }
.toggle-switch.on .lever-handle { transform: translateY(-7px); }
.missing .lever-handle { display: none; }

/* Item positioning handled by data inline coordinates */

/* Fans */
.fan { position: absolute; background: rgba(0,0,0,0.6); overflow: hidden; }
#fan-1 { top: 14px; left: 14px; width: 294px; height: 210px; border: 2px dashed #444; }
#fan-2 { top: 14px; left: 14px; width: 392px; height: 182px; border: 2px dashed #444; }
.fan-housing { width: 100%; height: 50px; background: #111; position: absolute; top: 0; left: 0; border-bottom: 2px solid #555; display:flex; justify-content:center; align-items:center;}
#fan-2 .fan-housing { top: auto; bottom: 0; border-bottom: none; border-top: 2px solid #555;}
.blades { width: 40px; height: 40px; background: conic-gradient(from 0deg, #333 0deg 30deg, transparent 30deg 120deg, #333 120deg 150deg, transparent 150deg 240deg, #333 240deg 270deg, transparent 270deg 360deg); border-radius: 50%;}
.on .blades { animation: spin 0.2s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.wind-overlay { width: 100%; height: 100%; position: absolute; top:0; left:0; display:none; pointer-events: none;}
.on .wind-overlay { display: block; }
.wind-lines { width: 100%; height: 100%; background: linear-gradient(180deg, transparent 20%, rgba(255,255,255,0.1) 50%, transparent 80%); background-size: 100% 200%; animation: windUp 0.5s linear infinite; }
.wind-lines.down { animation: windDown 0.5s linear infinite; }
@keyframes windUp { 0% { background-position: 0 200%; } 100% { background-position: 0 0; } }
@keyframes windDown { 0% { background-position: 0 0; } 100% { background-position: 0 200%; } }

/* UI Layer */
#hud-top { position: absolute; top: 20px; left: 20px; width: calc(100% - 40px); font-family: var(--font-heading); color: var(--neon-uncolored); font-weight: 800; font-size: 24px; letter-spacing: 2px;}

#inventory { position: absolute; right: 20px; bottom: 20px; background: rgba(10,10,15,0.8); border: 1px solid #333; backdrop-filter: blur(10px); padding: 15px; border-radius: 8px; width: 200px; height: 80px; display: flex; flex-direction: column; }
#inventory h3 { font-size: 10px; text-transform: uppercase; color: #888; margin-bottom: 10px;}
#inv-slots { display: flex; gap: 8px; }
.inv-item { width: 26px; height: 26px; transform: rotate(45deg); margin-left: 5px; }

#interaction-prompt { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.2); padding: 10px 20px; border-radius: 20px; backdrop-filter: blur(5px); font-weight: 600; display:flex; align-items: center; gap: 10px; z-index: 1000;}
.key-icon { background: #fff; color: #000; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-weight: bold; font-size: 12px;}

#dialogue-box { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); width: 400px; background: rgba(10,10,15,0.9); border: 2px solid var(--primary); padding: 20px; border-radius: 8px; z-index: 1001; animation: toastIn 0.3s ease-out; transition: opacity 0.3s; }
#dialogue-box.hint::after { content: 'SPACE to dismiss'; display: block; font-size: 11px; color: #888; margin-top: 10px; text-align: right; font-family: var(--font-heading); letter-spacing: 1px; }
@keyframes toastIn { from { transform: translateX(-50%) translateY(20px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
.prompt { display: block; font-size: 11px; color: #888; margin-top: 10px; text-align: right; }

.overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 2000; display: flex; justify-content: center; align-items: center; opacity: 1; transition: opacity 0.3s;}
.hidden { opacity: 0; pointer-events: none; }

.glass-panel { background: rgba(20,25,35,0.8); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 40px; text-align: center; box-shadow: 0 0 40px rgba(0,0,0,0.8); }
.glass-panel h2 { font-family: var(--font-heading); color: var(--neon-uncolored); margin-bottom: 30px; letter-spacing: 2px;}

/* Puzzles UI */
.bottles-display { display: flex; gap: 8px; justify-content: center; margin-bottom: 30px; align-items:flex-end; height:120px; border-bottom:2px solid #333;}
.bottle-ui { width: 34px; height: 100%; background: repeating-linear-gradient(to top, transparent, transparent calc(25% - 2px), rgba(255,255,255,0.2) calc(25% - 2px), rgba(255,255,255,0.2) 25%), rgba(255,255,255,0.05); border: 2px solid #555; border-radius: 4px; border-top-left-radius: 12px; border-top-right-radius: 12px; display: flex; align-items: flex-end; position: relative; transition: 0.2s; overflow: hidden; }
.bottle-ui.selected { border-color: var(--neon-orange); box-shadow: 0 0 15px rgba(249, 115, 22, 0.4); }
.bottle-fill { width: 100%; background: var(--neon-orange); transition: height 0.2s ease;}

.levers-display { display: flex; gap: 20px; justify-content: center; margin-bottom: 30px;}
.lever-ui { width: 40px; height: 100px; background: #111; border: 2px solid #444; border-radius: 4px; position: relative; display: flex; justify-content: center; align-items: center; transition: 0.2s;}
.lever-ui.selected { border-color: var(--neon-blue); box-shadow: 0 0 15px rgba(59, 130, 246, 0.4); }
.lever-ui::before { content:''; position:absolute; width:4px; height:70%; background:#000; border-radius:2px; }
.lever-ui-handle { width:16px; height:24px; background:#aaa; border:1px solid #fff; border-radius:4px; z-index:2; position:absolute; top:10px; transition:top 0.2s;}
.lever-ui.on .lever-ui-handle { top:66px; }

/* In-game visual props */
.bs-col { height:100%; width:10%; }
.bs-col.full { background:#854; border:1px solid #321; }
.bs-col.half { background:#643; border:1px solid #321; height:60%; align-self:flex-end; }
.bs-col.empty { background:transparent; }
.bottle-mini { width:10px; height:100%; background:rgba(255,255,255,0.1); border:1px solid #444; border-top-left-radius:4px; border-top-right-radius:4px; position:relative; overflow: hidden; }
.bottle-mini::after { content:''; position:absolute; bottom:0; left:0; width:100%; background:var(--neon-orange); height:var(--level, 0%); transition:height 0.2s; }
.clue-paper { background:#ffd; padding:4px 8px; color:#222; font-family:monospace; font-weight:bold; font-size:18px; transform:rotate(-5deg); box-shadow:2px 2px 5px rgba(0,0,0,0.5); display:inline-block; }

.controls-hint { font-size: 12px; color: #888; margin-top: 15px;}

/* End UI */
.gradient-text { font-family: var(--font-heading); font-size: 4rem; background: -webkit-linear-gradient(45deg, var(--neon-green), #fff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 15px; }
.btn { background: var(--primary); color: #fff; border: none; padding: 12px 24px; font-size: 16px; border-radius: 4px; cursor: pointer; margin-top: 20px; font-family: var(--font-heading); font-weight: bold; transition: 0.2s; }
.btn:hover { background: #fff; color: var(--primary); box-shadow: 0 0 15px #fff; }

.death { border-color: var(--neon-red); }
.wasted-text { font-family: var(--font-heading); font-size: 4rem; color: var(--neon-red); text-shadow: 0 0 20px var(--neon-red); margin-bottom: 15px; }

/* Start Screen */
.start-panel {
    border-color: var(--neon-blue);
    box-shadow: 0 0 60px rgba(59, 130, 246, 0.15);
    padding: 50px 60px;
}

.start-title {
    font-family: var(--font-heading);
    font-size: 5rem;
    font-weight: 900;
    letter-spacing: 6px;
    background: linear-gradient(135deg, var(--neon-blue), #a78bfa, #fff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    margin-bottom: 8px;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.3)); }
    100% { filter: drop-shadow(0 0 25px rgba(167, 139, 250, 0.5)); }
}

.start-subtitle {
    color: #666;
    font-size: 1rem;
    letter-spacing: 8px;
    font-family: var(--font-heading);
    margin-bottom: 40px;
}

.level-select {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.level-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 200px;
    padding: 30px 20px;
    background: rgba(15, 18, 28, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    margin-top: 0;
}

.level-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(167, 139, 250, 0.05));
    opacity: 0;
    transition: opacity 0.3s;
}

.level-btn:hover {
    border-color: var(--neon-blue);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.2), inset 0 0 30px rgba(59, 130, 246, 0.05);
    transform: translateY(-4px);
    background: rgba(20, 24, 40, 0.95);
}

.level-btn:hover::before {
    opacity: 1;
}

.level-num {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.06);
    line-height: 1;
    margin-bottom: 8px;
    transition: color 0.3s;
}

.level-btn:hover .level-num {
    color: rgba(59, 130, 246, 0.25);
}

.level-name {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: #ccc;
    letter-spacing: 2px;
    margin-bottom: 10px;
    transition: color 0.3s;
}

.level-btn:hover .level-name {
    color: #fff;
}

.level-desc {
    font-size: 0.75rem;
    color: #555;
    letter-spacing: 1px;
    transition: color 0.3s;
}

.level-btn:hover .level-desc {
    color: #888;
}

/* Keypad UI */
.keypad-display { display: flex; gap: 15px; justify-content: center; margin-bottom: 30px;}
.digit { width: 60px; height: 80px; background: #000; border: 2px solid #333; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 40px; font-family: monospace; font-weight: bold; color: #555; transition: 0.2s;}
.digit.selected { border-color: var(--neon-blue); color: var(--neon-blue); box-shadow: 0 0 15px rgba(59, 130, 246, 0.4); }

/* Quit Button */
.btn-quit {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.4);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-quit:hover {
    border-color: var(--neon-red);
    color: var(--neon-red);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

/* ─── Virtual Touch Controls ────────────── */
#touch-controls {
    display: none; /* hidden by default, shown via JS on touch devices */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 180px;
    padding: 10px 30px 20px;
    justify-content: space-between;
    align-items: center;
    z-index: 9999;
    pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 60%, transparent 100%);
}

#touch-controls.visible {
    display: flex;
}

/* D-Pad */
#dpad {
    display: grid;
    grid-template-columns: 60px 60px 60px;
    grid-template-rows: 60px 60px 60px;
    gap: 4px;
    pointer-events: auto;
}

#dpad-up    { grid-column: 2; grid-row: 1; }
#dpad-left  { grid-column: 1; grid-row: 2; }
#dpad-right { grid-column: 3; grid-row: 2; }
#dpad-down  { grid-column: 2; grid-row: 3; }
.dpad-center { grid-column: 2; grid-row: 2; }

.dpad-btn {
    width: 60px;
    height: 60px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(20, 24, 40, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.dpad-btn:active, .dpad-btn.pressed {
    background: rgba(59, 130, 246, 0.35);
    border-color: var(--neon-blue);
    color: #fff;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), inset 0 0 10px rgba(59, 130, 246, 0.15);
    transform: scale(0.92);
}

.dpad-center {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 14px;
}

/* Action Button */
#touch-action {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid rgba(250, 204, 21, 0.3);
    background: rgba(20, 24, 40, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--neon-yellow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.1);
}

#touch-action:active, #touch-action.pressed {
    background: rgba(250, 204, 21, 0.25);
    border-color: var(--neon-yellow);
    box-shadow: 0 0 30px rgba(250, 204, 21, 0.4), inset 0 0 15px rgba(250, 204, 21, 0.1);
    transform: scale(0.92);
}

.action-icon {
    font-size: 28px;
    line-height: 1;
}

.action-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    opacity: 0.7;
}

/* Prompt visibility: show keyboard hint by default, touch hint on touch devices */
.prompt-touch {
    display: none;
}

.prompt-keyboard {
    display: inline-block;
}

/* ─── Touch-device Media Query ─────────── */
@media (pointer: coarse) {
    .prompt-touch {
        display: inline-block;
    }
    .prompt-keyboard {
        display: none;
    }

    .controls-hint {
        display: none;
    }

    /* Move inventory to left side so it doesn't overlap the action button */
    #inventory {
        right: auto;
        left: 20px;
    }
}

/* Responsive scaling is computed dynamically by JS (computeScale) */
/* iPad landscape adjustments */
@media (max-width: 1400px) and (orientation: landscape) {
    #inventory {
        width: 150px;
        padding: 10px;
    }

    #hud-top {
        font-size: 18px;
    }
}

/* Taller touch controls on smaller screens */
@media (max-height: 768px) and (pointer: coarse) {
    #touch-controls {
        height: 150px;
        padding: 8px 20px 12px;
    }

    .dpad-btn {
        width: 50px;
        height: 50px;
        border-radius: 12px;
    }

    #dpad {
        grid-template-columns: 50px 50px 50px;
        grid-template-rows: 50px 50px 50px;
    }

    .dpad-center {
        width: 50px;
        height: 50px;
    }

    #touch-action {
        width: 85px;
        height: 85px;
    }

    .action-icon {
        font-size: 22px;
    }
}
