:root {
    --blood: #bc131f;
    --blood-dark: #660708;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.1);
    --bg-deep: #020617;
}

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

body {
    background: var(--bg-deep);
    background-image:
        radial-gradient(at 0% 0%, rgba(188, 19, 31, 0.15) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(18, 24, 60, 0.2) 0, transparent 50%);
    min-height: 100vh;
    min-height: 100dvh;
    /* Modern mobile height */
    color: white;
    overflow-x: hidden;
    font-family: 'Inter', sans-serif;
    padding: 2rem;
    padding-top: calc(2rem + env(safe-area-inset-top));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    padding-left: calc(1.5rem + env(safe-area-inset-left));
    padding-right: calc(1.5rem + env(safe-area-inset-right));
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    /* Remove grey box on touch */
}

@media (min-width: 768px) {
    body {
        padding: 3rem;
    }
}

.container {
    max-width: 1152px;
    margin: 0 auto;
}

h1,
h2,
h3,
.serif {
    font-family: 'Cinzel', serif;
}

.hidden {
    display: none !important;
}

/* Glassmorphism System */
.glass {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: var(--glass);
    border: 1px solid var(--border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 1.5rem;
}

/* Header Styles */
.main-header {
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
    transition: all 0.7s ease;
}

.godfather-title {
    font-size: 3.5rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    text-shadow: 0 0 30px rgba(188, 19, 31, 0.4);
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .godfather-title {
        font-size: 5rem;
    }
}

.header-subtitle {
    font-size: 1.125rem;
    color: var(--blood);
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

/* Layout Grid (Simplified for Centering) */
.main-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    width: 100%;
}

.sidebar,
.display-area {
    width: 100%;
}

@media (min-width: 1024px) {

    .sidebar,
    .display-area {
        max-width: 480px;
        /* Optimal width for desktop focus */
    }
}

/* Sidebar & Inputs */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.config-panel {
    padding: 2rem;
    border-radius: 2rem;
}

.panel-title {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    letter-spacing: 0.05em;
}

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

.input-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #9ca3af;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.number-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 1rem;
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: white;
    text-align: center;
    transition: border-color 0.3s;
}

.number-input:focus {
    outline: none;
    border-color: rgba(188, 19, 31, 0.5);
}

/* Role Toggles */
.role-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.role-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.role-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.toggle-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-icon svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.toggle-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.switch {
    width: 2.5rem;
    height: 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    position: relative;
    transition: background 0.3s;
}

.switch::after {
    content: '';
    position: absolute;
    left: 0.25rem;
    top: 0.25rem;
    width: 0.75rem;
    height: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: all 0.3s;
}

input:checked+.switch {
    background: rgba(188, 19, 31, 0.3);
}

input:checked+.switch::after {
    left: 1.5rem;
    background: var(--blood);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 1.25rem;
    border-radius: 1rem;
    font-family: 'Cinzel', serif;
    font-size: 1.125rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    color: white;
    user-select: none;
    -webkit-user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blood) 0%, var(--blood-dark) 100%);
    margin-top: 2.5rem;
    box-shadow: 0 10px 30px -5px rgba(102, 7, 8, 0.6);
}

.btn-primary:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--glass);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    padding: 1rem;
    letter-spacing: 0.2em;
}

.btn-secondary:hover {
    background: var(--glass-hover);
}

/* Reveal Mode Styles */
.reveal-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 2.5rem 0;
    text-align: center;
}

.reveal-header h2 {
    font-size: 2.25rem;
    color: var(--blood);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.reveal-header p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* 3D Card */
.card-container {
    perspective: 1000px;
    -webkit-perspective: 1000px;
    width: 280px;
    height: 400px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    -webkit-transition: -webkit-transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    cursor: pointer;
}

.card-inner.is-flipped {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 1px solid var(--border);
}

.card-back {
    background: linear-gradient(145deg, #1e293b, #020617);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(188, 19, 31, 0.05) 10px, rgba(188, 19, 31, 0.05) 20px);
}

.card-front {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

.card-back-icon {
    font-size: 2.5rem;
    opacity: 0.1;
    margin-bottom: 1rem;
}

.pulse-text {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    color: rgba(255, 255, 255, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }
}

/* Summary Mode Styles */
.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
}

.summary-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    width: 100%;
}

@media (min-width: 640px) {
    .summary-grid {
        grid-template-columns: 1fr 1fr;
        max-width: 800px;
        /* Expand grid for final view */
    }
}

.summary-card {
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left-width: 4px;
    border-left-style: solid;
    cursor: pointer;
    transition: all 0.3s ease;
}

.summary-card:hover {
    transform: translateX(5px);
    background: var(--glass-hover);
}

.summary-card.eliminated {
    opacity: 0.15;
    filter: grayscale(1);
    text-decoration: line-through;
    border-color: #4b5563 !important;
}

.summary-card.eliminated .player-num {
    text-decoration: line-through;
}

.card-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.player-num {
    opacity: 0.3;
    font-size: 0.75rem;
    font-weight: 700;
}

.role-name-mini {
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--blood-dark);
    border-radius: 10px;
}

/* Utilities for JS-injected styles */
.border-mafia {
    border-color: rgba(127, 29, 29, 0.5);
    color: #ef4444;
}

.bg-mafia {
    background: rgba(69, 10, 10, 0.2);
}

.border-boss {
    border-color: #bc131f;
    color: #bc131f;
}

.bg-boss {
    background: rgba(127, 29, 29, 0.3);
}

.border-civilian {
    border-color: #1e293b;
    color: #94a3b8;
}

.bg-civilian {
    background: rgba(15, 23, 42, 0.4);
}

.border-comm {
    border-color: #2563eb;
    color: #3b82f6;
}

.bg-comm {
    background: rgba(30, 58, 138, 0.2);
}

.border-doc {
    border-color: #059669;
    color: #10b981;
}

.bg-doc {
    background: rgba(6, 78, 59, 0.2);
}

.border-beauty {
    border-color: #db2777;
    color: #ec4899;
}

.bg-beauty {
    background: rgba(131, 24, 67, 0.2);
}

.border-maniac {
    border-color: #d97706;
    color: #f59e0b;
}

.bg-maniac {
    background: rgba(120, 53, 15, 0.2);
}

.border-kamikaze {
    border-color: #ea580c;
    color: #fb923c;
}

.bg-kamikaze {
    background: rgba(154, 52, 18, 0.2);
}