:root {
    --font-title: 'Montserrat', system-ui, sans-serif;
    --font-body: 'Lexend', system-ui, sans-serif;
    --glass-bg: rgba(15, 23, 42, 0.78);
    --glass-border: rgba(255, 255, 255, 0.22);
}

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    touch-action: none;
    background: #0f172a;
    color: #f8fafc;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    box-sizing: border-box;
}

.interactive-element {
    pointer-events: auto;
}

#top-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#hud {
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 8px 16px;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--glass-border);
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #e2e8f0;
}

.stat-pill strong {
    font-family: var(--font-title);
    font-weight: 800;
    color: #ffffff;
}

#profile-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #ffffff;
    padding: 5px 12px;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease;
}

#profile-trigger:hover {
    background: rgba(255, 255, 255, 0.24);
}

#profile-trigger:active {
    transform: scale(0.95);
}

#profile-trigger strong {
    font-family: var(--font-title);
    font-weight: 800;
    color: #fde68a;
}

.badge-level {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
    padding: 3px 10px;
    border-radius: 999px;
    font-family: var(--font-title);
    font-size: 0.76rem;
    font-weight: 800;
}

.hud-btn {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.24);
    padding: 6px 11px;
    border-radius: 999px;
    font-family: var(--font-title);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hud-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.hud-btn:active {
    transform: scale(0.94);
}

#zone-badge {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.94));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fef3c7;
    padding: 7px 16px;
    border-radius: 999px;
    font-family: var(--font-title);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    text-align: center;
}

#zone-badge.visible {
    opacity: 1;
    transform: translateY(0);
}

#power-meter-wrap {
    position: absolute;
    bottom: 135px;
    left: 50%;
    transform: translateX(-50%);
    width: 170px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    padding: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    z-index: 30;
}

#power-meter-wrap.visible {
    opacity: 1;
}

#power-meter-fill {
    height: 10px;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #f59e0b, #ef4444);
}

@keyframes bannerBlinkThree {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.88); }
    18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
    64%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
}

#goal-banner {
    position: absolute;
    top: 24%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.88);
    background: linear-gradient(135deg, #10b981, #047857);
    border: 2px solid #a7f3d0;
    color: #ffffff;
    padding: 14px 30px;
    border-radius: 999px;
    font-family: var(--font-title);
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    box-shadow: 0 16px 40px rgba(16, 185, 129, 0.45);
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    white-space: nowrap;
}

#goal-banner.basket-style {
    background: linear-gradient(135deg, #f97316, #c2410c);
    border-color: #fed7aa;
    box-shadow: 0 16px 40px rgba(249, 115, 22, 0.48);
}

#goal-banner.show {
    animation: bannerBlinkThree 0.72s ease-in-out 3 forwards;
}

#modal-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    max-width: 740px;
    max-height: 82vh;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.45);
    z-index: 100;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.4);
    pointer-events: auto;
}

#modal-header {
    background: linear-gradient(135deg, #0f172a, #1e3a8a);
    color: white;
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#modal-header h2 {
    margin: 0;
    font-family: var(--font-title);
    font-size: 1.12rem;
    font-weight: 800;
}

#modal-body {
    padding: 22px;
    overflow-y: auto;
    flex-grow: 1;
    color: #1e293b;
    font-size: 0.94rem;
    line-height: 1.6;
    user-select: text;
    -webkit-user-select: text;
}

.close-btn {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-family: var(--font-title);
    font-weight: 800;
}

.close-btn:hover {
    background: #ef4444;
}

/* Formulaire profil */
.profile-group {
    margin-bottom: 16px;
}

.profile-label {
    display: block;
    font-family: var(--font-title);
    font-weight: 800;
    font-size: 0.85rem;
    color: #0f172a;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.profile-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    outline: none;
    user-select: text;
    -webkit-user-select: text;
    transition: border-color 0.2s;
}

.profile-input:focus {
    border-color: #2563eb;
}

.pill-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.choice-pill {
    padding: 8px 16px;
    border-radius: 999px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 0.84rem;
    cursor: pointer;
}

.choice-pill.active {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

.swatch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.swatch-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid #e2e8f0;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.swatch-btn.active {
    border-color: #2563eb;
    transform: scale(1.14);
}

/* Modules pédagogiques, fiches mémo et quiz */
.memo-box {
    background: #f0f9ff;
    border-left: 4px solid #2563eb;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 12px 0 18px;
}

.memo-box h4 {
    margin: 0 0 6px;
    font-family: var(--font-title);
    color: #1e3a8a;
    font-size: 0.94rem;
}

.quiz-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 14px;
}

.quiz-question {
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 12px;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-opt-btn {
    text-align: left;
    padding: 10px 14px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quiz-opt-btn:hover:not(:disabled) {
    border-color: #3b82f6;
    background: #eff6ff;
}

.quiz-opt-btn.correct {
    border-color: #10b981;
    background: #ecfdf5;
    color: #065f46;
    font-weight: 700;
}

.quiz-opt-btn.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.quiz-feedback {
    margin-top: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    color: #334155;
}

.quest-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-family: var(--font-title);
    font-size: 0.74rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.quest-status-badge.done {
    background: #dcfce7;
    color: #166534;
}

.quest-status-badge.todo {
    background: #fef3c7;
    color: #92400e;
}

.reward-banner {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 14px;
    padding: 12px 16px;
    color: #78350f;
    font-weight: 700;
    margin-top: 14px;
}

/* Contrôles directionnels */
#bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    width: 100%;
}

#instructions {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: #f1f5f9;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 0.78rem;
    max-width: 410px;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
}

#instructions strong {
    font-family: var(--font-title);
    color: #fde68a;
}

#mobile-controls {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    margin-left: auto;
}

.dpad-row {
    display: flex;
    gap: 7px;
}

.pad-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(15, 23, 42, 0.74);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.28);
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.12s ease;
}

.pad-btn:active, .pad-btn.pressed {
    background: rgba(59, 130, 246, 0.88);
    transform: scale(0.94);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
    margin-top: 4px;
}

#shoot-btn {
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    font-family: var(--font-title);
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.42);
    cursor: pointer;
}

#shoot-btn.basket-mode {
    background: linear-gradient(135deg, #ea580c, #9a3412);
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.45);
}

#shoot-btn:active {
    transform: scale(0.95);
}

#enter-btn {
    padding: 11px 17px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-family: var(--font-title);
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
    cursor: pointer;
}

#enter-btn:active {
    transform: scale(0.95);
}

.zone-btn {
    display: inline-block;
    margin-top: 12px;
    margin-right: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 0.86rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.zone-btn.secondary {
    background: #e2e8f0;
    color: #0f172a;
    box-shadow: none;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.info-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.info-card h4 {
    margin: 0 0 6px 0;
    font-family: var(--font-title);
    font-size: 0.92rem;
    color: #0f172a;
}

@media (max-width: 720px) {
    #instructions {
        display: none;
    }
    #hud {
        padding: 7px 10px;
        gap: 6px;
    }
    .stat-pill, #profile-trigger {
        font-size: 0.75rem;
    }
    .hud-btn {
        padding: 5px 8px;
        font-size: 0.69rem;
    }
}
