*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --black-bg: #000000;
    --darker-bg: #141414;
    --bg-gray: #232323;
    --blood-red: #a92408;
    --blood-red-hover: #c22c0f;
    --blood-red-click: #681706;
    --text-light: #e0e0e0;
    --text-lighter: #ffffff;
    --text-de-emph: #5e5d5d;
    --border-dark: #333333;
    --inner-border-dark: #242424;
    --coin-bright: #e6ba2b;
    --coin-light: #fad447;
    --coin-base: #d2a616;
    --coin-dark: #ffae00;
    --coin-shadow: #c798008c;
    --coin-shadow-t: #cb860555;
    --max-width-body: 800px;
    --padding-game-element: 15px;
    --padding-body: 5px;
    --tail-symbol: "🐺"; 
}


/* Base styles */

body {
    font-family: -apple-system, system-ui, sans-serif;
    max-width: var(--max-width-body);
    margin: 0 auto;
    padding: var(--padding-body);
    background-color: var(--black-bg);
    color: var(--text-light);
}


.header-title {
    position: relative;
    flex-shrink: 1;
    min-width: 0;
}
.header-logo {
    position: relative;
    flex-shrink: 1;
    min-height: 2rem;
    max-width: min(60vw, var(--max-width-body)*0.6);
    max-height: 12vh;
    width: auto;
    height: auto;
    transition: opacity 6.5s ease;
}
body[data-phase="day"] .header-logo,
body[data-phase="night"] .header-logo {
    opacity: 0;
    transition: opacity 0.2s ease;
}
.index-logo {
    position: relative;
    flex-shrink: 1;
    min-height: 2rem;
    max-width: min(60vw, var(--max-width-body)*0.6);
    width: auto;
    height: auto;
}
.index-title {
    display: flex;
    justify-content: left;
    width: 100%;
}

h1 {
    flex-shrink: 1;
    min-width: 0;
    font-size: clamp(1.2rem, 5vw, 2.5rem); /* Shrinks between 1.5rem and 2.5rem based on viewport width */
}

/* Night sky container */


/* .night-sky {
    position: relative;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 10%, var(--darker-bg), #727272);
}


/* Moon styling */


/* .moon {
    position: absolute;
    top: 10%;
    right: 7%;
    width: 40px;
    height: 40px;
    background-color: #f0f0f0;
    border-radius: 50%;
    box-shadow: 0 0 60px rgba(255, 255, 255, 0.8), 
    0 0 120px rgba(255, 255, 255, 0.6), 
    0 0 180px rgba(255, 255, 255, 0.4);
    animation: float 30s infinite ease-in-out;
}  */


/* .crater {
    position: absolute;
    background-color: #e2e2e2ab;
    box-shadow: 0 0 2px rgba(171, 171, 171, 0.403);
    border-radius: 50%;
} */


/* Crater 1 */


/* .crater1 {
    width: 9px;
    height: 9px;
    top: 20%;
    left: 21%;
} */


/* Crater 2 */


/* .crater2 {
    width: 6px;
    height: 6px;
    top: 47%;
    left: 20%;
} */


/* Crater 3 */


/* .crater3 {
    width: 7px;
    height: 7px;
    top: 65%;
    left: 50%;
} */


/* Crater 4 */


/* .crater4 {
    width: 3px;
    height: 3px;
    top: 8px;
    left: 23px;
} */


/* Optional: Add a subtle floating animation to the moon */


/* @keyframes float {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
} */

.container {
    background-color: var(--darker-bg);
    padding: 0px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 0px;
    min-height: calc(100vh - 10px - 2*var(--padding-body));
    display: flex;
    position: relative;
    flex-direction: column;
}


/* Header styles */

.header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: sticky;
    top: 0px;
    border-radius: 10px 10px 0 0;
    padding: 0;
    background-color: var(--darker-bg);
    margin-bottom: 0;
    z-index: 10;
    overflow: hidden;
}

.header-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0px 8px;
    min-height: min-content;
    border-bottom: 1px solid var(--border-dark);
    max-height: 12vh;
}


/* .header {
    background-image: linear-gradient(180deg, var(--text-light), var(--darker-bg), var(--blood-red));
    color: transparent;
    background-clip: text
} */


/* Button styles */

.btn,
button {
    width: 100%;
    padding: 9px 18px;
    margin: 5px 0;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--blood-red);
    background-image: radial-gradient(100% 60% at 75% 5%, #ff959541 0, #570d0d3f 100%);
    box-shadow: 0 3px 3cap #432c2c;
    color: rgb(197, 193, 193);
    display: block;
}

.btn:hover,
button:hover {
    background-color: var(--blood-red-hover);
}

.btn:active,
button:active {
    background-color: var(--blood-red-click);
}

.btn:disabled,
button:disabled {
    background: #cccccc !important;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.7;
}

.screen-element {
    margin-left: 10px;
    margin-right: 10px;
}
/* Input styles */

input {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    border: 1px solid #ddd;
    border-radius: 5px;
}

#playerName {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    background-color: var(--black-bg);
    color: var(--text-light);
    font-size: 1rem;
    box-sizing: border-box;
}


.game-status {
    font-weight: 500;
    margin: 5px 8px;
    font-size: 0.95rem;
}

.game-phase,
.night-action,
.player-list {
    position: relative;
    margin: 10px 10px;
    background: var(--bg-gray);
    border-radius: 8px;
    border: 1px solid var(--border-dark);
}
.game-phase,
.night-action {
    padding: 10px 10px;
}

.player-list {
    padding: 10px 5px 5px 5px;
}

