:root {
    --primary-color: #facc15;
    /* Yellow */
    --accent-color: #fbbf24;
    --bg-dark: transparent;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-light: #4e4e49;
    /* Dark text for light bg */
    --text-dim: #e9e769;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    /* Prevent selection on UI elements usually */
}

body {
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-light);
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass through to canvas where no UI exists */
}

/* Enable pointer events on active UI elements */
.screen,
.modal,
.hud-header,
.riddle-display,
.chat-container,
button,
input {
    pointer-events: auto;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.primary-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Loading Screen */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: rgba(20, 20, 30, 0.9);
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.modal-content ul {
    text-align: left;
    margin: 1rem 0;
    padding-left: 1.5rem;
    color: var(--text-dim);
}

#about-modal {
    color: var(--text-dim);
}

/* Persistent Home/Audio Controls */
#controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
    /* Above most things, below modal if needed, but modals are usually 100 */
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

#controls button {
    width: 60px;
    height: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

#controls button:hover {
    transform: scale(1.1);
}

.modal-content li {
    margin-bottom: 0.5rem;
}

.modal-content li {
    margin-bottom: 0.5rem;
}

/* Game HUD */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.hud-header {
    display: flex;
    justify-content: space-between;
}

.level-info {
    font-size: 1.2rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Chat & Riddle Area */
/* For layout, we push chat to bottom right or bottom center */
.riddle-display {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    text-align: center;
}

#riddle-image-placeholder {
    width: 150px;
    height: 150px;
    object-fit: contain;
    border-radius: 12px;
    margin: 0 auto 10px;
    display: block;
    background: transparent;
    /* box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); */
}

#riddle-hint-text {
    font-style: italic;
    font-size: 1.4rem;
}

.chat-container {
    align-self: flex-end;
    /* Or center bottom */
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.85);
    /* Darker for readability */
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 350px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.msg.user {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
}

.msg.ai {
    align-self: flex-start;
    background-color: #334155;
    color: #e2e8f0;
}

.msg.system {
    align-self: center;
    background-color: transparent;
    color: #ffd700;
    font-style: italic;
    font-size: 0.8rem;
    text-align: center;
}

.chat-input-area {
    display: flex;
    border-top: 1px solid var(--glass-border);
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
}

#player-input {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #475569;
    background: #1e293b;
    color: white;
    outline: none;
}

#player-input:focus {
    border-color: var(--primary-color);
}

#send-btn {
    margin-left: 10px;
    background: url('../image/Ask.png');
    background-size: cover;
    background-position: center;
    padding: 0 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
}

#send-btn:hover {
    scale: 1.1;
}

.send-icon {
    height: 24px;
    width: auto;
    vertical-align: middle;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}