/* ==========================================================================
   MAFIA GAME - MODERN NOIR DESIGN SYSTEM
   ========================================================================== */

:root {
    --bg-primary: #0a0c10;
    --bg-surface: #141720;
    --bg-surface-elevated: #1c202c;
    --bg-surface-hover: #242938;
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-active: rgba(255, 255, 255, 0.18);
    
    --text-primary: #f0f2f5;
    --text-secondary: #9aa2b2;
    --text-muted: #626b7d;
    
    /* Role & Accent Colors */
    --accent-crimson: #e63946;
    --accent-crimson-hover: #ff4d5a;
    --accent-crimson-glow: rgba(230, 57, 70, 0.35);
    
    --role-mafia: #e63946;
    --role-don: #f4a261;
    --role-doctor: #06d6a0;
    --role-sheriff: #3a86ff;
    --role-maniac: #9b5de5;
    --role-kamikaze: #fb5607;
    --role-villager: #8d99ae;
    
    --color-day: #f4a261;
    --color-voting: #3a86ff;
    --color-night: #9b5de5;
    
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    
    --font-heading: 'Cinzel', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 8px 32px rgba(0, 0, 0, 0.6);
    --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -ms-overflow-style: none;
    scrollbar-width: none;
    overscroll-behavior-y: none;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -ms-overflow-style: none;
    scrollbar-width: none;
    overscroll-behavior-y: none;
}

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background: transparent;
}

/* Ambient Background Light */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-crimson) 0%, transparent 70%);
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #3a86ff 0%, transparent 70%);
    bottom: -100px;
    right: 10%;
}

/* Top Fixed Navigation Bar in Top Right Corner */
.top-nav-bar {
    position: fixed;
    top: max(18px, env(safe-area-inset-top));
    right: max(22px, env(safe-area-inset-right));
    z-index: 999;
    pointer-events: auto;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Fullscreen gameplay owns the whole screen; global controls must not cover it. */
body:has(.player-phase-overlay.show) .top-nav-bar,
body:has(.player-voting-modal.show) .top-nav-bar,
body:has(.qr-modal.show) .top-nav-bar,
body:has(.custom-role-modal[style*="display: flex"]) .top-nav-bar,
body:has(.game-results-overlay[style*="display: flex"]) .top-nav-bar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.nav-controls-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(20, 23, 32, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.audio-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-active);
    color: var(--accent-crimson);
}

.lang-selector {
    display: flex;
    background: rgba(20, 23, 32, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 3px;
    gap: 3px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 700;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.lang-btn:hover {
    color: #ffffff;
}

.lang-btn.active {
    background: var(--accent-crimson);
    color: #ffffff;
    box-shadow: 0 2px 10px var(--accent-crimson-glow);
}

/* Layout Container */
.page-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
    padding-top: calc(60px + env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: calc(36px + env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    justify-content: center;
}

@media (max-width: 600px) {
    .top-nav-bar {
        top: max(10px, env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
    }
    .page-container {
        padding-top: calc(64px + env(safe-area-inset-top));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        min-height: 100dvh;
    }
}

.main-wrapper {
    width: 100%;
}

/* Card Container */
.glass-card {
    background: rgba(20, 23, 32, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 26px 22px;
    box-shadow: var(--shadow-glow);
    transition: var(--transition);
}

/* Spacing Utilities */
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }

/* Typography */
.brand-header {
    text-align: center;
    margin-bottom: 26px;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(230, 57, 70, 0.2), rgba(20, 23, 32, 0.9));
    border: 1px solid rgba(230, 57, 70, 0.4);
    border-radius: 50%;
    color: var(--accent-crimson);
    font-size: 28px;
    margin-bottom: 14px;
    box-shadow: 0 0 24px var(--accent-crimson-glow);
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #ffffff;
    margin-bottom: 6px;
}

.brand-title span {
    color: var(--accent-crimson);
}

.brand-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
}

/* Navigation Tabs */
.tabs-nav {
    display: flex;
    background: var(--bg-surface-elevated);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid var(--border-subtle);
}

.tab-btn {
    flex: 1;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.tab-btn.active {
    background: var(--bg-surface);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease-out forwards;
}

.tab-content.active {
    display: block;
}

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

/* Forms & Inputs */
.form-group {
    margin-bottom: 18px;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 1.05rem;
    pointer-events: none;
    transition: var(--transition);
}

.form-input {
    width: 100%;
    padding: 13px 16px 13px 46px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-crimson);
    background: var(--bg-surface-hover);
    box-shadow: 0 0 0 3px var(--accent-crimson-glow);
}

.form-input:focus + .input-icon,
.form-input:focus ~ .input-icon {
    color: var(--accent-crimson);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-crimson), #c02734);
    color: #ffffff;
    box-shadow: 0 4px 16px var(--accent-crimson-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-crimson-hover), var(--accent-crimson));
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-crimson-glow);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-active);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ==========================================================================
   HOST DASHBOARD STYLES & SPACING
   ========================================================================== */

.room-header {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.room-code-badge {
    display: flex;
    flex-direction: column;
}

.room-code-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.room-code-val {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--accent-crimson);
}

.room-actions {
    display: flex;
    gap: 8px;
}

.icon-action-btn {
    padding: 9px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    transition: var(--transition);
}

.icon-action-btn:hover {
    background: var(--bg-surface-hover);
    color: #ffffff;
    border-color: var(--border-active);
}

/* Game Phase Switcher Pill Bar (Day / Voting / Night) */
.phase-selector-bar {
    display: flex;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
    gap: 4px;
}

.phase-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 44px;
    transition: var(--transition);
}

.phase-btn:hover {
    color: #ffffff;
    background: var(--bg-surface);
}

.phase-btn.active-day {
    background: rgba(244, 162, 97, 0.2);
    color: var(--color-day);
    border: 1px solid rgba(244, 162, 97, 0.4);
}

