/* Variabelen verplaatsen naar :root zodat JS ze goed kan overschrijven */
:root {
    --p-main: #FF69B4;   /* Roze Hoofdkleur (Tekst/Vlag) */
    --p-base: #ff99cc;   /* Roze Blok Basis */
    --p-accent: #d147a3; /* Roze Blok Rand */
    
    --b-main: #1E90FF;   /* Blauw Hoofdkleur */
    --b-base: #99ccff;   /* Blauw Blok Basis */
    --b-accent: #47a3d1; /* Blauw Blok Rand */
}

html, body {
    width: 100%;
    height: 100%;
    background-color: #000; /* Zwarte achtergrond tegen witte randen */
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'MedievalSharp', cursive;
    background-image: url('background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    user-select: none; /* Voorkomt selecteren van tekst tijdens slepen */
    touch-action: none; /* Voorkomt ongewenst scrollen/zoomen op iPad */
}

#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Bovenbalk met status */
.top-bar {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    font-size: 24px;
    color: #5C4033;
    text-shadow: 1px 1px 0 #fff;
    pointer-events: auto;
}

.team-box {
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 20px;
    border-radius: 12px;
    border: 3px solid #8B4513;
    min-width: 150px;
    text-align: center;
}
.team-pink { border-color: var(--p-main); color: var(--p-main); }
.team-blue { border-color: var(--b-main); color: var(--b-main); }

.phase-indicator {
    background: #FFD700;
    padding: 10px 30px;
    border-radius: 0 0 15px 15px;
    border: 3px solid #8B4513;
    border-top: none;
    font-weight: bold;
    font-size: 28px;
    margin-top: -20px;
    color: #5C4033;
}

/* Knoppen onderin (Bouwfase) */
#build-controls {
    pointer-events: auto;
    text-align: center;
    padding: 20px;
    background: rgba(139, 69, 19, 0.8);
    border-top: 3px solid #5C4033;
    display: none; /* Start verborgen */
}

.build-btn {
    font-family: 'MedievalSharp', cursive;
    font-size: 18px;
    margin: 0 10px;
    padding: 10px 20px;
    cursor: pointer;
    border: 2px solid #5C4033;
    border-radius: 8px;
    background: #FFD700;
    color: #5C4033;
    transition: transform 0.1s;
}
.build-btn:active { transform: scale(0.95); }
.build-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Quiz Overlay */
#quiz-modal {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 15px;
    border: 5px solid #8B4513;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    text-align: center;
    max-width: 600px;
    pointer-events: auto;
    display: none;
    z-index: 100;
    color: #5C4033;
}

#question-text { font-size: 28px; margin-bottom: 20px; }
.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.answer-btn {
    padding: 15px;
    background: #FFD700;
    border: 2px solid #8B4513;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'MedievalSharp', cursive;
    font-size: 20px;
    color: #5C4033;
}
.answer-btn:hover { background: #f0e68c; }

/* Winnaar Scherm */
#winner-screen {
    position: absolute; top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #FFD700;
    z-index: 200;
    pointer-events: auto;
}
#winner-text { font-size: 60px; margin-bottom: 20px; text-align: center; }

.start-btn {
    font-family: 'MedievalSharp', cursive;
    font-size: 30px; padding: 15px 40px;
    background: #FFD700; color: #5C4033;
    border: 2px solid #8B4513;
    border-radius: 10px; cursor: pointer;
}

#instruction-overlay {
    position: absolute; bottom: 100px; width: 100%; text-align: center;
    font-size: 22px; color: white; text-shadow: 0 2px 4px black;
    pointer-events: none;
}

/* --- NIEUWE KLEUR SELECTIE (MINI) --- */
.team-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.mini-color-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 8px;
    pointer-events: auto;
}

.mini-color-btn {
    width: 20px; height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}
.mini-color-btn:hover { transform: scale(1.2); border-color: #FFD700; }

.mini-color-btn.selected {
    border: 2px solid #fff;
    transform: scale(1.2);
    box-shadow: 0 0 5px #fff;
}

/* --- NIEUWE STIJLEN --- */

#center-divider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, #8B4513, transparent);
    transform: translateX(-50%);
    pointer-events: none;
}

#block-palette {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    background: rgba(82, 54, 34, 0.85);
    border-top: 4px solid #5C4033;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
    z-index: 50;
}

.palette-item {
    width: 60px;
    height: 60px;
    background: #FFD700;
    border: 3px solid #8B4513;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    position: relative;
    font-size: 14px;
    color: #5C4033;
    font-weight: bold;
    text-align: center;
}

.palette-item:active {
    cursor: grabbing;
}

.palette-item .count {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #c71585;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    border: 2px solid white;
}

.palette-item[data-team="pink"] .count { background: var(--p-main); }
.palette-item[data-team="blue"] .count { background: var(--b-main); }

/* Palet items zelf meekleuren (rand en gloed) */
.palette-item[data-team="pink"] {
    border-color: var(--p-main);
    box-shadow: 0 0 5px var(--p-main);
}
.palette-item[data-team="blue"] {
    border-color: var(--b-main);
    box-shadow: 0 0 5px var(--b-main);
}

