/* ── Mindplay : Mots – game.css ──
   Même identité visuelle que Mindplay : Lumière (HUD, modales, boutons, records),
   sans aucune ressource externe. Panneau d'affichage des mots, puis quatre cartes de réponse. */

:root {
    --ui-bg: rgba(2, 10, 24, .90);
    --ui-border: rgba(80, 190, 240, .22);
    --ui-text: #e0f4ff;
    --ui-pale: #8dc8e8;
    --ui-accent: #5bc8f5;
    --ui-danger: #ef476f;
    --text-dim: #8dc8e8;
    --lit-1: #fff8c4;
    --lit-2: #ffd84d;
    --lit-3: #f59e0b;
    --ok-1: #b9ffd9;
    --ok-2: #3fe08f;
    --ok-3: #0f9d58;
    --transition: all .4s cubic-bezier(.4, 0, .2, 1);
    --font: 'Fredoka', 'Nunito', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    font-family: var(--font);
    background: radial-gradient(ellipse at 50% 35%, #0b2442 0%, #04122a 55%, #020a18 100%);
    color: var(--ui-text);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

/* ─── HUD ─── */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 52px;
    background: var(--ui-bg);
    border-bottom: 1px solid var(--ui-border);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
}

.hud-left,
.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 80px;
}

.hud-right {
    justify-content: flex-end;
}

.hud-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.score-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--ui-pale);
    letter-spacing: .6px;
}

.score-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--ui-accent);
    line-height: 1;
    transition: color .2s;
    font-variant-numeric: tabular-nums;
}

.score-value.level-up {
    color: var(--lit-2);
}

/* ─── ICON BUTTONS ─── */
.icon-btn {
    background: rgba(91, 200, 245, .12);
    border: 1px solid var(--ui-border);
    color: var(--ui-text);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    text-decoration: none;
}

.icon-btn:hover {
    background: rgba(91, 200, 245, .25);
}

.icon-btn svg {
    pointer-events: none;
}

/* ─── ZONE DE JEU ─── */
#stage {
    --board: min(94vw, max(220px, calc(100vh - 250px)), 520px);
    --board: min(94vw, max(220px, calc(100dvh - 250px)), 520px);
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
}

.board {
    width: var(--board);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-chip {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 12px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
}

.chip-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ui-pale);
}

.chip-value {
    font-size: 17px;
    font-weight: 700;
    color: var(--ui-text);
    font-variant-numeric: tabular-nums;
}

.round-info {
    text-align: center;
    font-size: 13px;
    letter-spacing: .5px;
    color: var(--ui-pale);
    text-transform: uppercase;
}

.status-line {
    text-align: center;
    min-height: 28px;
    font-size: 20px;
    font-weight: 700;
    color: var(--ui-accent);
    transition: color .2s;
}

.status-line.show {
    color: var(--lit-2);
}

.status-line.good {
    color: var(--ok-2);
}

.status-line.bad {
    color: var(--ui-danger);
}

/* ─── PANNEAU DES MOTS ─── */
.panel {
    position: relative;
    width: 100%;
    height: calc(var(--board) * .72);
    background: rgba(2, 10, 24, .55);
    border: 1px solid var(--ui-border);
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .55), inset 0 0 30px rgba(91, 200, 245, .05);
    overflow: hidden;
}

/* Phase de mémorisation : un mot à la fois, centré */
.word-view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 14px;
}

.panel.phase-show .word-view,
.panel.phase-wait .word-view {
    display: flex;
}

.word-display {
    max-width: 100%;
    font-size: clamp(30px, 11vw, 64px);
    font-weight: 700;
    line-height: 1.1;
    color: var(--lit-2);
    text-transform: capitalize;
    text-align: center;
    text-shadow: 0 0 22px rgba(255, 216, 77, .55);
    overflow-wrap: anywhere;
    min-height: 1.2em;
    opacity: 0;
    transform: scale(.9);
    transition: opacity .1s, transform .1s;
}