.phase-btn.active-voting {
    background: rgba(58, 134, 255, 0.2);
    color: var(--color-voting);
    border: 1px solid rgba(58, 134, 255, 0.4);
}

.phase-btn.active-night {
    background: rgba(155, 93, 229, 0.2);
    color: var(--color-night);
    border: 1px solid rgba(155, 93, 229, 0.4);
}

/* Force Balance Card (Alive Mafia vs Town) */
.force-balance-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    font-size: 0.88rem;
    font-weight: 600;
}

.balance-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.balance-num {
    font-size: 1.1rem;
    font-weight: 800;
}

/* Players Section */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 8px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-count {
    background: rgba(230, 57, 70, 0.2);
    color: var(--accent-crimson);
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.player-list::-webkit-scrollbar {
    width: 5px;
}
.player-list::-webkit-scrollbar-thumb {
    background: var(--bg-surface-hover);
    border-radius: 10px;
}

.player-item {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.player-item:hover {
    border-color: var(--border-active);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid var(--border-subtle);
}

.player-name {
    font-weight: 600;
    font-size: 0.98rem;
    overflow-wrap: anywhere;
}

.player-role-tag {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-tag-mafia { background: rgba(230, 57, 70, 0.2); color: var(--role-mafia); border: 1px solid rgba(230, 57, 70, 0.4); }
.role-tag-don { background: rgba(244, 162, 97, 0.2); color: var(--role-don); border: 1px solid rgba(244, 162, 97, 0.4); }
.role-tag-doctor { background: rgba(6, 214, 160, 0.2); color: var(--role-doctor); border: 1px solid rgba(6, 214, 160, 0.4); }
.role-tag-sheriff { background: rgba(58, 134, 255, 0.2); color: var(--role-sheriff); border: 1px solid rgba(58, 134, 255, 0.4); }
.role-tag-maniac { background: rgba(155, 93, 229, 0.2); color: var(--role-maniac); border: 1px solid rgba(155, 93, 229, 0.4); }
.role-tag-kamikaze { background: rgba(251, 86, 7, 0.2); color: var(--role-kamikaze); border: 1px solid rgba(251, 86, 7, 0.4); }
.role-tag-villager { background: rgba(141, 153, 174, 0.2); color: var(--role-villager); border: 1px solid rgba(141, 153, 174, 0.4); }
.role-tag-custom { display: inline-flex; align-items: center; gap: 4px; }

.player-dead {
    opacity: 0.45;
    text-decoration: line-through;
}

.status-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 6px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.status-toggle-btn:hover {
    color: #ffffff;
    background: var(--bg-surface-hover);
}

.status-toggle-btn.alive {
    color: var(--color-success);
}

.status-toggle-btn.dead {
    color: var(--color-danger);
}

/* Roles Configurator Grid & Spacing */
.roles-config-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px 18px;
    margin-bottom: 22px;
}

.role-stepper-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 14px;
    margin-bottom: 14px;
}

@media (min-width: 480px) {
    .role-stepper-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.role-stepper-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    min-height: 60px;
    box-sizing: border-box;
}

.role-stepper-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.role-stepper-label span:not(.role-indicator) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.role-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.controls-stepper {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.stepper-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: #ffffff;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.stepper-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-active);
}

.stepper-val {
    width: 20px;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.stepper-delete-btn {
    background: rgba(230, 57, 70, 0.1);
    border: 1px solid rgba(230, 57, 70, 0.25);
    color: var(--color-danger);
    border-radius: 6px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-left: 2px;
}

.stepper-delete-btn:hover {
    background: var(--color-danger);
    color: #ffffff;
}

.villager-auto-box {
    background: rgba(141, 153, 174, 0.08);
    border: 1px dashed rgba(141, 153, 174, 0.35);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
}

.composition-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 183, 3, 0.35);
    border-radius: var(--radius-md);
    background: rgba(255, 183, 3, 0.1);
    color: #ffd166;
    font-size: 0.84rem;
    line-height: 1.45;
}

.composition-warning[hidden] {
    display: none;
}

.composition-warning i {
    margin-top: 2px;
    flex-shrink: 0;
}

.join-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid rgba(230, 57, 70, 0.4);
    border-radius: var(--radius-md);
    background: rgba(230, 57, 70, 0.1);
    color: #ff8b94;
    font-size: 0.86rem;
    line-height: 1.45;
}

.join-error i {
    margin-top: 2px;
    flex-shrink: 0;
}

/* Host Timer & Phase Control */
.host-controls-panel {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.timer-digits {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-crimson);
}

.timer-btn-group {
    display: flex;
    gap: 6px;
}

/* Compact phones need the host controls to reflow instead of clipping. */
@media (max-width: 360px) {
    .glass-card {
        padding-right: 14px;
        padding-left: 14px;
    }

    .room-header {
        padding: 14px;
    }

    .phase-btn {
        padding: 10px 4px;
        gap: 2px;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .phase-btn i {
        display: none;
    }

    .force-balance-card {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
        padding: 10px 6px;
    }

    .balance-item {
        flex-direction: column;
        justify-content: center;
        gap: 1px;
        min-width: 0;
        text-align: center;
        font-size: 0.72rem;
        line-height: 1.2;
    }

    .balance-num {
        font-size: 1rem;
    }

    .host-controls-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px;
    }

    .timer-box {
        justify-content: center;
    }

    .timer-btn-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .timer-btn-group .icon-action-btn {
        justify-content: center;
        min-width: 0;
        padding-right: 8px;
        padding-left: 8px;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: 92vw;
}

.toast-item {
    background: rgba(18, 22, 32, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-active);
    color: #ffffff;
    padding: 9px 18px;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(230, 57, 70, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90vw;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(90vw - 40px);
}

.toast-item.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success i { color: var(--color-success); }
.toast-error i { color: var(--color-danger); }
.toast-info i { color: var(--role-sheriff); }

/* QR Code Modal */
.qr-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(10, 12, 16, 0.85);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    overflow-y: auto;
}

.qr-modal.show {
    display: flex;
}

.qr-modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
    max-width: 340px;
    width: 100%;
    box-shadow: var(--shadow-glow);
}

