/* ==========================================================================
   LUDOBOX — STYLE PRINCIPAL
   Police : Nunito (arrondie, lisible, "jeu de société")
   Thème  : Chaud/ludique avec mode sombre propre
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* --------------------------------------------------------------------------
   VARIABLES & THÈMES
   -------------------------------------------------------------------------- */
:root {
    --bg-primary:    #f0f2f7;
    --bg-secondary:  #ffffff;
    --bg-tertiary:   #e8eaf2;
    --text-primary:  #1a1d2e;
    --text-secondary:#6b7280;
    --accent:        #6366f1;
    --accent-hover:  #4f46e5;
    --accent-light:  rgba(99,102,241,0.12);
    --success:       #10b981;
    --warning:       #f59e0b;
    --danger:        #ef4444;
    --radius:        16px;
    --radius-sm:     10px;
    --shadow:        0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.14);
    --transition:    0.2s ease;
    --font:          'Nunito', system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg-primary:    #0f1117;
    --bg-secondary:  #1c1f2e;
    --bg-tertiary:   #252838;
    --text-primary:  #f0f2ff;
    --text-secondary:#8b92b3;
    --accent:        #818cf8;
    --accent-hover:  #a5b4fc;
    --accent-light:  rgba(129,140,248,0.15);
    --shadow:        0 2px 12px rgba(0,0,0,0.35);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.5);
}

/* --------------------------------------------------------------------------
   RESET & BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    transition: background var(--transition), color var(--transition);
}

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */
.main-header {
    background: var(--bg-secondary);
    padding: 0.9rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-header h1 {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: -0.5px;
}

#theme-toggle {
    background: var(--bg-tertiary);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
#theme-toggle:hover { background: var(--accent-light); color: var(--accent); }

/* --------------------------------------------------------------------------
   MAIN CONTENT
   -------------------------------------------------------------------------- */
main {
    flex: 1;
    padding: 1.25rem;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

/* --------------------------------------------------------------------------
   NAVIGATION BAS
   -------------------------------------------------------------------------- */
.bottom-nav {
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-around;
    padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--bg-tertiary);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.bottom-nav button {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 700;
    gap: 0.2rem;
    cursor: pointer;
    padding: 0.4rem 1.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.bottom-nav button i { font-size: 1.1rem; }
.bottom-nav button:hover, .bottom-nav button.active {
    color: var(--accent);
    background: var(--accent-light);
}

/* --------------------------------------------------------------------------
   MODAL
   -------------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 640px;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
    position: relative;
    max-height: 90dvh;
    overflow-y: auto;
    animation: slide-up 0.3s ease;
}

@keyframes slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.btn-close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-tertiary);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    z-index: 10;
}

/* --------------------------------------------------------------------------
   BOUTONS COMMUNS
   -------------------------------------------------------------------------- */
.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.9rem 1.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
    margin-top: 0.75rem;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-back {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: var(--transition);
}
.btn-back:hover { background: var(--accent-light); color: var(--accent); }

/* --------------------------------------------------------------------------
   TOASTS
   -------------------------------------------------------------------------- */
#toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    width: min(90vw, 420px);
}

.toast {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-left: 4px solid var(--accent);
}
.toast-success { border-color: var(--success); }
.toast-error   { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }
.toast-info    { border-color: var(--accent); }
.toast-visible { opacity: 1; transform: translateY(0) scale(1); }
.toast-hiding  { opacity: 0; transform: translateY(-10px); transition: all 0.3s ease; }
.toast-icon    { font-size: 1.1rem; }

/* --------------------------------------------------------------------------
   ÉCRAN CONFIGURATION JOUEURS
   -------------------------------------------------------------------------- */
.players-setup {
    animation: fade-in 0.3s ease;
}

.players-setup-header {
    text-align: center;
    padding: 1.5rem 0 1rem;
}
.players-setup-header h2 {
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 0.3rem;
}
.players-setup-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg-secondary);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    animation: fade-in 0.2s ease;
}

.player-emoji-btn {
    font-size: 1.5rem;
    cursor: pointer;
    user-select: none;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}
.player-emoji-btn:hover { transform: scale(1.2); }

.player-name-input {
    flex: 1;
    border: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    outline: none;
    transition: var(--transition);
}
.player-name-input:focus { box-shadow: 0 0 0 2px var(--accent); }

