:root {
    --bise-red: #c8102e;
    --bise-red-deep: #9a0c23;
    --cream: #fff8f0;
    --ink: #1a0a0c;
    --frame: rgba(255, 255, 255, 0.35);
    --accent: #ffe566;
    --panel: rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: "Segoe UI", sans-serif;
    color: var(--cream);
    background: linear-gradient(160deg, var(--bise-red) 0%, var(--bise-red-deep) 55%, #6b0a12 100%);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#app {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.page {
    display: none;
    flex: 1;
    flex-direction: column;
    align-items: center;
    /* center si ça tient ; safe center / flex-start évite de couper haut/bas */
    justify-content: center;
    justify-content: safe center;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 0;
    width: 100%;
}
.page.active { display: flex; }

/* Accueil : toujours scroller depuis le haut (logo + liens visibles) */
#page-home.active {
    justify-content: flex-start;
    padding: max(8px, env(safe-area-inset-top, 0px)) 0 max(24px, env(safe-area-inset-bottom, 0px));
}

/* ===== HOME ===== */
.home-header { text-align: center; margin-bottom: 18px; padding-top: 14px; display: flex; flex-direction: column; align-items: center; }
.logo {
    width: 220px; height: 220px; object-fit: cover;
    border-radius: 18px; box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    margin-bottom: 14px; cursor: pointer;
    border: 2px solid var(--frame);
}
.tagline {
    font-size: clamp(1.35rem, 3.5vw, 1.85rem);
    font-weight: 600; opacity: 0.95; line-height: 1.3;
    max-width: 28rem; padding: 0 12px;
}

.catalog { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; padding: 14px 16px 0; align-items: flex-start; }
.game-card-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.game-card-wrap.game-off,
.scores-col.game-off {
    display: none !important;
}
/* Badge hors flux : la tuile concours reste alignée avec les autres */
.game-card-wrap > .contest-badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -55%);
    z-index: 2;
    margin: 0;
    pointer-events: none;
}
.game-card-wrap:not(.is-contest) > .contest-badge,
.game-card-wrap.is-contest > .contest-badge[hidden] {
    display: none !important;
}
.game-card-wrap.is-contest > .contest-badge:not([hidden]) {
    display: inline-block !important;
    visibility: visible;
}
.game-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0,0,0,0.25); border: 2px solid var(--frame);
    border-radius: 18px; padding: 14px 12px 12px;
    width: 220px; height: 292px;
    box-sizing: border-box;
    text-align: center;
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(4px);
    overflow: hidden;
}
.game-card:hover, .game-card:active {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.5);
}
.card-visual {
    width: 112px; height: 112px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px;
    flex-shrink: 0;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--frame);
}
.card-visual-preview { padding: 0; }
.game-preview-canvas,
.game-preview-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}
.game-icon {
    width: 70px; height: 70px;
    display: block; flex-shrink: 0;
}
.scores-icon { margin-bottom: 8px; }
.game-card h2 {
    font-size: 1.25rem;
    margin: 0 0 4px;
    line-height: 1.2;
    flex-shrink: 0;
    width: 100%;
}
.game-card > p {
    font-size: 0.78rem;
    opacity: 0.7;
    margin: 0 0 6px;
    line-height: 1.25;
    min-height: 2.5em;
    max-height: 2.5em;
    width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    flex-shrink: 0;
}
.card-remaining {
    min-height: 1.15em;
    font-size: 0.72rem;
    margin-bottom: 4px;
    flex-shrink: 0;
    width: 100%;
}
.card-scores {
    font-size: 0.7rem;
    opacity: 0.85;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
    width: 100%;
    min-height: 3.1em;
}
.card-best,
.card-record {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.25;
    overflow: hidden;
    word-break: break-word;
}
.card-best { color: var(--accent); font-weight: 600; }
.card-record { opacity: 0.65; font-size: 0.66rem; }

