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

body {
    font-family: 'Alata', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #040506, #3f3a04);
    color: white;
    padding: 30px;
    text-align: center;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.content {
    padding: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.form-section {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #080505;
    box-shadow: 4px 4px 0 #040506;
    transition: all 0.25s ease-in-out;
}

.form-section:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #040506;
}

.section-title {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #040506;
    padding-bottom: 8px;
    border-bottom: 2px solid #eaeaea;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #444;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #06090e;
    border-radius: 8px;
    font-family: 'Alata', Arial, sans-serif;
    font-size: 1rem;
    background-color: #f0f4f8;
    transition: all 0.3s ease;
    box-shadow: 3px 3px 0 #040506;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: #4a6491;
    background-color: #ffffff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 100, 145, 0.2);
}

input[type="text"]:hover,
input[type="number"]:hover,
textarea:hover,
select:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #040506;
}

textarea {
    height: 200px;
    resize: vertical;
}

#words {
    width: 100%;
    height: 280px;
    padding: 12px 14px;
    font-size: 15px;
    font-family: 'Alata', Arial, sans-serif;
    color: #111;
    background-color: #fffef8;
    border: 2px solid #040506;
    border-radius: 10px;
    box-shadow: inset 2px 2px 6px rgba(0,0,0,0.15);
    line-height: 1.6;
    resize: vertical;
    white-space: pre;
    word-break: normal;
    overflow-x: auto;
    overflow-y: auto;
}

#words::selection {
    background: rgba(255, 204, 0, 0.45);
    color: #000;
}

#words:focus {
    outline: none;
    border-color: #ffdd00;
    box-shadow: 0 0 10px rgba(255, 220, 0, 0.5);
    background-color: #fffce8;
}

.controls {
    background: #f0f4f8;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    border: 2px solid #06090e;
    box-shadow: 4px 4px 0 #040506;
    transition: all 0.25s ease-in-out;
}

.controls:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #040506;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
}

.control-group {
    flex: 1;
    min-width: 200px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 12px;
    margin-bottom: 7px;
}

.hint {
    color: #666;
    font-size: 0.9rem;
    margin-top: 10px;
    line-height: 1.5;
}

.button-group {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 25px;
}

button {
    font-size: 1rem;
    padding: 14px 25px;
    border-radius: 12px;
    border: 2px solid #040506;
    background: #fff;
    color: #040506;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 3px 3px 0 #040506;
    position: relative;
    overflow: hidden;
    min-width: 180px;
    font-family: 'Alata', Arial, sans-serif;
}

button:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #040506;
}

button:active {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 #040506;
}

