:root {
    --bg-dark: #050510;
    --text-glow: #e0d0a0;
    --accent: #d4af37; /* Gold Default */
    --accent-hover: #f3e5ab;
    --ui-bg: rgba(10, 10, 15, 0.75);
    --ui-border: rgba(212, 175, 55, 0.4);
    --danger: #ff4444;
    --success: #44ff44;
    --font-main: 'Montserrat', sans-serif;
    --font-cinematic: 'Cinzel', serif;
}

/* Phase Themes injected by JS */
body.theme-phase-1 { --accent: #d4af37; --accent-hover: #f3e5ab; --ui-border: rgba(212, 175, 55, 0.4); } /* Gold */
body.theme-phase-2 { --accent: #39ff14; --accent-hover: #a3ff99; --ui-border: rgba(57, 255, 20, 0.4); } /* Neon Green */
body.theme-phase-3 { --accent: #00ffff; --accent-hover: #99ffff; --ui-border: rgba(0, 255, 255, 0.4); } /* Cyan / Ice */
body.theme-phase-4 { --accent: #ff8c00; --accent-hover: #ffad5c; --ui-border: rgba(255, 140, 0, 0.4); } /* Copper / Gear */
body.theme-phase-5 { --accent: #ff0055; --accent-hover: #ff6699; --ui-border: rgba(255, 0, 85, 0.4); } /* Master Crimson */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #000;
    color: #fff;
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    touch-action: none; 
    transition: --accent 1s ease;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at center, #111, #000);
}

#game-container::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, transparent 40%, rgba(0,0,0,0.85) 100%);
    pointer-events: none;
    z-index: 2;
}

.screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 10;
    opacity: 0; pointer-events: none;
    transform: scale(1.05);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
    opacity: 1; pointer-events: auto; transform: scale(1);
}

.hidden { display: none !important; }

/* UI Elements */
.game-title {
    font-family: var(--font-cinematic);
    font-size: clamp(2rem, 8vw, 4.5rem);
    color: var(--accent);
    text-align: center;
    text-shadow: 0 0 10px rgba(var(--accent), 0.5), 0 0 20px rgba(var(--accent), 0.3);
    margin-bottom: 2rem;
    letter-spacing: 4px;
}

.glow-text {
    animation: glowText 2.5s infinite alternate ease-in-out;
}

@keyframes glowText {
    0% { filter: drop-shadow(0 0 5px var(--accent)); }
    100% { filter: drop-shadow(0 0 20px var(--accent-hover)); }
}

.btn {
    font-family: var(--font-cinematic);
    font-size: clamp(1rem, 4vw, 1.3rem);
    padding: 15px 35px;
    margin: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 3px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent) 0%, rgba(50,50,50,0.8) 100%);
    color: #fff;
    border: 2px solid var(--accent-hover);
    box-shadow: 0 4px 15px var(--ui-border), inset 0 0 10px rgba(255,255,255,0.5);
    text-shadow: 0 1px 2px #000;
}

.btn.primary:hover, .btn.primary:active {
    background: var(--accent-hover);
    color: #000;
    box-shadow: 0 6px 25px var(--ui-border), inset 0 0 15px rgba(255,255,255,0.7);
    transform: translateY(-2px) scale(1.02);
}

.btn.primary:active { transform: translateY(2px) scale(0.98); }