@keyframes actionGlow {
    0%   { box-shadow: 0 0 8px rgba(169,36,8,0.4), 0 0 20px rgba(169,36,8,0.15); }
    50%  { box-shadow: 0 0 18px rgba(169,36,8,0.7), 0 0 40px rgba(169,36,8,0.35); }
    100% { box-shadow: 0 0 8px rgba(169,36,8,0.4), 0 0 20px rgba(169,36,8,0.15); }
}

.action-card {
    border-color: var(--blood-red) !important;
    animation: actionGlow 2.5s ease-in-out infinite;
}

.setting-selector h3,
.night-action h3,
.game-phase h3,
.player-list h3 {
    margin: 0 0 15px 4px;
    color: var(--text-light);
    font-size: 0.95rem;
}
.setting-selector:open{
    position: relative; /* Required for the pseudo-element */
}
.setting-selector h3 {
    margin:  0 0 0px 0;
    color: var(--text-light);
    font-size: 0.95rem;
    position: relative;
}
.setting-selector h4 {
    margin:  10px 0 3px 0;
    font-size: 0.90rem;
}
.setting-selector p {
    margin:  0;
}
.setting-selector:open h3 {
    margin:  0 0 20px 0;
}

.setting-selector:open::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: calc(1.2em + var(--padding-game-element) + 18px);
    height: 1px;
    background-color: var(--border-dark); /* Use your theme's border color */
}

.symbol-display {
    margin: 0;
    background-color: #242424;
    font-size: 5em;
    border-radius: 5px;
    border-color: var(--blood-red);
}

p {
    margin-block-start: 0.2em;
    margin-block-end: 0.5em;
}

#playerRoleDuringGame h3 {
    margin-block-start: 0.33em;
    margin-block-end: 0.33em
}
#playerRoleDuringGame p {
    margin-block-start: 0.33em;
    margin-block-end: 1em;
    text-align: left;
}

.vote-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: auto;
    margin: 0px 0.2em 0px 0.8em; /* Increased left margin */
    padding: 0.5em 0.8em;
    height: auto;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.7em;
    font-weight: 300;
    background-color: var(--blood-red);
    background-image: radial-gradient(100% 60% at 75% 5%, #ff95957c 0, #570d0d47 100%);
    box-shadow: 0px #432c2c;
    color: rgb(197, 193, 193);
    touch-action: manipulation;
}

.vote-button:disabled {
    display: none;
}

.vote-indicators { 
    display: flex;
    flex-direction: row-reverse;
    margin-left: auto;
    gap: 2px;
    align-items: flex-end;
    flex-wrap: wrap;
    max-height: 2em;
    font-size: clamp(0.3em , 1em, 1.8em);
}


#playerListContent {
    display: flex;
    flex-direction: column;
    background: var(--darker-bg);
    border: 1px solid var(--inner-border-dark);
    padding: 6px;
    border-radius: 5px;
    gap: 5px;
    height: auto;
    position: relative; 
    width: 100%; 
    --itemCount: 1; /* Default value */
    
    /* Font size calculation:
       - Limited by height (many players) or width (small screens)
       - Target height (90vh) divided by number of items
       - Divided by the height of each item in rem (2.0)
       - Width in view width 5vw
       - Clamped between 0.85em and 1.3em
     */
    font-size: clamp(0.85rem, min(calc(90vh / var(--itemCount) / 2.5), 5vw), 1.25rem);
}


.player-item {
    display: flex;
    position: relative;
    align-items: center;
    padding: 0.1em 0.2em;
    margin: 0;
    height: 2.0em;
    font-size: 0.82em;
    background: var(--black-bg);
    border-radius: 5px;
    transition: 
        opacity 3s ease-in, 
        color 3s ease-in, 
        border-top 2s ease-in, 
        border 1s ease-in, 
        box-shadow 2.0s ease-in;
    color: var(--text-light);
}

.player-item.joined {
    background: rgba(139, 0, 0, 0.2);
    border-left: 4px solid var(--blood-red);
}

.player-item.dead {
    opacity: 0.45;
    color: #666;
    pointer-events: none;
    position: relative;
}

.player-item.dead::after {
    content: "";
    position: absolute;
    width: 97%;
    top: 53%;
    left: 50%;
    border-top: 1px solid #666666a5;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.player-item.winner {
    border: 2px solid gold;
    box-shadow: 0 0px 4px rgba(248, 211, 0, 0.884);
}

.vote-status {
    margin-top: 15px;
    padding: 10px;
    background: var(--darker-bg);
    border: 1px solid var(--inner-border-dark);
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    color: var(--text-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-size: clamp(0.8em, 1em, 1.2em);
}

.player-name {
    font-weight: bold;
    color: var(--text-lighter);
    /* margin to the right */
    margin: 0 5px 0 5px;
}

/* Button containers */

.leader-candidates,
.victims-list,
.witch-kill-action,
.witch-save-action,
.day-vote-candidates,
#successorCandidates {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* Special case for the show role button in header */

.show-role-btn {
    width: auto;
    padding: 10px 10px;
    margin: 0;
    background: var(--blood-red);
    background-image: radial-gradient(100% 60% at 75% 5%, #ff95957c 0, #570d0d47 100%);
    box-shadow: 0 3px 3cap #432c2c;
    border-radius: 5px;
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
}

.show-role-btn:hover {
    background: var(--blood-red-hover);
}

.show-role-area {
    margin: 0;
    height: min(min(25vw, calc(var(--max-width-body) / 4)), 10vh);
    width: min(min(25vw, calc(var(--max-width-body) / 4)), 10vh);
    display: flex;
    position: relative;
    flex-direction: column;
    align-items: center;
    font-size: min(min(25vw, calc(var(--max-width-body) / 4)), 10vh);
    justify-content: center;
}
.show-role-area p {
    position: relative;
    z-index: 10;
    margin: 0;
    font-size: 0.08em;
}

.popup-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 40px;
    height: 40px;
    padding: 0px 0px 0.6px 2px;
    margin: 0px 0px;
    background-color: #000;
    background-image: #000;
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    line-height: 0;
    font-weight: 300;
    font-family: Arial, sans-serif;
}

.popup-close:hover {
    background-color: var(--blood-red);
}


/* Add popup styling for showPlayerRoleDuringGame */

.popup-text-screen {
    position: fixed;
    top: 45%;
    left: 50%;
    background: var(--darker-bg);
    border-radius: 8px;
    transform: translate(-50%, -50%);
    z-index: 1000;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-in-out;
    border: 2px solid var(--blood-red);
    text-align: center;
    padding: 20px 15px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}


/* Optional: Add an overlay behind the popup */

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: none;
}

