/* ─── Variables (ACTotal Theme) ─── */
:root {
    --bg: #050506;
    --surface: #111827;
    --surface-light: #1f2937;
    --accent: #DC2626;
    /* Red for Conga */
    --accent-glow: rgba(220, 38, 38, 0.3);

    --warning: #F59E0B;
    /* Amber/Orange for 80+ */
    --danger: #EF4444;
    /* Red for 90+ */

    --text: #ffffff;
    --text-dim: #9ca3af;
    --radius: 16px;
    --radius-sm: 8px;
}

/* ─── Base Reset ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* ─── Layout ─── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: 1.5rem 1rem;
    max-width: 600px;
    /* Slightly wider for grid */
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, #F87171, #DC2626);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, .08);
    background: var(--surface);
    color: var(--text-dim);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all .2s;
}

.btn-icon-subtle {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
}

.btn-icon:hover,
.btn-icon-subtle:hover {
    background: var(--surface-light);
    color: var(--text);
    opacity: 1;
}

/* ─── Main Content ─── */
.conga-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 1.2rem;
}

/* Top Bar: Add Player */
.add-player-bar {
    display: flex;
    gap: 0.5rem;
    background: var(--surface);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.add-player-bar input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.8rem 1rem;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

.btn-add {
    background: var(--accent);
    color: white;
    border: none;
    width: 44px;
    border-radius: var(--radius-sm);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-add:active {
    transform: scale(0.95);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius);
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

/* Players Grid */
.players-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .6rem;
    align-items: start;
}

@media (min-width: 500px) {
    .players-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Player Card */
.player-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: .6rem .8rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .8rem;
    position: relative;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.player-header {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-name {
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.btn-remove {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem;
    opacity: 0.5;
}

.btn-remove:hover {
    opacity: 1;
    color: var(--danger);
}

/* Score Display */
.player-score {
    font-size: 1.6rem;
    font-weight: 900;
    line-height: 1;
    min-width: 3rem;
    text-align: center;
    color: #fff;
    transition: color 0.3s;
    font-variant-numeric: tabular-nums;
}

/* Warnings based on score */
.player-card.warn .player-score {
    color: var(--warning);
    text-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.player-card.danger .player-score {
    color: var(--danger);
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

/* Input for this round */
.round-input-group {
    display: flex;
    gap: 0.3rem;
    margin-left: auto;
}

.round-input-group input {
    width: 60px;
    min-width: 0;
    background: var(--bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: white;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    padding: .5rem .2rem;
    outline: none;
}

/* Eliminated State */
.player-card.eliminated {
    opacity: 0.6;
    filter: grayscale(0.8);
    border-color: rgba(239, 68, 68, 0.3);
}

.player-card.eliminated .player-name {
    text-decoration: line-through;
    color: var(--danger);
}

.player-card.eliminated .round-input-group {
    display: none;
}

.btn-buyin {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: auto;
}

.btn-buyin:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Global Actions */
.global-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.global-actions.hidden {
    display: none;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #F87171, #DC2626);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.98);
}

/* Helpers */
.app-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 2rem;
}

/* ─── Settings Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, .85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    animation: fadeIn .3s ease;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popUp {
    from {
        transform: scale(.5);
        opacity: 0;
    }

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

.modal-content {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
    animation: popUp .4s cubic-bezier(.34, 1.56, .64, 1);
}

.modal-content h2 {
    font-size: 1.3rem;
    margin-bottom: 1.2rem;
    text-align: center;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group>label {
    display: block;
    color: var(--text-dim);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .8rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.radio-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .8rem 1rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s;
}

.radio-btn:has(input[type="radio"]:checked) {
    border-color: var(--accent);
    background: rgba(220, 38, 38, 0.12);
}

.radio-btn input[type="radio"] {
    accent-color: var(--accent);
    transform: scale(1.2);
}

.custom-limit-input {
    width: 80px;
    background: var(--bg);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 6px;
    color: var(--text);
    text-align: center;
    font-size: .95rem;
    font-weight: 600;
    padding: .3rem .4rem;
    outline: none;
    margin-left: auto;
}

.custom-limit-input:focus {
    border-color: var(--accent);
}

.btn-modal-close {
    width: 100%;
    padding: .8rem;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--surface-light);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s;
}

.btn-modal-close:hover {
    background: rgba(255, 255, 255, .1);
}

/* Rules Modal */
.rules-content {
    max-width: 400px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.rules-text {
    overflow-y: auto;
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
}

.rules-text h3 {
    color: var(--text);
    font-size: 1rem;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
}

.rules-text p {
    margin-bottom: 0.8rem;
}

.rules-text ol, .rules-text ul {
    margin-left: 1.5rem;
    margin-bottom: 0.8rem;
}

.rules-text li {
    margin-bottom: 0.3rem;
}

/* ─── Confirm Modal ─── */
.confirm-message {
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.confirm-actions {
    display: flex;
    gap: .6rem;
}

.btn-confirm-cancel,
.btn-confirm-ok {
    flex: 1;
    padding: .8rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    transition: all .2s;
}

.btn-confirm-cancel {
    background: var(--surface-light);
    color: var(--text-dim);
}

.btn-confirm-cancel:hover {
    background: rgba(255, 255, 255, .1);
    color: var(--text);
}

.btn-confirm-ok {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-confirm-ok:hover {
    opacity: .9;
}

/* ─── Toast Notifications ─── */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.toast {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--radius-sm);
    padding: .8rem 1.2rem;
    color: var(--text);
    font-size: .9rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
    animation: toastIn .3s ease forwards;
    pointer-events: auto;
}

.toast.toast-out {
    animation: toastOut .3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}