/* === GAME PAGE OVERRIDES === */
/* Allow scrolling on game page */
body:has(.game-wrapper) {
    overflow-y: auto;
}

.main-content:has(.game-wrapper) {
    max-width: 100%;
    height: auto;
    min-height: 100vh;
    padding: 2rem;
    padding-left: 100px; /* Space for hamburger */
}

/* === GAME WRAPPER === */
.game-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.game-header {
    text-align: center;
    margin-bottom: 2rem;
}

.game-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--color-title);
}

.game-subtitle {
    font-size: 1.25rem;
    color: var(--color-text);
}

/* === GAME LAYOUT === */
.game-layout {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: nowrap;
}

.game-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

.game-center {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

.game-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

/* === GAME GRID === */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 100px);
    grid-template-rows: repeat(5, 100px);
    gap: 0;
    width: 406px; /* 4×100px + 2×3px border */
    border: 3px solid var(--color-text);
    background: #4a6741;
    position: relative;
}

.grid-cell {
    width: 100px;
    height: 100px;
    position: relative;
    cursor: pointer;
}

.tile-image, .house-image, .housetype-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    image-rendering: pixelated;
}

.tile-image {
    z-index: 1;
}

.house-image {
    z-index: 2;
}

.housetype-image {
    z-index: 3;
}

/* === ELIMINATED HOUSES (click-to-grey feature) === */
.grid-cell.house-eliminated .house-image,
.grid-cell.house-eliminated .housetype-image {
    filter: grayscale(100%) brightness(0.6);
    opacity: 0.5;
}

/* === CHARACTER CONTAINER === */
.character-container {
    width: 200px;
    display: grid;
    grid-template-columns: repeat(2, 100px);
    grid-template-rows: repeat(4, 100px);
    gap: 0;
    background-color: var(--color-bg);
    border: 3px solid var(--color-text);
    z-index: 10;
}

.character-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
}

/* Wrapper holds image + name together */
.character-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    user-select: none;
    pointer-events: auto;
    position: relative;
    transition: none;
}

.character-wrapper:active {
    cursor: grabbing;
}

.character-wrapper.dragging {
    opacity: 0.5;
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    transition: none;
}

.character-wrapper:hover .character {
    transform: scale(1.1);
}

/* Locked characters (correctly placed and accepted) */
.character-wrapper.locked {
    cursor: default;
    opacity: 0.95;
}

.character-wrapper.locked .character {
    filter: brightness(0.9);
}

.character-wrapper.locked:hover .character {
    transform: none;
}

/* Characters placed in the puzzle grid need high z-index */
.puzzle-grid .character-wrapper {
    z-index: 50;
}

.character-name {
    font-size: 12px;
    text-align: center;
    margin-top: 3px;
    color: var(--color-text);
    font-weight: bold;
    pointer-events: none;
}

/* === CHARACTERS === */
.character {
    width: 50px;
    height: 50px;
    cursor: grab;
    transition: transform 0.2s ease;
    pointer-events: none;
    z-index: 100;
}

/* === CHECK BUTTON === */
#check-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: bold;
    font-family: 'Walter Turncoat', cursive;
    background-color: var(--color-bg);
    color: var(--color-text);
    border: 3px solid var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

#check-btn:hover {
    background-color: var(--color-hover);
    color: var(--color-text);
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 var(--color-text);
}

#check-btn:active {
    transform: translate(0, 0);
    box-shadow: none;
}

/* === CLUE CONTAINER === */
.clue-container {
    width: 250px;
    background-color: var(--color-bg);
    border: 3px solid var(--color-text);
    padding: 1rem 1.25rem;
    box-sizing: border-box;
}

.clue-container h3 {
    margin: 0 0 0.75rem 0;
    color: var(--color-title);
}

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

#clue-list li {
    padding: 0.5rem 0;
    font-size: 14px;
    color: var(--color-text);
    border-bottom: 1px solid color-mix(in srgb, var(--color-text) 30%, transparent);
}

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

/* === GENERAL CLUE (Step 0) === */
.general-clue {
    color: var(--color-text);
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.general-clue:hover {
    opacity: 0.8;
}

/* === CROSSED OUT CLUES === */
.crossed-out {
    text-decoration: line-through;
    opacity: 0.5;
}

#clue-list li {
    cursor: pointer;
    user-select: none;
}

#clue-list li:hover {
    opacity: 0.8;
}

/* === STEP CLUES SECTION === */
.step-clues-header {
    font-size: 13px;
    color: var(--color-text);
    opacity: 0.8;
    margin: 0.75rem 0 0.5rem 0;
    font-weight: normal;
}

/* === GAME LOADING STATE === */
.game-wrapper.loading {
    visibility: hidden;
}

.game-wrapper.loading ~ .modal-overlay {
    visibility: visible;
}

/* === RESUME MODAL === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: color-mix(in srgb, var(--color-text) 50%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--color-bg);
    border: 3px solid var(--color-text);
    padding: 2rem;
    max-width: 400px;
    text-align: center;
    animation: modal-slide-in 0.3s ease;
}

@keyframes modal-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    color: var(--color-title);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--color-text);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    font-family: 'Walter Turncoat', cursive;
    border: 3px solid var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn-primary {
    background-color: var(--color-hover);
    color: var(--color-text);
}

.modal-btn-primary:hover {
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 var(--color-text);
}

.modal-btn-secondary {
    background-color: var(--color-bg);
    color: var(--color-text);
}

.modal-btn-secondary:hover {
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 var(--color-text);
}

.modal-btn:active {
    transform: translate(0, 0);
    box-shadow: none;
}

/* === COMPLETION MODAL === */
.completion-modal {
    text-align: center;
}

.completion-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-10px);
    }
}

.completion-modal h2 {
    color: var(--color-title);
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.completion-modal p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .main-content:has(.game-wrapper) {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .game-layout {
        flex-direction: column;
        align-items: center;
    }

    .game-header h1 {
        font-size: 2rem;
    }

    .clue-container {
        width: 100%;
        max-width: 410px;
    }
}
