:root {
    --bg-dark: #0a0a0c;
    --panel-bg: rgba(20, 20, 25, 0.7);
    --accent-primary: #00f2ff;
    --accent-secondary: #7000ff;
    --danger: #ff0055;
    --text-main: #e0e0e5;
    --text-dim: #80808a;
    --border-glass: rgba(255, 255, 255, 0.1);
}

/* --- THEMES --- */
body.theme-killword {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --accent-color: #ef4444;
    /* Red for killword */
    --glass-bg: rgba(15, 23, 42, 0.85);
    --glass-border: rgba(239, 68, 68, 0.3);
    font-family: 'Roboto Mono', monospace;
}


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

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    overflow-y: auto;
    height: 100vh;
    width: 100vw;
}

h1,
h2,
.glitch {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 2px;
    max-width: 90vw;
    word-wrap: break-word;
}

.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen {
    display: none;
    width: 100%;
    max-width: 500px;
    padding: 20px;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding-bottom: 60px;
    /* Space for footer */
    animation: fadeIn 0.5s ease-out;
}

.screen.active {
    display: flex;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    width: 100%;
}

.glass-panel.mini {
    padding: 15px;
    text-align: center;
}

.centered {
    text-align: center;
}

.glitch {
    font-size: 3.5rem;
    font-weight: bold;
    text-align: center;
    color: var(--text-main);
    position: relative;
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
        -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
        0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    animation: glitch 500ms infinite;
}

@keyframes glitch {
    0% {
        transform: translate(0);
    }

    20% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(-2px, -2px);
    }

    60% {
        transform: translate(2px, 2px);
    }

    80% {
        transform: translate(2px, -2px);
    }

    100% {
        transform: translate(0);
    }
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 30px;
    text-transform: uppercase;
}

.how-to-play {
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 25px;
    line-height: 1.5;
    border-left: 4px solid var(--accent-primary);
    text-align: left;
    width: 100%;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 12px 15px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.button-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    font-size: 0.85rem;
    min-width: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 5px auto;
}

.btn.primary {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn.primary:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 20px var(--accent-primary);
    transform: translateY(-1px);
}

.btn.secondary {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}

.btn.danger {
    background: transparent;
    border: 1px dashed var(--danger);
    color: var(--danger);
    opacity: 0.7;
}

.btn.danger:hover {
    opacity: 1;
    background: rgba(255, 0, 85, 0.1);
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
}

.btn.small {
    padding: 8px 15px;
    font-size: 0.7rem;
    min-width: 140px;
    /* Reduced-width for small buttons */
    margin: 5px 0;
}

.sharing-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    gap: 15px;
}

.qr-section,
.link-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sharing-divider {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    color: var(--text-dim);
    opacity: 0.5;
}

.host-action-center {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

.qr-code {
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    width: 150px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.qr-code img {
    max-width: 100%;
    height: auto;
}

.mini-text {
    font-size: 0.7rem;
    letter-spacing: 1px;
}

.mini-text.dim {
    color: var(--text-dim);
    margin-bottom: 5px;
}

/* Tab Bar */
.tab-bar {
    display: flex;
    margin-bottom: 20px;
    gap: 10px;
    width: 100%;
    /* Force full width */
}

.tab-btn {
    flex: 1;
    padding: 12px 5px;
    /* Added vertical padding, reduced horizontal */
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.tab-pane {
    display: none;
    width: 100%;
    min-width: 320px;
    /* Prevent collapse on narrow content */
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
    width: 100%;
}

/* Ensure tab content uses full width */
#tab-content {
    width: 100%;
    max-width: 500px;
}

.tab-pane>.glass-panel {
    width: 100%;
    box-sizing: border-box;
}

/* Lists */
.player-list-container {
    margin: 20px 0;
}

ul {
    list-style: none;
}

#lobby-player-list li {
    padding: 10px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--accent-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kick-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    font-family: Arial, sans-serif;
    opacity: 0.6;
    transition: opacity 0.2s;
    line-height: 1;
}

.kick-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

.status-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid var(--border-glass);
}

.status-list .dead {
    text-decoration: line-through;
    color: var(--text-dim);
}

