/* --- Global Styles & Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap');

:root {
    --bg-color: #1a2a33;
    --board-bg: #1f3641;
    --text-color: #a8bec9;
    --accent-color-1: #31c3bd; /* Teal */
    --accent-color-2: #f2b137; /* Yellow/Orange */
    --danger-color: #db4455;
    --success-color: #32de84;
    --shadow-dark: #10212a;
    --font-family: 'Montserrat', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.game-container {
    width: 100%;
    height: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    text-align: center;
    padding: 1rem;
}

/* --- Screen Management --- */
.screen {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* --- Home Screen --- */
#home-screen {
    justify-content: center;
    gap: 2rem;
}

.title {
    font-size: 2.5rem;
}

.subtitle {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.difficulty-selection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- Game Screen --- */
#game-screen {
    justify-content: flex-start;
    gap: 1rem;
}

.game-header, .game-footer {
    padding: 0.5rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-shrink: 0;
}

#board-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    flex-grow: 1;
    min-height: 0;
}

.game-board {
    display: grid;
    /* CORRECTED LINES: Base size on height instead of width */
    height: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    gap: 5px;
    position: relative;
    overflow: hidden; /* This is the fix for the overlay */
}
/* --- Cells and Circles --- */
.cell {
    background-color: var(--board-bg);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

.cell.fixed {
    background-color: #24414e;
    cursor: not-allowed;
}

.cell:not(.fixed):hover {
    background-color: #2c4a58;
}

.circle {
    width: 70%;
    height: 70%;
    border-radius: 50%;
    transition: all 0.2s ease-in-out;
}

.circle.filled {
    background-color: var(--accent-color-1);
}

.circle.stroked {
    background-color: transparent;
    box-shadow: inset 0 0 0 4px var(--accent-color-2);
}

/* --- Relational Signs --- */
.sign {
    position: absolute;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: bold;
    pointer-events: none;
}

/* --- Buttons --- */
.btn {
    font-family: var(--font-family);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1rem;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--accent-color-2);
    color: var(--bg-color);
    border-bottom: 5px solid #cc8b13;
}
.btn:hover {
    filter: brightness(1.1);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 10px;
    transition: all 0.2s ease;
}
.btn-icon:hover {
    background-color: var(--board-bg);
    transform: scale(1.1);
}
.btn-icon svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
}

.btn-action {
    flex-grow: 1;
    margin: 0 0.5rem;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.75rem 0.5rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--text-color);
    color: var(--bg-color);
    border-bottom: 4px solid #6B8997;
}
.btn-action:hover {
    filter: brightness(1.1);
}

.btn-end {
    background-color: var(--danger-color);
    border-bottom-color: #a72836;
    color: white;
}
#restart-btn-footer {
    display: none;
}

/* --- Modals / Overlays --- */
.hidden {
    display: none !important;
}

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background-color: var(--board-bg);
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 90%;
    max-width: 400px;
}
.modal h2 {
    font-size: 1.8rem;
    color: white;
}
.modal p {
    font-size: 1.2rem;
}
.modal ul {
    text-align: left;
    list-style: none;
    padding: 0;
}
.modal li {
    margin-bottom: 0.75rem;
    line-height: 1.4;
}
.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}
.modal-buttons .btn {
    flex-grow: 1;
}
.modal-buttons .btn:first-child {
    background-color: var(--accent-color-1);
    border-bottom-color: #118c87;
}

/* --- Validation Visuals --- */
.invalid-overlay {
    position: absolute;
    background-color: rgba(219, 68, 85, 0.4);
    border-radius: 5px;
    pointer-events: none;
    z-index: 100;
    transition: opacity 0.3s;
}

.valid-blink {
    animation: blink-success 0.4s 2;
}

@keyframes blink-success {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 5px var(--success-color); }
}

