/* ============================================================
   StarGet — theme "CRT annees 80" : vert phosphore sur noir.
   Ethereal & smooth : grille synthwave a l'horizon, scanlines,
   barre de balayage, neons, animations douces.
   Charge APRES le style.css partage : la palette est redefinie
   via les variables CSS, donc topbar / modals / boutons passent
   automatiquement au vert.
   ============================================================ */

:root {
    --bg: #010604;
    --panel: rgba(2, 14, 8, 0.90);
    --panel-solid: #041209;
    --panel-2: #072415;
    --line: #14522d;
    --line-dim: rgba(80, 255, 140, 0.14);
    --accent: #4dff88;
    --accent-soft: rgba(77, 255, 136, 0.10);
    --gold: #ffd166;
    --star: #eafff2;
    --text: #bdf5d3;
    --dim: #5fa87c;
    --good: #4dff88;
    --bad: #ff5f6e;
    --shadow: 4px 4px 0 rgba(0, 0, 0, 0.6), 0 0 28px rgba(77, 255, 136, 0.07);
    --glow-txt: 0 0 6px rgba(77, 255, 136, 0.55), 0 0 24px rgba(77, 255, 136, 0.25);
}

/* ------------------------------------------------------------
   Fond de jeu : nebuleuse verte, canvas calibre 1:1 avec l'ecran
   ------------------------------------------------------------ */
#game {
    position: fixed;
    inset: 0;
    /* Taille CSS explicite : sans elle le canvas s'affiche a la taille
       de son bitmap (x devicePixelRatio) et la hitbox est decalee. */
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
    cursor: crosshair;
    touch-action: none;
    background:
        radial-gradient(ellipse at 50% 118%, rgba(20, 120, 60, 0.30), transparent 58%),
        radial-gradient(ellipse at 12% -8%, rgba(10, 70, 40, 0.22), transparent 55%),
        radial-gradient(ellipse at 88% 4%, rgba(8, 60, 34, 0.18), transparent 50%),
        var(--bg);
}

/* ------------------------------------------------------------
   Couches retro (au-dessus du jeu, jamais cliquables)
   .vignette         -> vignette + scanlines statiques
   .vignette::before -> barre de balayage CRT qui descend
   .vignette::after  -> grille synthwave a l'horizon
   ------------------------------------------------------------ */
.vignette {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
        radial-gradient(ellipse at center, transparent 52%, rgba(1, 6, 4, 0.88) 100%);
}

.vignette::before { /* balayage CRT */
    content: "";
    position: absolute;
    left: 0; right: 0;
    top: -18%;
    height: 16%;
    background: linear-gradient(to bottom,
        transparent,
        rgba(120, 255, 170, 0.05) 45%,
        rgba(120, 255, 170, 0.09) 50%,
        rgba(120, 255, 170, 0.05) 55%,
        transparent);
    animation: sg-scan 7s linear infinite;
}
@keyframes sg-scan {
    from { transform: translateY(0); }
    to   { transform: translateY(740%); }
}

.vignette::after { /* grille synthwave qui defile vers l'horizon */
    content: "";
    position: absolute;
    left: -25%; right: -25%;
    bottom: -8vh;
    height: 44vh;
    background:
        repeating-linear-gradient(90deg, rgba(77, 255, 136, 0.30) 0 1px, transparent 1px 64px),
        repeating-linear-gradient(0deg,  rgba(77, 255, 136, 0.30) 0 1px, transparent 1px 46px);
    transform: perspective(330px) rotateX(58deg);
    transform-origin: 50% 100%;
    animation: sg-grid 2.8s linear infinite;
    -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.9) 30%, transparent);
            mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.9) 30%, transparent);
    opacity: 0.30;
}
@keyframes sg-grid {
    from { background-position: 0 0, 0 0; }
    to   { background-position: 0 0, 0 46px; }
}

/* ------------------------------------------------------------
   Topbar : bandeau noir, liseres et titre neon
   ------------------------------------------------------------ */
.topbar {
    background: rgba(1, 8, 5, 0.92);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(77, 255, 136, 0.12), 0 6px 30px rgba(0, 0, 0, 0.55);
}
.brand {
    color: var(--star);
    text-shadow: var(--glow-txt);
    transition: color .25s ease, text-shadow .25s ease;
}
.brand:hover {
    color: var(--accent);
    text-shadow: 0 0 10px rgba(77, 255, 136, 0.8), 0 0 34px rgba(77, 255, 136, 0.35);
}
.top-btn, .lang-switch a { transition: color .25s ease, border-color .25s ease, background .25s ease, box-shadow .25s ease; }
.top-btn:hover, .top-btn.active, .lang-switch a:hover:not(.active) {
    box-shadow: 0 0 14px rgba(77, 255, 136, 0.18), inset 0 0 10px rgba(77, 255, 136, 0.06);
}
.lang-switch a.active { text-shadow: none; }

/* ------------------------------------------------------------
   HUD score / record : cadran neon
   ------------------------------------------------------------ */
