:root {
    --bg-color: #0a0a0a;
    --card-bg: #161a1e;
    --qelvin-orange: #e67e22;
    --accent-orange: #d35400;
    --accent-green: #2ecc71;
    --team-red: #e74c3c;
    --undo-orange: #f39c12;
    --text-white: #ffffff;
    --text-gray: #a0a6b5;
    --gold: #f1c40f;
    --keypad-bg: #222;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-white);
    font-family: 'Arial Black', sans-serif;
    user-select: none;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.setup-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.setup-step {
    background: var(--card-bg);
    border: 1px solid #2a303a;
    border-radius: 12px;
    padding: 25px 20px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.format-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.starter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.selector-card {
    background: #0a0a0a;
    border: 1px solid #333;
    padding: 15px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    font-size: 1rem;
    color: #ccc;
}

.selector-card.active {
    border-color: var(--qelvin-orange);
    box-shadow: 0 0 15px rgba(230, 126, 34, 0.3);
    background: rgba(230, 126, 34, 0.05);
    color: #ffffff;
    font-weight: bold;
}

.legs-input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.leg-btn {
    background: #222;
    border: 1px solid #444;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    font-family: 'Arial Black', sans-serif;
}

.auth-btn {
    background: var(--qelvin-orange);
    color: black;
    border: none;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    font-family: 'Arial Black', sans-serif;
    box-shadow: 0 4px 0 var(--accent-orange);
    margin-top: 10px;
    transition: all 0.1s ease;
}

.auth-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.nav-buttons-row {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.tournament-input {
    background: #0a0a0a;
    border: 1px solid #333;
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    font-family: 'Arial Black', sans-serif;
    box-sizing: border-box;
    margin-bottom: 12px;
}

.tournament-input:focus {
    border-color: var(--qelvin-orange);
}

/* --- GAME INTERFACE --- */
#game-interface {
    flex: 1;
    display: none;
    flex-direction: column;
    height: 100%;
}

.score-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--card-bg);
    border-bottom: 2px solid #222;
    padding: 10px 0;
}

.player-panel {
    text-align: center;
    padding: 10px;
    position: relative;
    transition: all 0.3s;
}

.player-panel.active {
    background: rgba(230, 126, 34, 0.08);
}

.p-name {
    font-size: 1.1rem;
    color: var(--text-gray);
    text-transform: uppercase;
    margin-top: 5px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-panel.active .p-name {
    color: var(--qelvin-orange);
    font-weight: bold;
}

.player-panel.active .p-name::before {
    content: '🎯';
    font-size: 1.6rem;
    margin-right: 10px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
}

.p-score {
    font-size: 3.5rem;
    color: white;
    margin: 5px 0;
    font-family: 'Arial Black', sans-serif;
}

.p-legs {
    font-size: 2.2rem;
    color: var(--gold);
    background: #000000;
    border: 3px solid var(--gold);
    border-radius: 15px;
    padding: 8px 25px;
    display: inline-block;
    margin-top: 10px;
    font-weight: 900;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.3);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.middle-bar {
    background: #0a0a0a;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#turn-indicator {
    font-size: 0.9rem;
    color: var(--text-gray);
}

#checkout-hint {
    font-size: 1.3rem;
    color: #000;
    background: var(--accent-green);
    padding: 5px 15px;
    border-radius: 8px;
    font-family: 'Arial Black', sans-serif;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
    transition: transform 0.1s;
    letter-spacing: 1px;
}

#checkout-hint:active {
    transform: scale(0.95);
}

#checkout-hint.hidden-hint {
    background: transparent;
    color: var(--text-gray);
    box-shadow: none;
    cursor: default;
}

.stop-match-btn {
    background: #2a1515;
    border: 1px solid var(--team-red);
    color: var(--team-red);
    padding: 6px 12px;
    border-radius: 8px;
    font-family: 'Arial Black', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.stop-match-btn:active {
    background: var(--team-red);
    color: black;
}

.input-display-container {
    background: #111;
    padding: 15px;
    text-align: center;
    font-size: 2.2rem;
    color: var(--gold);
    min-height: 40px;
    border-bottom: 2px solid var(--qelvin-orange);
    font-family: 'Arial Black', sans-serif;
    letter-spacing: 2px;
}

.input-display-container.bust {
    color: var(--team-red);
    border-color: var(--team-red);
    animation: shake 0.3s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.keypad-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--keypad-bg);
}

.key {
    border: 1px solid #111;
    background: #262626;
    color: white;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Arial Black', sans-serif;
    box-shadow: 0 3px 0 #111;
    transition: transform 0.1s;
}

.key:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #111;
}

.key.action-delete {
    background: #3a2222;
    color: var(--team-red);
    font-size: 1.4rem;
}

.key.action-undo {
    background: #3a2f1e;
    color: var(--undo-orange);
    font-size: 1.1rem;
}

.key.action-enter {
    background: var(--accent-green);
    color: #000;
    grid-row: span 2;
    font-size: 1.5rem;
    box-shadow: 0 3px 0 #1e8449;
}

