/* ==========================================================================
   CARD COUNTING STYLES
   ========================================================================== */

:root {
    --dynamic-card-width: 120px;
    --dynamic-card-height: 170px;
    
    --red-suit: #e11d48;
    --black-suit: #1e293b;
    --card-bg-front: #ffffff;
}

/* 1. INTERFACE GÉNÉRALE */
.game-interface {
    position: absolute; inset: 0; z-index: 2;
    width: 100%; height: 100%; 
    padding: 1.5rem; 
    box-sizing: border-box; 
    display: flex; 
    flex-direction: column; 
}
.game-interface.visible { opacity: 1; pointer-events: all; }
.game-interface.hidden { display: none; }

#start-overlay.visible ~ .game-interface,
#game-over-overlay.visible ~ .game-interface {
    opacity: 0; pointer-events: none;
}

.game-header > *, .game-actions-row > *, .settings-btn, .icon-btn, .score-box, .input-controls { 
    pointer-events: auto; 
}

/* 2. HEADER */
.game-header {
    width: 100%;
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
    margin-bottom: 10px;
    position: relative;
}
.score-box { flex-direction: column; min-width: 80px; }
.label-small { font-size: 0.7rem; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; }
.stat-box { font-family: var(--font-heading); color: var(--text-primary); font-size: 1.6rem; font-weight: 500; line-height: 1; }

/* CENTRAGE DES VIES */
.lives-display {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex; align-items: flex-start; justify-content: center;
    gap: 8px; height: 100%; padding-top: 5px;
    z-index: 5;
}

.lives-display span {
    font-size: 3.5rem; font-weight: 600; line-height: 1;
    color: var(--text-primary);
}

.heart-icon {
    height: 5.5vh; width: auto; 
    min-height: 35px; max-height: 55px; 
    fill: var(--accent-color-secondary) !important;  
}
.heart-lost { fill: var(--border-color) !important; opacity: 0.5; transform: scale(0.8); }

/* --- OVERLAY DE STATUT (PRÊT ?) --- */
#status-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    cursor: pointer;
}
#status-overlay.hidden { display: none !important; opacity: 0; }

.status-main-text {
    font-family: var(--font-heading); 
    font-size: 5.5rem; 
    font-weight: 500; 
    color: var(--text-primary); 
    letter-spacing: -4px; 
    line-height: 1; 
    transition: opacity 0.2s;
}

.status-sub-text {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; margin-top: 1.5rem;
    font-family: var(--font-body); font-size: 1.1rem;
    color: var(--text-secondary); font-weight: 500;
    text-transform: uppercase; letter-spacing: 1px;
}

.status-sub-text svg {
    width: 24px; height: 24px;
    color: var(--text-primary); 
}

:fullscreen .status-main-text { font-size: 8.5rem; }
:fullscreen .status-sub-text { font-size: 1.5rem; margin-top: 2rem; }
:fullscreen .status-sub-text svg { width: 32px; height: 32px; }

.blurred { filter: blur(10px); opacity: 0.3; pointer-events: none; }


/* 3. ZONE CENTRALE (Cartes) */
.game-center-area {
    flex: 1; 
    width: 100%;
    display: flex;
    flex-direction: column; 
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 0; 
    padding-bottom: 1rem; 
}

.card-display-area {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center; 
    align-content: center;
    flex-wrap: wrap;
    gap: 10px;
    overflow-y: auto; 
    max-height: 100%;
    padding: 10px;
}

/* --- STYLE DES CARTES (Transition rapide 0.25s) --- */
.playing-card {
    width: var(--dynamic-card-width);
    height: var(--dynamic-card-height);
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border-radius: calc(var(--dynamic-card-width) * 0.08);
    flex-shrink: 0;
    transform: perspective(1000px) rotateY(0deg);
}

.playing-card.hidden { opacity: 0; }

.card-front, .card-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; 
    border-radius: calc(var(--dynamic-card-width) * 0.08);
    overflow: hidden;
}