.player-color-input {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 2px;
    background: none;
    flex-shrink: 0;
}

.btn-remove-player {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    font-size: 1rem;
}
.btn-remove-player:hover { background: #ef444420; }

.btn-add-player {
    background: none;
    border: 2px dashed var(--accent);
    color: var(--accent);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    width: 100%;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.25rem;
}
.btn-add-player:hover { background: var(--accent-light); }

.btn-start-evening {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 900;
    width: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.75rem;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(99,102,241,0.4);
}
.btn-start-evening:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99,102,241,0.5); }

/* Badges joueurs */
.player-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    border: 1.5px solid;
    font-weight: 700;
    font-size: 0.85rem;
}
.player-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* --------------------------------------------------------------------------
   ACCUEIL
   -------------------------------------------------------------------------- */
.home-players-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.home-player-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    border: 1.5px solid;
    font-size: 0.82rem;
    font-weight: 700;
}

.btn-edit-players {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: var(--transition);
}
.btn-edit-players:hover { color: var(--accent); background: var(--accent-light); }

.search-container {
    position: relative;
    margin-bottom: 1.25rem;
}
.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.search-container input {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 2.75rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--bg-tertiary);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    transition: var(--transition);
}
.search-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.9rem;
}

.game-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}
.game-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}
.game-card:active { transform: translateY(0); }

.game-card-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}
.game-card h3 {
    font-size: 0.95rem;
    font-weight: 800;
}
.game-card-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.game-card-soon {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --------------------------------------------------------------------------
   VUE JEU
   -------------------------------------------------------------------------- */
.game-view-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.game-view-title {
    font-size: 1.2rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Cartes de setup générique */
.game-setup-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.game-setup-card h3 {
    font-size: 1.1rem;
    font-weight: 900;
    margin-bottom: 1rem;
    color: var(--accent);
}

.setup-players-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.setup-player-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: 2px solid;
    font-size: 0.9rem;
}
.setup-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

/* --------------------------------------------------------------------------
   OUTILS COMMUNS
   -------------------------------------------------------------------------- */
.tools-panel-title {
    font-size: 1.1rem;
    font-weight: 900;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-section {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.tool-title {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
}
.tool-divider {
    height: 1px;
    background: var(--bg-tertiary);
    margin: 0.5rem 0 1.25rem;
}

/* Dés */
.dice-config { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.dice-config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
}
.stepper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
}
.stepper-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--accent);
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: var(--transition);
}
.stepper-btn:hover { background: var(--accent-light); }
#dice-count-display { font-weight: 900; font-size: 1.1rem; min-width: 24px; text-align: center; }

.dice-type-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.dice-type-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 800;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}
.dice-type-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-roll {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 800;
    width: 100%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-roll:hover { transform: translateY(-1px); }
.btn-roll.rolling { animation: roll-shake 0.4s ease; }

@keyframes roll-shake {
    0%,100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg) scale(1.05); }
    75% { transform: rotate(8deg) scale(1.05); }
}