/* Visuele representatie van blokken in het palet - NU MET VARIABELEN */
/* Roze Team (Links) */
.palette-item[data-team="pink"][data-type="wood_h"]::before { content: ''; width: 40px; height: 15px; background: var(--p-base); border: 2px solid var(--p-accent); }
.palette-item[data-team="pink"][data-type="wood_v"]::before { content: ''; width: 15px; height: 40px; background: var(--p-base); border: 2px solid var(--p-accent); }
.palette-item[data-team="pink"][data-type="stone"]::before { content: ''; width: 25px; height: 25px; background: var(--p-base); border: 2px solid #333; filter: brightness(0.8); }
/* Blauw Team (Rechts) */
.palette-item[data-team="blue"][data-type="wood_h"]::before { content: ''; width: 40px; height: 15px; background: var(--b-base); border: 2px solid var(--b-accent); }
.palette-item[data-team="blue"][data-type="wood_v"]::before { content: ''; width: 15px; height: 40px; background: var(--b-base); border: 2px solid var(--b-accent); }
.palette-item[data-team="blue"][data-type="stone"]::before { content: ''; width: 25px; height: 25px; background: var(--b-base); border: 2px solid #333; filter: brightness(0.8); }
.palette-item[data-type="king"]::before { content: '👑'; font-size: 30px; }

/* Stijl voor het "spook" blok tijdens het slepen */
#ghost-block {
    position: absolute;
    z-index: 1000;
    opacity: 0.7;
    background: #fff;
    border: 2px dashed #000;
    pointer-events: none;
}

#ghost-block.invalid {
    background-color: rgba(255, 0, 0, 0.4) !important;
    box-shadow: 0 0 15px red;
    border: 3px dashed red !important;
}

/* --- NIEUW: Screen Shake Animatie --- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

body.shake-hard {
  animation: shake 0.5s ease-in-out;
}

.ui-btn {
    font-family: 'MedievalSharp', cursive;
    font-size: 24px;
    width: 45px;
    height: 45px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #FFD700;
    color: #5C4033;
    border: 2px solid #8B4513;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.1s, background-color 0.2s, opacity 0.2s;
    pointer-events: auto;
    opacity: 0.5;
    position: relative; /* Nodig voor de tooltip positionering */
}

.ui-btn:active {
    transform: scale(0.95);
}

.ui-btn:hover {
    background-color: #f0e68c;
    opacity: 1;
}

/* Tooltip stijl */
.ui-btn::after {
    content: attr(data-tooltip); /* Haal tekst uit het attribuut */
    position: absolute;
    left: 55px; /* Rechts van de knop */
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #FFD700;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid #8B4513;
    z-index: 1001;
}

.ui-btn:hover::after {
    opacity: 1;
}

#build-timer-display {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 60px;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 2px 2px 0 #8B4513, -1px -1px 0 #8B4513, 1px -1px 0 #8B4513, -1px 1px 0 #8B4513, 1px 1px 0 #8B4513;
    z-index: 50;
    pointer-events: none;
    display: none; /* Start verborgen */
    font-family: 'MedievalSharp', cursive;
}

/* --- KRACHT & STREAK METER --- */
.strength-ui {
    position: absolute;
    top: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    pointer-events: none;
    z-index: 50;
}

#strength-ui-pink {
    left: 20px;
}

#strength-ui-blue {
    right: 20px;
}

.strength-badge {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #FFD700;
    border-radius: 10px;
    padding: 5px 15px;
    color: #FFD700;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
    display: flex;
    align-items: center;
    gap: 10px;
}

.streak-bar {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 15px;
    margin-top: 5px;
}

.streak-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #555;
    border: 2px solid #888;
    transition: all 0.3s ease;
}

.streak-dot.active {
    transform: scale(1.3);
    border-color: #fff;
}

.triple-ready {
    color: #FF4500;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 0 5px #fff, 0 0 10px #FF4500;
    animation: flash 0.8s infinite alternate;
    margin-top: 2px;
    display: none;
}

@keyframes flash {
    from { opacity: 0.6; transform: scale(1); }
    to { opacity: 1; transform: scale(1.1); }
}

/* --- SPELUITLEG MODAL --- */
#info-modal {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    border: 5px solid #8B4513;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    text-align: left;
    max-width: 650px;
    pointer-events: auto;
    display: none;
    z-index: 2000;
    color: #5C4033;
}

#info-modal h2 {
    text-align: center;
    font-size: 36px;
    margin-top: 0;
    color: #8B4513;
    text-shadow: 1px 1px 0 #FFD700;
}

#info-modal p {
    font-size: 20px;
    margin-bottom: 15px;
    line-height: 1.4;
}

.info-close-btn {
    display: block;
    margin: 20px auto 0;
    padding: 10px 30px;
    font-family: 'MedievalSharp', cursive;
    font-size: 24px;
    background: #FFD700;
    border: 3px solid #8B4513;
    border-radius: 8px;
    cursor: pointer;
    color: #5C4033;
    transition: transform 0.1s;
}
.info-close-btn:hover { background: #f0e68c; }
.info-close-btn:active { transform: scale(0.95); }

/* Stijl voor de naaminvulvelden op het startscherm */
.name-input {
    font-family: 'MedievalSharp', cursive;
    font-size: 20px;
    padding: 10px;
    margin: 5px;
    border: 2px solid #8B4513;
    border-radius: 8px;
    text-align: center;
    width: 80%;
    max-width: 280px;
    background: #fdf5e6;
    color: #5C4033;
}
.name-input:focus {
    outline: none;
    border-color: #FFD700;
    background: #fff;
}