/* --- DOS DE LA CARTE --- */
.card-back {
    background-color: var(--accent-color);
    transform: rotateY(180deg);
    display: flex; align-items: center; justify-content: center;
    border: calc(var(--dynamic-card-width) * 0.05) solid #fff;
}

.pattern-inner {
    width: 100%; height: 100%;
    background-image: 
        linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.2) 75%, rgba(255,255,255,0.2)),
        linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.2) 75%, rgba(255,255,255,0.2));
    background-size: 20px 20px; background-position: 0 0, 10px 10px;
}

/* --- FACE DE LA CARTE --- */
.card-front {
    transform: rotateY(0deg);
    background-color: var(--card-bg-front);
    font-family: 'Space Grotesk', sans-serif;
    color: var(--black-suit);
    border: 1px solid #cbd5e1;
}

.card-front.face-card-mode { border: none; padding: 0; display: flex; justify-content: center; align-items: center; }
.card-front.red-suit { color: var(--red-suit); }
.card-front.black-suit { color: var(--black-suit); }

.card-corner {
    position: absolute;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    line-height: 1; font-weight: 700; 
    width: calc(var(--dynamic-card-width) * 0.2);
    padding-top: calc(var(--dynamic-card-width) * 0.05);
}
.card-corner .corner-val { font-size: calc(var(--dynamic-card-width) * 0.22); letter-spacing: -1px; }
.card-corner .corner-suit { font-size: calc(var(--dynamic-card-width) * 0.10); margin-top: 0; }
.corner-top-left { top: 0; left: 0; }
.corner-bottom-right { bottom: 0; right: 0; transform: rotate(180deg); }

.card-inner-layout {
    position: absolute;
    left: 0; right: 0; top: calc(var(--dynamic-card-width) * 0.15); bottom: calc(var(--dynamic-card-width) * 0.15);
    padding: 0 calc(var(--dynamic-card-width) * 0.18);
    display: flex; justify-content: space-between; align-items: stretch;
}
.pip-col { display: flex; flex-direction: column; justify-content: space-between; align-items: center; flex: 1 1 0px; width: 0; }
.pip-col.mid-col { justify-content: center; gap: 15%; }
.pip-symbol { font-size: calc(var(--dynamic-card-width) * 0.22); line-height: 1; }
.pip-symbol.inverted { transform: rotate(180deg); }
.pip-symbol.transparent { opacity: 0; }
.layout-ace { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.big-ace-symbol { font-size: calc(var(--dynamic-card-width) * 0.6); }

.face-card-wrapper { position: absolute; inset: calc(var(--dynamic-card-width) * 0.5); display: flex; flex-direction: column; justify-content: center; align-items: center; }

/* 3D Transform */
.playing-card.flipped { transform: perspective(1000px) rotateY(180deg); }
.game-board.disable-flip .playing-card { transition: none !important; }

/* 4. BARRE D'ACTIONS */
.game-actions-row { 
    position: absolute; bottom: 0; left: 0; right: 0;
    width: 100%; padding: 1.5rem; box-sizing: border-box;
    display: flex; justify-content: space-between; align-items: flex-end; 
    z-index: 60; pointer-events: none; 
}

/* ==========================================================================
   5. BARRE DE SAISIE (Alignée avec le footer)
   ========================================================================== */

.input-controls {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center; 
    pointer-events: none; 
    z-index: 55; 
    transition: transform 0.2s ease, opacity 0.2s, filter 0.3s ease;
}

.input-bar-wrapper {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0;
    height: 72px; 
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
    opacity: 0.6;
    transform: scale(0.98);
    overflow: hidden;
}

.input-controls.active .input-bar-wrapper {
    opacity: 1;
    border-color: var(--accent-color);
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: scale(1);
}

.native-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-heading);
    font-size: 2.5rem; 
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    padding: 0 56px; /* Balanced padding for centered text (8px margin + 48px button) */
    margin: 0;
    line-height: normal;
}