.sg-hud {
    position: fixed;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow), inset 0 0 18px rgba(77, 255, 136, 0.05);
    pointer-events: none;
    animation: sg-drop .5s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes sg-drop {
    from { opacity: 0; transform: translateX(-50%) translateY(-14px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.sg-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 24px 9px;
    border-right: 1px solid var(--line);
    min-width: 104px;
    position: relative;
}
.sg-stat:last-child { border-right: none; }
.sg-stat::before { /* petit repere lumineux au-dessus de chaque cadran */
    content: "";
    position: absolute;
    top: 0; left: 50%;
    width: 26px; height: 2px;
    transform: translateX(-50%);
    background: var(--accent);
    box-shadow: 0 0 10px rgba(77, 255, 136, 0.8);
    opacity: 0.55;
}
.sg-stat .sv {
    font-size: 23px;
    font-weight: 700;
    color: var(--star);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: var(--glow-txt);
    transition: text-shadow .3s ease;
}
.sg-stat .sv.gold {
    color: var(--gold);
    text-shadow: 0 0 6px rgba(255, 209, 102, 0.55), 0 0 22px rgba(255, 209, 102, 0.22);
}
.sg-stat .sk {
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: lowercase;
    color: var(--dim);
    margin-top: 5px;
}

/* ------------------------------------------------------------
   Overlay intro / fin de partie : apparition douce, coins neon
   ------------------------------------------------------------ */
.sg-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 3, 2, 0.72);
    backdrop-filter: blur(3px);
}
.sg-overlay.open { display: flex; animation: sg-fade .35s ease both; }
@keyframes sg-fade { from { opacity: 0; } to { opacity: 1; } }

.sg-panel {
    width: 400px;
    max-width: 100%;
    text-align: center;
    position: relative;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    box-shadow: var(--shadow), 0 0 60px rgba(77, 255, 136, 0.10);
    animation: sg-rise .45s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes sg-rise {
    from { opacity: 0; transform: translateY(22px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* Coins lumineux (crochets retro) */
.sg-panel::before, .sg-panel::after {
    content: "";
    position: absolute;
    width: 16px; height: 16px;
    pointer-events: none;
}
.sg-panel::before {
    top: -1px; left: -1px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
    box-shadow: -2px -2px 14px rgba(77, 255, 136, 0.35);
}
.sg-panel::after {
    bottom: -1px; right: -1px;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
    box-shadow: 2px 2px 14px rgba(77, 255, 136, 0.35);
}

.sg-panel h2 {
    text-shadow: var(--glow-txt);
    animation: sg-flicker 1.6s ease both;
}
@keyframes sg-flicker { /* allumage de tube cathodique */
    0%   { opacity: 0; }
    6%   { opacity: 1; }
    10%  { opacity: .35; }
    14%  { opacity: 1; }
    22%  { opacity: .6; }
    28%  { opacity: 1; }
    100% { opacity: 1; }
}

.sg-panel .panel-body { padding: 20px 22px 22px; }
.sg-text {
    color: var(--dim);
    font-size: 12.5px;
    line-height: 1.7;
    margin: 4px 0 14px;
}
.sg-note { color: var(--dim); font-size: 11px; margin: 2px 0 8px; }

.sg-panel .go-score {
    font-size: 42px;
    font-weight: 700;
    color: var(--gold);
    margin: 8px 0 14px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 8px rgba(255, 209, 102, 0.55), 0 0 30px rgba(255, 209, 102, 0.25);
}

.sg-panel input[type=text] {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 5, 3, 0.75);
    border: 1px solid var(--line);
    color: var(--star);
    font-size: 13px;
    text-align: center;
    letter-spacing: 1px;
    font-family: var(--mono);
    margin-bottom: 6px;
    caret-color: var(--accent);
    transition: border-color .25s ease, box-shadow .25s ease;
}
.sg-panel input[type=text]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(77, 255, 136, 0.20), inset 0 0 12px rgba(77, 255, 136, 0.05);
}
.sg-wide { width: 100%; margin-bottom: 8px; }

/* ------------------------------------------------------------
   Boutons : neon vert, halo pulsant sur COMMENCER
   ------------------------------------------------------------ */
.btn { transition: color .25s ease, border-color .25s ease, background .25s ease, box-shadow .25s ease, transform .12s ease; }
.btn:hover { box-shadow: 0 0 18px rgba(77, 255, 136, 0.22); }
.btn:active { transform: translate(2px, 2px); }
.btn-primary {
    color: #01130a;
    text-shadow: none;
}
#sgStart {
    animation: sg-pulse 2.2s ease-in-out infinite;
}
@keyframes sg-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(77, 255, 136, 0.25); }
    50%      { box-shadow: 0 0 26px rgba(77, 255, 136, 0.55), 0 0 60px rgba(77, 255, 136, 0.15); }
}
#sgStart:hover { animation-play-state: paused; box-shadow: 0 0 30px rgba(77, 255, 136, 0.6); }

/* ------------------------------------------------------------
   Mode "landing" : etoiles lentes eliminables derriere, panneau
   reduit a l'essentiel (titre + PLAY au centre). Les clics passent
   au canvas grace a pointer-events:none sur tout sauf le bouton.
   ------------------------------------------------------------ */
