:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --background-start: #f3f4f6;
    --background-end: #e5e7eb;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--background-start), var(--background-end));
    color: var(--text-color);
    overflow: hidden; /* Prevent body scroll, handle content scroll inside */
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--primary-color);
}

.controls button {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
    transition: all 0.2s;
}

.controls button:hover {
    background: var(--background-start);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

#game-container {
    flex: 1;
    display: flex;
    gap: 1rem;
    overflow: hidden; /* Prevent overflow */
    position: relative;
}

#game-canvas {
    flex: 2; /* Takes more space */
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    /* Canvas size is controlled by JS, but max-width helps */
    max-width: 100%;
    max-height: 100%;
    touch-action: none; /* Disable default touch actions for canvas */
}

#clues-container {
    flex: 1;
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1rem;
    overflow-y: auto;
    min-width: 250px;
}

#clues-container h2 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

#clues-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#clues-list li {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    line-height: 1.4;
    transition: background-color 0.2s;
    cursor: pointer;
}

#clues-list li:last-child {
    border-bottom: none;
}

#clues-list li:hover {
    background-color: var(--background-start);
}

#clues-list li.completed {
    text-decoration: line-through;
    color: var(--text-muted);
    background-color: #f9fafb;
}

footer {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.1rem;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.hidden {
    display: none !important;
}

.modal {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal h2 {
    color: var(--primary-color);
    margin-top: 0;
}

.modal button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0.5rem;
    transition: background-color 0.2s, transform 0.1s;
}

.modal button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.modal button:active {
    transform: translateY(0);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
    }

    #game-canvas {
        flex: none; /* Let canvas define its height based on width */
        width: 100%;
        /* Ideally maintain aspect ratio or fix height */
        height: 50vh;
    }

    #clues-container {
        flex: 1;
        min-height: 200px;
    }
}
