:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --error: #ef4444;
    --success: #22c55e;
    --cell-size: 40px;
    --radius: 12px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 2rem 1rem;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

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

header h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

header h1 span {
    color: var(--primary);
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.input-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    text-align: center;
}

.input-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
}

input[type="text"] {
    flex: 1;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
    text-transform: uppercase;
}

input[type="text"]:focus {
    border-color: var(--primary);
}

.language-switcher {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
}

.lang-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.lang-btn.active {
    border-color: var(--primary);
    background-color: #eef2ff;
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

#generate-btn,
.primary-btn {
    background-color: var(--primary);
    color: white;
}

#generate-btn:hover,
.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

.secondary-btn:hover {
    background-color: #cbd5e1;
}

.error-message {
    color: var(--error);
    margin-top: 1rem;
    font-weight: 500;
    min-height: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Puzzle Styles */
.puzzle-section {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.puzzle-container {
    overflow-x: auto;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 1rem;
}

.crossword-grid {
    display: grid;
    gap: 4px;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: 1px solid var(--border);
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.cell.empty {
    border: none;
    background-color: transparent;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    outline: none;
    background: transparent;
}

.cell.intersect {
    background-color: #f1f5f9;
    border: 2px solid var(--primary);
}

.cell .number {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.6rem;
    color: var(--text-muted);
}

.clues-container {
    width: 100%;
    max-width: 600px;
}

.clues-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.clues-header h2 {
    margin-bottom: 0;
    border-bottom: none;
}

#clue-type-select {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background-color: #f8fafc;
}

#clues-list {
    list-style: none;
    display: grid;
    gap: 1rem;
}

#clues-list li {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

#clues-list li .num {
    font-weight: 800;
    color: var(--primary);
    min-width: 25px;
}

#clues-list li .clue-content {
    flex: 1;
}

#clues-list li img {
    max-width: 150px;
    max-height: 40px;
    border-radius: 4px;
    display: block;
}

.actions {
    display: flex;
    gap: 1rem;
}

footer {
    text-align: center;
    margin-top: 4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    :root {
        --cell-size: 30px;
    }

    .input-group {
        flex-direction: column;
    }

    header h1 {
        font-size: 2rem;
    }

    .language-switcher {
        position: static;
        justify-content: center;
        margin-bottom: 1rem;
    }
}

@media print {

    header,
    .input-section,
    .actions,
    .language-switcher,
    #clue-type-select,
    footer {
        display: none !important;
    }

    body {
        background-color: white;
        padding: 0;
    }

    .container {
        max-width: 100%;
    }

    .puzzle-section {
        box-shadow: none;
        padding: 0;
        margin: 0;
        gap: 2rem;
    }

    .cell {
        border: 1px solid #000 !important;
    }

    .cell.empty {
        border: none !important;
    }

    .cell.intersect {
        background-color: #f8fafc !important;
        /* Kevyt harmaa risteyskohdassa auttaa hahmottamaan sanan */
        border: 2px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cell input {
        color: transparent !important;
        /* Tyhjennetään ruudut tulostusta varten */
    }

    .clues-container h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .answers-section {
        display: block !important;
        break-before: page;
        page-break-before: always;
        margin-top: 2rem;
        padding-top: 2rem;
        border-top: 2px dashed var(--border);
    }

    .answers-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        font-size: 0.9rem;
    }
}

.answers-section.print-only {
    display: none;
}

.answers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}