/* ============================================
   Wni 7 différences - Feuille de styles
   Design responsive, thème néon sombre (style Pulse Pattern)
   ============================================ */

#game-main * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

#game-main {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #e0e0e0;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    overscroll-behavior: none;
}

#game-main #app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 1100px;
    margin: 0 auto;
}

/* --- Topbar --- */
#game-main .topbar {
    padding: 12px 14px 8px;
    background: linear-gradient(180deg, rgba(15,12,41,0.95), rgba(20,20,42,0.95));
    border-bottom: 1px solid rgba(0,210,255,0.15);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}
/* Compact topbar during gameplay */
#game-main #screen-game.active ~ nav ~ #main,
#game-main:has(#screen-game.active) .topbar {
    padding: 6px 14px 4px;
}
#game-main:has(#screen-game.active) .title {
    font-size: 16px;
}
#game-main:has(#screen-game.active) .infos {
    margin-top: 4px;
    gap: 4px;
}
#game-main:has(#screen-game.active) .badge {
    padding: 2px 8px;
    font-size: 11px;
}
#game-main .title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-align: center;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
#game-main .infos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    justify-content: center;
}
#game-main .badge {
    background: rgba(0,210,255,0.08);
    border: 1px solid rgba(0,210,255,0.25);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #cfd0ff;
}

/* --- Main / screens --- */
#game-main #main {
    flex: 1;
    padding: 14px;
    padding-bottom: 96px;
    position: relative;
    display: flex;
    flex-direction: column;
}
#game-main .screen { display: none; animation: fade 0.18s ease-out; }
#game-main .screen.active { display: block; }
#game-main #screen-game.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 6px;
}
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* --- Home --- */
#game-main .hero { text-align: center; padding: 24px 8px 8px; }
#game-main .logo {
    width: 96px; height: 96px; margin: 8px auto 14px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 56px; font-weight: 800;
    background: radial-gradient(circle at 30% 30%, #00d2ff, #7b2ff7 50%, #ff6fd8);
    color: #0f0c29;
    box-shadow: 0 10px 30px rgba(0,210,255,0.25);
}
#game-main .tagline { font-size: 16px; margin: 6px 0; color: #d8d8f0; }
#game-main .tagline.small { font-size: 13px; color: #9a9ac0; }

/* --- Buttons --- */
#game-main .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
#game-main .btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: #f1f1f5;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 18px;
    border-radius: 12px;
    min-height: 48px;
    min-width: 88px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    touch-action: manipulation;
    user-select: none;
    transition: transform 0.06s, background 0.15s, border-color 0.15s;
}
#game-main .btn:active { transform: scale(0.97); }
#game-main .btn-primary { background: linear-gradient(135deg, #00d2ff, #7b2ff7); border-color: transparent; }
#game-main .btn-warn    { background: linear-gradient(135deg, #ff9a3c, #ff5e7e); border-color: transparent; }
#game-main .btn-danger  { background: linear-gradient(135deg, #ff4d6d, #c9184a); border-color: transparent; }

/* --- Game --- */
#game-main .image-stack { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
#game-main .image-card {
    background: rgba(15,12,41,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 4px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
#game-main .image-label {
    font-size: 11px;
    color: #9a9ac0;
    margin-bottom: 2px;
    text-align: center;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
#game-main .canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}
#game-main .game-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    touch-action: manipulation;
}
#game-main .overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    touch-action: manipulation;
    pointer-events: auto;
}

#game-main .solution-dialog {
    position: fixed;
    top: 80px;
    right: 12px;
    background: rgba(15,12,41,0.96);
    border: 1px solid rgba(0,210,255,0.35);
    border-radius: 12px;
    padding: 10px 14px;
    z-index: 45;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    text-align: center;
    max-width: 240px;
}
#game-main .solution-dialog[hidden] { display: none; }
#game-main .solution-dialog-text {
    margin: 0 0 10px;
    font-size: 13px;
    color: #e0e0e0;
    line-height: 1.3;
}
#game-main .solution-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* --- Cards (rules / scores / end) --- */
#game-main .card {
    background: rgba(15,12,41,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 18px;
    max-width: 640px;
    margin: 0 auto;
}
#game-main .card h2 {
    margin: 0 0 12px;
    font-size: 20px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
#game-main .rules { padding-left: 18px; line-height: 1.55; }
#game-main .rules li { margin: 6px 0; }
#game-main .muted { color: #9a9ac0; font-size: 13px; text-align: center; }

/* --- Score box --- */
#game-main .score-box-server {
    background: rgba(0,210,255,0.06);
    border: 1px solid rgba(0,210,255,0.2);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 14px;
    text-align: center;
}
#game-main .score-row { display: flex; justify-content: space-between; align-items: center; }
#game-main .score-label { color: #9a9ac0; font-size: 14px; }
#game-main .score-number { font-size: 28px; font-weight: 800; color: #00d2ff; }

#game-main .score-list { padding-left: 22px; margin: 8px 0 14px; }
#game-main .score-list li { padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,0.08); display: flex; justify-content: space-between; gap: 8px; }
#game-main .score-list .rank { color: #00d2ff; font-weight: 700; min-width: 30px; }
#game-main .score-list .pseudo { flex: 1; }
#game-main .score-list .pts { color: #ffea7e; font-weight: 700; }
#game-main .score-list .when { color: #7777a0; font-size: 12px; }

/* --- End screen --- */
#game-main .end-card { text-align: center; }
#game-main .end-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0 16px;
}
#game-main .end-stats > div {
    background: rgba(0,210,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 10px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
#game-main .end-stats span { color: #9a9ac0; font-size: 12px; }
#game-main .end-stats strong { font-size: 22px; color: #ffea7e; }

/* --- Bottom bar --- */
#game-main .bottombar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: rgba(15,12,41,0.96);
    border-top: 1px solid rgba(0,210,255,0.15);
    padding: 6px;
    display: flex;
    gap: 4px;
    justify-content: space-around;
    z-index: 20;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
}
#game-main .bottombar .btn { flex: 1; padding: 8px 4px; min-width: 0; font-size: 12px; min-height: 40px; text-align: center; }

/* --- Toast --- */
#game-main .toast[hidden] { display: none; }
#game-main .toast {
    position: fixed;
    left: 50%;
    top: 22%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.78);
    color: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    z-index: 50;
    pointer-events: none;
    animation: toastIn 0.2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* --- Tablet / desktop --- */
@media (min-width: 768px) {
    #game-main .title { font-size: 24px; }
    #game-main #main { padding: 18px; }
    #game-main .image-stack {
        flex-direction: row;
        align-items: stretch;
        gap: 10px;
    }
    #game-main .image-card { flex: 1; }
    #game-main .actions .btn { min-width: 140px; }
    #game-main .end-stats { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    #game-main .image-card { padding: 10px; }
}

@media (max-height: 520px) and (orientation: landscape) {
    #game-main .image-stack { flex-direction: row; }
    #game-main #main { padding-bottom: 70px; padding-top: 4px; }
    #game-main .bottombar .btn { min-height: 34px; padding: 4px 4px; }
}

/* Markers animation hint */
#game-main .marker-pulse { animation: pulse 0.6s ease-out; }
@keyframes pulse {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