.status-update {
    animation: fadeInOut 3s ease-in-out;
    transition: all 0.3s ease-in-out;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0.8;
    }
}


.vote-timer {
    font-size: 1.5em;
    font-weight: bold;
    padding: 10px;
    margin: 10px 0;
    border-radius: 5px;
    text-align: center;
    transition: all 0.3s ease;
}

.vote-timer.normal {
    color: #2ecc71;
    background-color: rgba(46, 204, 113, 0.1);
    border: 2px solid #2ecc71;
}

.vote-timer.warning {
    color: #f1c40f;
    background-color: rgba(241, 196, 15, 0.1);
    border: 2px solid #f1c40f;
    animation: pulse 1s infinite;
}

.vote-timer.critical {
    color: var(--blood-red);
    background-color: rgba(139, 0, 0, 0.2);
    border: 2px solid var(--blood-red);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.setting-selector {
    margin: 10px 10px;
    padding: var(--padding-game-element, 15px);
    background-color: var(--bg-gray);
    border-radius: 8px;
    border: 1px solid var(--border-dark);
    cursor: pointer;
}

.setting-selector.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.setting-selector .form-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-selector label {
    display: flex;
    align-items: left;
    width: 50%;
    gap: 10px;
    font-size: 1em;
    color: var(--text-light);
}
.setting-selector select {
    width: 50%;
    padding: 8px;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    background-color: #242424;
    cursor: pointer;
    margin-top: 5px;
    color: var(--text-light);
}

.setting-selector input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-left: 10px;
    accent-color: var(--blood-red);
}

.join-game-section {
    margin: 0 auto;
    margin-top: 15px;
    padding: 20px;
}

.form-group {
    width: 100%;
    margin: 6px 0px;
}

.leave-game-btn {
    margin: 20px 0;
}

.leave-game-btn .btn {
    background-color: transparent;
    border: 1px solid var(--border-dark);
    color: var(--text-light);
    opacity: 0.8;
    transition: all 0.3s ease;
}

.leave-game-btn .btn:hover {
    background-color: rgba(139, 0, 0, 0.2);
    border-color: var(--blood-red);
    opacity: 1;
}


/* Color picker styles */

.color-picker-section {
    margin: 15px 0;
    display: none;
    /* Will be shown when in lobby */
}

.color-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

#signPicker {
    margin-bottom: 15px;
}

.sign-color-display {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    margin-top: 10px;
}
.color-sign-display-container {
    justify-content: center;
    padding: 10px 5px 5px 5px;
    background: var(--darker-bg);
    border: 1px solid var(--inner-border-dark);
    border-radius: 5px;
    margin: 5px; 
}


.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.681);
    touch-action: manipulation;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px #000;
}

.color-option.disabled {
    background: repeating-linear-gradient( 45deg, #393939aa, #393939aa 2.5px, #f0f0f032 2.5px, #f0f0f032 5px);
    opacity: 0.6;
    box-shadow: #121212 0 0 0 3px;
    transform: scale(0.9);
    cursor: not-allowed;
    pointer-events: none;
}

.player-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 5px;
    user-select: none;
}

.sign-option {
    background-color: var(--text-lighter);
    color: transparent;
    font-size: 1.43em;
    height: 30px;
    width: 30px;
    border-radius: 15%;
    margin: 0px;
    padding-bottom: 3px;
    background-clip: text;
    -webkit-background-clip: text;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.681);
    user-select: none;
    touch-action: manipulation;
}

.sign-option:hover {
transform: scale(1.1);
}

.sign-option.selected {
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px #000;
}

.player-sign {
    font-size: 1.0em;
    background-color: var(--text-lighter);
    color: transparent;
    background-clip: text;
    user-select: none;
}

