:root {
            --felt-green: #0d5c2e;
            --felt-dark: #094122;
            --wood-brown: #5c3d2e;
            --wood-light: #8b6914;
            --gold: #d4af37;
            --gold-light: #f4cf67;
            --cream: #f5f0e1;
            --red-ball: #d32f2f;
            --yellow-ball: #fdd835;
            --green-ball: #2e7d32;
            --brown-ball: #5d4037;
            --blue-ball: #1565c0;
            --pink-ball: #e91e63;
            --black-ball: #212121;
            --white-ball: #fafafa;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            font-family: 'Source Sans Pro', sans-serif;
            background: linear-gradient(145deg, #1a1a1a 0%, #2d2d2d 100%);
            min-height: 100vh;
            color: var(--cream);
            overflow-x: hidden;
        }

        /* Wood frame border effect */
        .app-frame {
            min-height: 100vh;
            padding: 12px;
            background: 
                linear-gradient(90deg, var(--wood-brown) 0%, var(--wood-light) 50%, var(--wood-brown) 100%);
        }

        .app-container {
            background: var(--felt-green);
            min-height: calc(100vh - 24px);
            border-radius: 8px;
            position: relative;
            overflow: hidden;
        }

        /* Felt texture overlay */
        .app-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
            opacity: 0.03;
            pointer-events: none;
        }

        /* Navigation Tabs */
        .nav-tabs {
            display: flex;
            background: var(--felt-dark);
            border-bottom: 3px solid var(--gold);
        }

        .nav-tab {
            flex: 1;
            padding: 12px 16px;
            text-align: center;
            font-family: 'Playfair Display', serif;
            font-size: 16px;
            font-weight: 600;
            color: var(--cream);
            opacity: 0.6;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
            background: transparent;
            position: relative;
        }

        .nav-tab.active {
            opacity: 1;
            background: var(--felt-green);
        }

        .nav-tab.active::after {
            content: '';
            position: absolute;
            bottom: -3px;
            left: 20%;
            right: 20%;
            height: 3px;
            background: var(--gold-light);
        }

        .nav-ball {
            display: inline-block;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: radial-gradient(circle at 30% 30%, #ef5350, #d32f2f);
            vertical-align: middle;
            margin-right: 4px;
            box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3);
        }

        /* Page containers */
        .page {
            display: none;
            padding: 12px;
            position: relative;
            z-index: 1;
        }

        .page.active {
            display: block;
        }

        /* ============ GAME PAGE ============ */
        
        /* Session info bar */
        .session-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: rgba(0,0,0,0.3);
            padding: 8px 16px;
            border-radius: 8px;
            margin-bottom: 12px;
        }

        .session-date {
            font-size: 13px;
            opacity: 0.8;
        }

        .frame-indicator {
            font-family: 'Playfair Display', serif;
            font-size: 16px;
            color: var(--gold);
        }

        .session-score {
            font-size: 20px;
            font-weight: 700;
            letter-spacing: 2px;
        }

        /* Scoreboard */
        .scoreboard {
            display: grid;
            grid-template-columns: 1fr auto 1fr;
            gap: 12px;
            margin-bottom: 12px;
        }

        .player-score {
            background: rgba(0,0,0,0.4);
            border-radius: 10px;
            padding: 12px;
            text-align: center;
            position: relative;
            border: 2px solid transparent;
            transition: all 0.3s ease;
        }

        .player-score.active {
            border: 6px solid var(--gold);
            box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
        }

        .player-score.active::before {
            content: '▶';
            position: absolute;
            left: 6px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--gold);
            font-size: 16px;
        }

        .player-name {
            font-family: 'Playfair Display', serif;
            font-size: 22px;
            margin-bottom: 4px;
            color: var(--gold-light);
        }

        .player-points {
            font-size: 72px;
            font-weight: 700;
            line-height: 1;
            margin-bottom: 4px;
        }

        .player-break-container {
            font-size: 28px;
            opacity: 0.8;
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .player-break-container span {
            color: var(--gold);
            font-weight: 700;
            font-size: 32px;
        }

        .break-sequence {
            display: flex;
            gap: 6px;
            align-items: center;
        }

        .break-ball {
            width: 44px;
            height: 44px;
            border-radius: 50%;
            border: 3px solid rgba(0, 0, 0, 0.4);
            box-shadow: 
                inset -4px -4px 8px rgba(0, 0, 0, 0.3),
                inset 4px 4px 8px rgba(255, 255, 255, 0.3),
                0 4px 8px rgba(0, 0, 0, 0.3);
        }

        .break-ball.red { background: radial-gradient(circle at 30% 30%, #ff4444, #cc0000); }
        .break-ball.yellow { background: radial-gradient(circle at 30% 30%, #ffed4e, #f9d71c); }
        .break-ball.green { background: radial-gradient(circle at 30% 30%, #4caf50, #2e7d32); }
        .break-ball.brown { background: radial-gradient(circle at 30% 30%, #8d6e63, #5d4037); }
        .break-ball.blue { background: radial-gradient(circle at 30% 30%, #42a5f5, #1565c0); }
        .break-ball.pink { background: radial-gradient(circle at 30% 30%, #ec407a, #c2185b); }
        .break-ball.black { background: radial-gradient(circle at 30% 30%, #424242, #212121); }

        /* Ballenspoor (v6.0): live verloop van het frame onderaan het scherm */
        .frame-trail {
            --trail-johan: #e8c24a;
            --trail-dirk: #6fc3e6;
            display: flex;
            height: 150px;
            margin-top: 16px;
            background: var(--felt-dark);
            border: 1px solid rgba(212, 175, 55, 0.35);
            border-radius: 10px;
            overflow: hidden;
        }
        .trail-names {
            flex: none;
            display: grid;
            grid-template-rows: 1fr 1fr;
            padding: 0 10px 0 14px;
            font-weight: 700;
            font-size: 14px;
            border-right: 1px solid rgba(245, 240, 225, 0.12);
        }
        .trail-names span { align-self: center; }
        .trail-names .johan { color: var(--trail-johan); }
        .trail-names .dirk { color: var(--trail-dirk); }
        .trail-scroll {
            flex: 1;
            min-width: 0;
            overflow-x: auto;
            overflow-y: hidden;
            scrollbar-width: thin;
            -webkit-overflow-scrolling: touch;
        }
        .trail-empty {
            height: 100%;
            display: flex;
            align-items: center;
            padding: 0 16px;
            color: rgba(245, 240, 225, 0.5);
            font-style: italic;
        }
        .trail-track {
            display: flex;
            gap: 14px;
            height: 100%;
            min-width: 100%;
            width: max-content;
            padding: 0 16px;
            /* middellijn tussen Johan (boven) en Dirk (onder) */
            background: linear-gradient(transparent calc(50% - 0.5px), rgba(245, 240, 225, 0.15) calc(50% - 0.5px), rgba(245, 240, 225, 0.15) calc(50% + 0.5px), transparent calc(50% + 0.5px));
        }
        .trail-turn {
            flex: none;
            display: grid;
            grid-template-rows: 1fr 1fr;
        }
        .trail-cell {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 8px 0;
        }
        /* Johan: ballen tegen de middellijn, totaal erboven. Dirk: ballen tegen de middellijn, totaal eronder. */
        .trail-turn.johan .trail-cell { grid-row: 1; flex-direction: column-reverse; justify-content: flex-start; }
        .trail-turn.dirk .trail-cell { grid-row: 2; flex-direction: column; justify-content: flex-start; }
        .trail-balls {
            display: flex;
            align-items: center;
            gap: 3px;
            min-height: 26px;
        }
        .trail-ball.break-ball {
            width: 22px;
            height: 22px;
            flex: none;
            border-width: 1.5px;
            box-shadow:
                inset -2px -2px 4px rgba(0, 0, 0, 0.3),
                inset 2px 2px 4px rgba(255, 255, 255, 0.3);
        }
        .trail-ball.fb { outline: 2px solid var(--cream); outline-offset: 2px; }
        .trail-points {
            font-weight: 700;
            font-size: 15px;
            font-variant-numeric: tabular-nums;
            line-height: 1;
        }
        .trail-turn.johan .trail-points { color: var(--trail-johan); }
        .trail-turn.dirk .trail-points { color: var(--trail-dirk); }
        .trail-miss {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: rgba(245, 240, 225, 0.4);
        }
        .trail-foul {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #ff6b5b;
            font-weight: 700;
            line-height: 1;
        }
        .trail-foul span { font-size: 18px; }
        .trail-foul small { font-size: 11px; font-weight: 600; white-space: nowrap; }
        /* Reeks beurten zonder pot (v6.2): één puntje op de middellijn */
        .trail-turn.misses { display: flex; align-items: center; }

        /* Ballenspoor in de Historie (v6.1): compacter, onder de frame-score */
        .frame-trail.compact { height: 112px; margin: -4px 0 14px; }
        .frame-trail.compact .trail-names { font-size: 12px; padding: 0 8px 0 10px; }
        .frame-trail.compact .trail-track { gap: 10px; padding: 0 10px; }
        .frame-trail.compact .trail-cell { padding: 4px 0; gap: 2px; }
        .frame-trail.compact .trail-balls { min-height: 20px; gap: 2px; }
        .frame-trail.compact .trail-ball.break-ball { width: 16px; height: 16px; border-width: 1px; }
        .frame-trail.compact .trail-points { font-size: 13px; }
        @media (min-width: 768px) {
            #session-modal .modal-content { max-width: 900px; }
        }

        .vs-divider {
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Playfair Display', serif;
            font-size: 18px;
            color: var(--gold);
            opacity: 0.6;
        }

        /* Ball buttons */
        .balls-section {
            flex: 0 0 auto;
        }

        .section-title {
            font-family: 'Playfair Display', serif;
            font-size: 13px;
            color: var(--gold);
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 2px;
        }

        .balls-grid {
            display: flex;
            justify-content: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .ball-btn {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            border: 3px solid rgba(255,255,255,0.3);
            cursor: pointer;
            font-size: 22px;
            font-weight: 700;
            color: white;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
            transition: all 0.15s ease;
            position: relative;
            box-shadow: 
                inset -4px -4px 8px rgba(0,0,0,0.4),
                inset 4px 4px 8px rgba(255,255,255,0.2),
                0 4px 8px rgba(0,0,0,0.3);
        }

        .ball-btn:active {
            transform: scale(0.95);
            box-shadow: 
                inset -2px -2px 4px rgba(0,0,0,0.4),
                inset 2px 2px 4px rgba(255,255,255,0.2),
                0 2px 4px rgba(0,0,0,0.3);
        }

        .ball-btn.red { background: radial-gradient(circle at 30% 30%, #ef5350, var(--red-ball)); }
        .ball-btn.yellow { background: radial-gradient(circle at 30% 30%, #ffee58, var(--yellow-ball)); color: #333; }
        .ball-btn.green { background: radial-gradient(circle at 30% 30%, #66bb6a, var(--green-ball)); }
        .ball-btn.brown { background: radial-gradient(circle at 30% 30%, #8d6e63, var(--brown-ball)); }
        .ball-btn.blue { background: radial-gradient(circle at 30% 30%, #42a5f5, var(--blue-ball)); }
        .ball-btn.pink { background: radial-gradient(circle at 30% 30%, #f48fb1, var(--pink-ball)); }
        .ball-btn.black { background: radial-gradient(circle at 30% 30%, #616161, var(--black-ball)); }

        .ball-btn .ball-points {
            position: absolute;
            bottom: -6px;
            right: -6px;
            background: var(--gold);
            color: #333;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            font-size: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }

        /* Red balls counter */
        .reds-remaining {
            font-size: 26px;
            opacity: 0.9;
            margin-bottom: 8px;
        }

        .reds-remaining span {
            color: var(--red-ball);
            font-weight: 700;
        }

        .expected-ball-indicator {
            font-size: 26px;
            padding: 6px 12px;
            background: rgba(0,0,0,0.3);
            border-radius: 20px;
        }

        .expected-ball-indicator span {
            font-weight: 700;
        }

        .info-and-balls-container {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 30px;
            margin-bottom: 10px;
        }

        .ball-info-text {
            flex: 0 0 auto;
            text-align: left;
        }

        .free-ball-btn {
            padding: 12px 24px;
            border-radius: 8px;
            border: 2px solid var(--gold);
            background: rgba(0, 100, 0, 0.6);
            color: var(--gold);
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            margin-bottom: 10px;
            display: inline-block;
        }

        .free-ball-btn:hover {
            background: rgba(0, 120, 0, 0.7);
            box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
        }

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

        .free-ball-indicator {
            background: linear-gradient(135deg, rgba(0, 100, 0, 0.8), rgba(0, 150, 0, 0.8));
            color: var(--gold);
            padding: 10px 20px;
            border-radius: 8px;
            margin-bottom: 10px;
            text-align: center;
            font-size: 16px;
            font-weight: 600;
            border: 2px solid var(--gold);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
            display: none;
        }

        .free-ball-indicator.active {
            display: block;
        }

        .snookers-indicator {
            text-align: center;
            margin: 0 auto 10px auto;
            font-size: 14px;
            padding: 8px 16px;
            background: rgba(255, 193, 7, 0.3);
            border: 2px solid #ffc107;
            border-radius: 8px;
            color: #ffc107;
            display: none;
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.7; }
        }

        /* Foul section */
        .foul-section {
            background: rgba(0,0,0,0.3);
            border-radius: 10px;
            padding: 10px;
            margin-bottom: 12px;
        }

        .foul-grid {
            display: flex;
            justify-content: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .foul-btn {
            padding: 14px 26px;
            border-radius: 8px;
            border: 2px solid rgba(255,255,255,0.2);
            background: rgba(139, 0, 0, 0.6);
            color: white;
            font-size: 24px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .foul-btn:active {
            background: rgba(139, 0, 0, 0.9);
            transform: scale(0.98);
        }

        .free-ball-foul-btn {
            background: rgba(212, 175, 55, 0.6) !important;
        }

        .free-ball-foul-btn:active {
            background: rgba(212, 175, 55, 0.9) !important;
        }

        /* Action buttons */
        .action-buttons {
            display: flex;
            gap: 8px;
            justify-content: center;
            flex-wrap: wrap;
        }

        .action-btn {
            padding: 10px 16px;
            border-radius: 8px;
            border: 2px solid var(--gold);
            background: transparent;
            color: var(--gold);
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            font-family: 'Source Sans Pro', sans-serif;
        }

        .action-btn:active {
            background: var(--gold);
            color: var(--felt-dark);
        }

        .action-btn.primary {
            background: var(--gold);
            color: var(--felt-dark);
        }

        .action-btn.primary:active {
            background: var(--gold-light);
        }

        .action-btn.danger {
            border-color: var(--red-ball);
            color: var(--red-ball);
        }

        .action-btn.danger:active {
            background: var(--red-ball);
            color: white;
        }

        /* ============ STATISTICS PAGE ============ */
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 16px;
            margin-bottom: 24px;
        }

        .stat-card {
            background: rgba(0,0,0,0.4);
            border-radius: 12px;
            padding: 20px;
            text-align: center;
        }

        .stat-card.full-width {
            grid-column: span 2;
        }

        .stat-label {
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 1px;
            opacity: 0.7;
            margin-bottom: 8px;
        }

        .stat-value {
            font-family: 'Playfair Display', serif;
            font-size: 36px;
            color: var(--gold);
        }

        .stat-value.small {
            font-size: 24px;
        }

        .stat-sub {
            font-size: 14px;
            opacity: 0.6;
            margin-top: 4px;
        }

        /* Player comparison */
        .player-stats {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 24px;
        }

        .player-stat-card {
            background: rgba(0,0,0,0.4);
            border-radius: 12px;
            padding: 20px;
        }

        .player-stat-card h3 {
            font-family: 'Playfair Display', serif;
            font-size: 24px;
            color: var(--gold-light);
            margin-bottom: 16px;
            text-align: center;
        }

        .stat-row {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid rgba(255,255,255,0.1);
        }

        .stat-row:last-child {
            border-bottom: none;
        }

        /* Ball stats */
        .balls-stats {
            display: flex;
            justify-content: center;
            gap: 12px;
            flex-wrap: wrap;
            margin-top: 12px;
        }

        .ball-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
        }

        .ball-stat-circle {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 14px;
            color: white;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        }

        /* ============ HISTORY PAGE ============ */
        
        .history-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .session-card {
            background: rgba(0,0,0,0.4);
            border-radius: 12px;
            padding: 16px 20px;
            cursor: pointer;
            transition: all 0.2s ease;
            border: 2px solid transparent;
        }

        .session-card:active {
            border-color: var(--gold);
        }

        .session-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }

        .session-card-date {
            font-size: 14px;
            opacity: 0.7;
        }

        .session-card-result {
            font-family: 'Playfair Display', serif;
            font-size: 28px;
            color: var(--gold);
        }

        .session-card-frames {
            font-size: 13px;
            opacity: 0.85;
            margin-bottom: 6px;
            letter-spacing: 0.3px;
        }

        .session-details {
            font-size: 13px;
            opacity: 0.6;
        }

        .session-winner {
            display: inline-block;
            background: var(--gold);
            color: var(--felt-dark);
            padding: 2px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 600;
        }

        /* Session detail modal */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.8);
            z-index: 100;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

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

        .modal-content {
            background: var(--felt-green);
            border-radius: 12px;
            padding: 24px;
            max-width: 500px;
            width: 100%;
            max-height: 80vh;
            overflow-y: auto;
            border: 3px solid var(--gold);
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .modal-title {
            font-family: 'Playfair Display', serif;
            font-size: 24px;
            color: var(--gold);
        }

        .modal-close {
            background: none;
            border: none;
            color: var(--cream);
            font-size: 28px;
            cursor: pointer;
            opacity: 0.7;
        }

        .frame-result {
            background: rgba(0,0,0,0.3);
            border-radius: 8px;
            padding: 12px 16px;
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .frame-number {
            font-weight: 600;
            opacity: 0.7;
        }

        .frame-scores {
            font-size: 20px;
            font-weight: 700;
        }

        .frame-winner {
            color: var(--gold);
        }

        .frame-delete-btn {
            background: transparent;
            border: none;
            cursor: pointer;
            font-size: 16px;
            opacity: 0.5;
            padding: 4px 8px;
            transition: opacity 0.2s;
        }

        .frame-delete-btn:hover,
        .frame-delete-btn:active {
            opacity: 1;
        }

        /* No data message */
        .no-data {
            text-align: center;
            padding: 60px 20px;
            opacity: 0.6;
        }

        .no-data-icon {
            font-size: 48px;
            margin-bottom: 16px;
        }

        /* Start session button */
        .start-session-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 60px 20px;
            gap: 20px;
        }

        .start-session-btn {
            padding: 20px 48px;
            font-size: 20px;
            font-family: 'Playfair Display', serif;
            background: var(--gold);
            color: var(--felt-dark);
            border: none;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        }

        .start-session-btn:active {
            transform: scale(0.98);
            background: var(--gold-light);
        }

        /* Delete confirmation */
        .delete-buttons {
            display: flex;
            gap: 12px;
            margin-top: 20px;
            justify-content: center;
        }

        /* Toast notifications */
        .toast {
            position: fixed;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            background: rgba(0,0,0,0.9);
            color: white;
            padding: 12px 24px;
            border-radius: 8px;
            font-size: 14px;
            z-index: 200;
            opacity: 0;
            transition: all 0.3s ease;
        }

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

        /* Fireworks celebration overlay */
        .celebration-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.85);
            z-index: 300;
            align-items: center;
            justify-content: center;
            flex-direction: column;
        }

        .celebration-overlay.active {
            display: flex;
        }

        .winner-text {
            font-family: 'Playfair Display', serif;
            font-size: 48px;
            color: var(--gold);
            text-align: center;
            margin-bottom: 20px;
            animation: winnerPulse 0.5s ease-out;
        }

        .winner-score {
            font-size: 72px;
            font-weight: 700;
            color: white;
            margin-bottom: 30px;
            animation: scoreZoom 0.6s ease-out;
        }

        .celebration-btn {
            padding: 16px 40px;
            font-size: 18px;
            background: var(--gold);
            color: var(--felt-dark);
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-family: 'Playfair Display', serif;
            margin-top: 20px;
        }

        @keyframes winnerPulse {
            0% { transform: scale(0.5); opacity: 0; }
            50% { transform: scale(1.1); }
            100% { transform: scale(1); opacity: 1; }
        }

        @keyframes scoreZoom {
            0% { transform: scale(0); opacity: 0; }
            100% { transform: scale(1); opacity: 1; }
        }

        /* Firework particles */
        .fireworks {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            pointer-events: none;
            overflow: hidden;
        }

        .firework {
            position: absolute;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            animation: fireworkBurst 1s ease-out forwards;
        }

        @keyframes fireworkBurst {
            0% {
                transform: scale(1);
                opacity: 1;
            }
            100% {
                transform: scale(0);
                opacity: 0;
            }
        }

        .spark {
            position: absolute;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            animation: sparkFly 1.5s ease-out forwards;
        }

        @keyframes sparkFly {
            0% {
                transform: translate(0, 0) scale(1);
                opacity: 1;
            }
            100% {
                opacity: 0;
            }
        }

        /* Progress/Charts */
        .player-progress-section {
            margin-bottom: 40px;
            padding: 20px;
            background: rgba(0,0,0,0.2);
            border-radius: 8px;
        }

        .progress-chart {
            background: rgba(0,0,0,0.3);
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 30px;
        }

        .progress-chart h4 {
            color: var(--cream);
            font-size: 16px;
            margin-bottom: 15px;
            text-align: center;
            font-weight: normal;
        }

        .chart-scroll-wrapper {
            overflow-x: auto;
            overflow-y: hidden;
            max-width: 100%;
        }

        .progress-chart canvas {
            height: 250px !important;
        }

        /* Login page */
        .login-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 80vh;
            text-align: center;
            padding: 40px;
        }

        .login-logo {
            font-size: 80px;
            margin-bottom: 24px;
        }

        .snooker-balls-logo {
            display: flex;
            justify-content: center;
            gap: 8px;
            margin-bottom: 10px;
        }

        .logo-ball {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            box-shadow: 
                inset -3px -3px 6px rgba(0,0,0,0.4),
                inset 3px 3px 6px rgba(255,255,255,0.2),
                0 3px 6px rgba(0,0,0,0.3);
        }

        .logo-ball.red { background: radial-gradient(circle at 30% 30%, #ef5350, #d32f2f); }
        .logo-ball.yellow { background: radial-gradient(circle at 30% 30%, #ffee58, #fdd835); }
        .logo-ball.green { background: radial-gradient(circle at 30% 30%, #66bb6a, #2e7d32); }
        .logo-ball.brown { background: radial-gradient(circle at 30% 30%, #8d6e63, #5d4037); }
        .logo-ball.blue { background: radial-gradient(circle at 30% 30%, #42a5f5, #1565c0); }
        .logo-ball.pink { background: radial-gradient(circle at 30% 30%, #f48fb1, #e91e63); }
        .logo-ball.black { background: radial-gradient(circle at 30% 30%, #616161, #212121); }

        .login-title {
            font-family: 'Playfair Display', serif;
            font-size: 36px;
            color: var(--gold);
            margin-bottom: 8px;
        }

        .login-subtitle {
            font-size: 18px;
            opacity: 0.7;
            margin-bottom: 40px;
        }

        .google-login-btn {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 14px 32px;
            background: white;
            color: #333;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        }

        .google-login-btn:hover {
            background: #f5f5f5;
        }

        .google-login-btn svg {
            width: 24px;
            height: 24px;
        }

        /* Responsive iPad optimizations */
        @media (min-width: 768px) {
            .session-bar {
                padding: 12px 20px;
                margin-bottom: 16px;
            }

            .session-date {
                font-size: 16px;
            }

            .frame-indicator {
                font-size: 20px;
            }

            .session-score {
                font-size: 24px;
            }

            .scoreboard {
                gap: 16px;
                margin-bottom: 20px;
            }

            .player-score {
                padding: 20px;
            }

            .player-name {
                font-size: 28px;
                margin-bottom: 8px;
            }

            .player-points {
                font-size: 140px;
                margin-bottom: 8px;
            }

            .player-break-container {
                font-size: 36px;
            }

            .vs-divider {
                font-size: 24px;
            }

            .reds-remaining {
                font-size: 48px;
                margin-bottom: 12px;
            }

            .expected-ball-indicator {
                font-size: 48px;
                padding: 12px 24px;
                margin-bottom: 16px;
            }

            .info-and-balls-container {
                gap: 40px;
                margin-bottom: 20px;
            }

            .ball-btn {
                width: 130px;
                height: 130px;
                font-size: 38px;
            }

            .ball-btn .ball-points {
                width: 38px;
                height: 38px;
                font-size: 22px;
                bottom: -10px;
                right: -10px;
            }

            .balls-grid {
                gap: 18px;
            }

            .foul-section {
                margin-bottom: 20px;
                padding: 16px;
            }

            .section-title {
                font-size: 18px;
                margin-bottom: 12px;
            }

            .foul-grid {
                gap: 14px;
            }

            .foul-btn {
                padding: 24px 48px;
                font-size: 38px;
            }

            .action-buttons {
                gap: 12px;
            }

            .action-btn {
                padding: 14px 24px;
                font-size: 16px;
            }

            .free-ball-btn {
                padding: 14px 28px;
                font-size: 18px;
                margin-bottom: 16px;
            }

            .free-ball-indicator {
                font-size: 16px;
                padding: 12px 20px;
                margin-bottom: 16px;
            }

            .snookers-indicator {
                font-size: 18px;
                padding: 12px 20px;
            }
        }

        /* Extra small screens (iPhone) */
        @media (max-width: 480px) {
            .app-frame {
                padding: 4px;
            }

            .page {
                padding: 6px;
            }

            .session-bar {
                padding: 6px 10px;
                font-size: 11px;
            }

            .session-date {
                font-size: 11px;
            }

            .frame-indicator {
                font-size: 13px;
            }

            .session-score {
                font-size: 16px;
            }

            .scoreboard {
                gap: 8px;
            }

            .player-score {
                padding: 8px;
            }

            .player-name {
                font-size: 16px;
            }

            .player-points {
                font-size: 56px;
            }

            .player-break-container {
                font-size: 22px;
            }

            .vs-divider {
                font-size: 14px;
            }

            .reds-remaining {
                font-size: 20px;
            }

            .expected-ball-indicator {
                font-size: 20px;
                padding: 4px 10px;
            }

            .info-and-balls-container {
                flex-direction: column;
                gap: 10px;
            }

            .ball-info-text {
                text-align: center;
            }

            .ball-btn {
                width: 50px;
                height: 50px;
                font-size: 18px;
            }

            .ball-btn .ball-points {
                width: 18px;
                height: 18px;
                font-size: 11px;
                bottom: -4px;
                right: -4px;
            }

            .balls-grid {
                gap: 6px;
            }

            .foul-btn {
                padding: 12px 20px;
                font-size: 20px;
            }

            .action-btn {
                padding: 8px 12px;
                font-size: 12px;
            }

            .free-ball-btn {
                padding: 8px 16px;
                font-size: 13px;
            }

            .free-ball-indicator {
                font-size: 12px;
                padding: 6px 12px;
            }
        }

        /* Small screens (small tablets/large phones) */
        @media (min-width: 481px) and (max-width: 767px) {
            .app-frame {
                padding: 8px;
            }

            .page {
                padding: 10px;
            }

            .player-points {
                font-size: 80px;
            }

            .reds-remaining {
                font-size: 28px;
            }

            .expected-ball-indicator {
                font-size: 28px;
            }

            .ball-btn {
                width: 70px;
                height: 70px;
                font-size: 24px;
            }

            .ball-btn .ball-points {
                width: 24px;
                height: 24px;
                font-size: 14px;
                bottom: -6px;
                right: -6px;
            }

            .balls-grid {
                gap: 10px;
            }

            .foul-btn {
                padding: 16px 28px;
                font-size: 24px;
            }
        }

        /* Landscape mode - compact everything (including iPad) */
        @media (max-width: 1400px) and (orientation: landscape) {
            .app-frame {
                padding: 6px;
            }

            .page {
                padding: 8px;
            }

            .session-bar {
                padding: 6px 12px;
                margin-bottom: 8px;
            }

            .session-date {
                font-size: 13px;
            }

            .frame-indicator {
                font-size: 14px;
            }

            .session-score {
                font-size: 16px;
            }

            .scoreboard {
                gap: 8px;
                margin-bottom: 10px;
            }

            .player-score {
                padding: 10px;
            }

            .player-name {
                font-size: 18px;
                margin-bottom: 4px;
            }

            .player-points {
                font-size: 60px !important;
                margin-bottom: 4px;
            }

            .player-break-container {
                font-size: 26px;
            }

            .vs-divider {
                font-size: 16px;
            }

            .reds-remaining {
                font-size: 24px !important;
                margin-bottom: 8px;
            }

            .expected-ball-indicator {
                font-size: 24px !important;
                padding: 6px 12px;
            }

            .info-and-balls-container {
                gap: 20px;
                margin-bottom: 12px;
            }

            /* Ballen 10% kleiner: 112px → 100px */
            .ball-btn {
                width: 100px !important;
                height: 100px !important;
                font-size: 29px !important;
            }

            .ball-btn .ball-points {
                width: 29px !important;
                height: 29px !important;
                font-size: 17px !important;
                bottom: -7px !important;
                right: -7px !important;
            }

            .balls-grid {
                gap: 12px;
            }

            .foul-section {
                margin-bottom: 12px;
                padding: 12px;
            }

            .section-title {
                font-size: 14px;
                margin-bottom: 8px;
            }

            /* Fout buttons 2x groter: 18px → 36px */
            .foul-btn {
                padding: 16px 32px !important;
                font-size: 36px !important;
            }

            .foul-grid {
                gap: 12px;
            }

            .action-buttons {
                gap: 10px;
            }

            /* Action buttons 2x groter: 11px → 22px */
            .action-btn {
                padding: 12px 24px;
                font-size: 18px;
            }

            .free-ball-btn {
                padding: 12px 24px;
                font-size: 18px;
                margin-bottom: 12px;
            }

            .free-ball-indicator {
                font-size: 15px;
                padding: 8px 16px;
                margin-bottom: 12px;
            }

            .snookers-indicator {
                font-size: 16px;
                padding: 10px 16px;
            }
        }
        /* NAS (v7.0): banner op de oude Firebase-versie */
        .old-version-banner {
            background: #b71c1c;
            color: #fff;
            padding: 10px 14px;
            font-size: 14px;
            line-height: 1.4;
            text-align: center;
        }
        .old-version-banner a { color: #fff; font-weight: 700; }
        .old-version-banner[hidden] { display: none; }

        /* NAS (v7.0): de stand wacht op verbinding — rode rand rond de app */
        body.save-failing .app-container { box-shadow: inset 0 0 0 3px var(--red-ball); }

        /* NAS (v7.0): eenmalige kopie Firebase -> NAS (Historie, enkel met ?migratie) */
        .nas-migration {
            margin: 24px 16px;
            padding: 16px;
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 8px;
            font-size: 14px;
            line-height: 1.5;
        }
        .nas-migration[hidden] { display: none; }
        .nas-migration h3 { color: var(--gold); margin-bottom: 8px; }
        .migration-btn {
            margin: 12px 0;
            min-height: 44px;
            padding: 10px 20px;
            background: var(--gold);
            color: var(--felt-dark);
            border: none;
            border-radius: 8px;
            font-weight: 700;
            cursor: pointer;
        }
        .migration-btn:disabled { opacity: 0.5; }
        .nas-migration-log { font-family: monospace; font-size: 12px; }
        .migratie-kop { color: var(--gold); margin-top: 6px; }
        .migratie-fout { color: #ff8a80; }
        .migratie-ok { color: #b9f6ca; font-weight: 700; }