.word-display.on {
    opacity: 1;
    transform: scale(1);
}

.panel.veiled .word-display {
    opacity: 0;
}

.word-timer {
    width: 62%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .08);
    overflow: hidden;
}

.word-timer-fill {
    height: 100%;
    width: 0;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--lit-3), var(--lit-2));
}

.dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    max-width: 90%;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    transition: background .15s, box-shadow .15s;
}

.dot.done {
    background: rgba(255, 216, 77, .45);
}

.dot.now {
    background: var(--lit-2);
    box-shadow: 0 0 8px rgba(255, 216, 77, .8);
}

/* Phase de réponse : quatre cartes */
.choices {
    position: absolute;
    inset: 0;
    display: none;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: clamp(6px, 1.8vw, 12px);
    padding: clamp(8px, 2vw, 14px);
}

.panel.phase-input .choices,
.panel.phase-result .choices {
    display: grid;
}

.choice {
    appearance: none;
    -webkit-appearance: none;
    min-width: 0;
    border: 1px solid rgba(91, 200, 245, .18);
    border-radius: 16px;
    background: linear-gradient(160deg, #0d1e36, #07142a);
    color: var(--ui-text);
    font-family: var(--font);
    font-size: clamp(16px, 5vw, 28px);
    font-weight: 700;
    text-transform: capitalize;
    overflow-wrap: anywhere;
    padding: 6px;
    cursor: default;
    touch-action: manipulation;
    position: relative;
    transition: background .18s, box-shadow .18s, transform .12s, border-color .18s;
}

.choice:focus-visible {
    outline: 2px solid var(--ui-accent);
    outline-offset: 2px;
}

.panel.phase-input .choice:not(.ok) {
    cursor: pointer;
}

.panel.phase-input .choice:not(.ok):hover {
    border-color: rgba(91, 200, 245, .55);
    background: linear-gradient(160deg, #12294a, #0a1b36);
}

.panel.phase-input .choice:not(.ok):active {
    transform: scale(.95);
}

.choice-key {
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, .3);
}

@media (pointer: coarse) {
    .choice-key {
        display: none;
    }
}

/* Bon mot sélectionné */
.choice.ok {
    background: radial-gradient(circle at 35% 30%, var(--ok-1), var(--ok-2) 55%, var(--ok-3));
    border-color: rgba(185, 255, 217, .85);
    box-shadow: 0 0 18px rgba(63, 224, 143, .65);
    color: #04230f;
    animation: pop .25s ease;
}

/* Mauvais mot */
.choice.bad {
    background: radial-gradient(circle at 35% 30%, #ffc2d0, var(--ui-danger) 55%, #a3102f);
    border-color: rgba(255, 194, 208, .9);
    box-shadow: 0 0 22px rgba(239, 71, 111, .8);
    color: #fff;
}

/* Bon mot oublié, révélé après l'erreur */
.choice.missed {
    background: rgba(255, 216, 77, .16);
    border: 2px dashed rgba(255, 216, 77, .8);
}

.panel.win .choice.ok {
    animation: win-flash .6s ease;
}

.panel.shake {
    animation: shake .35s ease;
}

@keyframes pop {
    0% { transform: scale(.8); }
    60% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes win-flash {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.45); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ─── OVERLAYS ─── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(1, 6, 18, .87);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.overlay.open {
    display: flex;
}

.modal {
    position: relative;
    background: linear-gradient(160deg, #0a1f3a, #030f22);
    border: 1px solid var(--ui-border);
    border-radius: 22px;
    padding: 30px 26px;
    max-width: 380px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .7);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: var(--ui-pale);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, .1);
}

.modal h2 {
    font-size: 22px;
    color: var(--ui-accent);
    margin-bottom: 18px;
}

.modal h3 {
    font-size: 15px;
    color: var(--ui-accent);
    margin: 14px 0 6px;
}

.modal section {
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    padding-bottom: 12px;
    margin-bottom: 4px;
}

.modal ul {
    padding-left: 18px;
}

.modal li {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 4px;
    color: var(--ui-pale);
}

.modal li strong {
    color: var(--ui-text);
}

.pause-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

#pauseOverlay .modal h2 {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 28px;
    letter-spacing: 1px;
}

/* Écran de démarrage */
.start-modal {
    text-align: center;
}

.start-title {
    font-size: 30px !important;
    letter-spacing: 1px;
    margin-bottom: 12px !important;
}

.start-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--ui-pale);
    margin-bottom: 10px;
}

