:root {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --accent-color: #9b59b6;
    /* Lavender */
    --accent-glow: #8e44ad;
    --cell-bg: #ffffff;
    --cell-text: #1a1a1a;
    --input-focus: #3498db;
    --success-color: #2ecc71;
    --font-main: 'Outfit', sans-serif;
    --grid-rows: 21;
    --grid-cols: 15;
    /* Calculate cell based on columns since width is constraint */
    --u-cell: min(60px, calc((100vw - 10px) / var(--grid-cols)));
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
}

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

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.2rem;
    color: #a0a0a0;
}

.game-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3rem;
    justify-content: center;
    max-width: 1200px;
    width: 100%;
}

.crossword-board {
    display: grid;
    gap: 2px;
    background-color: #333;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    /* Dynamic sizing */
    grid-template-columns: repeat(var(--grid-cols), var(--u-cell)) !important;
    grid-template-rows: repeat(var(--grid-rows), var(--u-cell)) !important;
    margin: 0 auto;
}

.cell {
    background-color: #2a2a2a;
    position: relative;
    width: var(--u-cell);
    height: var(--u-cell);
}

.cell.active {
    background-color: var(--cell-bg);
    transition: background-color 0.3s;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-family: var(--font-main);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cell-text);
    text-transform: uppercase;
    outline: none;
    cursor: pointer;
    caret-color: transparent;
    /* Hide cursor line, just show generic focus */
}

.cell input:focus {
    background-color: #e8f0fe;
}

.cell .number {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.75rem;
    color: #666;
    pointer-events: none;
}

.clues-container {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    background: #252525;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.clue-section {
    margin-bottom: 2rem;
}

.clue-section h3 {
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.clue-section ul {
    list-style: none;
}

.clue-section li {
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
    line-height: 1.4;
    cursor: pointer;
    transition: color 0.2s;
}

.clue-section li:hover,
.clue-section li.highlighted {
    color: var(--accent-color);
}

.clue-section li span {
    font-weight: 700;
    margin-right: 8px;
    color: var(--accent-glow);
}

.controls {
    margin-top: 1rem;
    width: 100%;
    display: flex;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: var(--font-main);
    font-weight: 600;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(108, 92, 231, 0.4);
}

.language-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.language-options button {
    min-width: 150px;
    margin: 10px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.5s;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: linear-gradient(160deg, #ffffff, #f0f0f0);
    color: #333;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(255, 255, 255, 0.2);
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.animate-pop {
    font-size: 3rem;
    background: linear-gradient(90deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.big-reveal {
    font-size: 2.5rem;
    font-weight: 800;
    color: #2d3436;
    margin-bottom: 0.5rem;
}

.sub-reveal {
    font-size: 1.8rem;
    color: #636e72;
    margin-bottom: 2rem;
}

.registry-link {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #fff0f5;
    border-radius: 12px;
    border: 1px dashed #ff9a9e;
}

.registry-link p {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.registry-btn {
    display: inline-block;
    background: #ff7675;
    color: white;
    text-decoration: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    transition: background 0.3s;
}

.registry-btn:hover {
    background: #d63031;
}

.btn-secondary {
    margin-top: 1.5rem;
    background: transparent;
    border: 1px solid #ccc;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .game-container {
        flex-direction: column;
        gap: 1.5rem;
    }

    .crossword-board {
        order: 1;
        /* Board first */
    }

    .clues-container {
        order: 2;
        /* Clues second */
        max-width: 100%;
    }

    .controls {
        order: 3;
    }

    .cell input {
        font-size: 1.2rem;
        /* Adjusted for smaller cells */
        padding: 0;
    }

    /* Prevent zoom on iOS */
    @media screen and (-webkit-min-device-pixel-ratio:0) {

        select,
        textarea,
        input {
            font-size: 16px !important;
        }
    }

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