.sign-option.disabled {
    background-image: repeating-linear-gradient( 45deg, #393939aa, #393939aa 2.5px, #f0f0f032 2.5px, #f0f0f032 5px);
    box-shadow: #121212 0 0 0 3px;
    transform: scale(0.9);
    cursor: not-allowed;
    pointer-events: none;
}

.sign-display {
    background-color: var(--black-bg);
    width: 60px;
    height: 60px;
    border-radius: 25%;
    position: relative;
}

.player-sign-big {
    font-size: 2.0em;
    background-color: white;
    color: transparent;
    background-clip: text;
    position: absolute;
    top: 48%;
    left: 51%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.game-controls{
    margin: 5px 10px;

}

/* Session code display */

/* .session-code-display {
    margin-top: auto;
    text-align: center;
    padding-top: 5px;
    border-top: 1px solid #ccc;
} */

.session-code-display p {
    margin: 0;
    font-size: 1.2em;
    color: var(--text-light);
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.9em;
    width: 50%;
    margin: 5px auto;
    background-color: rgba(85, 85, 85, 0.2);
    background-image: none;
    border: 1px solid var(--border-dark);
    color: var(--text-de-emph);
    box-shadow: none;
    opacity: 1.0;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background-color: rgba(131, 131, 131, 0.2);
    border-color: var(--blood-red);
    opacity: 1;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

.active-sessions {
    margin-top: 2rem;
    width: 100%;
    max-width: 600px;
}

.active-sessions h2 {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.session-item {
    background-color: var(--darker-bg);
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-dark);
}

.session-item span {
    color: var(--text-light);
}

.session-item button {
    padding: 5px 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.setting-group-container {
    padding-top: 10px;
}

.session-stats {
    background-color: var(--bg-gray);
    padding: 20px;
    border-radius: 5px;
    margin: 20px 10px;
    border: 1px solid var(--border-dark);
}
.join-section {
    margin: 20px 10px;
}
.join-section h2 {
    margin-top: 0;
}

.session-stats h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-light);
}

#sessionStats {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
}

#sessionStats span {
    font-size: 1.4em;
    color: var(--text-light);
    margin: 0;
    text-align: center;
    flex: 1;
    min-width: 200px;
}

#sessionStats .session-stats-highlight {
    font-size: 1.4em;
    font-weight: bold;
    color: #4CAF50;
    padding-left: 10px;
}