.qr-box {
    background: #ffffff;
    padding: 16px;
    border-radius: var(--radius-md);
    display: inline-block;
    margin: 16px 0;
}

/* Night / Voting Screen Shroud for Players */
.player-phase-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: #07090e;
    z-index: 1200;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: max(30px, env(safe-area-inset-top));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(30px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: fadeIn 0.4s ease-out forwards;
}

.player-phase-overlay.show {
    display: flex;
}

.night-action-reopen {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 1150;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 11px 15px;
    border: 1px solid rgba(155, 93, 229, 0.55);
    border-radius: 999px;
    background: rgba(20, 15, 35, 0.94);
    box-shadow: 0 8px 28px rgba(155, 93, 229, 0.35);
    color: #ffffff;
    font-weight: 700;
}

.phase-overlay-icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(155, 93, 229, 0.12);
    border: 2px solid rgba(155, 93, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px auto;
    box-shadow: 0 0 35px rgba(155, 93, 229, 0.35);
    animation: moonFloat 3s ease-in-out infinite alternate;
}

.phase-overlay-icon i {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 44px;
    color: var(--color-night);
}

@keyframes moonFloat {
    0% { transform: scale(0.96); box-shadow: 0 0 20px rgba(155, 93, 229, 0.2); }
    100% { transform: scale(1.04); box-shadow: 0 0 45px rgba(155, 93, 229, 0.45); }
}

.phase-overlay-title {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #ffffff;
    margin-bottom: 12px;
}

.phase-overlay-desc {
    color: var(--text-secondary);
    max-width: 340px;
    line-height: 1.6;
    font-size: 0.96rem;
}

/* ==========================================================================
   LIVE VOTING INTERACTIVE STYLES
   ========================================================================== */

/* Host Voting Management Card */
.host-voting-box {
    background: var(--bg-surface-elevated);
    border: 1px solid rgba(58, 134, 255, 0.35);
    border-radius: var(--radius-lg);
    padding: 20px 18px;
    margin-bottom: 22px;
    box-shadow: 0 4px 20px rgba(58, 134, 255, 0.15);
}

/* Host Night Action Monitor Card */
.host-night-box {
    background: var(--bg-surface-elevated);
    border: 1px solid rgba(230, 57, 70, 0.35);
    border-radius: var(--radius-lg);
    padding: 20px 18px;
    margin-bottom: 22px;
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.15);
    animation: fadeInModal 0.25s ease-out;
}

.host-night-target-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 11px 13px;
    border: 1px dashed color-mix(in srgb, currentColor 38%, transparent);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, currentColor 7%, transparent);
    color: var(--text-secondary);
    transition: var(--transition);
}

.host-night-target-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.host-night-target-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: right;
}

.host-night-monitor-list {
    display: grid;
    gap: 8px;
}

.host-night-target-row.action-mafia { color: var(--role-mafia); }
.host-night-target-row.action-doctor { color: var(--role-doctor); }
.host-night-target-row.action-sheriff { color: var(--role-sheriff); }
.host-night-target-row.action-maniac { color: #bb86fc; }
.host-night-target-row.action-don { color: var(--role-don); }

.host-night-target-row .host-night-target-label span,
.host-night-target-row strong {
    color: var(--text-primary);
}

.host-night-target-row.inactive {
    opacity: 0.42;
}

.host-night-target-row.complete {
    border-style: solid;
}

.night-monitor-waiting {
    color: var(--text-muted);
    font-weight: 500;
}

.night-monitor-target {
    color: inherit;
    font-weight: 800;
}

.night-readiness {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.night-readiness.all-complete {
    background: rgba(6, 214, 160, 0.12);
    color: var(--color-success);
}

.player-item.is-mafia-targeted {
    border-color: rgba(230, 57, 70, 0.6) !important;
    background: rgba(230, 57, 70, 0.08) !important;
    box-shadow: 0 0 16px rgba(230, 57, 70, 0.25);
}

.player-item.is-don-targeted {
    border-color: rgba(244, 162, 97, 0.6) !important;
    background: rgba(244, 162, 97, 0.08) !important;
    box-shadow: 0 0 16px rgba(244, 162, 97, 0.25);
}

.mafia-target-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(230, 57, 70, 0.25);
    border: 1px solid var(--role-mafia);
    color: var(--role-mafia);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
    vertical-align: middle;
    animation: pulseGlow 1.8s infinite;
}

.mafia-target-badge.don {
    background: rgba(244, 162, 97, 0.25);
    border-color: var(--role-don);
    color: var(--role-don);
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 4px rgba(230, 57, 70, 0.3); }
    50% { box-shadow: 0 0 12px rgba(230, 57, 70, 0.7); }
}

.candidate-selector-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 16px 0;
}

.candidate-chip {
    padding: 8px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    user-select: none;
    min-height: 44px;
}

.candidate-chip:hover {
    border-color: var(--color-voting);
    color: #ffffff;
}

.candidate-chip.selected {
    background: rgba(58, 134, 255, 0.2);
    border-color: var(--color-voting);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(58, 134, 255, 0.3);
}

/* Live Tally Display on Host Screen */
.vote-tally-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.vote-tally-row {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tally-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.92rem;
    font-weight: 700;
}

.tally-bar-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.tally-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3a86ff, #06d6a0);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Player Fullscreen / Popup Voting Modal */
.player-voting-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(5, 7, 12, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1300;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: fadeIn 0.3s ease-out forwards;
}

.player-voting-modal.show {
    display: flex;
}