.btn.secondary {
    background: rgba(20, 20, 25, 0.85);
    color: var(--accent);
    border: 1px solid var(--ui-border);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.btn.secondary:hover, .btn.secondary:active {
    background: rgba(40, 40, 50, 0.95);
    border-color: var(--accent);
    color: var(--accent-hover);
    transform: translateY(-2px);
}

.btn.secondary:active { transform: translateY(2px) scale(0.98); }

/* Panels */
.panel-3d {
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    padding: clamp(20px, 5vw, 40px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.9), inset 0 0 30px rgba(255,255,255,0.05);
    backdrop-filter: blur(15px);
    display: flex; flex-direction: column; align-items: center;
}

.big-panel {
    width: 95%; max-width: 600px; max-height: 85vh; overflow-y: auto;
}
.big-panel::-webkit-scrollbar { width: 5px; }
.big-panel::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

.panel-3d h2 {
    font-family: var(--font-cinematic);
    color: var(--accent-hover);
    margin-bottom: 25px;
    font-size: clamp(1.8rem, 6vw, 2.5rem);
    text-align: center;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

/* Spinner */
.spinner {
    width: 60px; height: 60px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top: 4px solid var(--accent);
    border-right: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 20px auto;
    box-shadow: 0 0 20px var(--ui-border);
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Menu */
#main-menu .menu-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: url('../assets/images/thumbnail.png') no-repeat center center / cover;
    opacity: 0.9;
    filter: blur(2px) brightness(1.1) contrast(1.1);
    z-index: -1; transform: scale(1.05);
    animation: slowZoom 20s linear infinite alternate;
}
@keyframes slowZoom { 0% { transform: scale(1.05); } 100% { transform: scale(1.15); } }

.menu-content { display: flex; flex-direction: column; align-items: center; z-index: 5; }

.menu-icon {
    width: clamp(100px, 25vw, 150px);
    height: clamp(100px, 25vw, 150px);
    border-radius: 25px;
    box-shadow: 0 0 30px var(--ui-border), inset 0 0 10px rgba(255,255,255,0.3);
    margin-bottom: 25px;
    border: 3px solid var(--accent);
    animation: float 4s ease-in-out infinite;
}
@keyframes float {
    0% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-10px) scale(1.02); }
    100% { transform: translateY(0px) scale(1); }
}

.menu-buttons { display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 300px; }

/* Tutorial */
.tutorial-steps { display: flex; flex-direction: column; gap: 15px; margin-bottom: 30px; width: 100%; }
.step {
    display: flex; align-items: center; background: rgba(0,0,0,0.6);
    padding: 15px 20px; border-radius: 8px; border-left: 4px solid var(--accent);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5); font-size: clamp(0.9rem, 4vw, 1.1rem);
}
.step .icon { font-size: 1.8rem; margin-right: 20px; }

/* Environment */
#environment-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; z-index: 1; }
#bg-image {
    width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0;
    transition: filter 1s ease; transform: scale(1.05);
}

#objects-layer { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; 
}

.interactable-container {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transform: translate(-50%, -50%);
    z-index: 3;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.interactable-obj {
    /* Support for Realistic Images */
    width: clamp(80px, 20vw, 150px);
    height: auto;
    min-height: 80px;
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.interactable-obj img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 15px 15px rgba(0,0,0,0.8));
    transition: filter 0.3s ease, transform 0.3s ease;
}

/* Subtle Shimmer Overlay */
.interactable-obj::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    background-size: 200% 200%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: inherit;
}

.interactable-container:hover .interactable-obj::before, 
.interactable-container:active .interactable-obj::before {
    opacity: 1;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% { background-position: -200% -200%; }
    100% { background-position: 200% 200%; }
}

.room-item-name {
    background: linear-gradient(180deg, rgba(20,20,25,0.95), rgba(5,5,10,0.95));
    color: var(--accent);
    padding: 6px 15px;
    border-radius: 8px;
    font-size: clamp(0.75rem, 3vw, 1.1rem);
    border: 1px solid var(--accent);
    opacity: 0;
    white-space: nowrap;
    text-shadow: 0 2px 4px #000;
    margin-top: 10px;
    font-family: var(--font-cinematic);
    font-weight: 700;
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.9);
    transition: all 0.3s ease;
    transform: translateY(10px);
}

.interactable-container:hover .interactable-obj img {
    filter: drop-shadow(0 20px 25px rgba(0,0,0,0.9)) brightness(1.2);
    transform: scale(1.05);
}

.interactable-container:hover .room-item-name, 
.interactable-container:active .room-item-name { 
    opacity: 1; 
    transform: translateY(0px); 
}

#fx-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* In-Game UI Overlay */
#game-ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; display: flex; flex-direction: column; justify-content: space-between; }

.top-bar { padding: clamp(10px, 3vw, 20px); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0)); pointer-events: auto; }
.level-info { font-family: var(--font-cinematic); font-size: clamp(1.2rem, 5vw, 1.8rem); color: var(--accent); text-shadow: 0 2px 5px rgba(0,0,0,0.8), 0 0 10px var(--ui-border); }
.top-buttons { display: flex; gap: 10px; }