.dice-results { margin-top: 1rem; }
.dice-throw-result { text-align: center; }
.dice-faces-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.5rem;
}
.dice-face {
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    color: var(--accent);
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 900;
    animation: dice-pop 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes dice-pop {
    from { transform: scale(0) rotate(180deg); opacity: 0; }
    to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}
.dice-total {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.dice-total strong { color: var(--accent); font-size: 1.2rem; }

/* Chwazi dans Outils */
.chwazi-players-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.chwazi-player-chip {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border: 1.5px solid;
    border-radius: 20px;
}
.chwazi-area {
    position: relative;
    width: 100%;
    height: 220px;
    background: #0b0f19;
    border-radius: var(--radius);
    overflow: hidden;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chwazi-instructions {
    color: #94a3b8;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.3s;
}
.chwazi-instructions small { display: block; font-size: 0.78rem; opacity: 0.6; margin-top: 0.25rem; }
.chwazi-finger {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    border: 3px solid;
    transition: transform 0.15s ease;
    box-shadow: 0 0 16px currentColor;
}
.chwazi-finger.vibrating { animation: chwazi-vib 0.1s linear infinite; }
.chwazi-finger.winner {
    transform: translate(-50%, -50%) scale(1.8) !important;
    box-shadow: 0 0 50px currentColor, 0 0 100px currentColor;
    z-index: 10;
    transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.4s ease;
}
.chwazi-finger.loser {
    transform: translate(-50%, -50%) scale(0) !important;
    opacity: 0;
    transition: all 0.5s ease;
}
.chwazi-winner-banner {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
    animation: fade-in 0.3s ease;
    z-index: 20;
}
.chwazi-fallback { font-size: 0.8rem; color: var(--text-secondary); text-align: center; margin-top: 0.5rem; }
@keyframes chwazi-vib {
    0%   { transform: translate(-52%, -48%) scale(1.02); }
    50%  { transform: translate(-48%, -52%) scale(1.04); }
    100% { transform: translate(-50%, -50%) scale(1.02); }
}

/* --------------------------------------------------------------------------
   RULES ACCORDION (partagé entre modules)
   -------------------------------------------------------------------------- */
.rules-accordion {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: var(--shadow);
    margin-top: 1rem;
}
.rules-accordion summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.rules-accordion summary::-webkit-details-marker { display: none; }
.rules-accordion[open] summary i { transform: rotate(180deg); }
.rules-accordion summary i { transition: transform 0.2s ease; }
.rules-content {
    margin-top: 1rem;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
}
.rules-content p { margin-top: 0.75rem; margin-bottom: 0.25rem; }
.rules-content ul { margin-left: 1.25rem; }
.rules-content li { margin-bottom: 0.25rem; }

/* --------------------------------------------------------------------------
   CALCULATRICE
   -------------------------------------------------------------------------- */
.calc-display {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.15rem;
}
.calc-expr {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text-primary);
    word-break: break-all;
    text-align: right;
}
.calc-result {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    min-height: 1.2em;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
}
.calc-btn {
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.8rem 0.4rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}
.calc-btn:hover { background: var(--bg-tertiary); transform: scale(1.04); }
.calc-btn:active { transform: scale(0.96); }
.calc-wide { grid-column: span 2; }
.calc-op { background: var(--accent-light); color: var(--accent); }
.calc-op:hover { background: var(--accent); color: white; }
.calc-clear { background: #ef444420; color: var(--danger); }
.calc-clear:hover { background: var(--danger); color: white; }

/* --------------------------------------------------------------------------
   ANIMATIONS GLOBALES
   -------------------------------------------------------------------------- */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ==========================================================================
   AIDES DE JEU & HISTORIQUE — CSS
   ========================================================================== */

/* ---- Conteneur générique aide de jeu ---- */
.aid-container { animation: fade-in 0.3s ease; }

/* ---- Bouton sauvegarder ---- */
.btn-save-history {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.75rem;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.btn-save-history:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16,185,129,0.4); }

.gf-save-row { margin-top: 0.5rem; }

/* ==========================================================================
   HISTORIQUE
   ========================================================================== */

.history-screen { animation: fade-in 0.3s ease; }

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.history-header h2 {
    font-size: 1.3rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-clear-history {
    background: #ef444420;
    color: var(--danger);
    border: none;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition);
}
.btn-clear-history:hover { background: var(--danger); color: white; }

/* Stats */
.history-stats {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.history-stat {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.history-stat-val { display: block; font-size: 1.4rem; font-weight: 900; color: var(--accent); }
.history-stat-label { font-size: 0.7rem; font-weight: 700; color: var(--text-secondary); }

/* Empty state */
.history-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}
.history-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.history-empty p { font-weight: 600; margin-bottom: 0.35rem; }
.history-empty-hint { font-size: 0.85rem; }

/* Liste */
.history-list { display: flex; flex-direction: column; gap: 0.75rem; }

.history-entry {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow);
    animation: fade-in 0.2s ease;
}

.history-entry-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}
.history-entry-game { display: flex; flex-direction: column; gap: 0.1rem; }
.history-game-name { font-weight: 900; font-size: 1rem; }
.history-date { font-size: 0.72rem; color: var(--text-secondary); font-weight: 600; }

.btn-delete-entry {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: var(--transition);
    flex-shrink: 0;
}
.btn-delete-entry:hover { color: var(--danger); background: #ef444415; }

.history-winner {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.history-players {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.history-player-chip {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    background: var(--bg-primary);
    border-radius: 20px;
    color: var(--text-secondary);
}
.history-player-chip.is-winner {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 800;
}
.history-player-chip em {
    font-style: normal;
    font-weight: 900;
    opacity: 0.8;
}

.history-notes {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
    font-style: italic;
}