.voting-modal-card {
    background: linear-gradient(180deg, rgba(24, 29, 44, 0.96) 0%, rgba(14, 18, 28, 0.98) 100%);
    border: 1px solid rgba(58, 134, 255, 0.45);
    border-radius: 24px;
    padding: 24px 20px;
    max-width: 390px;
    width: 100%;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 35px rgba(58, 134, 255, 0.25);
}

.voting-timer-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(58, 134, 255, 0.25) 0%, rgba(58, 134, 255, 0.05) 100%);
    border: 2px solid var(--color-voting);
    color: #ffffff;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 12px;
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.4);
    animation: pulseTimer 1s infinite alternate;
}

@keyframes pulseTimer {
    0% { transform: scale(0.96); }
    100% { transform: scale(1.04); }
}

.voting-candidate-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    max-height: 270px;
    overflow-y: auto;
    padding-right: 4px;
}

.vote-btn {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    min-height: 44px;
}

.vote-btn-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #ffffff;
}

.vote-avatar-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(58, 134, 255, 0.15);
    border: 1px solid rgba(58, 134, 255, 0.35);
    color: var(--color-voting);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.vote-radio-icon {
    font-size: 1.15rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.vote-btn:hover {
    background: rgba(58, 134, 255, 0.12);
    border-color: var(--color-voting);
}

.vote-btn.selected {
    background: rgba(58, 134, 255, 0.25);
    border-color: var(--color-voting);
    box-shadow: 0 0 16px rgba(58, 134, 255, 0.35);
}

.vote-btn.selected .vote-radio-icon {
    color: var(--color-voting);
}

.vote-btn.selected .vote-avatar-icon {
    background: var(--color-voting);
    color: #ffffff;
}

.vote-btn-abstain {
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.15);
}

.vote-btn-abstain .vote-avatar-icon {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
}

.vote-btn.disabled, .vote-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Result Modal Banner */
.voting-result-banner {
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 14px;
    animation: fadeIn 0.3s ease;
}

/* Ghost / Spectator Mode Styles for Dead Players */
.ghost-roster-container {
    width: 100%;
    max-width: 440px;
    margin-top: 24px;
    background: rgba(20, 24, 35, 0.8);
    border: 1px solid rgba(155, 93, 229, 0.35);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 25px rgba(155, 93, 229, 0.15);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ghost-roster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 10px;
}

.ghost-roster-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-night);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ghost-roster-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.ghost-player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 0.88rem;
}

.ghost-player-row.dead {
    opacity: 0.55;
}

.ghost-status-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.ghost-status-badge.alive {
    background: rgba(6, 214, 160, 0.15);
    color: var(--color-success);
}

.ghost-status-badge.dead {
    background: rgba(230, 57, 70, 0.15);
    color: var(--color-danger);
}

/* ==========================================================================
   CUSTOM ROLES BUILDER MODAL & CONTROLS
   ========================================================================== */

.roles-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.btn-add-custom-role {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(58, 134, 255, 0.12);
    border: 1px dashed rgba(58, 134, 255, 0.45);
    color: var(--color-voting);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 44px;
}

.btn-add-custom-role:hover {
    background: rgba(58, 134, 255, 0.25);
    border-color: var(--color-voting);
    color: #ffffff;
}

@media (max-width: 480px) {
    .roles-header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .btn-add-custom-role {
        justify-content: center;
        width: 100%;
        padding: 8px 12px;
    }
}

.custom-roles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
}

@media (min-width: 500px) {
    .custom-roles-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.custom-role-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.custom-team-chip {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 999px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.team-chip-town {
    background: rgba(6, 214, 160, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(6, 214, 160, 0.3);
}

.team-chip-mafia {
    background: rgba(230, 57, 70, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(230, 57, 70, 0.3);
}

.team-chip-neutral {
    background: rgba(155, 93, 229, 0.15);
    color: var(--role-maniac);
    border: 1px solid rgba(155, 93, 229, 0.3);
}

/* Custom Role Creator Modal */
.custom-role-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
    box-sizing: border-box;
}

.custom-role-modal-card {
    background: #151822;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    max-width: 440px;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95), 0 0 30px rgba(58, 134, 255, 0.2);
    box-sizing: border-box;
}

.modal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 10px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    width: 44px;
    height: 44px;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-close-btn:hover {
    color: #ffffff;
}

.custom-role-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    text-align: left;
}

.custom-role-field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.team-selector-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.team-selector-chips .team-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 4px;
    font-size: 0.76rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    white-space: nowrap;
    text-align: center;
    min-height: 44px;
}

.team-selector-chips .team-chip:hover {
    background: rgba(255, 255, 255, 0.08);
}

.team-selector-chips .team-chip.selected {
    background: rgba(58, 134, 255, 0.2);
    border-color: var(--color-voting);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(58, 134, 255, 0.3);
}

.icon-selector-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.icon-choice-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

@media (max-width: 480px) {
    .icon-selector-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.icon-choice-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.icon-choice-btn.selected {
    background: rgba(58, 134, 255, 0.25);
    border-color: var(--color-voting);
    color: var(--color-voting);
    box-shadow: 0 0 10px rgba(58, 134, 255, 0.4);
}

.color-palette-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-swatch-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.color-swatch-btn:hover {
    transform: scale(1.15);
}

.color-swatch-btn.selected {
    border-color: #ffffff;
    box-shadow: 0 0 12px currentColor;
    transform: scale(1.2);
}

.modal-input {
    width: 100%;
    height: 42px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 0.92rem;
    padding: 0 14px;
    box-sizing: border-box;
    outline: none;
    transition: var(--transition);
}

.modal-input:focus {
    border-color: var(--color-voting);
    background: rgba(58, 134, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.15);
}

.modal-textarea {
    width: 100%;
    height: 68px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 0.88rem;
    padding: 10px 14px;
    box-sizing: border-box;
    outline: none;
    resize: none;
    line-height: 1.4;
    transition: var(--transition);
}

.modal-textarea:focus {
    border-color: var(--color-voting);
    background: rgba(58, 134, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.15);
}

.modal-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}

.modal-card-actions .btn {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    border-radius: var(--radius-md);
    margin: 0;
}

/* ==========================================================================
   END-GAME RESULTS OVERLAY (ALL PLAYERS SUMMARY)
   ========================================================================== */

.game-results-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(8, 10, 16, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    box-sizing: border-box;
    animation: fadeInModal 0.4s ease-out;
}

.game-results-card {
    background: #141722;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    max-width: 480px;
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), 0 0 35px rgba(230, 57, 70, 0.2);
    box-sizing: border-box;
    text-align: center;
}

