* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: #202020;
    color: #f2f2f2;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Zone principale : le canvas 3D remplit tout, l'interface se superpose */
#quiz3d-app {
    position: relative;   /* référence de positionnement de la boussole */
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#canvas-container {
    position: absolute;
    inset: 0;
}
#canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Message de chargement */
#loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    font-size: 18px;
    z-index: 5;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* Panneau du quiz */
#quiz-ui {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    width: min(360px, calc(100% - 32px));
    padding: 16px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
}

#progression {
    font-size: 13px;
    opacity: 0.8;
    margin-bottom: 6px;
}

#question {
    margin: 0 0 12px;
    font-size: 20px;
    line-height: 1.3;
}

#answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

#quiz-ui button {
    padding: 10px 12px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #f2f2f2;
    color: #202020;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
#quiz-ui button:hover:not(:disabled) { background: #ffb347; }
#quiz-ui button:disabled { cursor: default; }
#quiz-ui button.correct { background: #2e9e5b; color: #fff; }
#quiz-ui button.wrong   { background: #d64545; color: #fff; }

#result {
    min-height: 1.4em;
    margin-top: 12px;
    font-weight: 600;
}

#next-button, #restart-button {
    display: none;
    width: 100%;
    margin-top: 10px;
    text-align: center !important;
    background: #4c9be8 !important;
    color: #fff !important;
}
#next-button:hover, #restart-button:hover { background: #3a86d1 !important; }

#score {
    margin-top: 12px;
    font-size: 14px;
    opacity: 0.85;
}

/* Boussole : croix N / O / E / S en bas à droite */
#compass {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 10;
    width: 112px;
    height: 112px;
    padding: 6px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}
#compass button {
    border: none;
    border-radius: 50%;
    background: #f2f2f2;
    color: #202020;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, transform 0.1s;
}
#compass button:hover  { background: #ffb347; }
#compass button:active { transform: scale(0.92); }
#compass .n { grid-area: 1 / 2; }
#compass .w { grid-area: 2 / 1; }
#compass .e { grid-area: 2 / 3; }
#compass .s { grid-area: 3 / 2; }

/* Hotspots */
#hotspots {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    overflow: hidden;
    pointer-events: none;   /* la souris traverse jusqu'au canvas */
}
.hotspot {
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #ffb347;
    color: #202020;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.2s;
    animation: hotspot-pulse 2s infinite;
}
.hotspot:hover  { background: #fff; }
.hotspot.active { background: #fff; animation: none; }
.hotspot.hidden { opacity: 0; pointer-events: none; }

@keyframes hotspot-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 179, 71, 0.7); }
    70%  { box-shadow: 0 0 0 12px rgba(255, 179, 71, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 179, 71, 0); }
}

#hotspot-info {
    display: none;
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 11;
    width: min(420px, calc(100% - 150px));
    padding: 14px 40px 14px 16px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
}
#hotspot-info h2 { margin: 0 0 6px; font-size: 17px; }
#hotspot-info p  { margin: 0; font-size: 14px; line-height: 1.5; }
#hotspot-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: none;
    background: transparent;
    color: #f2f2f2;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

/* Petits écrans */
@media (max-width: 520px) {
    #quiz-ui { padding: 12px; }
    #question { font-size: 17px; }
    #answers { grid-template-columns: 1fr; }
    #compass { width: 96px; height: 96px; right: 10px; bottom: 10px; }
    #hotspot-info { left: 10px; bottom: 10px; width: calc(100% - 130px); }
}
