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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

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

/* Navigation */
.main-nav {
    background-color: #2c3e50;
    color: white;
    padding: 0;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    padding-top: env(safe-area-inset-top, 0);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    gap: 1rem;
}

.nav-brand {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 1px;
    transition: transform 0.3s, opacity 0.3s;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.nav-links a:hover {
    background-color: #34495e;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: #34495e;
}

h1 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #34495e;
}

.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

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

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

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.2;
    transition: background-color 0.3s;
    min-height: 44px;
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-primary {
    background-color: #27ae60;
}

.btn-primary:hover {
    background-color: #229954;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-warning {
    background-color: #f39c12;
}

.btn-warning:hover {
    background-color: #e67e22;
}

.btn-danger {
    background-color: #e74c3c;
}

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

.btn-secondary {
    background-color: #95a5a6;
}

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

/* Cookie consent banner */
.cookie-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0));
    background: rgba(44, 62, 80, 0.97);
    color: #ecf0f1;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.cookie-banner-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.5rem;
}

.cookie-banner-text {
    flex: 1 1 280px;
    min-width: 0;
}

.cookie-banner-heading {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
    color: #fff;
}

.cookie-banner-desc {
    font-size: 0.95rem;
    line-height: 1.45;
    color: #bdc3c7;
    margin: 0;
}

.cookie-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0;
}

.cookie-banner-btn {
    white-space: nowrap;
}

.actions {
    margin-bottom: 2rem;
}

.next-round-actions {
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

table thead {
    background-color: #34495e;
    color: white;
}

table th,
table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Speloverzicht: ronden als matrix (spelers = kolommen) */
.table-wrapper-rounds-overview {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.rounds-overview-table {
    min-width: 640px;
}

.rounds-overview-table .round-col {
    white-space: nowrap;
    font-weight: 600;
    text-align: left;
    background-color: #f0f2f4;
    color: #2c3e50;
}

.rounds-overview-table tbody th.round-col {
    border-right: 1px solid #ddd;
}

.round-player-stats {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.9rem;
    line-height: 1.35;
}

.round-stat-label {
    color: #555;
    margin-right: 0.25rem;
}

/* Mobiele kaarten-weergave voor rondenoverzicht (standaard verborgen, getoond op <=768px) */
.rounds-mobile-view {
    display: none;
}

.round-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    padding: 1rem;
    margin-bottom: 1rem;
}

.round-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

.round-card-header h3 {
    margin: 0;
    font-size: 1.05rem;
    color: #2c3e50;
}

.round-card-cards {
    font-weight: 400;
    color: #666;
    font-size: 0.9rem;
}

.round-card-players {
    list-style: none;
    margin: 0;
    padding: 0;
}

.round-card-player {
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.round-card-player:last-child {
    border-bottom: none;
}

.round-card-player-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.35rem;
}

.round-card-player-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    font-size: 0.9rem;
}

.round-card-player-stats span {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.5rem;
    background: #f7f9fb;
    border-radius: 4px;
    text-align: center;
}

.round-card-player-stats .round-stat-label {
    font-size: 0.75rem;
    color: #666;
    margin: 0 0 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.round-card-player-stats strong {
    color: #2c3e50;
    font-size: 1rem;
}

table input[type="number"],
table input[type="text"] {
    width: 100%;
    min-width: 60px;
    font-size: 16px;
    min-height: 44px;
    padding: 0.5rem;
}

/* Tricks stepper: afgerond veld met cirkel - en + knoppen */
.tricks-stepper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 9999px;
    padding: 0.25rem 0.5rem;
    background: white;
    min-height: 44px;
    max-width: 160px;
}

.tricks-stepper-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: #f5f5f5;
    color: #333;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.tricks-stepper-btn:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.tricks-stepper-btn:active {
    background: #ddd;
}

.tricks-stepper input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.25rem;
}

.tricks-stepper input:focus {
    outline: none;
}

.tricks-stepper input::-webkit-outer-spin-button,
.tricks-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tricks-stepper input[type="number"] {
    -moz-appearance: textfield;
}

/* Override table input styles binnen stepper */
table .tricks-stepper {
    width: auto;
}

table .tricks-stepper input {
    width: auto;
    min-width: 0;
}