/* --- POP-UPS / MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--card-bg);
    border: 1px solid var(--qelvin-orange);
    padding: 25px;
    border-radius: 12px;
    width: 85%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.modal-title {
    font-size: 1.4rem;
    color: white;
    margin-bottom: 5px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-subtitle {
    color: var(--text-gray);
    margin-bottom: 20px;
    font-size: 1rem;
    font-family: Arial, sans-serif;
}

.modal-btns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}

.btn-yes {
    background: var(--accent-green);
    color: black;
}

.btn-no {
    background: #1a1e24;
    border: 1px solid #333;
    color: var(--text-gray);
}

.btn-danger {
    background: var(--team-red);
    color: white;
}

/* --- OVERLAYS & ANIMATIES --- */
#celebration-overlay,
#score-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1500;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.8);
}

.cele-text-big {
    font-size: 6rem;
    color: var(--gold);
    font-weight: 900;
    text-shadow: 0 0 40px var(--gold);
    margin: 0;
    line-height: 1;
}

.score-splash-text {
    font-size: 10rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 30px var(--qelvin-orange);
    margin: 0;
    line-height: 1;
}

.pop-in-anim {
    animation: popInBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.pop-out-anim {
    animation: popOutFade 0.3s ease-in forwards;
}

@keyframes popInBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    70% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes popOutFade {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    z-index: 1000;
    pointer-events: none;
    animation: fall 6s linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(105vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes pulse-logo {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(230, 126, 34, 0.3);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 60px rgba(230, 126, 34, 0.8);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(230, 126, 34, 0.3);
    }
}

@keyframes blink-text {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* --- SCREENSAVER & WIN SCHERM --- */
#screensaver {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 20000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#go-box {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    border: none !important;
    background: radial-gradient(circle, #1a1a1a 0%, #000000 100%) !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#go-box .trophy-img {
    max-width: 350px !important;
    height: 350px !important;
    margin-bottom: 40px !important;
}

#go-title {
    font-size: 8vw !important;
    text-shadow: 0 0 50px rgba(241, 196, 15, 0.8);
    margin-bottom: 10px;
}

#go-reason {
    font-size: 3vw !important;
    line-height: 1.5;
    color: white !important;
    font-style: normal !important;
}

.eindstand-highlight {
    display: inline-block;
    background: #000;
    border: 4px solid var(--qelvin-orange);
    color: white;
    font-size: 5vw !important;
    font-weight: 900;
    padding: 15px 50px;
    border-radius: 25px;
    margin-top: 30px;
    box-shadow: 0 0 40px rgba(230, 126, 34, 0.6);
    letter-spacing: 3px;
}

#go-box .modal-btns {
    margin-top: 60px;
    width: 100%;
    display: flex;
    justify-content: center;
}

#go-box .modal-btn {
    font-size: 1.5rem;
    padding: 20px 40px;
    max-width: 400px;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.4);
}

/* --- NIEUWE PROFESSIONELE MENU KNOPPEN --- */
.nav-ghost-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-gray);
    font-size: 0.8rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    text-transform: uppercase;
    font-family: 'Arial Black', sans-serif;
    padding: 12px 20px;
    border-radius: 30px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.nav-ghost-btn:hover,
.nav-ghost-btn:active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.nav-ghost-btn.danger-hover:hover,
.nav-ghost-btn.danger-hover:active {
    background: rgba(231, 76, 60, 0.15);
    color: var(--team-red);
    border-color: rgba(231, 76, 60, 0.4);
}

/* --- SMARTPHONE FIX VOOR MENU & SETUP --- */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }

    .setup-container {
        justify-content: flex-start;
        padding-top: 40px;
        padding-bottom: 40px;
    }
}

/* --- SMARTPHONE OPTIMALISATIE VOOR HET SCOREBORD & KLAVIER --- */
@media (max-width: 768px),
(max-height: 600px) {

    /* Zorg dat het hoofdscherm niet weggedrukt wordt en mag scrollen */
    #game-interface {
        justify-content: flex-start !important;
        padding: 10px !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow-y: auto !important;
        gap: 10px !important;
    }

    /* Maak de actuele score kleiner */
    .p-score {
        font-size: 3.5rem !important;
        line-height: 1 !important;
    }

    .p-name {
        font-size: 1rem !important;
    }

    /* Maak de balk in het midden compacter */
    .middle-bar {
        padding: 5px 10px !important;
        margin: 5px 0 !important;
    }

    #turn-indicator {
        font-size: 0.9rem !important;
    }

    .stop-match-btn {
        padding: 8px 15px !important;
        font-size: 0.8rem !important;
    }

    /* Verklein het vak waar de getypte score verschijnt */
    .input-display-container {
        font-size: 3rem !important;
        min-height: 60px !important;
        line-height: 60px !important;
        margin-bottom: 5px !important;
    }

    /* Krimp het klavier in elkaar zodat het op het scherm past */
    .keypad-container {
        gap: 6px !important;
        margin-top: 5px !important;
        padding-bottom: 25px !important;
    }

    .key {
        padding: 12px 0 !important;
        font-size: 1.5rem !important;
        min-height: unset !important;
    }
}