.btn-scores {
    margin-top: 18px; padding: 10px 24px; border-radius: 999px;
    border: 1.5px solid var(--frame); background: rgba(0,0,0,0.2);
    color: var(--cream); font-size: 0.9rem; cursor: pointer;
}
.btn-scores:hover { background: rgba(0,0,0,0.4); }
.home-actions {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
    margin-top: 16px; padding: 0 12px;
}
.home-actions .btn-scores { margin-top: 0; }
.btn-contest-cta {
    background: rgba(255,229,102,0.2);
    border-color: rgba(255,229,102,0.55);
    color: var(--accent); font-weight: 700;
}
.btn-contest-scores {
    background: rgba(255,255,255,0.08);
}
.contest-board .contest-board-game {
    text-align: center; color: var(--accent); font-weight: 600; margin: 4px 0 0;
}
.contest-board-body {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    width: min(1100px, 96vw);
    margin: 12px auto 20px;
    padding: 0 8px;
}
.contest-qr-panel {
    flex: 0 0 min(200px, 22%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    position: sticky;
    top: 8px;
}
.contest-qr-title {
    margin: 0;
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    font-weight: 800;
    line-height: 1.25;
    color: var(--accent);
    letter-spacing: 0.02em;
}
.contest-qr-btn {
    appearance: none;
    border: 1px solid var(--frame);
    background: #fff;
    border-radius: 14px;
    padding: 10px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.contest-qr-btn:hover { border-color: rgba(255,229,102,0.7); }
.contest-qr-target {
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.contest-qr-target img,
.contest-qr-target canvas {
    display: block;
    width: 160px !important;
    height: 160px !important;
}
.contest-qr-hint {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.75;
    line-height: 1.3;
}
.contest-lots {
    flex: 0 0 min(240px, 26%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    position: sticky;
    top: 8px;
}
.contest-lots-title {
    font-size: 0.95rem;
    color: var(--accent);
    margin: 0 0 2px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.contest-lots-empty { opacity: 0.6; font-size: 0.85rem; }
.contest-lot {
    background: rgba(0,0,0,0.28); border: 1px solid var(--frame);
    border-radius: 10px; padding: 10px; font-size: 0.82rem;
    line-height: 1.35; max-width: none; width: 100%;
}
.contest-lot-img {
    display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
    border-radius: 8px; margin-bottom: 8px; background: rgba(0,0,0,0.25);
}
.contest-lot-body { display: flex; align-items: flex-start; gap: 6px; }
.contest-lot-rank {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
    background: var(--accent); color: #1a0a0c; font-weight: 800; font-size: 0.75rem;
    margin-right: 0;
}
.contest-lot-draw { border-color: rgba(255,229,102,0.45); }
.contest-lot-draw em { opacity: 0.7; font-style: normal; font-size: 0.75rem; }
.contest-score-list {
    list-style: none; padding: 0; margin: 0; flex: 1; min-width: 0; width: auto; max-width: none;
}
.contest-score-list li {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}
.contest-score-list li:first-child { color: var(--accent); font-weight: 700; }
@media (max-width: 720px) {
    .contest-board-body { flex-direction: column; align-items: stretch; }
    .contest-qr-panel,
    .contest-lots { flex: none; width: 100%; position: static; }
    .contest-qr-panel { order: -2; }
    .contest-lots { order: -1; }
}
.sl-rank { opacity: 0.6; min-width: 1.6rem; }
.home-privacy {
    margin-top: 12px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    text-align: center;
    padding: 0 16px 8px;
    line-height: 1.45;
}
.home-privacy a { color: rgba(255,255,255,0.7); text-decoration: underline; }

/* ===== GAME PAGE ===== */
#page-game { padding: 0; overflow: hidden; }
#page-game.active {
    height: 100%;
    max-height: 100dvh;
    justify-content: flex-start;
    overscroll-behavior: none;
}
.game-header {
    display: flex; align-items: center; padding: 8px 12px;
    background: rgba(0,0,0,0.3); width: 100%; gap: 12px; flex-shrink: 0;
}
.btn-back {
    width: 40px; height: 40px; border-radius: 10px;
    border: 1.5px solid var(--frame); background: rgba(0,0,0,0.3);
    color: #fff; font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.btn-back:active { background: rgba(0,0,0,0.6); }
.game-record { font-size: 0.85rem; opacity: 0.8; }
.game-record strong { color: var(--accent); }

#game-container {
    flex: 1; min-height: 0; width: 100%;
    display: flex; flex-direction: column;
    align-items: stretch; justify-content: stretch;
    overflow: hidden; position: relative; padding: 0;
}
#game-container > .game-shell,
#game-container > .mem-stage {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* Shell commun : HUD haut (overlay) + plateau centré max + commandes bas */
.game-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.game-hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 8px 10px;
    pointer-events: none;
}
.game-hud-top > * { pointer-events: auto; }
.game-stage {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    container-type: size;
    padding: 8px;
    position: relative;
}
.game-controls-dock {
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, 0.42);
    border-top: 1px solid var(--frame);
    z-index: 4;
}
.game-countdown {
    flex: 1; width: 100%; min-height: 50vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px;
}
.game-countdown-label {
    font-size: 0.95rem; letter-spacing: 0.12em; text-transform: uppercase;
    opacity: 0.7;
}
.game-countdown-num {
    font-size: clamp(4rem, 18vw, 7rem); font-weight: 800;
    color: var(--accent); line-height: 1;
    text-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.game-countdown-num.pop {
    animation: cd-pop 0.35s ease-out;
}
.game-countdown-num.go {
    color: #fff; font-size: clamp(2.8rem, 12vw, 4.5rem);
}
@keyframes cd-pop {
    0% { transform: scale(0.55); opacity: 0.2; }
    60% { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
}

.brick-bg-logo {
    position: absolute; inset: 0; opacity: 0.06; pointer-events: none;
    background: url('../assets/logo-bise.png') center / min(40vw, 280px) no-repeat;
}
.brick-wrap { /* shell */ max-width: none; margin: 0; }
.brick-stats { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.snake-board-frame.brick-frame,
.snake-board-frame.galaga-frame {
    width: min(100cqi, calc(100cqh * 360 / 520));
    height: min(100cqh, calc(100cqi * 520 / 360));
    aspect-ratio: 360 / 520;
    max-width: 100%;
    max-height: 100%;
}
.snake-board-frame.brick-frame #bb-cv {
    display: block; width: 100%; height: 100%;
    background: #0a0614; border-radius: 8px;
}
.brick-controls {
    display: flex; gap: 10px; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brick-hint {
    font-size: 0.72rem; opacity: 0.7; text-align: center; margin: 0;
}

/* ===== MEMORY GAME (matching original) ===== */
.mem-atmosphere {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(200,16,46,0.14), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(26,26,26,0.08), transparent 50%),
        linear-gradient(165deg, #faf8f5 0%, #efebe4 45%, #e8e2d8 100%);
}
.mem-stage {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: min(560px, 96%);
    width: 100%;
    margin: 0 auto;
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 0;
    padding: 12px 8px;
    box-sizing: border-box;
}
.mem-stats { display: flex; gap: 1.2rem; justify-content: center; margin-bottom: 12px; width: 100%; }
.mem-stat { display: flex; flex-direction: column; align-items: center; min-width: 50px; }
.mem-stat-label { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: #5c5c5c; }
.mem-stat-value { font-size: 1.4rem; font-weight: 700; color: var(--ink); }

.mem-board {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.7rem; perspective: 1200px;
    width: 100%; margin: 0 auto;
}
.mem-board-20 {
    grid-template-columns: repeat(5, 1fr); gap: 0.55rem;
    max-width: 560px; width: 100%; margin: 0 auto;
}
.mem-error { color: #9a0c23; padding: 16px; text-align: center; font-size: 0.9rem; }
.mem-card {
    position: relative; display: block; aspect-ratio: 1/1.05; width: 100%;
    border: none; padding: 0; background: transparent; cursor: pointer;
    border-radius: 12px; animation: dealIn 0.5s ease both;
    animation-delay: calc(var(--i, 0) * 40ms);
}
.mem-card-inner {
    position: absolute; inset: 0; transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.22,1,0.36,1);
}
.mem-card.is-flipped .mem-card-inner, .mem-card.is-matched .mem-card-inner { transform: rotateY(180deg); }
.mem-card.is-matched .mem-card-inner { animation: matchPulse 0.4s ease; }
.mem-card-face {
    position: absolute; inset: 0; backface-visibility: hidden;
    border-radius: 12px; overflow: hidden; box-shadow: 0 12px 30px rgba(26,26,26,0.15);
}
.mem-card-back {
    background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.18), transparent 45%),
        linear-gradient(145deg, var(--bise-red) 0%, var(--bise-red-deep) 100%);
    display: grid; place-items: center;
}
.mem-card-back::before {
    content: ""; position: absolute; inset: 6px;
    border: 1px solid rgba(255,255,255,0.35); border-radius: 8px; pointer-events: none;
}
.mem-card-back-logo {
    width: 58%; height: 58%; object-fit: contain;
    border-radius: 10px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25));
}
.mem-card-back-mark { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.1em; color: #fff; text-transform: uppercase; }
.mem-card-front { transform: rotateY(180deg); background: #fff; display: flex; flex-direction: column; }
.mem-card-front img { flex: 1; width: 100%; height: 100%; object-fit: cover; background: #f0ece6; }
.mem-card-label {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 0.4rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff; font-size: 0.7rem; font-weight: 600; text-align: center;
}
.mem-card.is-matched { cursor: default; }
.mem-card.is-matched .mem-card-front::after {
    content: ""; position: absolute; inset: 0;
    box-shadow: inset 0 0 0 3px var(--bise-red); border-radius: 12px; pointer-events: none;
}

.mem-overlay {
    position: absolute; inset: 0; z-index: 10; display: grid; place-items: center;
    background: rgba(26,26,26,0.45); backdrop-filter: blur(6px);
}
.mem-overlay[hidden] { display: none; }
.mem-win-card {
    background: #fff; border-radius: 20px; padding: 2rem; text-align: center;
    max-width: 340px; width: 90%; box-shadow: 0 18px 40px rgba(0,0,0,0.2);
    color: var(--ink);
}
.mem-win-eyebrow { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--bise-red); margin-bottom: 4px; }
.mem-win-card h2 { font-size: 1.6rem; margin-bottom: 8px; }
.mem-win-meta { color: #5c5c5c; }

@keyframes dealIn { from { opacity: 0; transform: translateY(14px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes matchPulse { 0% { transform: rotateY(180deg) scale(1); } 50% { transform: rotateY(180deg) scale(1.04); } 100% { transform: rotateY(180deg) scale(1); } }

/* ===== TETRIS GAME (matching original) ===== */
.tetris-bg-logo {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background: url("../assets/logo-bise.png") center / min(50vmin, 300px) no-repeat;
    opacity: 0.06;
}
.tetris-wrap { /* shell */ }
.tetris-board-frame {
    border-radius: 14px; border: 3px solid var(--frame);
    box-shadow: 0 0 0 4px rgba(0,0,0,0.15), 0 18px 40px rgba(0,0,0,0.35);
    overflow: hidden; background: rgba(0,0,0,0.35);
    width: min(100cqi, calc(100cqh * 10 / 20));
    height: min(100cqh, calc(100cqi * 20 / 10));
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 10 / 20;
}
#tetris-cv { display: block; width: 100%; height: 100%; }

.tetris-hud .tetris-panel {
    background: rgba(0,0,0,0.55); border: 1px solid var(--frame); border-radius: 12px;
    padding: 6px 8px; backdrop-filter: blur(4px); text-align: center;
    min-width: 64px;
}
.tetris-panel-label { display: block; font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.8; margin-bottom: 2px; }
.tetris-stat-val { font-size: 1.05rem; font-weight: 700; color: var(--accent); }
#tetris-next { display: block; width: 56px; height: 56px; margin: 0 auto; border-radius: 8px; background: rgba(20,4,6,0.45); }
.tetris-next-name { margin-top: 2px; font-size: 0.7rem; font-weight: 600; color: var(--accent); }
.tetris-panel-next { min-width: 72px; }

.tetris-controls { display: flex; flex-direction: column; gap: 6px; align-items: center; margin-top: 0; }
.tetris-controls .row { display: flex; gap: 6px; }
.t-btn {
    width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--frame);
    background: rgba(0,0,0,0.35); color: var(--cream); font-size: 1.2rem;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.t-btn:active { background: rgba(255,230,102,0.35); color: var(--ink); }

/* ===== SNAKE GAME (matching original) ===== */
.snake-bg-logo {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background: url("../assets/logo-bise.png") center / min(50vmin, 300px) no-repeat;
    opacity: 0.06;
}
.snake-wrap { /* shell */ }
.snake-stats { display: flex; gap: 0.65rem; flex-shrink: 0; }
.snake-score-box {
    background: rgba(0,0,0,0.55); border: 1px solid var(--frame); border-radius: 10px;
    padding: 0.35rem 0.65rem; min-width: 64px; text-align: center; backdrop-filter: blur(4px);
}
.snake-score-box .snake-label { display: block; font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.85; }
.snake-score-box span:last-child { font-size: 1.15rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.snake-board-frame {
    width: min(100cqi, 100cqh);
    height: min(100cqi, 100cqh);
    aspect-ratio: 1;
    max-width: 100%;
    max-height: 100%;
    border-radius: 14px;
    border: 3px solid var(--frame);
    box-shadow: 0 0 0 4px rgba(0,0,0,0.15), 0 18px 40px rgba(0,0,0,0.35);
    overflow: hidden; background: rgba(0,0,0,0.35);
}
#snake-cv {
    display: block; width: 100%; height: 100%;
    background:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
        rgba(20,4,6,0.55);
    background-size: 20px 20px, 20px 20px, auto;
}

.snake-pad {
    display: grid;
    grid-template-areas: ". up ." "left down right";
    grid-template-columns: repeat(3, 56px);
    gap: 6px; justify-content: center;
    flex-shrink: 0;
}
.snake-pad-up { grid-area: up; }
.snake-pad-left { grid-area: left; }
.snake-pad-down { grid-area: down; }
.snake-pad-right { grid-area: right; }
.snake-pad-btn {
    width: 56px; height: 56px; border: 2px solid var(--frame); border-radius: 14px;
    background: rgba(0,0,0,0.35); color: var(--cream); font-size: 1.2rem;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; user-select: none;
}
.pacman-bg-logo {
    position: absolute; inset: 0; opacity: 0.06; pointer-events: none;
    background: url('../assets/logo-bise.png') center / min(40vw, 280px) no-repeat;
}
.pacman-wrap { /* shell */ max-width: none; }
.pacman-stats { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.pacman-main.game-stage {
    gap: 12px;
}
.pacman-board-frame {
    width: min(100cqi, calc(100cqh * 19 / 21));
    height: min(100cqh, calc(100cqi * 21 / 19));
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 19 / 21;
    flex: 0 0 auto;
}
#pm-cv {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
}
.pacman-maze-hint {
    color: #ffe566; font-size: 0.8rem; font-weight: 600;
    text-align: center; margin: 0; min-height: 1.1em;
}
.pacman-apt {
    width: min(300px, 94vw);
    background: #f7f3ec;
    border: 2px solid rgba(26,10,12,0.4);
    border-radius: 10px;
    padding: 10px;
    color: #1a0a0c;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.pacman-apt-title {
    font-size: 0.82rem; text-align: center; margin: 0 0 8px;
    color: #9a0c23; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700;
}
.house-plan {
    border: 2.5px solid #1a0a0c;
    border-radius: 3px;
    overflow: hidden;
    background: #fffdf8;
    display: flex;
    flex-direction: column;
}
.house-room {
    position: relative;
    border-bottom: 2.5px solid #1a0a0c;
    min-height: 100px;
}
.house-room:last-child { border-bottom: none; }
.house-salon { min-height: 118px; background: #faf6f0; }
.house-cuisine { min-height: 100px; background: #f2f5f7; }
.house-chambre { min-height: 110px; background: #f6f2f4; }
.house-label {
    position: absolute; top: 5px; left: 7px; z-index: 2;
    font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase;
    font-weight: 700; color: #1a0a0c; opacity: 0.45;
}
.plan-item {
    position: absolute; z-index: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
}
.plan-item.empty {
    border: 1.5px dashed #c45c4a;
    background: rgba(196,92,74,0.07);
    border-radius: 3px;
    min-width: 48px; min-height: 40px;
    padding: 3px;
}
.plan-item.filled {
    border: none;
    background: transparent;
}
.plan-q { color: #c45c4a; font-weight: 800; font-size: 1rem; line-height: 1; }
.plan-tag {
    font-size: 0.5rem; text-transform: uppercase; letter-spacing: 0.03em;
    color: #1a0a0c; opacity: 0.7; white-space: nowrap;
}
.plan-draw {
    display: block; position: relative; background: currentColor;
}

/* Positions dans le plan */
.at-sofa { left: 12%; top: 28%; color: #c45c4a; }
.at-tv { left: 58%; top: 22%; color: #4a90a4; }
.at-lamp { right: 10%; top: 30%; color: #e8c547; }
.at-table { left: 38%; top: 28%; color: #8b6914; }
.at-chairs { left: 36%; top: 55%; color: #d21526; }
.at-bed { left: 12%; top: 26%; color: #9a0c23; }
.at-wardrobe { right: 12%; top: 22%; color: #6b4f3a; }
.at-shelf { right: 14%; bottom: 12%; color: #5b8c5a; }

/* Silhouettes vue de dessus */
.plan-sofa .plan-draw {
    width: 56px; height: 22px; border-radius: 5px 5px 3px 3px; color: #c45c4a; background: #c45c4a;
}
.plan-sofa .plan-draw::before, .plan-sofa .plan-draw::after {
    content: ''; position: absolute; top: -5px; width: 10px; height: 16px;
    background: #c45c4a; border-radius: 3px;
}
.plan-sofa .plan-draw::before { left: 3px; }
.plan-sofa .plan-draw::after { right: 3px; }
.plan-sofa.empty { width: 60px; height: 48px; }

.plan-tv .plan-draw {
    width: 48px; height: 14px; border-radius: 2px; background: #4a90a4;
}
.plan-tv.empty { width: 54px; height: 42px; }

.plan-lamp .plan-draw {
    width: 14px; height: 14px; border-radius: 50%; background: #e8c547;
    box-shadow: 0 0 0 4px rgba(232,197,71,0.35);
}
.plan-lamp.empty { width: 46px; height: 42px; }

.plan-table .plan-draw {
    width: 34px; height: 34px; border-radius: 50%; background: #8b6914;
}
.plan-table.empty { width: 52px; height: 48px; }

.plan-chairs .plan-draw {
    width: 40px; height: 18px; background: transparent;
    border: 2px solid #d21526; border-radius: 2px;
    box-shadow: inset 12px 0 0 #d21526, inset -12px 0 0 #d21526;
}
.plan-chairs.empty { width: 52px; height: 40px; }

.plan-bed .plan-draw {
    width: 32px; height: 48px; border-radius: 4px; background: #9a0c23;
}
.plan-bed .plan-draw::before {
    content: ''; position: absolute; top: 3px; left: 4px; right: 4px; height: 12px;
    background: rgba(255,255,255,0.35); border-radius: 2px;
}
.plan-bed.empty { width: 48px; height: 58px; }

.plan-wardrobe .plan-draw {
    width: 24px; height: 42px; border-radius: 2px; background: #6b4f3a;
}
.plan-wardrobe .plan-draw::before {
    content: ''; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 1px;
    background: rgba(255,255,255,0.4);
}
.plan-wardrobe.empty { width: 44px; height: 52px; }

.plan-shelf .plan-draw {
    width: 36px; height: 26px;
    background: repeating-linear-gradient(to bottom, #5b8c5a 0 6px, rgba(255,255,255,0.3) 6px 8px);
}
.plan-shelf.empty { width: 48px; height: 44px; }

.house-fixture { position: absolute; opacity: 0.35; pointer-events: none; }
.fix-plant {
    width: 16px; height: 16px; border-radius: 50%; background: #5b8c5a;
    right: 18%; bottom: 14%;
}
.fix-plant::after {
    content: ''; position: absolute; left: 6px; top: -6px; width: 4px; height: 8px; background: #3d6b3c;
}
.fix-sink {
    width: 28px; height: 16px; border: 1.5px solid #1a0a0c; border-radius: 2px;
    left: 8%; top: 36%;
}
.fix-stove {
    width: 22px; height: 22px; border: 1.5px solid #1a0a0c; border-radius: 2px;
    right: 10%; top: 32%;
}
.fix-stove::before, .fix-stove::after {
    content: ''; position: absolute; width: 6px; height: 6px; border: 1px solid #1a0a0c; border-radius: 50%;
}
.fix-stove::before { left: 3px; top: 3px; }
.fix-stove::after { right: 3px; bottom: 3px; }

.fp-progress {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 4px 2px; font-size: 0.72rem; color: #1a0a0c;
}
.fp-dots { display: flex; gap: 3px; }
.fp-dots i {
    width: 7px; height: 7px; border-radius: 50%;
    border: 1px solid #9a0c23; display: inline-block;
}
.fp-dots i.on { background: #9a0c23; }
.pacman-hint {
    font-size: 0.68rem; opacity: 0.7; text-align: center;
    margin: 8px 0 0; line-height: 1.3; color: #1a0a0c;
}

@media (max-width: 640px) {
    .pacman-main { flex-direction: column; align-items: center; }
    .pacman-apt { width: min(360px, 94vw); }
}

/* ===== FORM / AUTH ===== */
.form-container {
    background: rgba(0,0,0,0.3); border: 1px solid var(--frame);
    border-radius: 20px; padding: 28px; width: 90%; max-width: 380px;
    text-align: center; backdrop-filter: blur(6px);
}
.form-logo { height: 44px; margin-bottom: 10px; border-radius: 6px; }
.form-container h2 { margin-bottom: 4px; font-size: 1.3rem; }
.form-score { color: var(--accent); font-size: 1.1rem; margin-bottom: 14px; }
#player-form { display: flex; flex-direction: column; gap: 10px; }
#player-form input[type="text"], #player-form input[type="email"], #player-form input[type="tel"] {
    padding: 11px 14px; border-radius: 10px;
    border: 1px solid var(--frame); background: rgba(255,255,255,0.08);
    color: #fff; font-size: 0.95rem;
}
#player-form input::placeholder { color: rgba(255,255,255,0.4); }
.form-row { display: flex; gap: 8px; }
.form-row input { flex: 1; min-width: 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; text-align: left; }
.checkbox-label input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--bise-red); flex-shrink: 0; }
.privacy-hint {
    font-size: 0.78rem;
    opacity: 0.75;
    line-height: 1.35;
    text-align: left;
    margin: 4px 0 10px;
}
.register-contact-hint {
    color: var(--accent);
    opacity: 0.95;
    margin: 2px 0 8px;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.btn-submit {
    width: 100%; padding: 13px; border: none; border-radius: 10px;
    background: var(--bise-red); color: #fff; font-size: 1rem;
    cursor: pointer; font-weight: 600;
}
.btn-submit:hover { background: var(--bise-red-deep); }

.auth-card {
    display: flex; flex-direction: column; align-items: center;
    gap: 0;
}
.auth-logo {
    width: 140px; height: 140px; object-fit: cover;
    border-radius: 18px; border: 2px solid var(--frame);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    margin: 0 auto 16px; display: block;
}
.auth-logo-sm {
    width: 100px; height: 100px; border-radius: 14px; margin-bottom: 12px;
}
.auth-sub { font-size: 0.85rem; opacity: 0.7; margin: 0 0 16px; }
.auth-form {
    width: 100%; display: flex; flex-direction: column; gap: 10px;
    align-items: stretch;
}
.auth-form .btn-submit { margin-top: 4px; }
.auth-back {
    margin-top: 14px; width: 100%; text-align: center;
}
#page-admin-login .auth-form input[type="password"] {
    width: 100%; padding: 12px 14px; border-radius: 10px;
    border: 1px solid var(--frame); background: rgba(255,255,255,0.08);
    color: #fff; font-size: 1rem;
}

/* ===== SCOREBOARD (TV plein écran) ===== */
#page-scores.active {
    justify-content: stretch;
    align-items: stretch;
    overflow: hidden;
    padding: 0;
}
.scoreboard-full {
    position: relative;
    width: 100%;
    max-width: none;
    height: 100%;
    min-height: 100%;
    padding: 10px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}
.scoreboard-back {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 2;
    width: auto;
    margin: 0;
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.25);
    color: rgba(255,255,255,0.55);
    font-size: 0.68rem;
    line-height: 1.2;
    cursor: pointer;
    opacity: 0.55;
}
.scoreboard-back:hover { opacity: 0.95; color: #fff; }
.scoreboard-header {
    text-align: center;
    padding: 0 36px;
    flex-shrink: 0;
}
.scoreboard-header h2 {
    margin: 0 0 4px;
    font-size: clamp(1.15rem, 2.4vw, 1.75rem);
    letter-spacing: 0.02em;
}
.scoreboard-day-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.scoreboard-day-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--frame);
    background: rgba(0,0,0,0.28);
    color: var(--accent);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}
.scoreboard-day-btn:hover:not(:disabled) { background: rgba(255,255,255,0.12); }
.scoreboard-day-btn:disabled {
    opacity: 0.25;
    cursor: default;
}
.scoreboard-day-label {
    min-width: 12rem;
    font-size: clamp(0.95rem, 1.8vw, 1.25rem);
    font-weight: 600;
}
.scoreboard-refresh-hint {
    margin-top: 2px;
    font-size: 0.68rem;
    opacity: 0.45;
}
.galaga-bg-logo {
    position: absolute; inset: 0; opacity: 0.06; pointer-events: none;
    background: url('../assets/logo-bise.png') center / min(40vw, 280px) no-repeat;
}
.galaga-wrap { /* shell */ max-width: none; margin: 0; }
.galaga-stats { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.snake-board-frame.galaga-frame #ga-cv {
    display: block; width: 100%; height: 100%;
    background: #070816; border-radius: 8px;
}
.galaga-controls {
    display: flex; gap: 10px; align-items: center; justify-content: center;
}
.galaga-controls .snake-pad-btn { width: 64px; height: 48px; }
.ga-fire-btn {
    width: 72px !important; background: rgba(200,16,46,0.45) !important;
    border-color: rgba(255,229,102,0.5) !important; color: #ffe566 !important;
    font-size: 1.2rem;
}
.galaga-hint {
    font-size: 0.72rem; opacity: 0.7; text-align: center; margin: 0;
}

.scores-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex: 1;
    min-height: 0;
    align-content: stretch;
    padding-top: 12px;
}
@media (min-width: 1200px) {
    .scores-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (min-width: 900px) and (max-width: 1199px) {
    .scores-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 700px) and (max-width: 899px) {
    .scores-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.scores-col {
    position: relative;
    background: rgba(0,0,0,0.22); border: 1px solid var(--frame);
    border-radius: 14px; padding: 10px 10px 8px;
    backdrop-filter: blur(4px);
    display: flex; flex-direction: column; min-height: 0;
}
.scores-col .scores-icon {
    width: 48px; height: 48px; margin: 0 auto 4px;
}
.scores-col .scores-icon .game-icon { width: 48px; height: 48px; }
.scores-col h3 { text-align: center; font-size: clamp(0.95rem, 1.4vw, 1.15rem); margin-bottom: 2px; }
.scores-col-sub { text-align: center; font-size: 0.62rem; opacity: 0.5; margin-bottom: 6px; }
.scores-hist {
    text-align: center;
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    color: var(--accent);
    background: rgba(0,0,0,0.28);
    border: 1px solid rgba(255,229,102,0.25);
    border-radius: 8px;
    padding: 6px 8px;
    margin-bottom: 8px;
    line-height: 1.3;
    flex-shrink: 0;
}
.score-list {
    list-style: none; padding: 0;
    flex: 1; min-height: 0; overflow-y: auto;
}
.score-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: clamp(0.75rem, 1.15vw, 0.95rem);
}
.score-list li:first-child { color: var(--accent); font-weight: 600; }
.sl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-score { font-weight: 700; margin-left: 8px; white-space: nowrap; }
.sl-empty { text-align: center; opacity: 0.4; justify-content: center; }
@media (max-width: 640px) {
    .scores-grid { grid-template-columns: 1fr; }
    .scoreboard-day-btn { width: 36px; height: 36px; font-size: 1.35rem; }
}

.btn-back-light {
    display: block; width: 100%; margin-top: 14px; padding: 10px 16px;
    border-radius: 10px; border: 1px solid var(--frame);
    background: transparent; color: #fff; cursor: pointer; font-size: 0.85rem;
    text-align: center;
}
.btn-back-light:hover { background: rgba(255,255,255,0.1); }

/* ===== ADMIN ===== */
.admin-container {
    background: rgba(0,0,0,0.3); border: 1px solid var(--frame);
    border-radius: 20px; padding: 28px; width: 90%; max-width: 440px;
    text-align: center; backdrop-filter: blur(6px);
    display: flex; flex-direction: column; gap: 12px;
    max-height: 90vh; overflow-y: auto;
}
.admin-container.admin-wide { max-width: 520px; }
.admin-nav {
    display: flex; flex-direction: column; gap: 10px; margin: 8px 0 4px;
}
.admin-nav-card {
    display: block; width: 100%; text-align: left;
    padding: 16px 18px; border-radius: 14px;
    border: 1px solid var(--frame); background: rgba(255,255,255,0.08);
    color: #fff; cursor: pointer; transition: background .15s, border-color .15s;
}
.admin-nav-card:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,229,102,0.45);
}
.admin-nav-title {
    display: block; font-size: 1.05rem; font-weight: 700;
    color: var(--accent); margin-bottom: 4px;
}
.admin-nav-desc {
    display: block; font-size: 0.78rem; opacity: 0.7; line-height: 1.35;
}
.admin-subhead {
    margin-top: 16px !important;
    font-size: 0.95rem;
    text-align: center;
}
.admin-contest-game {
    display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px;
}
.admin-contest-radio input { accent-color: var(--accent); }

.contest-badge,
.contest-col-badge {
    display: inline-block;
    align-self: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1a0a0c;
    background: var(--accent);
    padding: 3px 8px;
    border-radius: 999px;
    margin-bottom: 6px;
    line-height: 1.2;
}
/* Scoreboard : badge hors flux pour garder les colonnes alignées */
.scores-col > .contest-col-badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -55%);
    z-index: 2;
    margin: 0;
    pointer-events: none;
}
.contest-col-badge[hidden] {
    display: none !important;
}
.game-card.is-contest {
    border-color: rgba(255,229,102,0.65);
    box-shadow: 0 0 0 1px rgba(255,229,102,0.25);
}
.scores-col.is-contest {
    border-color: rgba(255,229,102,0.55);
}

.admin-prize-photo {
    margin: 4px 0 14px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
}
.admin-prize-upload-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 6px;
}
.admin-prize-upload-label input[type="file"] {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    max-width: 100%;
}
.admin-prize-preview {
    margin-top: 8px;
}
.admin-prize-preview img {
    display: block;
    max-width: 180px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--frame);
}
.btn-linkish {
    background: none;
    border: none;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.78rem;
    padding: 4px 0;
    margin-top: 4px;
}

.game-howto {
    width: min(420px, 92vw);
    text-align: left;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--frame);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.game-howto-title {
    text-align: center;
    color: var(--accent);
    font-size: 1.15rem;
    margin: 0 0 6px;
}
.game-howto-goal {
    text-align: center;
    font-size: 0.88rem;
    opacity: 0.9;
    margin: 0 0 10px;
    line-height: 1.35;
}
.game-howto-rules {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.8rem;
    line-height: 1.45;
    opacity: 0.85;
}
.game-howto-rules li { margin-bottom: 4px; }
.game-howto-contest {
    margin: 10px 0 0;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
}
.game-howto-contest.muted { opacity: 0.65; font-weight: 600; }
.admin-games-toggles {
    display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px;
}
.admin-game-toggle {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    background: rgba(0,0,0,0.22); border: 1px solid var(--frame);
    cursor: pointer; font-size: 0.92rem;
}
.admin-game-toggle input {
    width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0;
}
.admin-check-row {
    display: flex !important; align-items: flex-start; gap: 10px;
    margin: 14px 0 4px !important; cursor: pointer; line-height: 1.35;
}
.admin-check-row input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.admin-check-row small { display: block; opacity: 0.65; font-size: 0.72rem; margin-top: 2px; }
.admin-dates input[type="number"] {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--frame); background: rgba(255,255,255,0.08);
    color: #fff; font-size: 0.95rem; color-scheme: dark;
    font-family: inherit; box-sizing: border-box;
}
.register-contest-hint {
    display: block;
    font-size: 0.78rem;
    opacity: 0.75;
    margin-top: 2px;
    font-weight: 500;
}
.admin-info { font-size: 0.8rem; opacity: 0.7; }
.admin-dates {
    text-align: left; background: rgba(0,0,0,0.2);
    border: 1px solid var(--frame); border-radius: 12px; padding: 14px;
}
.admin-dates h3 { font-size: 0.95rem; margin-bottom: 8px; text-align: center; }
.admin-dates-hint { font-size: 0.75rem; opacity: 0.65; margin-bottom: 10px; text-align: center; line-height: 1.35; }
.admin-dates label { display: block; font-size: 0.78rem; opacity: 0.8; margin: 8px 0 4px; }
.admin-dates input[type="date"],
.admin-dates input[type="text"],
.admin-dates input[type="number"],
.admin-dates textarea {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--frame); background: rgba(255,255,255,0.08);
    color: #fff; font-size: 0.95rem; color-scheme: dark;
    font-family: inherit; resize: vertical; box-sizing: border-box;
}
.admin-dates textarea { min-height: 72px; line-height: 1.4; }
.admin-dates .btn-submit { width: 100%; margin-top: 12px; }
.admin-memory { margin-top: 12px; }
.admin-slideshow { margin-top: 12px; }
.admin-memory-upload-row { margin-bottom: 10px; }
.admin-memory-upload-row .btn-submit { width: 100%; margin-top: 0; }
.admin-memory-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
    max-height: 320px; overflow-y: auto; margin-top: 8px;
}
.admin-memory-item {
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    background: rgba(0,0,0,0.22); border: 1px solid var(--frame);
    border-radius: 10px; padding: 8px 6px 6px; font-size: 0.72rem;
    text-align: center; position: relative;
}
.admin-memory-pick {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    cursor: pointer;
}
.admin-memory-item input.mem-img-check {
    position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; accent-color: var(--accent); z-index: 2;
}
.admin-memory-item img {
    width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
    background: rgba(255,255,255,0.1);
}
.admin-memory-item input:checked + img,
.admin-memory-pick:has(input:checked) img {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
.admin-memory-del {
    position: absolute; top: 4px; right: 4px; z-index: 2;
    width: 26px; height: 26px; border-radius: 8px;
    border: 1px solid rgba(255,100,100,0.5); background: rgba(80,0,0,0.55);
    color: #ffb4b4; font-size: 0.85rem; cursor: pointer; line-height: 1;
}
.admin-memory-del:hover { background: rgba(160,0,0,0.75); color: #fff; }
.btn-action {
    width: 100%; padding: 13px; border: 1px solid var(--frame); border-radius: 10px;
    background: rgba(255,255,255,0.08); color: #fff; font-size: 0.9rem; cursor: pointer;
}
.btn-action:hover { background: rgba(255,255,255,0.15); }
.btn-danger { border-color: #ff4444; color: #ff6666; }
.btn-danger:hover { background: rgba(255,0,0,0.15); }

/* ===== FIREWORKS ===== */
.fireworks-canvas {
    position: fixed; inset: 0; z-index: 9999;
    pointer-events: none; display: none;
}
.fireworks-canvas.active { display: block; }

/* ===== CODE PAGE ===== */
.form-logo-big { height: 80px; margin-bottom: 14px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
.code-subtitle { font-size: 0.9rem; opacity: 0.75; margin-bottom: 14px; }
.code-error { color: #ff6b6b; font-size: 0.85rem; margin-top: 10px; min-height: 2.5em; line-height: 1.3; }
.form-subtitle { font-size: 0.85rem; opacity: 0.7; margin-bottom: 12px; }
.user-welcome { font-size: 0.9rem; margin-top: 6px; opacity: 0.8; }
.card-remaining { font-size: 0.72rem; margin-bottom: 4px; color: rgba(255,255,255,0.7); min-height: 1.15em; }
.card-remaining.exhausted { color: #ff6b6b; }
.game-card.card-disabled { opacity: 0.45; pointer-events: none; }
.go-remaining { font-size: 0.85rem; opacity: 0.7; margin-bottom: 14px; }
.exhausted-text { font-size: 0.9rem; opacity: 0.8; margin-bottom: 16px; line-height: 1.5; }

.admin-users {
    text-align: left; background: rgba(0,0,0,0.2);
    border: 1px solid var(--frame); border-radius: 12px; padding: 14px;
}
.admin-users h3 { font-size: 0.95rem; margin-bottom: 8px; text-align: center; }
.admin-search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.admin-search-row input {
    flex: 1; min-width: 0; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--frame); background: rgba(255,255,255,0.08);
    color: #fff; font-size: 0.9rem;
}
.admin-search-btn { width: auto; padding: 10px 14px; margin: 0; flex-shrink: 0; }
.admin-users-list { max-height: 220px; overflow-y: auto; }
.admin-user-row {
    display: flex; gap: 8px; align-items: center; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.78rem;
}
.admin-user-info { flex: 1; min-width: 0; line-height: 1.35; }
.admin-user-info strong { color: var(--accent); }
.admin-user-meta { opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user-del {
    flex-shrink: 0; padding: 6px 10px; border-radius: 8px;
    border: 1px solid #ff4444; background: transparent; color: #ff6666;
    font-size: 0.72rem; cursor: pointer;
}
.admin-user-del:hover { background: rgba(255,0,0,0.15); }
.admin-codes-preview h3 { font-size: 0.9rem; margin-bottom: 8px; }
.codes-list { max-height: 150px; overflow-y: auto; }
.code-badge {
    display: inline-block; padding: 3px 8px; margin: 2px;
    background: rgba(255,255,255,0.1); border: 1px solid var(--frame);
    border-radius: 6px; font-size: 0.75rem; font-family: monospace; letter-spacing: 0.1em;
}

/* ===== POPUPS ===== */
.popup-overlay {
    position: fixed; inset: 0; z-index: 5000;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
    display: none; align-items: center; justify-content: center;
    padding: 16px;
}
.popup-overlay.visible { display: flex; }
.popup {
    position: relative;
    background: linear-gradient(160deg, #2a0a10, #1a0508);
    border: 1.5px solid var(--frame); border-radius: 20px;
    padding: 28px 24px; width: 90%; max-width: 380px; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: popIn 0.25s ease;
}
.popup-large { max-width: 400px; max-height: 90vh; overflow-y: auto; }
.popup-close {
    position: absolute; top: 10px; right: 10px;
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--frame); background: rgba(0,0,0,0.45);
    color: #fff; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.popup-close:hover { background: rgba(255,255,255,0.12); }
.popup h2 { margin: 0 0 6px; font-size: 1.3rem; }
.popup-sub { font-size: 0.85rem; opacity: 0.7; margin: 0 0 16px; line-height: 1.35; }
.popup-text { font-size: 0.9rem; opacity: 0.85; margin: 0 0 18px; line-height: 1.5; }
.popup-error {
    color: #ff6b6b; font-size: 0.82rem; margin: 12px 0 0;
    min-height: 1.2em; line-height: 1.35; width: 100%;
}
.popup input[type="text"], .popup input[type="email"], .popup input[type="tel"],
.popup input[type="password"] {
    width: 100%; padding: 12px 14px; border-radius: 10px;
    border: 1px solid var(--frame); background: rgba(255,255,255,0.08);
    color: #fff; font-size: 0.95rem;
}
.popup input::placeholder { color: rgba(255,255,255,0.4); }
.btn-danger-solid {
    background: #9a0c23 !important;
}
.btn-danger-solid:hover {
    background: #6b0a12 !important;
}

/* ===== RECORD / CONFETTI POPUP ===== */
.popup-record {
    overflow: hidden;
    padding: 0;
    max-width: 400px;
}
.popup-record-content {
    position: relative;
    z-index: 2;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-height: 800px) {
    .home-header { margin-bottom: 10px; padding-top: 8px; }
    .logo { width: 140px; height: 140px; margin-bottom: 10px; }
    .tagline { font-size: 1.25rem; }
    .game-card { padding: 12px 10px 10px; width: 170px; height: 236px; }
    .card-visual, .game-icon { width: 64px; height: 64px; }
    .game-card h2 { font-size: 1.1rem; }
}
@media (max-width: 720px) {
    .catalog { gap: 12px; padding: 12px 10px 0; }
    .logo { width: 120px; height: 120px; margin-bottom: 8px; }
    .tagline { font-size: 1.15rem; padding: 0 10px; }
    .home-header { margin-bottom: 10px; padding-top: 4px; }
    .game-card { width: 158px; height: 220px; padding: 12px 10px 10px; }
    .tetris-side { width: 100px; }
    .home-actions {
        flex-direction: column;
        align-items: stretch;
        width: min(320px, 92vw);
        margin-top: 12px;
        padding: 0 12px;
    }
    .home-actions .btn-scores { width: 100%; }
    .home-privacy { font-size: 0.75rem; padding-bottom: 16px; }
}

/* ===== MOBILE / TACTILE : plein écran + dock contrôles bas ===== */
@media (max-width: 900px), (pointer: coarse) {
    #page-game.active {
        height: 100%;
        max-height: 100dvh;
        overflow: hidden;
        overscroll-behavior: none;
    }
    #page-game .game-header {
        padding: 4px 8px;
        min-height: 44px;
    }
    #page-game .game-record { font-size: 0.72rem; line-height: 1.2; }

    #game-container > .game-shell,
    #game-container > .mem-stage {
        flex: 1 1 auto;
        width: 100%;
        height: 100%;
        min-height: 0;
    }
    #game-container > .mem-stage {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 8px env(safe-area-inset-bottom, 0px);
        margin: 0 auto;
        align-self: center;
    }

    .game-hud-top {
        padding: 6px 8px;
        gap: 0.3rem;
    }
    .snake-score-box {
        padding: 0.25rem 0.45rem;
        min-width: 54px;
    }
    .snake-score-box span:last-child { font-size: 0.95rem; }
    .snake-score-box .snake-label { font-size: 0.55rem; }
    .tetris-next-name { display: none; }
    #tetris-next { width: 48px; height: 48px; }

    .pacman-apt { display: none; }
    .galaga-hint,
    .brick-hint,
    .pacman-hint,
    .pacman-maze-hint { display: none; }

    .game-controls-dock {
        min-height: 148px;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
        touch-action: manipulation;
    }
    .snake-pad.game-controls-dock {
        display: grid;
        grid-template-columns: repeat(3, 76px);
        gap: 10px;
        min-height: 168px;
        justify-content: center;
    }
    .tetris-controls.game-controls-dock {
        flex-direction: column;
        gap: 8px;
        min-height: 168px;
    }
    .galaga-controls.game-controls-dock,
    .brick-controls.game-controls-dock {
        gap: 16px;
        min-height: 140px;
    }

    .snake-pad-btn,
    .t-btn {
        width: 76px;
        height: 76px;
        font-size: 1.55rem;
        border-radius: 18px;
        border-width: 2.5px;
        background: rgba(0, 0, 0, 0.5);
    }
    .galaga-controls .snake-pad-btn,
    .brick-controls .snake-pad-btn {
        width: 84px;
        height: 72px;
    }
    .ga-fire-btn {
        width: 96px !important;
        height: 80px !important;
        font-size: 1.7rem !important;
    }

    .card-visual { width: 96px; height: 96px; }
    .mem-board,
    .mem-board-20 {
        max-width: min(100%, 520px);
        margin: 0 auto;
        gap: 0.45rem;
    }
}

@media (pointer: fine) and (min-width: 901px) {
    .snake-pad { display: grid; }
    .tetris-controls { display: flex; }
    .game-controls-dock {
        background: transparent;
        border-top: none;
        padding-bottom: 12px;
    }
}

/* ===== Diaporama promo 10 s ===== */
.promo-slideshow {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: #0a0406;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.promo-slideshow[hidden] { display: none !important; }
.promo-slideshow-img {
    max-width: 92vw;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55);
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.promo-slideshow-img.is-visible {
    opacity: 1;
    transform: scale(1);
}
.promo-slideshow-bar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 4px;
    background: rgba(255,255,255,0.15);
}
.promo-slideshow-progress {
    height: 100%;
    width: 0%;
    background: var(--accent);
}
.promo-slideshow-hint {
    position: absolute;
    bottom: 18px;
    left: 0; right: 0;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.7;
    color: var(--cream);
    pointer-events: none;
}