.submit-btn {
    position: absolute;
    right: 8px; 
    background: var(--accent-color);
    color: var(--bg-main);
    border: none;
    border-radius: 4px;
    width: 48px; 
    height: 48px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.1s, opacity 0.2s;
}
.submit-btn:active { transform: scale(0.95); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.native-input::placeholder {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 2.5rem; 
    opacity: 0.4;
    line-height: 72px; 
    text-transform: uppercase;
}

.native-input::-webkit-outer-spin-button,
.native-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.native-input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
}

@keyframes shake-bar {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}
.shake-anim {
    animation: shake-bar 0.25s ease-in-out;
    border-color: var(--red-suit) !important;
    box-shadow: none !important; 
}

@keyframes pulse-accent {
    0% { transform: scale(1); border-color: var(--accent-color); }
    50% { transform: scale(1.05); border-color: var(--accent-color); }
    100% { transform: scale(1); border-color: var(--accent-color); }
}
.valid-anim {
    animation: pulse-accent 0.4s ease-out;
    border-color: var(--accent-color) !important;
    color: var(--accent-color) !important; 
}


/* 6. CLASSES MODE SWITCH & RESULTATS */
select.settings-select {
    background-color: var(--bg-main); color: var(--text-primary);
    border: 1px solid var(--border-color); padding: 8px; border-radius: var(--radius-md);
    font-family: var(--font-body); font-size: 1rem; cursor: pointer; outline: none; width: auto;
}
select.settings-select:focus { border-color: var(--accent-color); box-shadow: 0 0 0 2px var(--accent-glow); }

.mode-switch-wrapper {
    display: flex; position: relative; background-color: var(--bg-main);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 4px; margin-bottom: 1.5rem;
}
.mode-switch-wrapper input[type="radio"] { display: none; }
.mode-switch-wrapper label {
    flex: 1; text-align: center; padding: 10px 0; font-family: var(--font-heading); font-weight: 600; font-size: 0.9rem;
    color: var(--text-secondary); cursor: pointer; z-index: 2; margin: 0; transition: color 0.3s ease; text-transform: uppercase; letter-spacing: 1px;
}
.mode-switch-wrapper input:checked + label { color: var(--text-primary); }
.mode-slider {
    position: absolute; top: 4px; bottom: 4px; width: calc(50% - 4px);
    background-color: var(--card-bg); border-radius: 6px; z-index: 1;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.mode-switch-wrapper input[value="sandbox"]:checked ~ .mode-slider { transform: translateX(100%); }

.results-view { width: 100%; display: flex; flex-direction: column; align-items: center; }
.results-view.hidden { display: none !important; }
#game-over-overlay .overlay-content { justify-content: center; gap: 1.5rem; }

.centered-score-item { text-align: center; margin-bottom: 3rem; }
.centered-score-item .res-label { font-size: 1.2rem; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; opacity: 0.7; display: block; margin-bottom: 0.8rem; }
.big-score-container { display: flex; align-items: baseline; justify-content: center; position: relative; }
#results-ranked .res-value.big, #results-sandbox .res-value.big { font-size: 5.5rem; font-weight: 700; line-height: 1; font-family: var(--font-heading); }
.score-unit { font-size: 1.4rem; color: var(--accent-color); margin-left: 8px; font-family: var(--font-heading); font-weight: 500; }

.distribution-chart-container {
    position: relative; width: 100%; max-width: 650px; height: 180px;
    margin: 1.5rem 0 2rem 0;
    border-bottom: 2px solid var(--border-color); cursor: crosshair;
}
.curve-svg { width: 100%; height: 100%; overflow: visible; }
.axis-label { position: absolute; bottom: -25px; font-family: var(--font-body); font-size: 0.8rem; color: var(--text-secondary); }
.axis-label.left { left: 0; }
.axis-label.right { right: 0; }
.hover-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--text-primary); transform: translateX(-50%); pointer-events: none; opacity: 0.3; z-index: 3; transition: opacity 0.2s ease; }
.chart-tooltip { position: absolute; top: -55px; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: var(--radius-md); font-family: var(--font-body); font-size: 0.9rem; color: var(--text-primary); pointer-events: none; white-space: nowrap; z-index: 10; box-shadow: var(--shadow-card); text-align: center; line-height: 1.4; transition: opacity 0.2s ease, visibility 0.2s ease; }
.hover-line.hidden, .chart-tooltip.hidden { opacity: 0 !important; visibility: hidden !important; }
.score-marker { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; transform: translateX(-50%); pointer-events: none; transition: left 0.5s ease-out; }
.marker-line { width: 2px; height: 100%; border-left: 2px dashed currentColor; }
.marker-label { position: absolute; font-family: var(--font-heading); font-size: 0.8rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; white-space: nowrap; }
.marker-current { color: var(--accent-color); z-index: 2; }
.marker-current .marker-label { bottom: 100%; margin-bottom: 5px; background: var(--bg-main); border: 1px solid currentColor;}
.marker-best { color: var(--text-tertiary); z-index: 1; opacity: 0.8;}
.marker-best .marker-label { top: 100%; margin-top: 5px; color: var(--text-secondary); }

