/* ─── COLOR RUSH ───
   Socle commun repris des conventions du projet (variables, boutons, overlays) + menu, boutique, partie.
   Aucune police distante : piles système. */

:root {
    --bg: #0a0a0b;
    --bg2: #111113;
    --surface: #18181c;
    --surface2: #1e1e24;
    --border: rgba(255, 255, 255, 0.07);
    --text: #e8e8f0;
    --dim: #8a8aa0;
    --accent: #ff3d81;
    --gold: #ffd700;
    --success: #00d4aa;
    --bad: #ff6b5a;
    --font-display: 'Rajdhani', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'Share Tech Mono', ui-monospace, Consolas, 'Courier New', monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html,
body {
    overscroll-behavior: none;
}

[hidden] {
    display: none !important;
}

body {
    font-family: var(--font-display);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    width: 100vw;
    overflow-x: hidden;
}

/* ─── BOUTONS RONDS (retour / pause) ─── */
.pause-btn {
    position: fixed;
    top: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--dim);
    width: 44px;
    height: 44px;
    border-radius: 10px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.pause-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

/* ─── BOUTONS ─── */
.btn-primary {
    width: 100%;
    min-height: 50px;
    padding: 14px;
    margin: 8px 0 0;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 6px 20px rgba(255, 61, 129, 0.3);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    width: 100%;
    min-height: 46px;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    color: var(--text);
    flex-shrink: 0;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.25);
}

:is(button, a):focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* ─── OVERLAYS ─── */
.game-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 6, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(8px);
}

.overlay-content {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 26px 22px;
    text-align: center;
    max-width: 380px;
    width: 92%;
    max-height: 94dvh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.overlay-content h2 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.overlay-text {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--dim);
    line-height: 1.5;
    margin-bottom: 8px;
}

.help {
    list-style: none;
    text-align: left;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 10px;
    display: grid;
    gap: 6px;
}

.win-trophy {
    font-size: 48px;
    margin-bottom: 4px;
}

.recap {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
}

.recap-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 14px;
    text-align: left;
}

.recap-row b {
    font-family: var(--font-mono);
    white-space: nowrap;
}

.recap-total {
    border-color: rgba(255, 215, 0, 0.5);
}

.recap-total b {
    color: var(--gold);
    font-size: 17px;
}

/* ─── ÉCRANS MENU / BOUTIQUE ─── */
.menu-body {
    min-height: 100dvh;
}

.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 16px 24px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

.menu-header {
    text-align: center;
}

.menu-icon {
    font-size: 40px;
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.menu-title {
    font-size: clamp(30px, 9vw, 46px);
    font-weight: 700;
    letter-spacing: 3px;
}

.menu-title-pro {
    color: var(--accent);
}

.shop-title {
    font-size: clamp(26px, 7vw, 36px);
}

.menu-subtitle {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

.menu-note {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--dim);
    text-align: center;
    line-height: 1.5;
    max-width: 420px;
}

.coins-badge {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
    background: var(--surface);
    border: 1px solid rgba(255, 215, 0, 0.35);
    border-radius: 999px;
    padding: 6px 18px;
    transition: transform 0.2s;
}

.coins-badge.bump {
    transform: scale(1.15);
}

.section-title {
    font-size: 14px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 8px;
    text-align: center;
}

.maps-section {
    width: 100%;
}

.msg {
    min-height: 18px;
    font-family: var(--font-mono);
    font-size: 13px;
    text-align: center;
}

.msg.good {
    color: var(--success);
}

.msg.bad {
    color: var(--bad);
}

.menu-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 420px;
}

/* Les deux actions du menu partagent une géométrie fixe sur tous les écrans. */
.menu-actions>button {
    width: 100%;
    height: 50px;
    min-height: 50px;
    flex: 0 0 50px;
}

/* cartes (grille de choix) */
.maps {
    display: grid;
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    grid-auto-columns: minmax(140px, 160px);
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.maps::-webkit-scrollbar,
.shop-grid::-webkit-scrollbar {
    height: 6px;
}

.maps::-webkit-scrollbar-track,
.shop-grid::-webkit-scrollbar-track {
    background: transparent;
}

.maps::-webkit-scrollbar-thumb,
.shop-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

.map-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-display);
    min-height: 120px;
}

.map-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 61, 129, 0.3);
}

.map-card img,
.shop-item img {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
    display: block;
}

.map-card.locked img {
    filter: grayscale(1) brightness(0.55);
}

.map-name {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 1px;
}

.map-best {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gold);
}

.map-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--dim);
}

.map-tag {
    position: absolute;
    top: 6px;
    right: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--bg);
    border-radius: 6px;
    padding: 1px 5px;
    color: var(--gold);
}

/* boutique */
.tabs {
    display: flex;
    gap: 6px;
    width: 100%;
}

.tab {
    flex: 1;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--dim);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
    cursor: pointer;
}

.tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.shop-grid {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    grid-auto-columns: minmax(140px, 160px);
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.shop-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 14px;
}

.shop-item.equipped {
    border-color: var(--success);
}

.shop-name {
    font-weight: 700;
    font-size: 15px;
    text-align: center;
}

.swatch {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.shop-item canvas {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    image-rendering: pixelated;
}

.shop-btn {
    width: 100%;
    min-height: 42px;
    border: none;
    border-radius: 9px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    cursor: pointer;
    background: var(--gold);
    color: #1a1a1a;
}

.shop-btn.equip {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.shop-btn.on {
    background: var(--success);
    color: #05231d;
    cursor: default;
}

.shop-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ─── PARTIE ─── */
.game-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: none;
    background: var(--bg);
}

.hud {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(14px, 5vw, 48px);
    padding: 13px 54px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 56px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-item .label {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--dim);
    font-family: var(--font-mono);
}

.hud-item .value {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 1px;
    line-height: 1;
}

.hud-pct {
    font-size: 20px !important;
    color: var(--gold);
}

.hud-bar {
    width: 84px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.hud-bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--gold);
}

.stage {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    touch-action: none;
    cursor: crosshair;
}

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

.minimap {
    position: absolute;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: 104px;
    height: 104px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    background: rgba(10, 10, 12, 0.6);
    pointer-events: none;
}

.toast {
    position: absolute;
    left: 50%;
    top: 18%;
    transform: translateX(-50%);
    max-width: 88%;
    text-align: center;
    padding: 10px 18px;
    border-radius: 14px;
    font-size: clamp(16px, 4.5vw, 22px);
    font-weight: 700;
    letter-spacing: 1px;
    color: #fff;
    background: rgba(10, 10, 12, 0.86);
    border: 2px solid var(--accent);
    pointer-events: none;
    z-index: 4;
}

@media (max-width: 600px) {

    .maps,
    .shop-grid {
        grid-template-rows: repeat(3, auto);
    }
}

@media (min-width: 820px) {
    .menu-container {
        max-width: 760px;
        padding-top: 48px;
    }

    .menu-actions {
        flex-direction: row;
        max-width: 520px;
    }

    .menu-actions>button {
        /* Même largeur dans la rangée, même si les libellés ont des longueurs différentes. */
        flex: 1 1 0;
    }

    .menu-actions .btn-primary {
        margin: 0;
    }
}

@media (max-height: 640px) {
    .hud {
        min-height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .menu-icon,
    .overlay-content {
        animation: none;
    }

    * {
        transition: none !important;
    }
}