.start-text strong {
    color: var(--ui-text);
}

.start-keys {
    font-size: 12px;
    color: var(--ui-pale);
    opacity: .7;
    margin-bottom: 22px;
}

.gameover-emoji {
    font-size: 56px;
    text-align: center;
    margin-bottom: 4px;
}

.gameover-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
}

.final-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, .05);
    border-radius: 10px;
}

.stat-val {
    font-weight: 700;
    color: var(--ui-accent);
    font-variant-numeric: tabular-nums;
}

.go-world {
    margin: -4px 0 16px;
    min-height: 16px;
}

/* ─── BUTTONS ─── */
.btn-sky {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: none;
    font-family: var(--font);
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, #0077b6, #023e8a);
    box-shadow: 0 6px 18px rgba(0, 119, 182, .4);
    transition: var(--transition);
}

.btn-sky:hover {
    filter: brightness(1.12);
    transform: translateY(-2px);
}

.btn-sky:active {
    transform: translateY(0);
}

.btn-sky:disabled {
    opacity: .6;
    cursor: default;
}

.btn-sky.secondary {
    background: rgba(255, 255, 255, .07);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, .12);
}

.btn-sky.secondary:hover {
    background: rgba(255, 255, 255, .14);
}

/* ─── SCROLLBAR ─── */
.modal::-webkit-scrollbar {
    width: 5px;
}

.modal::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, .2);
    border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb {
    background: var(--ui-accent);
}

/* ─── RECORDS ─── */
.records-title {
    text-align: center;
    font-size: 26px !important;
    margin-bottom: 24px !important;
}

.records-section {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px !important;
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
}

.records-section h3 {
    margin-top: 0 !important;
    margin-bottom: 12px !important;
    font-size: 13px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    color: var(--ui-pale) !important;
}

.record-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.record-card {
    background: rgba(0, 119, 182, 0.08);
    border: 1px solid rgba(0, 119, 182, 0.15);
    padding: 14px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    transition: all 0.2s;
}

.record-card:hover {
    background: rgba(0, 119, 182, 0.12);
    transform: translateY(-2px);
}

.record-card.global {
    background: rgba(91, 200, 245, 0.08);
    border-color: rgba(91, 200, 245, 0.2);
}

.rc-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rc-value {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.record-card.global .rc-value {
    color: var(--ui-pale);
}

.rc-message {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    font-style: italic;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
}

.connection-status {
    font-size: 11px;
    text-align: center;
    margin-top: 12px;
    color: var(--text-dim);
    font-style: italic;
    opacity: 0.7;
}

/* 🏆 Popup Record 🏆 */
#recordMessagePopup .modal {
    background: rgba(22, 22, 31, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 119, 182, 0.2);
    padding: 40px 30px;
    overflow: hidden;
    animation: popIn .3s ease;
}

#recordMessagePopup .modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--ui-accent), transparent);
}

#recordMessagePopup h2 {
    color: var(--ui-pale);
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
    text-shadow: 0 0 15px rgba(91, 200, 245, 0.4);
}

#recordMessagePopup p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-dim);
    margin-bottom: 24px;
}

.message-input-wrapper {
    margin-bottom: 30px;
    position: relative;
}

#recordMsgInput {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: text;
    -webkit-user-select: text;
}

#recordMsgInput:focus {
    background: rgba(255, 255, 255, 0.06);
    border-bottom-color: var(--ui-accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.char-counter {
    position: absolute;
    bottom: -22px;
    right: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}