.beta-banner {
    background-color: #ff9800;
    color: #000;
    text-align: center;
    padding: 10px;
    font-weight: bold;
    width: min(100vw, 800px);
    position: relative;
    top: var(--padding-body);
    left: 0;
    transform: translateX(calc(0px - var(--padding-body)));
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.server-down {
    background-color: var(--blood-red);
    color: var(--text-light);
    text-align: center;
    padding: 10px;
    font-weight: bold;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Language Selector Styles */
.language-selector {
    position: absolute;
    top: 5px;
    right: 5px;
    margin-right: 0px;
}

.language-dropdown {
    color: var(--text-light);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.8em;
    padding-right: 15px;
    background-color: var(--darker-bg);
    border-radius: 8px;
    border: 1px solid var(--border-dark);
}
.language-dropdown select {
    padding: 8px;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    background-color: #242424;
    margin-top: 5px;
}

/* .language-dropdown:hover {
    background-color: #555;
}

.language-dropdown:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(106, 90, 205, 0.5);
} */

/* Remove old button styles */
.lang-btn {
    display: none;
}
.session-code-display {
    margin-top: auto;
    padding-top: 5px;
    border-top: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    padding-bottom: 10px;
}

.reload-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    box-sizing: content-box;
    font-size: larger;
    color: var(--text-light);
    background: var(--darker-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}


.role-coin {
    width: 1.4em;
    height: 1.4em;
    position: relative;
    perspective: 1000px;
    border-radius: 50%;
    font-size: 0.6em;
    transform-style: preserve-3d;
    transform-origin: center center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.animate-land {
    animation: land 0.6s cubic-bezier(0.5, 1.5, 0.5, 1) forwards;
}

@keyframes land {
    0% {
        transform: translate(-5px, 10px) rotateX(80deg)rotateY(80deg);
        opacity: 0;
    }
    60% {
        transform: translate(1px, -2px) rotateX(30deg)rotateY(30deg);
        opacity: 1;
    }
    70% {
        transform: translate(-1px, 1px) rotateX(0deg)rotateY(0deg);
    }
    80% {
        transform: translate(0px, 0px) rotateX(0deg)rotateY(0deg);
    }
    90% {
        transform: translate(0px, 1px) rotateX(0deg) rotateY(0deg);
    }
    100% {
        transform: translate(0px, 0px) rotateX(0deg) rotateY(0deg);
    }
}
.role-coin:hover{
    filter: brightness(1.1);
}
.coin-hold {
    font-size: min(min(25vw, calc(var(--max-width-body) / 4)), 10vh);
}
.coin {
    width: 1.4em;;
    height:  1.4em;;
    position: relative;
    perspective: 1000px;
    border-radius: 50%;
    font-size: 0.6em;
    transform-style: preserve-3d;
    transform-origin: center center;
    z-index: 11;
    animation: spin 0.4s linear 6 2.1s,
    half_spin 2s linear(0, 0.35 5%, 0.75 90%, 0.875 97%, 1) 4.5s,
    throw 6.5s linear,
    flyToTarget 0.5s ease-in 6.5s forwards;
    margin: 20px auto;
   
}

@keyframes spin {
    0% { 
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}
@keyframes half_spin {
    0% { 
        transform: rotateY(90deg);
    }
    100% {
        transform: rotateY(255deg);
    }
}
@keyframes flyToTarget {
    0% {
        transform: translate(0, 0) rotateY(-105deg) scale(4.2);
    }
    100% {
        transform: translate(var(--target-x), var(--target-y)) rotateY(270deg) scale(1);
    }
}


@keyframes throw {
    0% {
        scale: 1
    }
    56% {
        scale: 1.05
    }
    63% {
        scale: 1.1
    }
    65% {
        scale: 2;
    }
    70% {
        scale: 4.3;
    }
    80% {
        scale: 4.3;
    }
    100% {
        scale: 4.2;
    }
}

@keyframes blink {
    48% { filter: brightness(1.45); } 
    0%, 25%, 67%, 100% { filter: brightness(1); } 
}

.side {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    font-size: 0.35em;
    background-image: linear-gradient(45deg, var(--coin-dark) 0%,  var(--coin-light) 100%);
    box-shadow: inset var(--coin-shadow) 0em 0em 0em 0.07em;;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--coin-dark);
}

/* Add a middle layer to fill the gap */
.middle-layer {
    position: absolute;
    top: 0%;
    left: 50%;
    width: 4px;
    height: 100%;
    border-radius: 0%;
    background-image: linear-gradient(var(--coin-bright), var(--coin-dark));
    transform: rotateY(90deg) ;
    z-index: 5;
}

.head {
    transform: translateZ(2px);
    z-index: 2;
}
.head::after {
    transform: translateZ(1.5px);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 0;
    background-image: linear-gradient(var(--coin-bright), var(--coin-dark));
}

.tail {
    transform: translateZ(-2px) rotateY(180deg);
    animation: blink 2s linear(0, 0.35 5%, 0.75 90%, 0.875 97%, 1) 4.5s;
    z-index: 1;
}
.tail::after {
    transform: translateZ(-1.5px);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 0;
    background-image: linear-gradient(var(--coin-bright), var(--coin-dark));
}

.inset{
    width: 80%;
    height: 80%;
    border-radius: 50%;
    position: relative;
    user-select: none;
    
    /* border: 0.1em solid var(--coin-bright); */
/* #f3b121cf 0.0em 0.0em 0.3em 0.6em,
                #fdca13cf 0.0em 0.0em 0.1em 0.3em, */
                
    box-shadow: var(--coin-shadow-t) 0.0em 0.0em 0.3em 0.05em,
    /* #fff27e97 -0.1em 0.1em 0.3em 0.01em, */
    /* inset var(--coin-shadow) -0.02em 0.05em 0.06em 0.09em, */
    /* inset var(--coin-shadow) -0.02em 0.05em 0.06em 0.09em, */
    inset var(--coin-shadow) -0.0em 0.0em 0.0em 0.05em,
        inset #5b310052 -0.05em 0.05em 0.0em 0.005em;
    /* background-image: radial-gradient(circle at 80% 5%, #fff27e 0, #f3e249 60%, var(--coin-bright) 100%);  */
    background-image: linear-gradient(45deg, var(--coin-base) 0, var(--coin-light) 100%); 
    /* background-color: var(--coin-bright); */
}

.inset .coin-symbol {
    color: transparent;
    background-image: radial-gradient(circle at 75% 25%, var(--coin-light) 0,  var(--coin-dark) 40%, var(--coin-dark) 100%);
    background-clip: text;
    position: absolute;
    top: 0%;
    left: 0%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    z-index: 1;
}
.head .inset .coin-symbol {
    font-size: 1.5em;
}
.tail .inset .coin-symbol {
    font-size: 1.5em;
}
.role .inset .coin-symbol {
    font-size: 2.8em;
}
.inset::after {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-shadow:  var(--coin-shadow) -0.00em 0.00em 0.2em,
    var(--coin-shadow) -0.02em 0.02em 0.0em;
    color: transparent;
    text-align: center;
    transform: translate(-50%, -50%);
}
.head .inset::after {
    content: "🧍";
    font-size: 1.5em;
}
.tail .inset::after {
    content: var(--tail-symbol);
    font-size: 1.5em;
}
.role .inset::after {
    content: "?";
    font-size: 3.0em;
}

/* =========================================
   Role Card Settings - Drag & Drop System
   ========================================= */

.special-role-settings {
    margin-top: 15px;
}

/* Role Count Selector */
.role-count-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--darker-bg);
    border-radius: 8px;
}

.role-count-selector > span {
    font-size: 0.9em;
    color: var(--text-light);
}

.role-count-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.role-count-buttons + .role-count-buttons {
    margin-top: -3px;
}

.role-count-btn {
    flex: 1;
    min-width: 60px;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.85em;
    background: var(--bg-gray);
    border: 1px solid var(--border-dark);
    color: var(--text-light);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
}

.role-count-btn:hover {
    background: var(--border-dark);
}

.role-count-btn.active {
    background: var(--blood-red);
    border-color: var(--blood-red);
    color: var(--text-lighter);
}

/* Role Zones Container */
.role-zones-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.role-zone-section h4 {
    margin: 0 0 8px 0;
    font-size: 0.95em;
    color: var(--text-light);
}

/* Active Roles Drop Zone */
.role-drop-zone {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 90px;
    padding: 12px;
    background: var(--darker-bg);
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
}

.role-drop-zone.drag-over {
    border-color: var(--blood-red);
    background: rgba(169, 36, 8, 0.1);
}

.drop-zone-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-de-emph);
    font-size: 0.85em;
    text-align: center;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.role-drop-zone:has(.role-card) .drop-zone-placeholder {
    opacity: 0;
}

/* Available Roles Grid */
.role-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    background: var(--darker-bg);
    border-radius: 8px;
    min-height: 80px;
}

/* Role Card */
.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 85px;
    padding: 8px 5px;
    background: var(--bg-gray);
    border: 2px solid var(--border-dark);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
}

.role-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 5;
}

.role-card:active {
    transform: scale(0.98);
}

.role-card.active {
    border-color: var(--blood-red);
    box-shadow: 0 0 10px rgba(169, 36, 8, 0.5), 0 0 20px rgba(169, 36, 8, 0.3);
}

.role-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.role-card.locked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(0, 0, 0, 0.3) 4px,
        rgba(0, 0, 0, 0.3) 8px
    );
    border-radius: 6px;
    pointer-events: none;
}

