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

:root {
    --primary-color: #4a90e2;
    --secondary-color: #f39c12;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --dark-bg: #1a1a1a;
    --light-bg: #f5f5f5;
    --text-dark: #333;
    --text-light: #fff;
    --border-color: #ddd;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 40px;
    padding: 30px 0;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.3em;
    opacity: 0.9;
}

.main-nav {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.nav-button {
    background: var(--text-light);
    color: var(--primary-color);
    padding: 25px 40px;
    border-radius: 15px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.3s, box-shadow 0.3s;
    min-width: 200px;
}

.nav-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.nav-button .icon {
    font-size: 3em;
}

.nav-button .text {
    font-size: 1.2em;
    font-weight: bold;
}

.info-section {
    background: var(--text-light);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.info-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2em;
}

.info-section ol {
    margin-left: 20px;
    margin-bottom: 20px;
    line-height: 2;
}

.info-section li {
    margin-bottom: 10px;
}

.rules-info {
    background: #e8f4f8;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
    margin-top: 20px;
}

/* Playlist Page Styles */
.playlist-container {
    background: var(--text-light);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.playlist-header h2 {
    color: var(--primary-color);
    font-size: 2em;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-light);
}

.btn-primary:hover {
    background: #357abd;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-color);
    color: var(--text-light);
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: var(--danger-color);
    color: var(--text-light);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: #95a5a6;
    color: var(--text-light);
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.song-input {
    background: var(--light-bg);
    padding: 15px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
}

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

.song-input input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 0.95em;
}

.song-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.btn-fetch-title {
    background: var(--primary-color);
    color: var(--text-light);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
    padding: 5px 10px;
}

.btn-fetch-title:hover:not(:disabled) {
    background: #357abd;
    transform: scale(1.05);
}

.btn-fetch-title:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-preview-video {
    background: var(--success-color);
    color: var(--text-light);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
    padding: 5px 10px;
}

.btn-preview-video:hover:not(:disabled) {
    background: #28a745;
    transform: scale(1.05);
}

.btn-preview-video:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Runner Page Styles - Projector Optimized */
.runner-container {
    background: var(--dark-bg);
    color: var(--text-light);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
}

.runner-header {
    padding: 15px 20px;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    position: relative;
    z-index: 10;
    backdrop-filter: blur(5px);
    flex-shrink: 0;
    min-height: 70px;
}

.runner-header h1 {
    font-size: 2.5em;
    color: var(--text-light);
}

.runner-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.runner-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-bottom: 100px; /* Space for drawn balls */
    position: relative;
    overflow: hidden;
    min-height: 0; /* Allow flex shrinking */
}

.guessing-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 3;
    max-height: calc(100vh - 200px); /* Account for header and drawn balls */
    overflow: hidden;
}

.guess-message {
    font-size: 3.5em;
    font-weight: bold;
    color: var(--text-light);
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.5), 2px 2px 4px rgba(0,0,0,0.8);
    animation: pulse 2s infinite;
    position: relative;
    z-index: 3;
    line-height: 1.2;
    padding: 0 20px;
}

.music-controls-center {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    position: relative;
    z-index: 3;
    flex-shrink: 0;
}

.revealed-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 3;
    max-height: calc(100vh - 200px); /* Account for header and drawn balls */
    overflow: hidden;
}

.current-ball {
    font-size: 12em;
    font-weight: bold;
    color: var(--secondary-color);
    text-shadow: 0 0 30px rgba(243, 156, 18, 0.5), 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 20px;
    transition: transform 0.3s;
    position: relative;
    z-index: 3;
    line-height: 1;
}

.current-ball.animate {
    animation: pulse 0.5s;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.music-info {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 3;
    flex-shrink: 0;
}

.music-title {
    font-size: 2.5em;
    margin-bottom: 15px;
    color: var(--text-light);
    opacity: 0;
    transition: opacity 0.5s;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    position: relative;
    z-index: 3;
    line-height: 1.2;
    padding: 0 20px;
    text-align: center;
}

.music-title.revealed {
    opacity: 1;
}

.music-number {
    font-size: 2em;
    color: var(--secondary-color);
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    position: relative;
    z-index: 3;
}

.video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

/* Video starts below header */
.video-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px; /* Match header height */
    background: var(--dark-bg);
    z-index: 2;
}

.video-container.revealed {
    opacity: 1;
    pointer-events: auto;
}

.video-container iframe {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s, transform 0.3s;
    object-fit: cover;
}

.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.6) 100%);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

/* Overlay also starts below header */
.video-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px; /* Match header height */
    background: transparent;
    z-index: 1;
}

.video-overlay.revealed {
    opacity: 1;
}

.drawn-balls-container {
    position: fixed;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 0 10px;
    z-index: 100;
    max-height: 130px;
    overflow: hidden;
}

.drawn-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-content: flex-start;
    width: 90vw;
    max-width: calc(100vw - 20px);
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 12px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    align-items: center;
}

.drawn-ball {
    width: var(--ball-size, 50px);
    height: var(--ball-size, 50px);
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--ball-size, 50px) * 0.6);
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    flex-shrink: 0;
    transition: width 0.3s ease, height 0.3s ease, font-size 0.3s ease;
}

.drawn-ball.recent {
    animation: newBall 0.5s;
}

@keyframes newBall {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Grid Generator Page Styles */
.grids-container {
    background: var(--text-light);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.grids-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.grids-header h2 {
    color: var(--primary-color);
    font-size: 2em;
}

.grid-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.grid-controls input {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
}

.grids-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.grid-preview {
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    background: var(--light-bg);
}

.grid-preview h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* Print Styles */
@media print {
    @page {
        size: A4;
        margin: 1.5cm;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .no-print {
        display: none !important;
    }
    
    .grid-print {
        page-break-after: always;
        page-break-inside: avoid;
        padding: 0;
        margin-bottom: 0;
    }
    
    .grid-print:last-child {
        page-break-after: auto;
    }
    
    .grid-print h3 {
        margin-top: 0;
        margin-bottom: 15px;
        font-size: 1.5em;
    }
    
    .loto-grid {
        margin-bottom: 20px;
        border: 2px solid black;
    }
    
    .grid-cell {
        border: 1px solid #333;
        font-size: 1em;
    }
    
    .music-list {
        font-size: 0.85em;
        margin-top: 15px;
    }
    
    .music-list h4 {
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    .music-list-item {
        padding: 3px 0;
        font-size: 0.9em;
    }
}

.loto-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 5px;
    margin-bottom: 20px;
    border: 2px solid var(--text-dark);
    padding: 10px;
    border-radius: 5px;
}

.grid-cell {
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    background: var(--text-light);
}

.grid-cell.filled {
    background: #e8f4f8;
}

.music-list {
    margin-top: 20px;
    font-size: 0.9em;
}

.music-list-item {
    padding: 5px 0;
    border-bottom: 1px solid var(--border-color);
}

.music-list-item:last-child {
    border-bottom: none;
}

.status-message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.print-area {
    display: none;
}

@media print {
    .print-area {
        display: block;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: var(--text-light);
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--light-bg);
    color: var(--danger-color);
}

.modal-body {
    padding: 30px;
}

.playlist-item {
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 15px;
    background: var(--light-bg);
    transition: all 0.3s;
}

.playlist-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 10px rgba(74, 144, 226, 0.2);
}

.playlist-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.playlist-item-name {
    font-weight: bold;
    font-size: 1.2em;
    color: var(--primary-color);
}

.playlist-item-meta {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.playlist-item-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }
    
    .current-ball {
        font-size: 8em;
    }
    
    .music-title {
        font-size: 2em;
    }
    
    .playlist-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