/* Mission Tab */
.target-display {
    text-align: center;
    margin-bottom: 30px;
}

.label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

#target-name {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--accent-primary);
}

.word-grid {
    margin-top: 20px;
}

#kill-words li {
    background: rgba(255, 255, 255, 0.05);
    margin: 5px 0;
    padding: 8px;
    border-radius: 4px;
    font-weight: bold;
}

.action-panel,
[id*="host-reset-control"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

/* Privacy Gate */
#privacy-gate {
    background: var(--bg-dark);
}

.alert-text {
    color: var(--danger);
    margin-bottom: 15px;
}

/* Permanent Graveyard */
.terminal {
    border-left: 5px solid var(--danger);
}

.deceased-text {
    font-size: 4rem;
    color: var(--danger);
}

/* Utilities */
.hidden {
    display: none !important;
}

.blink {
    animation: blink 1s infinite alternate;
}

@keyframes blink {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.3;
    }
}

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

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

.pulse {
    animation: pulse 2s infinite;
}

.app-footer {
    position: fixed;
    bottom: 12px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: inherit;
    pointer-events: none;
    opacity: 0.4;
    z-index: 100;
}

#winner-screen .glitch {
    color: var(--accent-secondary);
    text-shadow: 0 0 20px var(--accent-secondary);
}

.trophy-container {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-20px) scale(1.1);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 242, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0, 242, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 242, 255, 0);
    }
}

/* --- VERSION TAG --- */
.version-tag {
    /* Inherit footer styles, just add a separator */
    margin-left: 15px;
    padding-left: 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    opacity: 0.8;
}

.roster-name {
    font-weight: bold;
    font-size: 1.1em;
}

.roster-status {
    font-size: 0.8em;
    opacity: 0.7;
    letter-spacing: 1px;
}

/* --- INFO MODAL --- */
.help-trigger {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    /* Explicitly unset left positioning */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    /* Circle shape */
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.help-trigger:hover {
    background: var(--accent-color);
    color: #fff;
    transform: scale(1.1) rotate(15deg);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-color);
}

.glass-modal {
    background: transparent;
    border: none;
    padding: 0;
    margin: auto;
    /* Centering for dialog */
    inset: 0;
    /* Centering for dialog */
    max-width: 90vw;
    width: 600px;
    color: inherit;
    overflow: visible;
}

.glass-modal::backdrop {
    background: rgba(0, 0, 0, 0.85);
    /* Darker backdrop */
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--panel-bg, rgba(0, 0, 0, 0.9));
    color: var(--text-main, #fff);
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.2));
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

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

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

.modal-content h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--accent-color);
    font-family: var(--font-heading, inherit);
    letter-spacing: 2px;
}

.close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 2rem;
    cursor: pointer;
    line-height: 0.5;
    padding: 0;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

.modal-body {
    overflow-y: auto;
    text-align: left;
    padding-right: 10px;
}

/* Custom Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.modal-body h3 {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
    letter-spacing: 2px;
    font-family: var(--font-heading, inherit);
    margin-top: 2rem;
}



.story-text {
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    /* Slight box for story */
    border-left: 3px solid var(--accent-color);
    font-family: var(--font-body, inherit);
    border-radius: 0 4px 4px 0;
}

.instructions-text {
    font-size: 1rem;
    line-height: 1.7;
    font-family: var(--font-body, inherit);
}

.instructions-text strong {
    color: var(--accent-color);
}

.about-section {
    margin-top: 40px;
    text-align: center;
    opacity: 0.6;
}

.about-section hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

/* Force phone links to be white/inherit on iOS */
a[href^="tel"] {
    color: inherit;
    text-decoration: none;
}

/* --- INVITE MODE (Magic Link) --- */
/* When a user arrives via an invite link, simplify the choice */
.invite-mode #host-game {
    display: none !important;
}

.invite-mode #join-game {
    /* Promote Join button to primary style */
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: none;
    font-weight: bold;
}

.invite-mode #join-game:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 20px var(--accent-primary);
    transform: translateY(-1px);
}

/* Game description styling */
.game-description {
    font-style: normal !important;
    background: transparent !important;
}

/* Host Protocol section spacing */
#modal-host-protocol {
    margin-top: 1.5rem;
}