.icon-btn {
    background: rgba(20,20,25,0.8); border: 1px solid var(--ui-border); color: #fff;
    width: clamp(40px, 10vw, 50px); height: clamp(40px, 10vw, 50px); border-radius: 50%;
    font-size: clamp(1rem, 4vw, 1.3rem); cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.icon-btn:hover, .icon-btn:active { background: rgba(50,40,20,0.95); border-color: var(--accent); transform: scale(1.1); box-shadow: 0 4px 15px var(--ui-border); }
.icon-btn:active { transform: scale(0.95); }

/* Phase indicator text overlay */
#phase-title {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-family: var(--font-cinematic); color: var(--accent); font-size: clamp(2rem, 6vw, 4rem);
    text-shadow: 0 0 20px var(--accent-hover), 0 5px 15px rgba(0,0,0,0.9);
    letter-spacing: 5px; opacity: 0; pointer-events: none; z-index: 15; text-align: center;
}
.show-phase { animation: phaseAnim 3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
@keyframes phaseAnim {
    0% { opacity: 0; transform: translate(-50%, -40%) scale(0.9); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1.1); }
}

/* Inventory */
.inventory-bar {
    max-height: 30%; padding: 10px clamp(10px, 3vw, 20px); margin: 5px auto 15px; width: 95%; max-width: 650px;
    border-radius: 16px; pointer-events: auto;
    background: linear-gradient(to top, rgba(5,5,8,0.95), rgba(15,15,20,0.85)); border: 1px solid var(--ui-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.9), inset 0 0 15px rgba(255,255,255,0.05); backdrop-filter: blur(10px);
}

.inventory-slots { display: flex; gap: clamp(8px, 2vw, 15px); overflow-x: auto; padding-bottom: 5px; scrollbar-width: thin; }
.inventory-slots::-webkit-scrollbar { height: 4px; }
.inventory-slots::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

.inv-slot {
    width: clamp(60px, 18vw, 80px); height: clamp(60px, 18vw, 80px); min-width: clamp(60px, 18vw, 80px);
    background: rgba(30,30,35,0.9); border: 2px solid #222; border-radius: 10px;
    display: flex; justify-content: center; align-items: center; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; box-shadow: inset 0 0 15px rgba(0,0,0,0.8), 0 4px 6px rgba(0,0,0,0.4);
}
.inv-slot:hover { border-color: var(--accent); }
.inv-slot.active {
    border-color: var(--accent); background: rgba(50,40,20,0.9);
    box-shadow: inset 0 0 20px var(--ui-border), 0 0 15px var(--ui-border); transform: translateY(-5px) scale(1.05);
}
.inv-slot span { font-size: clamp(25px, 6vw, 40px); filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6)); }

/* Inspect */
.overlay-panel {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px); display: flex; justify-content: center; align-items: center; z-index: 20;
    pointer-events: auto; opacity: 0; transform: scale(1.1); transition: opacity 0.3s ease, transform 0.3s ease;
}
.overlay-panel:not(.hidden) { display: flex; opacity: 1; transform: scale(1); }

.inspect-content { position: relative; width: 90%; max-width: 450px; align-items: center; padding: clamp(15px, 5vw, 30px); }
.close-btn {
    position: absolute; top: -10px; right: -10px; width: 45px; height: 45px; border-radius: 50%;
    background: linear-gradient(135deg, #ff4444, #aa0000); color: #fff; border: 2px solid #fff;
    font-size: 1.5rem; cursor: pointer; box-shadow: 0 4px 15px rgba(255,0,0,0.5); z-index: 10; transition: transform 0.2s;
    display: flex; justify-content: center; align-items: center;
}
.close-btn:active { transform: scale(0.9); }

.inspect-view {
    width: 100%; height: clamp(200px, 50vw, 300px); /* Larger for realistic feel */
    background: radial-gradient(circle, rgba(60,60,70,0.9), rgba(5,5,10,1)); border: 2px solid var(--ui-border);
    border-radius: 16px; display: flex; justify-content: center; align-items: center; margin: 20px 0;
    position: relative; overflow: hidden; box-shadow: inset 0 0 50px rgba(0,0,0,0.9);
}
.inspect-view span { 
    font-size: clamp(100px, 25vw, 160px); 
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.9)) drop-shadow(0 0 40px var(--accent)); 
    transform: scale(1.1); 
    animation: inspectFloat 4s ease-in-out infinite;
}
@keyframes inspectFloat {
    0% { transform: translateY(0) scale(1.1); }
    50% { transform: translateY(-15px) scale(1.15); }
    100% { transform: translateY(0) scale(1.1); }
}