.results-header-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.results-header-icon.winner-mafia {
    background: rgba(230, 57, 70, 0.2);
    color: var(--role-mafia);
    border: 2px solid var(--role-mafia);
    box-shadow: 0 0 20px var(--accent-crimson-glow);
}

.results-header-icon.winner-town {
    background: rgba(6, 214, 160, 0.2);
    color: var(--role-doctor);
    border: 2px solid var(--role-doctor);
    box-shadow: 0 0 20px rgba(6, 214, 160, 0.4);
}

.results-header-icon.winner-maniac {
    background: rgba(155, 93, 229, 0.2);
    color: var(--role-maniac);
    border: 2px solid var(--role-maniac);
    box-shadow: 0 0 20px rgba(155, 93, 229, 0.4);
}

.results-header-icon.winner-none {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.results-winner-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 1px;
    margin: 0 0 4px;
}

.results-winner-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 14px;
}

.results-outcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.results-outcome-badge.outcome-win {
    background: rgba(255, 209, 102, 0.18);
    color: #ffd166;
    border: 1px solid rgba(255, 209, 102, 0.5);
    box-shadow: 0 0 15px rgba(255, 209, 102, 0.3);
}

.results-outcome-badge.outcome-loss {
    background: rgba(230, 57, 70, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(230, 57, 70, 0.35);
}

.results-stats-row {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 18px;
    font-size: 0.82rem;
}

.results-stats-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.results-stats-val {
    font-weight: 800;
    font-size: 1.1rem;
}

.results-roster-box {
    text-align: left;
    margin-bottom: 20px;
}

.results-roster-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.results-roster-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.results-player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    gap: 8px;
}

.results-player-row.dead {
    opacity: 0.6;
}

.results-player-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.results-player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.results-player-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.results-player-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.results-status-tag {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.results-status-tag.alive {
    background: rgba(6, 214, 160, 0.15);
    color: var(--color-success);
}

.results-status-tag.dead {
    background: rgba(230, 57, 70, 0.15);
    color: var(--color-danger);
}

/* ==========================================================================
   GUNSHOT FLASH FX & MAFIA NIGHT ACTIONS
   ========================================================================== */

.mafia-night-section {
    margin-top: 18px;
    background: rgba(230, 57, 70, 0.09);
    border: 1px solid rgba(230, 57, 70, 0.35);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    text-align: left;
    box-shadow: 0 0 25px rgba(230, 57, 70, 0.15);
}

.night-action-section {
    --night-action-color: var(--accent-blue);
    width: 100%;
    max-width: 380px;
    box-sizing: border-box;
    margin-top: 18px;
    padding: 14px 16px;
    text-align: left;
    color: var(--night-action-color);
    background: color-mix(in srgb, var(--night-action-color) 9%, transparent);
    border: 1px solid color-mix(in srgb, var(--night-action-color) 38%, transparent);
    border-radius: var(--radius-md);
    box-shadow: 0 0 25px color-mix(in srgb, var(--night-action-color) 15%, transparent);
}

.night-action-doctor { --night-action-color: var(--role-doctor); }
.night-action-sheriff { --night-action-color: var(--role-sheriff); }
.night-action-maniac { --night-action-color: #bb86fc; }
.night-action-don { --night-action-color: var(--role-don); }

/* Explicit fallbacks keep night cards styled in older Android/iOS WebViews
   that do not support color-mix(). */
.night-action-doctor {
    background: rgba(6, 214, 160, 0.09);
    border-color: rgba(6, 214, 160, 0.38);
    box-shadow: 0 0 25px rgba(6, 214, 160, 0.15);
}

.night-action-sheriff {
    background: linear-gradient(145deg, rgba(58, 134, 255, 0.16), rgba(12, 27, 52, 0.92));
    border-color: rgba(58, 134, 255, 0.55);
    box-shadow: 0 0 28px rgba(58, 134, 255, 0.2);
}

.night-action-maniac {
    background: rgba(187, 134, 252, 0.09);
    border-color: rgba(187, 134, 252, 0.38);
    box-shadow: 0 0 25px rgba(187, 134, 252, 0.15);
}

.night-action-don {
    background: rgba(244, 162, 97, 0.09);
    border-color: rgba(244, 162, 97, 0.38);
    box-shadow: 0 0 25px rgba(244, 162, 97, 0.15);
}

.night-action-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    color: var(--night-action-color);
    font-size: 0.95rem;
    font-weight: 800;
}

.night-action-section > p {
    margin: 0 0 10px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.night-action-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    max-height: min(210px, 31vh);
    overflow-y: auto;
}

.night-action-target-btn {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 46px;
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.84rem;
    transition: var(--transition);
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.night-action-target-btn:hover:not(:disabled),
.night-action-target-btn.selected {
    border-color: var(--night-action-color);
    background: color-mix(in srgb, var(--night-action-color) 25%, transparent);
    box-shadow: 0 0 12px color-mix(in srgb, var(--night-action-color) 35%, transparent);
}

.night-action-doctor .night-action-target-btn:hover:not(:disabled),
.night-action-doctor .night-action-target-btn.selected {
    background: rgba(6, 214, 160, 0.24);
    box-shadow: 0 0 12px rgba(6, 214, 160, 0.35);
}

.night-action-sheriff .night-action-target-btn {
    border-color: rgba(58, 134, 255, 0.22);
    background: rgba(7, 18, 37, 0.72);
}

.night-action-sheriff .night-action-target-btn:hover:not(:disabled),
.night-action-sheriff .night-action-target-btn.selected {
    border-color: var(--role-sheriff);
    background: rgba(58, 134, 255, 0.28);
    box-shadow: 0 0 15px rgba(58, 134, 255, 0.45);
}

.night-action-maniac .night-action-target-btn:hover:not(:disabled),
.night-action-maniac .night-action-target-btn.selected {
    background: rgba(187, 134, 252, 0.24);
    box-shadow: 0 0 12px rgba(187, 134, 252, 0.35);
}

.night-action-don .night-action-target-btn:hover:not(:disabled),
.night-action-don .night-action-target-btn.selected {
    background: rgba(244, 162, 97, 0.24);
    box-shadow: 0 0 12px rgba(244, 162, 97, 0.35);
}

.night-action-target-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.night-action-target-name {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.night-action-target-name > i { color: var(--night-action-color); }

.night-investigation-result {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    background: rgba(6, 214, 160, 0.12);
    border: 1px solid rgba(6, 214, 160, 0.35);
    color: var(--color-success);
}

.night-investigation-result.danger {
    background: rgba(230, 57, 70, 0.14);
    border-color: rgba(230, 57, 70, 0.42);
    color: var(--color-danger);
}

.night-action-sheriff .night-investigation-result {
    position: relative;
    min-height: 54px;
    padding: 13px 14px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(6, 214, 160, 0.12), rgba(6, 214, 160, 0.05)),
        repeating-linear-gradient(0deg, transparent 0 8px, rgba(255, 255, 255, 0.025) 8px 9px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    font-size: 0.9rem;
    line-height: 1.35;
}

.night-action-sheriff .night-investigation-result.danger {
    background:
        linear-gradient(90deg, rgba(230, 57, 70, 0.17), rgba(230, 57, 70, 0.06)),
        repeating-linear-gradient(0deg, transparent 0 8px, rgba(255, 255, 255, 0.025) 8px 9px);
}

.night-action-sheriff .night-investigation-result > i {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.22);
}

.night-action-sheriff .night-investigation-result strong {
    color: #ffffff;
}

.night-investigation-result[hidden] { display: none; }
.night-action-empty { color: var(--text-muted); font-size: 0.8rem; }

.mafia-night-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--role-mafia);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.mafia-candidate-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-top: 10px;
    max-height: 160px;
    overflow-y: auto;
}