.sg-overlay.landing {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
}
.sg-overlay.landing .sg-panel {
    background: transparent;
    border: none;
    box-shadow: none;
}
.sg-overlay.landing .sg-panel::before,
.sg-overlay.landing .sg-panel::after { display: none; }
.sg-overlay.landing .sg-panel h2 {
    background: transparent;
    border: none;
    text-align: center;
    font-size: clamp(30px, 7vw, 44px);
    letter-spacing: 6px;
    text-shadow: 0 0 10px rgba(77, 255, 136, 0.55), 0 0 40px rgba(77, 255, 136, 0.25);
}
.sg-overlay.landing .sg-text {
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
.sg-overlay.landing #sgStart {
    pointer-events: auto;      /* seul element cliquable de l'overlay */
    padding: 16px 56px;
    font-size: 14px;
    letter-spacing: 3px;
}
.sg-overlay.landing #sgLb,
.sg-overlay.landing #sgOther { display: none; }

/* ------------------------------------------------------------
   Compte a rebours 3..2..1 avant le lancement de la partie
   ------------------------------------------------------------ */
.sg-count {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.sg-count.show { display: flex; }
.sg-count .n {
    font-family: var(--mono, Consolas, monospace);
    font-weight: 700;
    font-size: clamp(96px, 30vw, 240px);
    line-height: 1;
    color: #eafff2;
    text-shadow: 0 0 30px rgba(77, 255, 136, 0.75), 0 0 90px rgba(77, 255, 136, 0.35);
}
/* "Pop" a chaque chiffre : apparait grand, se stabilise, puis s'efface */
.sg-count.pop .n { animation: sg-count-pop 0.95s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes sg-count-pop {
    0%   { opacity: 0; transform: scale(1.7); }
    22%  { opacity: 1; transform: scale(1); }
    72%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.62); }
}

/* ------------------------------------------------------------
   Modal classement : memes codes neon
   ------------------------------------------------------------ */
.modal {
    box-shadow: var(--shadow), 0 0 60px rgba(77, 255, 136, 0.10);
}
.modal h2 { text-shadow: var(--glow-txt); }
.lb-table tr { transition: background .2s ease; }
.lb-table .sc { text-shadow: 0 0 8px rgba(77, 255, 136, 0.25); }
.lb-me td { background: rgba(255, 209, 102, 0.08); }

/* ------------------------------------------------------------
   Page "A propos" (fiche du jeu)
   ------------------------------------------------------------ */
.sg-panel .kv { text-align: left; }
.sg-panel .sg-origin {
    font-size: 11px;
    color: var(--dim);
    line-height: 1.5;
    max-width: 62%;
}
.sg-panel .kv a {
    color: var(--accent);
    transition: text-shadow .25s ease;
}
.sg-panel .kv a:hover { text-shadow: 0 0 10px rgba(77, 255, 136, 0.6); }

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 640px) {
    /* HUD score / record : pleine largeur, les deux cadrans se partagent l'ecran */
    .sg-hud {
        top: 52px;
        left: 10px;
        right: 10px;
        transform: none;
        animation-name: sg-drop-m;
    }
    .sg-stat { flex: 1; min-width: 0; padding: 8px 10px 7px; }
    .sg-stat .sv { font-size: 19px; }

    /* Cartes (intro / fin de partie / classement) : centrees a l'ecran */
    .sg-overlay {
        align-items: center;
        padding: 16px;
    }
    .modal-back {
        align-items: center;
        padding: 16px;
    }

    .vignette::after { height: 30vh; opacity: 0.22; }
}
@keyframes sg-drop-m { /* variante mobile de sg-drop (sans translateX) */
    from { opacity: 0; transform: translateY(-14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 380px) {
    .sg-stat { padding: 7px 8px 6px; }
    .sg-panel .panel-body { padding: 16px 14px 18px; }
}

/* ------------------------------------------------------------
   Allegement telephones (GPU/CPU modestes) : on coupe les effets
   qui repeignent l'ecran en continu, le look reste identique.
   ------------------------------------------------------------ */
@media (pointer: coarse), (max-width: 640px) {
    .vignette::before { display: none; }   /* barre de balayage CRT */
    .vignette::after { animation: none; }  /* grille synthwave : statique */
    .sg-overlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(0, 3, 2, 0.84);   /* compense l'absence de flou */
    }
    .lang-switch {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    /* Halo pulsant du bouton = repaint continu : halo fixe a la place */
    #sgStart {
        animation: none;
        box-shadow: 0 0 22px rgba(77, 255, 136, 0.40);
    }
}

/* Accessibilite : pas de grosses animations si le systeme le demande */
@media (prefers-reduced-motion: reduce) {
    .vignette::before, .vignette::after,
    #sgStart, .sg-hud, .sg-panel, .sg-panel h2, .sg-overlay.open {
        animation: none !important;
    }
    /* Compte a rebours : chiffre visible sans effet de scale/fondu */
    .sg-count.pop .n { animation: none !important; opacity: 1; }
}
