:root {
    --primary: #ff3e00;
    --secondary: #ff007a;
    --accent: #00f2ff;
    --bg-dark: #050a14;
    --bg-card: rgba(15, 23, 42, 0.8);
    --text-main: #ffffff;
    --text-dim: #94a3b8;
    --radius: 20px;
    --glass-border: rgba(255, 255, 255, 0.15);
    --success: #00ffa3;
    --danger: #ff2e63;
    --warning: #fbbf24;
    --gold: #ffd700;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', sans-serif;
}

body {
    background: radial-gradient(circle at 20% 20%, #1e1b4b, #0f172a, #050a14);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Background Decorations */
body::before, body::after {
    content: '';
    position: fixed;
    width: 300px;
    height: 300px;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.4;
}

body::before {
    top: -50px;
    left: -50px;
    background: var(--primary);
}

body::after {
    bottom: -50px;
    right: -50px;
    background: var(--accent);
}

.glass {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
}

.container {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    flex-grow: 1;
}

header {
    text-align: center;
    padding: 30px 0;
    position: relative;
}

h1 {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
    letter-spacing: -1px;
    text-transform: uppercase;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 2px;
}

/* Instructions */
.info-section {
    margin-bottom: 24px;
    text-align: left;
}

.info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    transition: background 0.3s;
}

.info-header:hover {
    background: rgba(255, 255, 255, 0.1);
}

.info-body {
    padding: 15px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-dim);
    display: none;
}

.info-body b { color: var(--text-main); }

/* Setup View */
.view {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#setup-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 16px 20px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.15);
}

.btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 14px;
    color: white;
    padding: 18px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn:hover::after { opacity: 1; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -5px var(--secondary); }
.btn:active { transform: translateY(0); }

#game-view {
    display: none;
    flex-direction: column;
    gap: 24px;
}

/* Timer */
.timer-container {
    position: relative;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.timer-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
}

.hourglass-svg {
    fill: var(--accent);
}

.hourglass-moving .sand {
    animation: sandFlow 2s infinite linear;
}

@keyframes sandFlow {
    0% { transform: translateY(-50%); }
    100% { transform: translateY(50%); }
}

#timer-display {
    font-size: 4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin: 10px 0;
    text-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

/* Players Grid */
.players-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.player-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid transparent;
    position: relative;
}

.player-card::before {
    content: '🀄';
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.2rem;
    opacity: 0.2;
}

.player-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.3);
}

.player-card.winner {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.05));
    border-color: var(--warning);
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.2);
}

.badge {
    position: absolute;
    top: -10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge-leader { background: var(--warning); color: #000; }
.badge-tie { background: var(--text-dim); color: #fff; }

.player-name {
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--text-main);
}

.player-score {
    font-size: 2rem;
    font-weight: 800;
}

.player-score.positive { color: var(--success); }
.player-score.negative { color: var(--danger); }

/* Dashboard Actions */
.actions-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 30px;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s;
    width: 80px;
}

.action-item:hover {
    transform: translateY(-5px);
}

.btn-icon {
    width: 55px;
    height: 55px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    transition: all 0.3s;
    color: var(--text-main);
}

.action-item:hover .btn-icon {
    background: var(--text-main);
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.action-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-item:hover .action-label {
    color: var(--text-main);
}

.icon-svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.management-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    color: var(--text-main);
}

/* History Modal */
#history-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    z-index: 2000;
    max-height: 80vh;
    overflow-y: auto;
    padding: 30px;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 1500;
    display: none;
}

.history-item {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:last-child { border: none; }

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

@media (max-width: 480px) {
    .players-grid { grid-template-columns: 1fr; }
    h1 { font-size: 2.2rem; }
}