.mafia-target-btn {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-sm);
    color: #ffffff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    min-height: 44px;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 600px) {
    .player-phase-overlay {
        justify-content: flex-start;
        gap: 0;
        padding-top: max(18px, env(safe-area-inset-top));
        padding-right: max(14px, env(safe-area-inset-right));
        padding-bottom: max(18px, env(safe-area-inset-bottom));
        padding-left: max(14px, env(safe-area-inset-left));
    }

    .phase-overlay-icon {
        width: 72px;
        height: 72px;
        margin-bottom: 14px;
        flex: 0 0 72px;
    }

    .phase-overlay-icon i {
        font-size: 34px;
    }

    .phase-overlay-title {
        margin-bottom: 8px;
        font-size: clamp(1.55rem, 8vw, 1.9rem);
        line-height: 1.1;
    }

    .phase-overlay-desc {
        max-width: 360px;
        margin-bottom: 4px;
        font-size: 0.88rem;
        line-height: 1.4;
    }

    .mafia-night-section,
    .night-action-section {
        width: 100%;
        max-width: 420px;
        margin-top: 12px;
        padding: 13px;
        flex-shrink: 0;
        border-radius: 14px;
    }

    .mafia-night-header,
    .night-action-header {
        font-size: 0.92rem;
    }

    .mafia-candidate-list,
    .night-action-list {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
        max-height: min(260px, 35dvh);
        padding: 1px;
    }

    .mafia-target-btn,
    .night-action-target-btn {
        min-width: 0;
        min-height: 50px;
        padding: 10px 11px;
        border-radius: 11px;
        font-size: 0.86rem;
    }

    .night-action-target-name {
        max-width: calc(100% - 24px);
    }

    .night-action-section + .btn,
    .mafia-night-section + .btn,
    .player-phase-overlay > .btn {
        width: min(100%, 280px);
        min-height: 50px;
        margin-top: 14px;
        flex-shrink: 0;
    }
}

@media (max-width: 340px) {
    .mafia-candidate-list,
    .night-action-list {
        grid-template-columns: 1fr;
    }
}