#inspect-desc { text-align: center; color: #ddd; font-style: italic; margin-bottom: 15px; font-size: clamp(0.9rem, 4vw, 1rem); line-height: 1.4; min-height: 2.8em; }

/* Puzzle Areas */
#puzzle-interaction-area { width: 100%; margin-top: 15px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.2); display: flex; flex-direction: column; align-items: center; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 2vw, 15px); max-width: 250px; margin: 0 auto; width: 100%; }
.num-btn {
    background: linear-gradient(180deg, #444, #222); color: #fff; border: 2px solid var(--ui-border);
    padding: clamp(10px, 4vw, 20px); font-size: clamp(1.2rem, 5vw, 1.8rem); font-family: var(--font-main);
    font-weight: 600; border-radius: 8px; cursor: pointer; box-shadow: inset 0 2px 0 rgba(255,255,255,0.2), 0 4px 10px rgba(0,0,0,0.8);
    transition: all 0.1s;
}
.num-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.1), 0 0 0 #000; background: linear-gradient(180deg, #555, #333); }

.puzzle-display {
    background: #050505; border: 3px inset #333; color: var(--accent); font-family: 'Courier New', Courier, monospace;
    font-size: clamp(1.8rem, 6vw, 2.5rem); font-weight: bold; text-align: center; padding: 10px; margin-bottom: 20px;
    letter-spacing: 8px; border-radius: 6px; box-shadow: inset 0 0 15px rgba(0,0,0,0.9), 0 0 10px var(--ui-border);
    text-shadow: 0 0 5px var(--accent); width: 100%; max-width: 250px;
}

/* Dialog Box */
#dialog-box {
    position: absolute; bottom: 35%; left: 50%; transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(20,20,30,0.95), rgba(5,5,10,0.95)); border: 2px solid var(--accent);
    padding: clamp(15px, 4vw, 20px) clamp(20px, 5vw, 40px); border-radius: 12px; text-align: center; color: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.9), inset 0 0 20px rgba(212,175,55,0.2); pointer-events: none; z-index: 15;
    opacity: 0; font-size: clamp(1rem, 4vw, 1.2rem); font-weight: 600; width: max-content; max-width: 90%; transition: opacity 0.3s ease, transform 0.3s ease;
}
.dialog-show { animation: dialogPopInOut 3.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes dialogPopInOut {
    0% { opacity: 0; transform: translate(-50%, 30px) scale(0.9); }
    10% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    85% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -20px) scale(0.95); }
}

/* Settings & Levels */
.setting-row { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 25px; font-size: clamp(1.1rem, 4vw, 1.3rem); border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 15px; }

.switch { position: relative; display: inline-block; width: 65px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #444; transition: .4s; border-radius: 34px; box-shadow: inset 0 2px 5px rgba(0,0,0,0.5); }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: #fff; transition: .4s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,0.5); }
input:checked + .slider { background-color: var(--accent); }
input:focus + .slider { box-shadow: 0 0 10px var(--accent); }
input:checked + .slider:before { transform: translateX(31px); }

.levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(60px, 15vw, 80px), 1fr)); gap: clamp(10px, 3vw, 20px); width: 100%; margin-top: 25px; padding: 10px; }
.level-btn {
    aspect-ratio: 1; background: rgba(30,30,40,0.8); border: 2px solid #555; border-radius: 12px; color: #fff;
    font-size: clamp(1.2rem, 5vw, 1.8rem); font-family: var(--font-cinematic); font-weight: bold; cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); display: flex; justify-content: center; align-items: center; box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.level-btn:hover:not(:disabled), .level-btn:active:not(:disabled) { background: var(--accent); color: #000; transform: scale(1.1); box-shadow: 0 0 20px var(--ui-border); }
.level-btn:disabled { opacity: 0.4; cursor: not-allowed; background: #111; box-shadow: inset 0 0 10px rgba(0,0,0,0.8); }
.level-btn.unlocked { border-color: var(--accent); color: var(--accent); background: rgba(20,20,30,0.9); }

.mt-20 { margin-top: 25px; }
