:root {
    --bg: #111826;
    --bg-soft: #0b1020;
    --accent: #F22797;
    --accent-soft: rgba(255, 59, 129, 0.12);
    --accent-2: #0B688C;
    --text: #f8fafc;
    --muted: #94a3b8;
    --border: #1e293b;
    --danger: #f97373;
    --success: #4ade80;
    --warning: #facc15;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-pill: 999px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #111827 0, #020617 40%, #000 80%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 1rem 1.25rem 0.5rem;
}

header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

header h1 span.logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

header p {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

main {
    flex: 1;
    padding: 0.5rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.card {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
    border-radius: var(--radius-lg);
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
}

.card+.card {
    margin-top: 0.25rem;
}

.hidden {
    display: none !important;
}

.btn {
    border: none;
    outline: none;
    border-radius: var(--radius-pill);
    padding: 0.6rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    white-space: nowrap;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #ff6fb0);
    color: #0b1020;
    box-shadow: 0 10px 30px rgba(255, 59, 129, 0.5);
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 4px 18px rgba(255, 59, 129, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:active {
    transform: scale(0.97);
    background: rgba(15, 23, 42, 0.8);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: var(--danger);
    color: #0b1020;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: var(--radius-pill);
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: var(--muted);
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-success {
    border-color: rgba(74, 222, 128, 0.4);
    color: var(--success);
}

.badge-danger {
    border-color: rgba(248, 113, 113, 0.4);
    color: var(--danger);
}

.badge-warning {
    border-color: rgba(250, 204, 21, 0.4);
    color: var(--warning);
}

.divider {
    height: 1px;
    background: radial-gradient(circle, rgba(148, 163, 184, 0.3), transparent);
    margin: 0.75rem 0;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

/* Accueil */
#screen-home h2 {
    margin: 0 0 0.4rem;
    font-size: 1.1rem;
}

#screen-home p {
    margin: 0.1rem 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.5rem;
}

.pill {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: var(--muted);
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.toggle {
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border);
    padding: 2px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.12s ease, border 0.12s ease;
}

.toggle-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.toggle.on {
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    border-color: transparent;
}

.toggle.on .toggle-thumb {
    transform: translateX(16px);
    background: #0b1020;
    box-shadow: 0 0 12px rgba(15, 23, 42, 0.9);
}

/* Setup */
.setup-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

@media (min-width: 640px) {
    .setup-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

label {
    display: inline-block;
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
    color: var(--muted);
}

select,
input[type="number"],
input[type="text"] {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text);
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    outline: none;
}

select:focus,
input:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3);
}

.player-name-row {
    margin-top: 0.4rem;
}

.player-name-row input {
    font-size: 0.85rem;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.3rem;
}

/* Dashboard */
#screen-dashboard .header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.5rem;
}

.players-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

@media (min-width: 768px) {
    .players-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.player-card {
    position: relative;
    padding: 0.8rem 0.9rem 0.9rem;
    border-radius: var(--radius-lg);
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.22), rgba(15, 23, 42, 0.96));
    border: 1px solid rgba(148, 163, 184, 0.2);
    overflow: hidden;
}

.player-card.eliminated {
    background: radial-gradient(circle at top left, rgba(248, 113, 113, 0.2), rgba(15, 23, 42, 0.96));
    opacity: 0.7;
}

.player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.player-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.player-data {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.player-data span.value {
    font-size: 1.4rem;
    letter-spacing: 0.04em;
}

.player-data span.unit {
    font-size: 0.7rem;
    color: var(--muted);
}

.progress-bar {
    position: relative;
    height: 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    overflow: hidden;
    margin: 0.15rem 0 0.35rem;
    border: 1px solid rgba(30, 64, 175, 0.8);
}

.progress-fill {
    height: 100%;
    width: 50%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.7);
    transition: width 0.15s ease-out;
}

.subsection-label {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.3rem;
    margin-bottom: 0.15rem;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.chip {
    font-size: 0.7rem;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    color: var(--muted);
    background: rgba(15, 23, 42, 0.9);
}

.chip.green {
    border-color: rgba(74, 222, 128, 0.6);
    color: var(--success);
}

.chip.red {
    border-color: rgba(248, 113, 113, 0.7);
    color: var(--danger);
}

.chip.yellow {
    border-color: rgba(250, 204, 21, 0.75);
    color: var(--warning);
}

.player-footer {
    margin-top: 0.5rem;
    display: flex;
    justify-content: flex-end;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 40;
}

@media (min-width: 640px) {
    .modal-backdrop {
        align-items: center;
    }
}

.modal {
    width: 100%;
    max-width: 480px;
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.98));
    border-radius: 20px 20px 0 0;
    border: 1px solid rgba(148, 163, 184, 0.32);
    padding: 0.9rem 1rem 1rem;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.9);
}

@media (min-width: 640px) {
    .modal {
        border-radius: 20px;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.modal-body {
    margin-top: 0.2rem;
}

.field-row {
    margin-top: 0.45rem;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.25rem;
}

.filter-btn {
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.9);
    color: var(--muted);
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, border 0.12s ease, color 0.12s ease,
        transform 0.06s ease;
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    border-color: transparent;
    color: #0b1020;
    transform: translateY(-1px);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.6rem;
}

@media (min-width: 520px) {
    .card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        /* 3 colonnes si l'écran est assez large */
    }
}

.card-tile {
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.card-tile-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-md);
    max-height: 130px;
}

.card-tile:hover {
    transform: scale(1.05);
}

.card-tile.selected {
    transform: scale(1.05);
    filter: drop-shadow(0 0 6px var(--accent));
}

.modal-footer {
    margin-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pill-info {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.4rem;
}

.stop-game-container {
    margin-top: 1.2rem;
    display: flex;
    justify-content: center;
}

.stop-game-btn {
    max-width: 280px;
    background-color: #00000000;
    color: #d11a2a;
    font-weight: 900;
    padding: 0.4rem 0.6rem;
    border-radius: 100px;
    border: rgba(141, 141, 141, 0.222) 1px solid;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
    border-radius: var(--radius-pill);
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.5);
    color: var(--text);
    z-index: 50;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.9);
}


.feedback-links {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-align: center;
}

.feedback-link {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    opacity: 0.85;
}

.feedback-link:hover {
    opacity: 1;
    text-decoration: underline;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* 2 cartes max sur mobile */
    gap: 0.8rem;
    margin-top: 0.8rem;
}

@media (min-width: 768px) {
    .library-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        /* 3 sur tablette */
    }
}

@media (min-width: 1200px) {
    .library-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        /* 4 sur grand écran */
    }
}

.library-card {
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: radial-gradient(circle at top left, rgba(148, 163, 184, 0.15), rgba(15, 23, 42, 0.98));
    padding: 0.6rem 0.7rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    /* vertical */
    align-items: center;
    /* centré */
    justify-content: flex-start;
    text-align: center;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.library-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.8);
}

.library-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.library-card-img {
    width: 100%;
    max-width: 120px;
    /* taille max de la carte */
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.chip-clickable {
  cursor: pointer;
}