/* Short screens and landscape mode keep every phase action scroll-reachable. */
@media (max-height: 700px), (orientation: landscape) {
    .player-phase-overlay {
        justify-content: flex-start;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    .player-phase-overlay {
        padding-top: max(14px, env(safe-area-inset-top));
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    .phase-overlay-icon {
        width: 58px;
        height: 58px;
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    .phase-overlay-icon i {
        font-size: 28px;
    }

    .phase-overlay-title {
        font-size: 1.55rem;
        margin-bottom: 6px;
    }

    .phase-overlay-desc {
        font-size: 0.86rem;
        line-height: 1.4;
    }

    .mafia-night-section,
    .night-action-section {
        margin-top: 10px;
        padding: 10px 12px;
        flex-shrink: 0;
    }

    .mafia-candidate-list,
    .night-action-list {
        max-height: 124px;
    }

    .player-phase-overlay > .btn {
        margin-top: 12px;
        flex-shrink: 0;
    }

    .voting-modal-card {
        border-radius: 18px;
        padding: 16px;
    }

    .voting-timer-circle {
        width: 44px;
        height: 44px;
        margin-bottom: 6px;
        font-size: 1.1rem;
    }

    .voting-candidate-list {
        margin: 10px 0;
        max-height: 128px;
    }

    .vote-btn-abstain {
        margin-top: 8px;
    }
}

.mafia-target-btn:hover {
    background: rgba(230, 57, 70, 0.2);
    border-color: var(--role-mafia);
}

.mafia-target-btn.selected {
    background: rgba(230, 57, 70, 0.38);
    border-color: var(--role-mafia);
    box-shadow: 0 0 16px rgba(230, 57, 70, 0.6);
    color: #ffffff;
    font-weight: 700;
}

/* Procedural bullet impact and shattered-glass scene. */
.bullet-glass-shatter-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    pointer-events: none;
    overflow: hidden;
    isolation: isolate;
    opacity: 0;
}

.bullet-glass-shatter-overlay[hidden] {
    display: none !important;
}

.bullet-glass-shatter-overlay.active {
    display: block;
    animation: glassSceneLife 3.75s linear forwards;
}

.glass-fx-stage,
.glass-scene-dim,
.glass-shot-flash,
.glass-refraction-canvas,
.glass-cracks-canvas,
.glass-shards-container,
.glass-particles-container,
.glass-edge-vignette {
    position: absolute;
    inset: 0;
}

.glass-fx-stage {
    overflow: hidden;
    transform-origin: var(--impact-x) var(--impact-y);
}

.bullet-glass-shatter-overlay.active .glass-fx-stage {
    animation: glassImpactKick 580ms cubic-bezier(0.17, 0.67, 0.2, 1) both;
}

.glass-scene-dim {
    z-index: 0;
    background:
        radial-gradient(circle at var(--impact-x) var(--impact-y), transparent 0 12%, rgba(3, 7, 11, 0.3) 42%, rgba(0, 0, 0, 0.82) 100%),
        rgba(2, 5, 8, 0.2);
    opacity: 0;
}

.active .glass-scene-dim {
    animation: glassRoomDarken 3.75s ease-out forwards;
}

.glass-shot-flash {
    z-index: 1;
    background:
        radial-gradient(circle at var(--impact-x) var(--impact-y), rgba(255, 255, 255, 1) 0 1.5%, rgba(196, 228, 255, 0.92) 3%, rgba(116, 184, 231, 0.4) 9%, transparent 23%),
        linear-gradient(96deg, rgba(255, 251, 224, 0) 0 36%, rgba(255, 255, 255, 0.88) 49%, rgba(255, 244, 206, 0) 61%);
    mix-blend-mode: screen;
    opacity: 0;
}

.active .glass-shot-flash {
    animation: glassShotFlash 240ms steps(2, end) forwards;
}

.bullet-tracer {
    position: absolute;
    z-index: 2;
    top: var(--impact-y);
    left: -70px;
    width: var(--tracer-length);
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 212, 145, 0.12) 45%, rgba(255, 250, 226, 0.95) 88%, #ffffff 100%);
    box-shadow: 0 0 5px rgba(255, 232, 190, 0.75);
    opacity: 0;
    transform: translateY(-50%) scaleX(0.2);
    transform-origin: right center;
}

.active .bullet-tracer {
    animation: bulletTracer 105ms ease-out forwards;
}

.glass-refraction-canvas,
.glass-cracks-canvas {
    z-index: 3;
    width: 100%;
    height: 100%;
}

.glass-refraction-canvas {
    opacity: 0;
}

.glass-cracks-canvas {
    filter: drop-shadow(0 0 2px rgba(188, 229, 255, 0.55));
}

.bullet-glass-shatter-overlay.webgl-glass .glass-refraction-canvas {
    opacity: 1;
}

.bullet-glass-shatter-overlay.webgl-glass .glass-cracks-canvas {
    opacity: 0;
}

.glass-shards-container,
.glass-particles-container {
    z-index: 4;
    overflow: visible;
}

.glass-shard {
    position: absolute;
    display: block;
    background:
        linear-gradient(var(--shard-shine), rgba(255, 255, 255, 0.92) 0 5%, rgba(175, 222, 248, 0.13) 22% 61%, rgba(255, 255, 255, 0.72) 67%, rgba(114, 176, 216, 0.18) 100%);
    border: 1px solid rgba(226, 246, 255, 0.92);
    box-shadow: inset 0 0 7px rgba(255, 255, 255, 0.42), 0 0 3px rgba(114, 192, 239, 0.72);
    opacity: 0;
    will-change: transform, opacity;
}

.glass-shard-near {
    filter: blur(0.35px);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.48), 0 4px 12px rgba(0, 0, 0, 0.28);
}

.active .glass-shard {
    animation: glassShardFlight var(--shard-duration) cubic-bezier(0.12, 0.58, 0.25, 1) var(--shard-delay) forwards;
}

.glass-spark,
.glass-dust {
    position: absolute;
    display: block;
    width: var(--particle-size);
    height: var(--particle-size);
    border-radius: 50%;
    opacity: 0;
    will-change: transform, opacity;
}

.glass-spark {
    z-index: 6;
    background: #fff7db;
    box-shadow: 0 0 6px 2px rgba(255, 205, 112, 0.88);
}

.glass-dust {
    z-index: 5;
    background: rgba(210, 237, 250, 0.64);
    box-shadow: 0 0 5px rgba(191, 226, 245, 0.45);
    filter: blur(0.7px);
}

.active .glass-spark,
.active .glass-dust {
    animation: glassParticleFlight var(--particle-duration) ease-out var(--particle-delay) forwards;
}

.glass-impact-center {
    position: absolute;
    z-index: 6;
    top: var(--impact-y);
    left: var(--impact-x);
    width: 112px;
    height: 112px;
    transform: translate(-50%, -50%);
}

.bullet-impact-flare {
    position: absolute;
    inset: -38px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffffff 0 3%, rgba(255, 224, 171, 0.96) 5%, rgba(150, 211, 247, 0.55) 18%, transparent 58%);
    opacity: 0;
    transform: scale(0.15);
    mix-blend-mode: screen;
}

