/* Reset and Variables */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #E91E63;
    --color-primary-dark: #C2185B;
    --color-secondary: #9C27B0;
    --color-background: #FAFAFA;
    --color-card: #FFFFFF;
    --color-text: #212121;
    --color-text-light: #757575;
    --color-free: #FFD700;
    --color-free-bg: #FFF8E1;
    --color-border: #E0E0E0;
    --color-success: #4CAF50;
    --color-error: #F44336;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.15);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.2);

    --transition-speed: 0.3s;
    --border-radius: 12px;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-background);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

/* App Container */
.app {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Header */
.header {
    text-align: center;
    padding: 16px 0;
    margin-bottom: 16px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Input Section */
.input-section {
    margin-bottom: 16px;
}

.label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text);
}

.label-hint {
    font-weight: 400;
    color: var(--color-text-light);
    font-size: 0.875rem;
}

.title-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-card);
    transition: border-color var(--transition-speed);
}

.title-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.items-textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-card);
    resize: vertical;
    min-height: 200px;
    font-family: inherit;
    line-height: 1.6;
    transition: border-color var(--transition-speed);
}

.items-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.items-textarea::placeholder {
    color: var(--color-text-light);
}

/* Counter */
.counter-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--color-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.counter {
    font-weight: 600;
    font-size: 0.9375rem;
}

.counter-status {
    font-size: 0.875rem;
}

.counter-status.ready {
    color: var(--color-success);
}

.counter-status.not-ready {
    color: var(--color-error);
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-card);
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-background);
    border-color: var(--color-primary);
}

.btn-back {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Hint Text */
.hint-text {
    margin-top: 16px;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.875rem;
}

/* Card View */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-number {
    font-weight: 600;
    color: var(--color-secondary);
}

.card-container {
    margin-bottom: 24px;
}

/* Bingo Card */
.bingo-card {
    background: var(--color-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bingo-title {
    background: var(--color-primary);
    color: white;
    text-align: center;
    font-weight: 700;
    font-size: 1.25rem;
    padding: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.bingo-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 2px;
    background: var(--color-border);
    flex: 1;
}

.bingo-cell {
    background: var(--color-card);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px;
    font-size: 0.75rem;
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
    overflow: hidden;
    aspect-ratio: 1;
}

.bingo-cell.free {
    background: var(--color-free-bg);
    color: var(--color-primary);
    font-weight: 700;
    font-size: 0.875rem;
}

/* Card Actions */
.card-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-text);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: calc(100% - 48px);
    text-align: center;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive - Tablet and up */
@media (min-width: 480px) {
    .bingo-cell {
        font-size: 0.8125rem;
        padding: 8px;
    }

    .bingo-cell.free {
        font-size: 1rem;
    }
}

@media (min-width: 768px) {
    .app {
        padding: 24px;
    }

    .logo {
        font-size: 1.75rem;
    }

    .items-textarea {
        min-height: 280px;
    }

    .bingo-cell {
        font-size: 0.875rem;
        padding: 10px;
    }

    .card-actions {
        flex-direction: row;
    }

    .card-actions .btn {
        flex: 1;
    }
}

/* Animations */
@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.bingo-cell {
    animation: popIn 0.3s ease backwards;
}

.bingo-cell:nth-child(1) { animation-delay: 0.01s; }
.bingo-cell:nth-child(2) { animation-delay: 0.02s; }
.bingo-cell:nth-child(3) { animation-delay: 0.03s; }
.bingo-cell:nth-child(4) { animation-delay: 0.04s; }
.bingo-cell:nth-child(5) { animation-delay: 0.05s; }
.bingo-cell:nth-child(6) { animation-delay: 0.06s; }
.bingo-cell:nth-child(7) { animation-delay: 0.07s; }
.bingo-cell:nth-child(8) { animation-delay: 0.08s; }
.bingo-cell:nth-child(9) { animation-delay: 0.09s; }
.bingo-cell:nth-child(10) { animation-delay: 0.1s; }
.bingo-cell:nth-child(11) { animation-delay: 0.11s; }
.bingo-cell:nth-child(12) { animation-delay: 0.12s; }
.bingo-cell:nth-child(13) { animation-delay: 0.13s; }
.bingo-cell:nth-child(14) { animation-delay: 0.14s; }
.bingo-cell:nth-child(15) { animation-delay: 0.15s; }
.bingo-cell:nth-child(16) { animation-delay: 0.16s; }
.bingo-cell:nth-child(17) { animation-delay: 0.17s; }
.bingo-cell:nth-child(18) { animation-delay: 0.18s; }
.bingo-cell:nth-child(19) { animation-delay: 0.19s; }
.bingo-cell:nth-child(20) { animation-delay: 0.2s; }
.bingo-cell:nth-child(21) { animation-delay: 0.21s; }
.bingo-cell:nth-child(22) { animation-delay: 0.22s; }
.bingo-cell:nth-child(23) { animation-delay: 0.23s; }
.bingo-cell:nth-child(24) { animation-delay: 0.24s; }
.bingo-cell:nth-child(25) { animation-delay: 0.25s; }