.role-card.dragging {
    opacity: 0.7;
    transform: scale(1.1) rotate(3deg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.role-card-symbol {
    font-size: 1.8em;
    line-height: 1;
    margin-bottom: 4px;
}

.role-card-name {
    font-size: 0.65em;
    color: var(--text-light);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Role Card Tooltip */
.role-card-tooltip {
    position: fixed;
    max-width: 250px;
    padding: 10px 12px;
    background: var(--darker-bg);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.role-card-tooltip.visible {
    opacity: 1;
}

.role-card-tooltip h5 {
    margin: 0 0 5px 0;
    font-size: 0.95em;
    color: var(--text-lighter);
}

.role-card-tooltip p {
    margin: 0;
    font-size: 0.8em;
    color: var(--text-light);
    line-height: 1.4;
}

/* Card Animation */
@keyframes cardFlyIn {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes cardFlyOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

.role-card.fly-in {
    animation: cardFlyIn 0.3s ease-out forwards;
}

.role-card.fly-out {
    animation: cardFlyOut 0.2s ease-in forwards;
}

/* Touch/Mobile Ghost Element */
.role-card-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.9;
    transform: scale(1.1);
}

/* Disabled states for non-host players */
.role-drop-zone.disabled,
.role-grid.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.role-count-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================
   Setting Groups - Segmented Buttons & Toggle
   ========================================= */

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--darker-bg);
    border-radius: 8px;
}

.setting-group:has(.toggle-switch) {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.setting-group.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.setting-label {
    font-size: 0.9em;
    color: var(--text-light);
}

.setting-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.setting-btn {
    flex: 1;
    min-width: 40px;
    padding: 8px 12px;
    font-size: 0.85em;
    background: var(--bg-gray);
    border: 1px solid var(--border-dark);
    color: var(--text-light);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-image: none;
    box-shadow: none;
}

.setting-btn:hover {
    background: var(--border-dark);
    background-image: none;
}

.setting-btn.active {
    background: var(--blood-red);
    background-image: none;
    border-color: var(--blood-red);
    color: var(--text-lighter);
}

.setting-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: #cccccc !important;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex: 0 0 52px;
    max-width: 52px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-dark);
    transition: all 0.3s ease;
    border-radius: 28px;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-light);
    transition: all 0.3s ease;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--blood-red);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Role container width snapping - centering */
.role-drop-zone,
.role-grid {
    margin: 0 auto;
}

/* =========================================
   Role Description Cards
   ========================================= */

.role-desc-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (max-width: 500px) {
    .role-desc-grid {
        grid-template-columns: 1fr;
    }
}

.role-desc-card {
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 10px;
    background: var(--darker-bg);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    border-left: 3px solid var(--border-dark);
}

.role-desc-card.role-active {
    opacity: 1;
    border-left-color: var(--blood-red);
}

.role-desc-card.role-inactive {
    opacity: 0.5;
}

.role-desc-symbol {
    font-size: 2em;
    line-height: 1;
    flex-shrink: 0;
    width: 1.4em;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}

.role-desc-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.role-desc-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.role-desc-name {
    font-weight: bold;
    font-size: 0.95em;
    color: var(--text-lighter);
}

.role-tier-badge {
    font-size: 0.65em;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.role-tier-badge.premium {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
    border: 1px solid rgba(212, 175, 55, 0.4);
}

.role-tier-badge.recommender {
    background: rgba(180, 80, 200, 0.2);
    color: #c77ddb;
    border: 1px solid rgba(180, 80, 200, 0.4);
}

.role-desc-text {
    font-size: 0.78em;
    color: var(--text-light);
    line-height: 1.4;
    margin: 0;
}

.role-desc-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active {
    background-color: #2ecc71;
}

.status-dot.always {
    background-color: #5b9bd5;
}

.status-dot.inactive {
    background-color: #666;
}

.status-dot.dependency {
    background-color: #d4af37;
}

/* ===================== Disconnect overlay ===================== */
.disconnect-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.disconnect-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-lighter);
    font-size: 1.1em;
    text-align: center;
    padding: 0 20px;
}

.disconnect-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: var(--blood-red);
    border-radius: 50%;
    animation: disconnectSpin 0.8s linear infinite;
}

@keyframes disconnectSpin {
    to { transform: rotate(360deg); }
}

/* ===================== Night wait screen ===================== */
#nightWaitScreen {
    text-align: center;
    padding: 40px 20px;
}

.night-wait-moon {
    font-size: 4em;
    display: block;
    animation: moonFloat 3s ease-in-out infinite;
}

@keyframes moonFloat {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

.night-wait-text {
    font-size: 1.2em;
    color: var(--text-light);
    margin: 16px 0 12px;
}

.night-wait-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.night-wait-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--blood-red);
    opacity: 0.3;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.night-wait-dots span:nth-child(2) { animation-delay: 0.2s; }
.night-wait-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* ===================== Horizon Strip ===================== */
.horizon-strip {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 28px;
    position: relative;
    overflow: hidden;
    clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 10px 100%);
    background: linear-gradient(90deg, #0c0c0c 0%, #111 50%, #0c0c0c 100%);
    border-top: 1px solid rgba(255,255,255,0.06);
    transition: background 0.6s ease, border-top-color 0.5s ease;
}


.horizon-strip-icon {
    display: none;
}

.horizon-strip-text {
    flex: 1;
    font-size: 0.76rem;
    font-style: italic;
    color: #505050;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.5s;
}