.active .bullet-impact-flare {
    animation: bulletImpactFlare 310ms ease-out forwards;
}

.glass-chip-halo {
    position: absolute;
    inset: 22px;
    border-radius: 43% 57% 47% 53%;
    background: repeating-conic-gradient(
        from 7deg,
        rgba(235, 249, 255, 0.92) 0deg 1.5deg,
        rgba(137, 196, 229, 0.34) 2deg 4deg,
        transparent 5deg 17deg
    );
    -webkit-mask: radial-gradient(circle, transparent 0 31%, #000 36% 43%, transparent 49%);
    mask: radial-gradient(circle, transparent 0 31%, #000 36% 43%, transparent 49%);
    filter: drop-shadow(1px 1px 1px #02070a) drop-shadow(0 0 3px rgba(186, 226, 248, 0.72));
    opacity: 0;
}

.active .glass-chip-halo {
    animation: glassChipHalo 560ms ease-out 35ms forwards;
}

.bullet-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 25px;
    height: 25px;
    border-radius: 43% 57% 48% 52%;
    background:
        radial-gradient(circle at 42% 38%, #020303 0 28%, #10161a 35%, #000000 56%, rgba(179, 217, 237, 0.92) 62%, rgba(255, 255, 255, 0.74) 67%, transparent 72%);
    box-shadow: inset 2px 3px 5px #000000, 0 0 3px #dff5ff, 0 0 16px rgba(139, 200, 235, 0.68);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.05) rotate(-18deg);
}

.bullet-hole span {
    position: absolute;
    inset: -9px;
    border: 1px solid rgba(227, 246, 255, 0.72);
    border-width: 2px 1px 1px 2px;
    border-radius: 38% 62% 55% 45%;
    filter: drop-shadow(1px 1px 1px #071017);
}

.active .bullet-hole {
    animation: bulletHoleOpen 420ms cubic-bezier(0.16, 0.8, 0.24, 1.25) 18ms forwards;
}

.glass-edge-vignette {
    z-index: 8;
    background:
        radial-gradient(circle at var(--impact-x) var(--impact-y), transparent 0 22%, rgba(0, 0, 0, 0.08) 48%, rgba(0, 0, 0, 0.78) 112%),
        linear-gradient(180deg, rgba(80, 9, 14, 0.08), rgba(0, 0, 0, 0.42));
    opacity: 0;
}

.active .glass-edge-vignette {
    animation: glassVignette 3.75s ease-out forwards;
}

@keyframes glassSceneLife {
    0% { opacity: 1; }
    78% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes glassImpactKick {
    0% { transform: scale(1); filter: brightness(1); }
    5% { transform: scale(1.035) translate3d(-9px, 5px, 0); filter: brightness(2.2) contrast(1.18); }
    14% { transform: scale(1.022) translate3d(8px, -6px, 0); }
    26% { transform: scale(1.014) translate3d(-5px, -2px, 0); filter: brightness(1.12) contrast(1.06); }
    43% { transform: scale(1.007) translate3d(3px, 3px, 0); }
    66% { transform: scale(1.003) translate3d(-1px, 0, 0); }
    100% { transform: scale(1) translate3d(0, 0, 0); filter: brightness(1) contrast(1); }
}

@keyframes glassRoomDarken {
    0% { opacity: 0; }
    8% { opacity: 0.88; }
    72% { opacity: 0.74; }
    100% { opacity: 0; }
}

@keyframes glassShotFlash {
    0% { opacity: 1; filter: brightness(2.4); }
    22% { opacity: 0.95; }
    43% { opacity: 0.16; }
    58% { opacity: 0.48; }
    100% { opacity: 0; filter: brightness(1); }
}

@keyframes bulletTracer {
    0% { opacity: 0; transform: translateY(-50%) scaleX(0.18); }
    22% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-50%) scaleX(1); }
}

@keyframes glassShardFlight {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.18) rotate(0deg) rotateX(0deg); }
    6% { opacity: 1; }
    48% { opacity: 0.92; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--shard-x)), calc(-50% + var(--shard-y))) scale(var(--shard-scale)) rotate(var(--shard-rotate)) rotateX(76deg); }
}

@keyframes glassParticleFlight {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
    13% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--particle-x)), calc(-50% + var(--particle-y))) scale(0.05); }
}

@keyframes bulletImpactFlare {
    0% { opacity: 1; transform: scale(0.12); }
    38% { opacity: 0.92; }
    100% { opacity: 0; transform: scale(1.35); }
}

@keyframes glassChipHalo {
    0% { opacity: 0; transform: scale(0.18) rotate(0); }
    20% { opacity: 1; }
    100% { opacity: 0.72; transform: scale(1.25) rotate(24deg); }
}

@keyframes bulletHoleOpen {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.05) rotate(-18deg); }
    42% { opacity: 1; transform: translate(-50%, -50%) scale(1.45) rotate(8deg); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
}

@keyframes glassVignette {
    0% { opacity: 0; }
    9% { opacity: 0.94; }
    72% { opacity: 0.8; }
    100% { opacity: 0; }
}

@media (max-width: 620px) {
    .glass-impact-center {
        width: 92px;
        height: 92px;
    }

    .glass-chip-halo {
        inset: 18px;
    }

    .bullet-hole {
        width: 22px;
        height: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bullet-glass-shatter-overlay.active,
    .active .glass-scene-dim,
    .active .glass-edge-vignette {
        animation-duration: 1.75s;
    }

    .bullet-glass-shatter-overlay.active .glass-fx-stage,
    .active .glass-shard,
    .active .glass-spark,
    .active .glass-dust,
    .active .bullet-tracer {
        animation: none;
    }

    .active .bullet-hole {
        animation-duration: 1ms;
    }
}