/* MEDIA QUERIES */
@media (max-width: 900px) { 
    .status-main-text { font-size: 5rem; }
}

@media (max-width: 600px) {
    .game-interface { padding: 0.5rem 1rem 0 1rem; }
    .game-center-area { padding-bottom: 0.5rem; }
    
    .input-controls { 
        max-width: 100%; 
        border: none;
    }

    .input-bar-wrapper {
        height: 60px; /* Match mobile icon-btn height */
        max-width: 100%;
    }

    .native-input, .native-input::placeholder {
        font-size: 1.8rem;
        line-height: 60px;
        padding: 0 44px; /* Balanced padding for mobile */
    }

    .submit-btn {
        width: 44px !important;
        height: 44px !important;
        right: 8px !important;
    }

    .game-actions-row {
        position: relative; 
        bottom: auto; left: auto; right: auto;
        padding: 0 5px;
        margin-bottom: 5px; 
        pointer-events: auto;
    }

    #results-ranked .res-value.big, #results-sandbox .res-value.big { font-size: 4.5rem; }
    .score-unit { font-size: 1.2rem; }
    .distribution-chart-container { height: 140px; margin-top: 1.5rem; margin-bottom: 2.5rem; }
    
    .status-main-text { font-size: 4rem; }
    .status-sub-text { font-size: 0.9rem; flex-wrap: wrap; }
}

@media (max-width: 700px) {
    #game-over-overlay { overflow-y: auto !important; }
    #game-over-overlay .overlay-content {
        height: auto !important;
        min-height: 100% !important;
        padding: 4rem 0 3rem 0 !important;
        justify-content: center !important;
        gap: 2.5rem !important;
    }
}

.card-corner .corner-val.is-ten { display: flex; align-items: center; transform: scaleX(0.85); letter-spacing: -2px; }
.narrow-zero { display: inline-block; transform: scaleX(0.90); transform-origin: left center; }

/* AJUSTEMENTS PLEIN ÉCRAN */
:fullscreen .input-bar-wrapper { max-width: 600px; transition: max-width 0.3s ease; }
:fullscreen .native-input { font-size: 3rem; }
:fullscreen .native-input::placeholder { font-size: 3rem; }
.game-center-area { justify-content: center; align-items: center; height: 100%; padding-bottom: 72px; }

.input-select, select {
    background-color: var(--bg-main); color: var(--text-primary);
    border: 1px solid var(--border-color); padding: 8px; border-radius: var(--radius-md);
    font-family: var(--font-body); font-size: 0.95rem; cursor: pointer; outline: none;
    width: auto; min-width: 140px; max-width: 200px;
    text-align: center;
    text-align-last: center;
}