/* Night */
body[data-phase="night"] .horizon-strip {
    background: linear-gradient(90deg, #080e1e 0%, #060b18 10%, #030710 45%, #020509 100%);
    border-top-color: rgba(60,90,200,0.40);
}
body[data-phase="night"] .horizon-strip-text { color: #5e6ea0; }

/* Day (also covers voting — same strip style) */
body[data-phase="day"] .horizon-strip {
    background: linear-gradient(90deg, #271500 0%, #231200 10%, #160900 45%, #100700 100%);
    border-top-color: rgba(210,120,15,0.45);
}
body[data-phase="day"] .horizon-strip-text { color: #8a5825; }

/* Neutral (lobby / voting / etc.) */
body:not([data-phase="day"]):not([data-phase="night"]) .horizon-strip {
    border-top-color: var(--blood-red-click);
}
body:not([data-phase="day"]):not([data-phase="night"]) .horizon-strip-text { color: #b8452f; }

/* Bar Drain (C4) */
.horizon-bar-wrap {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    overflow: hidden;
}
.horizon-bar {
    height: 2px;
    width: 0%;
    background: rgba(70,110,220,0.6);
    transition: none;
}
body[data-phase="day"] .horizon-bar {
    background: rgba(190,100,20,0.6);
}
body:not([data-phase="day"]):not([data-phase="night"]) .horizon-bar {
    background: #b8462f9e;
}

/* ===================== Player join animation ===================== */
@keyframes playerJoinAnim {
    0% {
        transform: translateX(-20px);
        opacity: 0;
        box-shadow: -4px 0 20px var(--player-color, transparent);
    }
    40% {
        transform: translateX(3px);
        opacity: 1;
        box-shadow: -2px 0 12px var(--player-color, transparent);
    }
    60% { box-shadow: 0 0 8px var(--player-color, transparent); }
    100% {
        transform: translateX(0);
        opacity: 1;
        box-shadow: none;
    }
}

.player-join-anim {
    animation: playerJoinAnim 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ===================== Vote tally bar ===================== */
.vote-tally-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--blood-red), #ff4422);
    width: 0%;
    opacity: 0;
    transition: width 0.6s ease, opacity 0.3s ease;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 6px rgba(169, 36, 8, 0.7);
    pointer-events: none;
}

/* ===================== Death screen drama ===================== */
.death-overlay-anim {
    animation: deathOverlayIn 0.8s ease-out forwards;
}

@keyframes deathOverlayIn {
    from { opacity: 0; background-color: rgba(0,0,0,0); }
    to { opacity: 1; background-color: rgba(0,0,0,0.92); }
}

#showDeathScreen.death-entrance {
    animation: deathEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes deathEntrance {
    from { transform: translate(-50%, -60%) scale(0.6); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ===================== Circular vote timer ===================== */
.vote-timer-ring {
    position: relative;
    width: 100px;
    margin: 0 auto 8px;
}

.timer-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.4em;
    font-weight: bold;
    color: var(--text-lighter);
    pointer-events: none;
}

/* ===================== Game-over screen for non-hosts ===================== */
#gameOverScreen .host-only {
    display: none;
}

body.is-host #gameOverScreen .host-only {
    display: inline-block;
}

.status-label {
    font-size: 0.7em;
    color: var(--text-de-emph);
}

/* ===================== Header Phase Indicator ===================== */

/* --- Atmospheric horizon glow (::before on .header, day only) --- */
body[data-phase="day"] .header::before {
    content: '';
    position: absolute;
    bottom: 28px; left: 0; right: 0;
    height: 80px;
    background: linear-gradient(to top, rgba(255,140,0,0.16) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

/* --- Gradient border glow (::after on .header) --- */
.header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 2px;
    pointer-events: none;
    background: transparent;
    box-shadow: none;
    opacity: 0;
    transition: background 6.5s ease, box-shadow 6.5s ease, opacity 6.5s ease;
}
.header:has(> .horizon-strip[style*="flex"])::after {
    bottom: 28px;
}
body[data-phase="night"] .header::after {
    background: linear-gradient(90deg, transparent 0%, #6c5ce7 20%, #2c3e8a 35%, rgba(44,62,138,0.3) 65%, transparent 100%);
    box-shadow: 0 3px 10px rgba(108,92,231,0.45), 0 1px 4px rgba(44,62,138,0.5);
    animation: headerGlowPulse 8s ease-in-out infinite;
}
body[data-phase="day"] .header::after {
    background: linear-gradient(90deg, transparent 0%, #f4d03f 20%, #c9760c 35%, rgba(180,90,10,0.3) 65%, transparent 100%);
    box-shadow: 0 3px 10px rgba(244,208,63,0.4), 0 1px 4px rgba(201,118,12,0.5);
    animation: headerGlowPulse 8s ease-in-out infinite;
}
body:not([data-phase="day"]):not([data-phase="night"]) .header::after {
    background: linear-gradient(90deg, transparent 0%, var(--blood-red-click) 20%, var(--blood-red) 35%, rgba(90,15,15,0.3) 65%, transparent 100%);
    box-shadow: 0 2px 8px var(--blood-red-click), 0 1px 3px var(--blood-red);
    opacity: 0.55;
    transition: background 6.5s ease, box-shadow 6.5s ease, opacity 6.5s ease;
}
@keyframes headerGlowPulse {
    0%, 100% { opacity: 0.3; }
    50%       { opacity: 1.0; }
}

/* --- Floating particles --- */
.header-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 10px 10px 0 0;
    z-index: 0;
}
.hp {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    width: 2px; height: 2px;
    background: rgba(200, 200, 255, 0.5);
}
body[data-phase="night"] .hp {
    background: rgba(220, 230, 255, 0.95);
    animation: hpTwinkle var(--hp-dur, 7s) ease-in-out var(--hp-delay, 0s) infinite;
}

.hp:nth-child(1)  { left:  5%; bottom: 40%; --hp-dur: 7.2s; --hp-delay: 0.0s; --hp-peak: 0.70; width: 1px; height: 1px; }
.hp:nth-child(2)  { left: 13%; bottom: 72%; --hp-dur: 9.5s; --hp-delay: 2.3s; --hp-peak: 0.50; width: 1px; height: 1px; }
.hp:nth-child(3)  { left: 21%; bottom: 38%; --hp-dur: 6.8s; --hp-delay: 4.1s; --hp-peak: 0.60; width: 2px; height: 2px; }
.hp:nth-child(4)  { left: 31%; bottom: 65%; --hp-dur: 8.4s; --hp-delay: 1.0s; --hp-peak: 0.75; width: 2px; height: 2px; }
.hp:nth-child(5)  { left: 40%; bottom: 52%; --hp-dur: 7.9s; --hp-delay: 3.5s; --hp-peak: 0.45; width: 1px; height: 1px; }
.hp:nth-child(6)  { left: 49%; bottom: 78%; --hp-dur: 6.3s; --hp-delay: 5.8s; --hp-peak: 0.65; width: 1px; height: 1px; }
.hp:nth-child(7)  { left: 57%; bottom: 42%; --hp-dur: 8.1s; --hp-delay: 0.9s; --hp-peak: 0.55; width: 2px; height: 2px; }
.hp:nth-child(8)  { left: 65%; bottom: 68%; --hp-dur: 7.4s; --hp-delay: 2.7s; --hp-peak: 0.70; width: 1px; height: 1px; }
.hp:nth-child(9)  { left: 72%; bottom: 85%; --hp-dur: 9.1s; --hp-delay: 4.8s; --hp-peak: 0.60; width: 2px; height: 2px; }
.hp:nth-child(10) { left: 80%; bottom: 95%; --hp-dur: 6.6s; --hp-delay: 1.6s; --hp-peak: 0.80; width: 2px; height: 2px; }
.hp:nth-child(11) { left: 5%; bottom: 75%; --hp-dur: 8.8s; --hp-delay: 3.2s; --hp-peak: 0.50; width: 1px; height: 1px; }
.hp:nth-child(12) { left: 91%; bottom: 48%; --hp-dur: 7.0s; --hp-delay: 6.1s; --hp-peak: 0.65; width: 1px; height: 1px; }
.hp:nth-child(13) { left: 96%; bottom: 62%; --hp-dur: 9.8s; --hp-delay: 0.4s; --hp-peak: 0.55; width: 2px; height: 2px; }
.hp:nth-child(14) { left: 36%; bottom: 85%; --hp-dur: 7.6s; --hp-delay: 5.0s; --hp-peak: 0.45; width: 1px; height: 1px; }
@keyframes hpTwinkle {
    0%, 100% { opacity: 0; }
    40%, 60% { opacity: var(--hp-peak, 0.65); }
}

/* --- Celestial icon container --- */
.celestial-icon {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.celestial-sun,
.celestial-moon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, calc(-50% - 80px));
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
body[data-phase="day"] .celestial-sun {
    opacity: 1;
    transform: translate(-50%, -50%);
    transition: opacity 1.5s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
body[data-phase="night"] .celestial-moon {
    opacity: 1;
    transform: translate(-50%, -50%);
    transition: opacity 1.5s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* CSS Sun */
.celestial-sun {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffee66 0%, #ffcc00 55%, #ff9900 100%);
    box-shadow:
        0 0 0 3px rgba(255,190,40,0.20),
        0 0 16px 5px rgba(255,160,0,0.55),
        0 0 36px 12px rgba(255,100,0,0.22);
    animation: sunGlowPulse 3s ease-in-out infinite;
}
.celestial-sun::before {
    content: '';
    position: absolute;
    inset: -60px;
    background: conic-gradient(
        transparent 0deg,
        transparent 39.8deg, rgba(255,190,0,0.35) 42.8deg, transparent 45.8deg,
        transparent 91.2deg, rgba(255,190,0,0.35) 94.2deg, transparent 97.2deg,
        transparent 142.7deg, rgba(255,190,0,0.35) 145.7deg, transparent 148.7deg,
        transparent 194.1deg, rgba(255,190,0,0.35) 197.1deg, transparent 200.1deg,
        transparent 245.5deg, rgba(255,190,0,0.35) 248.5deg, transparent 251.5deg,
        transparent 297.0deg, rgba(255,190,0,0.35) 300.0deg, transparent 303.0deg,
        transparent 348.4deg, rgba(255,190,0,0.35) 351.4deg, transparent 354.4deg
    );
    mask: radial-gradient(circle, transparent 20%, white 25%, transparent 68%);
    -webkit-mask: radial-gradient(circle, transparent 20%, white 25%, transparent 68%);
    pointer-events: none;
}
.celestial-sun::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 64px; height: 64px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(244,208,63,0.14) 0%, transparent 70%);
    pointer-events: none;
}
@keyframes sunGlowPulse {
    0%, 100% {
        box-shadow:
            0 0 0 3px rgba(255,190,40,0.15),
            0 0 10px 3px rgba(255,160,0,0.40),
            0 0 24px 8px rgba(255,100,0,0.15);
    }
    50% {
        box-shadow:
            0 0 0 5px rgba(255,190,40,0.28),
            0 0 22px 8px rgba(255,160,0,0.65),
            0 0 44px 14px rgba(255,100,0,0.28);
    }
}

/* CSS Crescent Moon */
.celestial-moon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: transparent;
    box-shadow: inset -16px -6px 0 0 rgba(200, 225, 255, 0.95);
    filter: drop-shadow(0 0 8px rgba(100, 150, 255, 0.70));
}
.celestial-moon::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 66px; height: 66px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(100,150,255,0.10) 0%, transparent 70%);
    pointer-events: none;
}