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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    min-height: 100vh;
    padding: 20px;
    color: #212529;
}

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

.header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.title-input {
    font-size: 24px;
    font-weight: 600;
    border: none;
    border-bottom: 2px dashed #dee2e6;
    padding: 8px 0;
    outline: none;
    background: transparent;
    color: #212529;
    min-width: 260px;
}

.title-input:focus {
    border-bottom-color: #4dabf7;
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.grid-selector {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-label {
    font-size: 12px;
    color: #495057;
    font-weight: 600;
}

.grid-btn {
    background: white;
    border: 2px solid #e9ecef;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.grid-btn:hover {
    border-color: #4dabf7;
}

.control-input {
    background: white;
    border: 2px solid #e9ecef;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    min-width: 110px;
    transition: all 0.2s;
}

.control-input:focus {
    border-color: #4dabf7;
    outline: none;
}

.grid-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 8px;
    display: none;
    z-index: 100;
    min-width: 100px;
}

.grid-dropdown.show {
    display: block;
}

.grid-option {
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.grid-option:hover {
    background: #e7f5ff;
}

.grid-option.active {
    background: #228be6;
    color: white;
}

.cards-count {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: #495057;
}

.cards-count input {
    width: 110px;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.cards-count input:focus {
    border-color: #4dabf7;
}

.cards-per-page {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: #495057;
}

.cards-per-page select {
    width: 130px;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.cards-per-page select:focus {
    border-color: #4dabf7;
}

.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: #228be6;
    color: white;
}

.btn-primary:hover {
    background: #1c7ed6;
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
}

.btn-secondary:hover {
    background: #dee2e6;
}

.download-btn {
    background: #40c057;
    color: white;
}

.download-btn:hover {
    background: #37b24d;
}

.ai-btn {
    background: #4f883d;
    color: white;
}

.section {
    margin-bottom: 28px;
}

.section-title {
    font-weight: 700;
    margin-bottom: 12px;
    color: #212529;
}

.bingo-grid {
    display: grid;
    gap: 2px;
    background: #212529;
    border: 2px solid #212529;
    border-radius: 8px;
    overflow: hidden;
}

.bingo-grid.editable {
    margin-bottom: 8px;
}

.bingo-cell {
    background: white;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    min-height: 80px;
}

.bingo-cell:hover {
    background: #f8f9fa;
}

.bingo-cell.has-content {
    background: white;
}

.cell-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    text-align: center;
}

.cell-text {
    font-size: 18px;
    font-weight: 600;
    color: #212529;
    word-break: break-word;
}

.cell-image {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.cell-placeholder {
    color: #adb5bd;
    font-size: 24px;
}

.cell-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.bingo-cell:hover .cell-delete {
    display: flex;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.card {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-title {
    font-weight: 600;
    font-size: 14px;
    color: #495057;
}

.card .bingo-grid {
    border-radius: 6px;
    border: 1px solid #adb5bd;
    gap: 1px;
    background: #adb5bd;
}

.card .bingo-cell {
    min-height: 60px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding-top: 40px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    color: #212529;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #868e96;
    padding: 4px;
}

.modal-close:hover {
    color: #212529;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.size-checkboxes,
.lang-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: #495057;
}

.size-checkboxes label,
.lang-radios label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.input-section {
    margin-bottom: 24px;
}

.input-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
}

.text-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.text-input:focus {
    border-color: #4dabf7;
}

.full-width {
    width: 100%;
    margin-top: 12px;
    justify-content: center;
}

.divider {
    text-align: center;
    color: #868e96;
    margin: 20px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #e9ecef;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.category-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.category-tab {
    padding: 8px 16px;
    background: #f1f3f4;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    color: #495057;
}

.category-tab:hover {
    background: #e9ecef;
}

.category-tab.active {
    background: #228be6;
    color: white;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
}

.image-item {
    aspect-ratio: 1;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.image-item:hover {
    border-color: #4dabf7;
    transform: scale(1.05);
}

.image-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .title-input {
        width: 100%;
    }

    .image-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