.form-group .tricks-stepper input[type="number"] {
    width: auto;
    min-width: 0;
    padding: 0.25rem;
    border: none;
    background: transparent;
    border-radius: 0;
    min-height: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px; /* Voorkomt zoom op iOS bij focus */
    min-height: 44px;
}

.form-group select {
    width: 100%;
    padding: 0.75rem;
    padding-right: 2rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    min-height: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-color: white;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

/* Radio-groep (bv. startende speler) - touch-vriendelijke tegels */
.radio-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0;
}

.radio-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    min-height: 44px;
    font-weight: 400;
    margin-bottom: 0;
    flex: 1 1 auto;
    -webkit-tap-highlight-color: transparent;
}

.radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: #3498db;
    flex-shrink: 0;
}

.radio-option:has(input:checked) {
    border-color: #3498db;
    background: #eaf4fb;
}

.player-input {
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.player-input label {
    min-width: 80px;
    flex-shrink: 0;
}

.player-input input {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    min-height: 44px;
}

.game-info {
    background-color: white;
    padding: 1.5rem;
    border-radius: 4px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-info p {
    margin-bottom: 0.5rem;
}

.round-info {
    background-color: #e8f4f8;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 2rem;
    border-left: 4px solid #3498db;
}

.info {
    background-color: #d1ecf1;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border-left: 4px solid #17a2b8;
}

.success {
    background-color: #d4edda;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border-left: 4px solid #28a745;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: #f39c12;
    color: white;
    border-radius: 3px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.prediction-zero-limit-note {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: #856404;
    font-weight: normal;
}

.status-complete {
    color: #28a745;
    font-weight: bold;
}

.status-pending {
    color: #f39c12;
}

tr.dealer {
    background-color: #fff3cd;
}

tr.dealer.dealer-sum-equals {
    background-color: #f8d7da;
}

.admin-actions {
    background-color: white;
    padding: 1.5rem;
    border-radius: 4px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cell-actions {
    white-space: nowrap;
}

.cell-actions .btn,
.cell-actions .inline-form {
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
}

.cell-actions .inline-form {
    margin-right: 0;
}

/* Responsive tabellen - horizontale scroll op kleine schermen */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin-bottom: 2rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-wrapper table {
    margin-bottom: 0;
    min-width: 400px;
}

/* Tablet */
@media (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.25rem;
        margin-top: 1.5rem;
    }
    
    /* Hamburger menu */
    .nav-toggle {
        display: flex;
    }
    
    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(280px, 85vw);
        background: #2c3e50;
        flex-direction: column;
        align-items: stretch;
        padding: calc(4rem + env(safe-area-inset-top)) 1rem calc(2rem + env(safe-area-inset-bottom));
        gap: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -4px 0 20px rgba(0,0,0,0.2);
        z-index: 999;
    }
    
    .nav-links-open {
        transform: translateX(0);
    }
    
    .nav-links a {
        padding: 1rem 1.25rem;
        border-radius: 8px;
        font-size: 1.1rem;
    }
    
    body.nav-open {
        overflow: hidden;
    }
    
    body.nav-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 998;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    table th,
    table td {
        padding: 0.75rem 0.5rem;
    }
    
    .button-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .button-group .btn,
    .button-group form {
        width: 100%;
    }
    
    .button-group .btn {
        text-align: center;
        justify-content: center;
    }
    
    /* Full-width knoppen voor formulieren en acties op mobiel */
    .actions .btn,
    form .btn-primary,
    form .btn[type="submit"],
    form button[type="button"].btn-primary,
    .button-group .btn,
    a.btn-primary {
        width: 100%;
        text-align: center;
        padding: 1rem 1.5rem;
    }
    
    .btn {
        padding: 1rem 1.5rem;
    }
    
    .btn-small {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
    
    /* Grotere steppers op touch-schermen */
    .tricks-stepper {
        min-height: 48px;
        max-width: 180px;
        padding: 0.3rem 0.6rem;
    }
    
    .tricks-stepper-btn {
        width: 40px;
        height: 40px;
        font-size: 1.4rem;
    }
    
    .tricks-stepper input {
        font-size: 1.15rem;
        min-width: 40px;
    }
    
    .player-input {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .player-input label {
        min-width: 0;
    }
    
    /* Radio groep stapelt op mobiel, maar blijft visueel duidelijk */
    .radio-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .radio-option {
        width: 100%;
        padding: 0.75rem 1rem;
    }
    
    .game-info,
    .round-info,
    .admin-actions {
        padding: 1rem;
    }
    
    .actions .btn {
        width: 100%;
    }
    
    .cell-actions {
        white-space: normal;
    }
    
    .cell-actions .btn,
    .cell-actions .inline-form {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .cell-actions .inline-form:last-child {
        margin-bottom: 0;
    }
    
    .cell-actions .btn,
    .cell-actions form button {
        width: 100%;
    }
    
    /* Rondenoverzicht: verberg matrix, toon kaarten op mobiel */
    .rounds-desktop-view {
        display: none;
    }
    
    .rounds-mobile-view {
        display: block;
    }
    
    /* Tabellen → kaart-layout (gebruik data-label attributen) */
    .table-wrapper-cards {
        overflow: visible;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }
    
    .table-mobile-cards {
        background: transparent;
        box-shadow: none;
        min-width: 0;
        display: block;
    }
    
    .table-mobile-cards thead {
        position: absolute;
        left: -9999px;
        top: auto;
        width: 1px;
        height: 1px;
        overflow: hidden;
    }
    
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-cards tr {
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
        padding: 0.75rem 1rem;
        margin-bottom: 0.75rem;
    }
    
    .table-mobile-cards tr:hover {
        background: white;
    }
    
    .table-mobile-cards tr.dealer {
        background-color: #fff9e6;
        border: 1px solid #f1c40f;
    }
    
    .table-mobile-cards tr.dealer.dealer-sum-equals {
        background-color: #fdecec;
        border-color: #e74c3c;
    }
    
    .table-mobile-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.55rem 0;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
        min-height: 44px;
    }
    
    .table-mobile-cards td:last-child {
        border-bottom: none;
    }
    
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #555;
        text-align: left;
        flex: 0 0 auto;
        margin-right: 1rem;
    }
    
    .table-mobile-cards td[data-label="Speler"] {
        font-weight: 600;
        color: #2c3e50;
        font-size: 1.05rem;
    }
    
    .table-mobile-cards td[data-label="Speler"]::before {
        display: none;
    }
    
    .table-mobile-cards td[data-label="Speler"] {
        justify-content: flex-start;
        text-align: left;
        border-bottom: 1px solid #eee;
        padding-bottom: 0.6rem;
        margin-bottom: 0.25rem;
    }
    
    .table-mobile-cards td .tricks-stepper {
        margin-left: auto;
    }
    
    .table-mobile-cards .cell-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .table-mobile-cards .cell-actions::before {
        margin-bottom: 0.25rem;
    }
    
    .table-mobile-cards .cell-actions .btn,
    .table-mobile-cards .cell-actions .inline-form {
        width: 100%;
        display: block;
        margin: 0;
    }
    
    .table-mobile-cards .cell-actions .inline-form button {
        width: 100%;
    }
    
    /* Cookie banner: stapelen en volle breedte knoppen */
    .cookie-banner-inner {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cookie-banner-actions {
        width: 100%;
    }
    
    .cookie-banner-btn {
        flex: 1 1 auto;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }
    
    .nav-brand {
        font-size: 1rem;
    }
    
    h1 {
        font-size: 1.35rem;
    }
    
    h2 {
        font-size: 1.15rem;
    }
    
    table th,
    table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.85rem;
    }
    
    /* Op hele smalle schermen: stappen Voorspeld/Behaald/Totaal onder elkaar */
    .round-card-player-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.35rem;
    }
    
    .round-card-player-stats span {
        padding: 0.35rem 0.3rem;
    }
    
    .round-card-player-stats .round-stat-label {
        font-size: 0.7rem;
    }
    
    .round-card-player-stats strong {
        font-size: 0.95rem;
    }
    
    .table-mobile-cards tr {
        padding: 0.65rem 0.85rem;
    }
    
    .cookie-banner-actions {
        flex-direction: column;
    }
    
    .cookie-banner-btn {
        width: 100%;
    }
}