.generate-btn {
    background: linear-gradient(to bottom, #fff905, #fff7bf);
    border: 2px solid #040506;
    color: #060708;
    font-size: 1.1em;
    padding: 16px 30px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 3px 3px 0px #000;
    transition: all 0.2s ease-in-out;
}

.preview-btn {
    background: linear-gradient(to bottom, #0073aa, #005f87);
    color: white;
    border: 2px solid #040506;
}

.download-btn {
    display: none;
    background: linear-gradient(to bottom, #27a745, #1e7e34);
    color: white;
    border: 2px solid #040506;
    text-decoration: none;
    text-align: center;
}

.back-home-container {
    text-align: center;
    margin-bottom: 20px;
}

.back-home-btn {
    background: linear-gradient(to bottom, #fff905, #fff7bf);
    border: 2px solid #040506;
    color: #040506;
    font-weight: bold;
    font-family: 'Alata', Arial, sans-serif;
    font-size: 1rem;
    padding: 12px 25px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 3px 3px 0 #040506;
    transition: all 0.2s ease;
}

.back-home-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #040506;
    background: linear-gradient(to bottom, #fff7bf, #fff905);
}

.choose-bg-btn {
    background: linear-gradient(to bottom, #ffc107, #ffb300);
    border: 2px solid #040506;
    color: #333;
    border-radius: 8px;
    padding: 12px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 3px 3px 0 #040506;
    transition: all 0.2s ease;
    width: 100%;
    font-family: 'Alata', Arial, sans-serif;
}

.choose-bg-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #040506;
    background: linear-gradient(to bottom, #ffd54f, #ffc107);
}

.text-controls-section {
    margin-top: 20px;
    padding: 20px;
    background: #f0f4f8;
    border-radius: 12px;
    border: 2px solid #06090e;
    box-shadow: 4px 4px 0 #040506;
}

.text-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.text-control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.text-control-label {
    font-weight: bold;
    margin-bottom: 12px;
    font-size: 16px;
    color: #333;
}

.text-control-buttons {
    display: flex;
    gap: 10px;
}

.text-control-btn {
    padding: 10px 15px;
    font-size: 14px;
    background: #6c757d;
    min-width: 100px;
    border: 2px solid transparent;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0 #040506;
}

.text-control-btn.active {
    background: #4a6491;
    border-color: #040506;
}

.text-control-btn:hover {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #040506;
}

.card-preview-section {
    margin-top: 25px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 12px;
    border: 2px solid #080505;
    box-shadow: 4px 4px 0 #040506;
}

.preview-title {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #040506;
    text-align: center;
    font-weight: bold;
}

#preview-container {
    display: flex;
    justify-content: center;
    position: relative;
    min-height: 200px;
}

.bingo-card {
    background: white;
    border: 2px solid #040506;
    border-radius: 12px;
    width: 94.5mm;
    height: 133.65mm;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    page-break-inside: avoid;
    position: relative;
    overflow: hidden;
}

.card-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 1;
}

.card-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.card-title {
    font-weight: 700;
    font-size: 24px;
    margin: 12px 0;
    font-family: 'Alata', Arial, sans-serif;
    color: #333;
}

.grid {
    display: grid;
    width: 90%;
    height: 85%;
    border-collapse: collapse;
    flex-grow: 1;
    gap: 2px;
}

.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #040506;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    text-align: center;
    font-weight: 700;
    padding: 2px;
    line-height: 1.1;
    word-break: break-word;
    overflow: hidden;
    color: #222;
    position: relative;
}

.cell-text {
    display: inline-block;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: center;
    width: 100%;
    padding: 2px;
    max-height: 100%;
    transition: all 0.3s ease;
}

.cell-text.multiline {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.1;
}

.cell-text.multiline .word-part {
    display: block;
}

.cell-text.horizontal {
    transform: none;
}

.cell-text.vertical {
    transform: rotate(-90deg);
    white-space: nowrap;
}

.cell-text.diagonal {
    transform: rotate(-45deg);
    white-space: nowrap;
}

.cell-text.small {
    font-size: 10px !important;
}

.cell-text.medium {
    font-size: 14px !important;
}

.cell-text.large {
    font-size: 18px !important;
}

.free-cell {
    color: black;
    font-size: 28px;
    font-weight: 900;
}

.status-message {
    margin: 15px 0;
    padding: 10px;
    border-radius: 4px;
    display: none;
}

.status-message.success {
    background: #e8f5e9;
    color: #4ba924;
    border: 1px solid #4ba924;
    display: block;
}

.status-message.error {
    background: #ffebee;
    color: #b93f05;
    border: 1px solid #b93f05;
    display: block;
}

.loading {
    display: none;
    margin: 15px 0;
}

.loading.active {
    display: block;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #4a6fa5;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.captcha-section {
    background: #f9f9f9;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    display: none;
}

.captcha-section.active {
    display: block;
}

.captcha-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.captcha-progress {
    margin: 10px 0;
    font-weight: bold;
}

.captcha-question {
    font-size: 20px;
    margin: 15px 0;
    padding: 10px;
    background: white;
    border-radius: 5px;
    display: inline-block;
}

.captcha-input {
    font-size: 18px;
    padding: 8px;
    width: 80px;
    text-align: center;
    margin: 0 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.captcha-feedback {
    margin: 10px 0;
    font-weight: bold;
    min-height: 24px;
}

.captcha-feedback.correct {
    color: #4ba924;
}

.captcha-feedback.incorrect {
    color: #b93f05;
}

.captcha-complete {
    background: #e8f5e9;
    border: 2px solid #4ba924;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    display: none;
}

.captcha-complete.active {
    display: block;
}

.bg-modal {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
}

.bg-modal-content {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px 32px 32px;
    box-shadow: 0 0 0 2.5px #222, 0 8px 48px #1116;
    max-width: 1100px;
    width: 90vw;
    min-width: 350px;
    max-height: 95vh;
    overflow-y: auto;
    text-align: center;
    margin: auto;
    border: 2px solid #222;
}

.bg-modal-close-x {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 48px;
    height: 48px;
    background: #fff;
    border: 2.5px solid #222;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 32px;
    font-weight: bold;
    color: #222;
    box-shadow: 3px 3px 0 #040506;
    z-index: 10001;
    transition: all 0.2s ease;
}

.bg-modal-close-x:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #040506;
    background: #eee;
    border-color: #0b79d0;
    color: #0b79d0;
}

.bg-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 34px 32px;
    justify-items: center;
    margin-bottom: 18px;
    margin-top: 7px;
    width: 100%;
}

.bg-thumb-block {
    width: 220px;
    height: 330px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 3px 3px 0 #040506;
    border: 2px solid #040506;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
}

.bg-thumb-block.selected, .bg-thumb-block:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #040506;
    border: 2px solid #0b79d0;
}

.bg-thumb-block .bg-preview {
    width: 100%;
    height: 100%;
    border-radius: 12px 12px 0 0;
    display: block;
    box-shadow: none;
    border: none;
    margin: 0;
}

.recommendation-box {
    margin-top: 25px;
    background: linear-gradient(to bottom right, #fffde7, #fff9c4);
    border: 2px solid #040506;
    border-radius: 12px;
    padding: 18px 22px;
    box-shadow: 3px 3px 0 #040506;
    color: #222;
    font-family: 'Alata', Arial, sans-serif;
    line-height: 1.6;
}

.recommendation-box h3 {
    font-size: 1.15rem;
    color: #040506;
    margin-bottom: 10px;
    text-align: center;
}

.recommendation-box ul {
    list-style-type: "✔ ";
    margin: 10px 0 10px 20px;
    padding: 0;
}

.recommendation-box li {
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.features-box {
    margin-top: 30px;
    background: linear-gradient(to bottom right, #fffde7, #fff9c4);
    border: 2px solid #040506;
    border-radius: 14px;
    padding: 25px 28px;
    box-shadow: 3px 3px 0 #040506;
    color: #222;
    font-family: 'Alata', Arial, sans-serif;
    line-height: 1.7;
}

.features-box h3 {
    font-size: 1.3rem;
    color: #040506;
    text-align: center;
    margin-bottom: 18px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #040506;
    display: inline-block;
    padding-bottom: 5px;
}

.features-box ul {
    list-style-type: "⭐ ";
    margin: 0;
    padding: 0 0 0 25px;
}

.features-box li {
    font-size: 1rem;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.features-box li:hover {
    color: #000;
    transform: translateX(4px);
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .control-group {
        min-width: 100%;
    }
    
    .bg-list {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .options-grid {
        grid-template-columns: 1fr;
    }
    
    .bingo-card {
        width: 100%;
        max-width: 94.5mm;
        height: auto;
        aspect-ratio: 94.5 / 133.65;
    }
    
    .text-controls-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .bg-list {
        grid-template-columns: 1fr;
    }
    
    .text-control-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
}
