/* Cyberpunk Post-Apocalyptic Theme - Mango Sunset & Pink */

:root {
    --bg-dark: #0a0a0f;
    --bg-darker: #050508;
    --primary-pink: #ff2e97;
    --primary-mango: #ff9e44;
    --secondary-purple: #b537f2;
    --accent-cyan: #00f4ff;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-dim: #606060;
    --success: #00ff88;
    --warning: #ffaa00;
    --error: #ff3366;
    --border: rgba(255, 46, 151, 0.3);
    --shadow-pink: rgba(255, 46, 151, 0.4);
    --shadow-mango: rgba(255, 158, 68, 0.4);
}

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

html {
    height: 100%;
    height: -webkit-fill-available; /* iOS Safari: pin to small viewport, prevents address-bar resize reflow */
}

body {
    font-family: 'Courier New', 'Consolas', monospace;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100%;
    min-height: -webkit-fill-available; /* iOS Safari: match html anchor */
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    overscroll-behavior-y: none; /* prevent scroll chaining to browser chrome */
}

/* Background Effects */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255, 46, 151, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 158, 68, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
    will-change: transform; /* own compositing layer — repaints don't interrupt scroll */
}

.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top, rgba(255, 46, 151, 0.15), transparent 50%),
                radial-gradient(ellipse at bottom, rgba(255, 158, 68, 0.15), transparent 50%);
    pointer-events: none;
    z-index: 0;
    will-change: transform; /* own compositing layer — repaints don't interrupt scroll */
}

/* Screen Management */
.screen {
    position: relative;
    min-height: 100%;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    z-index: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* momentum scroll on iOS Safari */
}

.screen.active {
    display: flex;
}

/* Chat screen: no padding, no scroll — internal elements handle it */
#chat-screen {
    padding: 0;
    overflow: hidden;
    align-items: stretch;
    height: 100vh;
    min-height: 0;
}

/* Container */
.container {
    max-width: 600px;
    width: 100%;
    margin: auto;
}

/* Logo Section */
.logo-section {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeInDown 1s ease-out;
}

.logo-text {
    font-size: 4rem;
    font-weight: bold;
    letter-spacing: 10px;
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-mango));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px var(--shadow-pink);
    animation: pulse 3s ease-in-out infinite;
}

.logo-bracket {
    color: var(--accent-cyan);
    -webkit-text-fill-color: var(--accent-cyan);
}

.logo-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    letter-spacing: 5px;
    margin-top: 10px;
    text-transform: uppercase;
}

/* Logo images */
.logo-img {
    height: 52px;
    width: auto;
    display: block;
    margin: 0 auto;
    animation: pulse 3s ease-in-out infinite;
}

.logo-img-small {
    height: 28px;
    width: auto;
    display: block;
}

/* Avatar logo icon in chat messages */
.avatar-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-section-small {
    text-align: center;
    margin-bottom: 40px;
}

.logo-text-small {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 5px;
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-mango));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Content Box */
.content-box {
    background: rgba(10, 10, 15, 0.8);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 40px;
    box-shadow: 0 0 40px var(--shadow-pink),
                inset 0 0 30px rgba(255, 46, 151, 0.05);
    backdrop-filter: blur(10px);
    animation: fadeInUp 1s ease-out;
}

/* Glitch Text Effect */
.glitch-text {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-pink);
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-text::before {
    color: var(--accent-cyan);
    animation: glitch 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.glitch-text::after {
    color: var(--primary-mango);
    animation: glitch 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) reverse both infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

/* Description */
.description {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 30px;
}

.highlight {
    color: var(--primary-mango);
    font-weight: bold;
}

.warning {
    color: var(--warning);
    font-size: 0.9rem;
}

/* Form Styles */
.form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.input-group input,
.input-group textarea,
.input-group select {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border);
    border-radius: 5px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.input-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff2e97' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 45px;
}

.input-group select option {
    background: var(--bg-dark);
    color: var(--text-primary);
    padding: 10px;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-pink);
    box-shadow: 0 0 20px var(--shadow-pink);
}

/* Button Styles */
.btn {
    position: relative;
    padding: 15px 30px;
    border: 2px solid var(--primary-pink);
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-mango));
    color: var(--bg-dark);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    border-radius: 5px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn:hover {
    box-shadow: 0 0 30px var(--shadow-pink);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-text {
    position: relative;
    z-index: 1;
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn:hover .btn-glow {
    left: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-divider {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    letter-spacing: 2px;
    margin: 8px 0;
}

.google-signin-wrap {
    display: flex;
    justify-content: center;
    min-height: 44px;
}

.identity-from-google {
    margin-bottom: 24px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.identity-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.identity-name {
    font-size: 1.1rem;
    color: var(--primary-mango);
    font-weight: bold;
}

.identity-email {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.clear-chat-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    min-width: 48px;
    flex-shrink: 0;
    background: transparent;
    border: 2px solid var(--text-dim);
    color: var(--text-secondary);
    overflow: visible;
}

.clear-chat-btn:hover {
    border-color: var(--primary-pink);
    color: var(--primary-pink);
}

.clear-chat-icon {
    width: 22px;
    height: 22px;
}

/* Error Message */
.error-message {
    color: var(--error);
    font-size: 0.9rem;
    text-align: center;
    margin-top: 15px;
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.5s ease-in-out;
}

/* Chat Screen */
.chat-container {
    max-width: 1200px;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 15, 0.9);
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 40px var(--shadow-pink);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid var(--border);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s ease-in-out infinite;
}

.status-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.user-info-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.user-email {
    color: var(--primary-mango);
    font-size: 0.9rem;
}

.user-role {
    color: var(--accent-cyan);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.logout-btn {
    padding: 6px 14px;
    font-size: 0.75rem;
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-secondary);
}

.logout-btn:hover {
    border-color: var(--error);
    color: var(--error);
    letter-spacing: 1px;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-messages::-webkit-scrollbar {
    width: 10px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary-pink);
    border-radius: 5px;
}

.message {
    display: flex;
    gap: 15px;
    animation: fadeInUp 0.5s ease-out;
}

.message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: rgba(10, 10, 20, 0.9);
    border: 1px solid var(--primary-pink);
    box-shadow: 0 0 16px var(--shadow-pink);
    padding: 8px;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, var(--primary-mango), var(--warning));
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--shadow-mango);
    order: 2;
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-message .message-content {
    align-items: flex-end;
}

.message-text {
    background: rgba(255, 46, 151, 0.1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 15px 20px;
    max-width: 80%;
    line-height: 1.6;
}

.user-message .message-text {
    background: rgba(255, 158, 68, 0.1);
    border-color: rgba(255, 158, 68, 0.3);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.chat-input-container {
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 2px solid var(--border);
}

.chat-form {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 12px;
}

.chat-form textarea {
    flex: 1;
    min-height: 52px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border);
    border-radius: 5px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: var(--text-primary);
    resize: none;
    transition: all 0.3s ease;
}

.chat-form textarea:focus {
    outline: none;
    border-color: var(--primary-pink);
    box-shadow: 0 0 20px var(--shadow-pink);
}

.btn-send {
    padding: 15px 30px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Logout Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

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

.modal-box {
    background: var(--bg-dark);
    border: 2px solid var(--primary-pink);
    border-radius: 10px;
    padding: 36px 40px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 0 40px var(--shadow-pink),
                inset 0 0 20px rgba(255, 46, 151, 0.05);
    animation: fadeInUp 0.2s ease-out;
    text-align: center;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: bold;
    letter-spacing: 4px;
    color: var(--primary-pink);
    text-shadow: 0 0 10px var(--shadow-pink);
    margin-bottom: 16px;
    text-transform: uppercase;
}

.modal-body {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 28px;
}

.modal-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
}

.modal-btn-cancel {
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-secondary);
}

.modal-btn-cancel:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 244, 255, 0.2);
}

.modal-btn-confirm {
    background: linear-gradient(135deg, var(--error), #c0002a);
    border-color: var(--error);
    color: #fff;
}

.modal-btn-confirm:hover {
    box-shadow: 0 0 24px rgba(255, 51, 102, 0.5);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(6px);
}

.loading-overlay.show {
    display: flex;
}

.loading-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 48px 56px;
    background: rgba(10, 10, 15, 0.95);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 0 60px var(--shadow-pink), inset 0 0 30px rgba(255, 46, 151, 0.03);
    overflow: hidden;
}

.loading-scanline {
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(180deg, transparent, rgba(255, 46, 151, 0.4), transparent);
    animation: scanlineSweep 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}

@keyframes scanlineSweep {
    0%   { top: -5%; }
    100% { top: 105%; }
}

.loading-logo {
    width: 72px;
    height: 72px;
    animation: logoPulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 20px var(--shadow-pink));
    position: relative;
    z-index: 1;
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 20px var(--shadow-pink));
    }
    50% {
        transform: scale(1.08);
        filter: drop-shadow(0 0 40px var(--shadow-pink))
                drop-shadow(0 0 80px rgba(255, 46, 151, 0.3));
    }
}

.loading-bar {
    width: 180px;
    height: 3px;
    background: rgba(255, 46, 151, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--primary-pink), var(--primary-mango));
    border-radius: 2px;
    animation: barSlide 1.5s ease-in-out infinite;
}

@keyframes barSlide {
    0%   { transform: translateX(-100%); }
    50%  { transform: translateX(250%); }
    100% { transform: translateX(-100%); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.75rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    animation: loadingTextPulse 2s ease-in-out infinite;
}

@keyframes loadingTextPulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; color: var(--primary-pink); }
}

/* Inline Chat Loading Indicator */
.typing-indicator {
    display: none;
    gap: 15px;
    animation: fadeInUp 0.3s ease-out;
}

.typing-indicator.show {
    display: flex;
}

.typing-indicator .message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-pink), var(--secondary-purple));
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--shadow-pink);
}

.typing-indicator .message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.typing-dots {
    background: rgba(255, 46, 151, 0.1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 15px 20px;
    max-width: 80%;
    display: flex;
    gap: 8px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-pink);
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.typing-status {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@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);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* CTF Timer */
.ctf-timer-block {
    text-align: center;
    margin-bottom: 28px;
    padding: 16px 12px;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid rgba(0, 244, 255, 0.35);
    border-radius: 10px;
    box-shadow: 0 0 24px rgba(0, 244, 255, 0.15),
                inset 0 0 20px rgba(0, 244, 255, 0.04);
    animation: fadeInDown 1s ease-out;
    width: 100%;
    box-sizing: border-box;
}

.timer-label {
    font-size: 0.78rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--accent-cyan);
    margin-bottom: 14px;
    text-shadow: 0 0 8px var(--accent-cyan);
}

.timer-label.live {
    color: var(--primary-pink);
    text-shadow: 0 0 8px var(--shadow-pink);
    animation: pulse 1s ease-in-out infinite;
}

.timer-digits {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(2px, 1vw, 6px);
    flex-wrap: wrap;
}

.timer-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: clamp(36px, 10vw, 64px);
}

.timer-num {
    font-size: clamp(1.4rem, 5vw, 2.6rem);
    font-weight: bold;
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, var(--accent-cyan), var(--primary-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    text-shadow: none;
    filter: drop-shadow(0 0 6px rgba(0, 244, 255, 0.5));
}

.timer-num.live {
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-mango));
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 0 6px rgba(255, 46, 151, 0.6));
}

.timer-unit-label {
    font-size: 0.6rem;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.timer-sep {
    font-size: clamp(1.1rem, 4vw, 2rem);
    font-weight: bold;
    color: var(--accent-cyan);
    opacity: 0.5;
    margin-bottom: 18px;
    line-height: 1;
}

.timer-sep.live {
    color: var(--primary-pink);
    animation: pulse 1s ease-in-out infinite;
}

/* Compact timer (chat header + leaderboard header) */
.compact-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border: 1px solid rgba(0, 244, 255, 0.3);
    border-radius: 4px;
    background: rgba(0, 244, 255, 0.05);
    white-space: nowrap;
}

.compact-timer-label {
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: var(--accent-cyan);
    text-transform: uppercase;
}

.compact-timer-value {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    font-family: 'Courier New', monospace;
}

.compact-timer.ct-live {
    border-color: rgba(255, 46, 151, 0.4);
    background: rgba(255, 46, 151, 0.07);
    animation: pulse 1.5s ease-in-out infinite;
}

.compact-timer.ct-live .compact-timer-label,
.compact-timer.ct-live .compact-timer-value {
    color: var(--primary-pink);
}

.compact-timer.ct-ended {
    border-color: rgba(255, 51, 102, 0.4);
    background: rgba(255, 51, 102, 0.07);
}

.compact-timer.ct-ended .compact-timer-label {
    color: var(--error);
    letter-spacing: 3px;
}

.timer-ended {
    font-size: 1.1rem;
    letter-spacing: 5px;
    color: var(--error);
    text-shadow: 0 0 12px var(--error);
    text-transform: uppercase;
    animation: pulse 2s ease-in-out infinite;
}

/* Rules Section */
.rules-section {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 158, 68, 0.4);
    border-radius: 8px;
    padding: 25px;
    margin: 30px 0;
    box-shadow: 0 0 20px rgba(255, 158, 68, 0.2),
                inset 0 0 20px rgba(255, 158, 68, 0.05);
}

.rules-header {
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-mango);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--shadow-mango);
}

.rules-bracket {
    color: var(--accent-cyan);
    font-size: 1.2rem;
    margin: 0 8px;
}

.rules-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rule-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    background: rgba(255, 46, 151, 0.05);
    border-left: 3px solid var(--primary-pink);
    border-radius: 5px;
    transition: all 0.3s ease;
}

.rule-item:hover {
    background: rgba(255, 46, 151, 0.1);
    border-left-color: var(--primary-mango);
    transform: translateX(5px);
}

.rule-number {
    color: var(--accent-cyan);
    font-weight: bold;
    font-size: 1rem;
    min-width: 35px;
    text-shadow: 0 0 5px var(--accent-cyan);
}

.rule-text {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Leaderboard page */
.leaderboard-screen {
    position: relative;
    min-height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 20px;
    z-index: 1;
}

.leaderboard-container {
    max-width: 700px;
    width: 100%;
}

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

.leaderboard-back {
    font-size: 0.9rem;
    color: var(--accent-cyan);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.leaderboard-back:hover {
    color: var(--primary-mango);
    text-shadow: 0 0 10px var(--shadow-mango);
}

.leaderboard-box {
    margin: 0;
}

.leaderboard-loading {
    text-align: center;
    color: var(--primary-pink);
    letter-spacing: 3px;
    padding: 40px;
}

.leaderboard-table-wrap {
    overflow-x: auto;
    margin-top: 20px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Right-align numeric columns */
.leaderboard-table th:nth-child(3),
.leaderboard-table td:nth-child(3),
.leaderboard-table th:nth-child(4),
.leaderboard-table td:nth-child(4) { text-align: right; white-space: nowrap; }

.leaderboard-table th {
    color: var(--primary-mango);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.85rem;
}

.leaderboard-table td {
    color: var(--text-primary);
}

.leaderboard-table tbody tr:hover {
    background: rgba(255, 46, 151, 0.08);
}

.leaderboard-table td:first-child {
    color: var(--accent-cyan);
    font-weight: bold;
}

.leaderboard-table td:nth-child(3) {
    color: var(--primary-mango);
    font-weight: bold;
}

.leaderboard-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}

/* Chat header leaderboard button */
.leaderboard-link {
    margin-right: 24px;
    padding: 10px 20px;
    font-size: 0.85rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    align-self: center;
    border-radius: 5px;
    white-space: nowrap;
    display: inline-block;
}

.leaderboard-link:hover {
    box-shadow: 0 0 25px var(--shadow-pink);
    transform: translateY(-2px);
}

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

/* --- Tablet (≤ 900px) --- */
@media (max-width: 900px) {
    .chat-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .leaderboard-container {
        max-width: 100%;
    }

    .logo-text {
        font-size: 3rem;
        letter-spacing: 7px;
    }
}

/* --- Mobile (≤ 640px) --- */
@media (max-width: 640px) {

    /* Screen wrapper */
    .screen {
        padding: 16px 10px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .container {
        width: 100%;
    }

    /* Logo */
    .logo-section {
        margin-bottom: 18px;
    }

    .logo-text {
        font-size: 2.2rem;
        letter-spacing: 5px;
    }

    .logo-subtitle {
        font-size: 0.65rem;
        letter-spacing: 3px;
    }

    .logo-text-small {
        font-size: 1.2rem;
        letter-spacing: 3px;
    }

    .logo-img {
        height: 38px;
    }

    .logo-img-small {
        height: 22px;
    }

    /* --- Main Timer (login screen) --- */
    .ctf-timer-block {
        margin-bottom: 14px;
    }

    .timer-label {
        font-size: 0.68rem;
        letter-spacing: 3px;
        margin-bottom: 10px;
    }

    .timer-unit-label {
        font-size: 0.5rem;
        letter-spacing: 2px;
    }

    .timer-ended {
        font-size: 0.9rem;
        letter-spacing: 3px;
    }

    /* --- Content box --- */
    .content-box {
        padding: 20px 14px;
    }

    .glitch-text {
        font-size: 1.1rem;
        letter-spacing: 1.5px;
        margin-bottom: 16px;
    }

    .description {
        font-size: 0.85rem;
        line-height: 1.7;
        margin-bottom: 16px;
    }

    /* --- Rules --- */
    .rules-section {
        padding: 14px 10px;
        margin: 16px 0;
    }

    .rules-header {
        font-size: 0.8rem;
        letter-spacing: 2px;
        margin-bottom: 14px;
    }

    .rules-content {
        gap: 10px;
    }

    .rule-item {
        padding: 8px 10px;
        gap: 8px;
    }

    .rule-number {
        font-size: 0.85rem;
        min-width: 28px;
    }

    .rule-text {
        font-size: 0.82rem;
        line-height: 1.5;
    }

    /* --- Form inputs --- */
    .input-group label {
        font-size: 0.78rem;
        letter-spacing: 1.5px;
    }

    .input-group input,
    .input-group select {
        padding: 11px 12px;
        font-size: 0.9rem;
    }

    .btn {
        padding: 12px 18px;
        font-size: 0.88rem;
    }

    /* Reset padding on icon-only button so the .btn override above doesn't squash it */
    .clear-chat-btn {
        padding: 0;
    }

    /* --- Chat header: 2-row layout on mobile --- */
    .chat-header {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 10px 12px;
    }

    .chat-header-left {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .chat-header-right {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 8px;
    }

    /* Hide "RECRUITMENT AI ONLINE" text on mobile — saves space */
    .status-indicator {
        display: none;
    }

    /* Compact timer in header */
    .compact-timer {
        padding: 3px 7px;
        gap: 5px;
    }

    .compact-timer-label {
        font-size: 0.55rem;
        letter-spacing: 1px;
    }

    .compact-timer-value {
        font-size: 0.75rem;
    }

    /* User info row */
    .user-info-block {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .user-info {
        align-items: flex-start;
    }

    .user-email {
        font-size: 0.72rem;
        max-width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-role {
        font-size: 0.62rem;
    }

    .leaderboard-link {
        padding: 6px 10px;
        font-size: 0.68rem;
        letter-spacing: 1px;
        margin-right: 0;
    }

    .logout-btn {
        padding: 5px 8px;
        font-size: 0.68rem;
        letter-spacing: 1px;
    }

    /* --- Chat messages --- */
    .chat-messages {
        padding: 14px 10px;
        gap: 12px;
    }

    .message {
        gap: 10px;
    }

    .message-avatar {
        width: 34px;
        height: 34px;
        font-size: 0.65rem;
        flex-shrink: 0;
    }

    .message-text {
        max-width: 88%;
        padding: 10px 12px;
        font-size: 0.88rem;
        line-height: 1.55;
    }

    .message-time {
        font-size: 0.65rem;
    }

    .typing-indicator .message-avatar {
        width: 34px;
        height: 34px;
        font-size: 0.65rem;
    }

    /* --- Chat input --- */
    .chat-input-container {
        padding: 10px 12px;
    }

    .chat-form {
        gap: 8px;
    }

    .chat-form textarea {
        min-height: 42px;
        padding: 10px 12px;
        font-size: 0.88rem;
    }

    .btn-send {
        padding: 10px 14px;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .clear-chat-btn {
        width: 42px;
        height: 42px;
        min-width: 42px;
        border-color: var(--text-secondary);
        color: var(--text-secondary);
        overflow: visible;
    }

    .clear-chat-icon {
        width: 20px;
        height: 20px;
        stroke-width: 2.5;
    }

    /* --- Leaderboard --- */
    .leaderboard-screen {
        padding: 16px 10px;
    }

    .leaderboard-header {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 16px;
        justify-content: space-between;
        align-items: center;
    }

    .leaderboard-back {
        font-size: 0.75rem;
        letter-spacing: 1px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 8px;
        font-size: 0.82rem;
    }

    /* Fixed layout + column widths only on mobile (safe because headers are short) */
    .leaderboard-table {
        table-layout: fixed;
    }

    .leaderboard-table th:nth-child(1),
    .leaderboard-table td:nth-child(1) { width: 10%; }

    .leaderboard-table th:nth-child(3),
    .leaderboard-table td:nth-child(3),
    .leaderboard-table th:nth-child(4),
    .leaderboard-table td:nth-child(4) { width: 20%; }

    /* Swap header labels for short versions using data-short attr */
    .leaderboard-table th[data-short] {
        font-size: 0;
        letter-spacing: 0;
    }

    .leaderboard-table th[data-short]::after {
        content: attr(data-short);
        font-size: 0.65rem;
        letter-spacing: 1.5px;
    }
}

/* ================================================
   DUPLICATE DETECTION FAILURE ANIMATION
   ================================================ */

/* Full-screen persistent duplicate overlay */
.duplicate-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(10, 0, 0, 0.93);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: duplicateOverlayIn 0.6s ease-out forwards;
}

@keyframes duplicateOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Red CRT flash — loops */
.duplicate-flash-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(255, 30, 30, 0.5), rgba(255, 0, 0, 0.1));
    pointer-events: none;
    z-index: 1;
    animation: duplicateFlash 2.5s ease-in-out infinite;
}

@keyframes duplicateFlash {
    0%, 100% { opacity: 0.05; }
    12%  { opacity: 0.6; }
    25%  { opacity: 0.08; }
    40%  { opacity: 0.5; }
    55%  { opacity: 0.06; }
    70%  { opacity: 0.45; }
    85%  { opacity: 0.04; }
}

/* Scanlines */
.duplicate-flash-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 2px,
        transparent 2px,
        transparent 4px
    );
    pointer-events: none;
}

/* Red matrix rain canvas — runs forever */
.duplicate-matrix-canvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0.6;
}

/* Glitch bar / interference canvas */
.duplicate-glitch-canvas {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0.4;
}

/* Failure popup content */
.duplicate-popup {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: duplicatePopupIn 0.8s ease-out forwards;
}

@keyframes duplicatePopupIn {
    0%   { opacity: 0; transform: scale(1.3) rotate(2deg); }
    30%  { opacity: 1; transform: scale(0.95) rotate(-1deg); }
    50%  { transform: scale(1.03) rotate(0.5deg); }
    70%  { transform: scale(0.99); }
    100% { transform: scale(1) rotate(0deg); }
}

.duplicate-popup-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    animation: duplicateIconPulse 0.4s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 20px rgba(255, 51, 102, 0.9))
            drop-shadow(0 0 50px rgba(255, 51, 102, 0.5));
}

@keyframes duplicateIconPulse {
    from { transform: scale(1) rotate(-1deg); filter: drop-shadow(0 0 20px rgba(255, 51, 102, 0.9)); }
    to   { transform: scale(1.12) rotate(1deg); filter: drop-shadow(0 0 40px rgba(255, 51, 102, 1)) drop-shadow(0 0 70px rgba(255, 0, 0, 0.5)); }
}

.duplicate-popup-title {
    font-family: 'Courier New', monospace;
    font-size: 3rem;
    font-weight: bold;
    color: var(--error);
    text-transform: uppercase;
    letter-spacing: 8px;
    position: relative;
    text-shadow:
        0 0 20px rgba(255, 51, 102, 0.8),
        0 0 40px rgba(255, 51, 102, 0.5),
        0 0 80px rgba(255, 51, 102, 0.3);
    animation: duplicateGlitchText 0.15s infinite;
}

.duplicate-popup-title::before,
.duplicate-popup-title::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.duplicate-popup-title::before {
    color: var(--accent-cyan);
    animation: duplicateGlitchClip1 0.3s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 40%, 0 40%);
}

.duplicate-popup-title::after {
    color: var(--primary-mango);
    animation: duplicateGlitchClip2 0.3s infinite;
    clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
}

@keyframes duplicateGlitchText {
    0%   { transform: translate(0); }
    20%  { transform: translate(-3px, 3px); }
    40%  { transform: translate(3px, -2px); }
    60%  { transform: translate(-2px, -3px); }
    80%  { transform: translate(2px, 2px); }
    100% { transform: translate(0); }
}

@keyframes duplicateGlitchClip1 {
    0%   { transform: translate(0); }
    25%  { transform: translate(-4px, -2px); }
    50%  { transform: translate(4px, 2px); }
    75%  { transform: translate(-2px, 4px); }
    100% { transform: translate(0); }
}

@keyframes duplicateGlitchClip2 {
    0%   { transform: translate(0); }
    25%  { transform: translate(4px, 2px); }
    50%  { transform: translate(-4px, -2px); }
    75%  { transform: translate(2px, -4px); }
    100% { transform: translate(0); }
}

.duplicate-popup-subtitle {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--text-secondary);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-top: 20px;
    text-shadow: 0 0 10px rgba(255, 51, 102, 0.3);
    animation: duplicateSubType 2.5s steps(35, end) forwards, duplicateSubBlink 0.5s step-end infinite;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    border-right: 2px solid var(--error);
}

@keyframes duplicateSubType {
    0%   { width: 0; }
    100% { width: 30ch; }
}

@keyframes duplicateSubBlink {
    50% { border-color: transparent; }
}

/* Warning badge */
.duplicate-popup-badge {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--error);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 24px;
    padding: 8px 24px;
    border: 1px solid rgba(255, 51, 102, 0.4);
    border-radius: 4px;
    background: rgba(255, 51, 102, 0.08);
    text-shadow: 0 0 10px rgba(255, 51, 102, 0.4);
    animation: duplicateBadgeFadeIn 1s 0.8s ease-out both;
}

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

/* Start Over button — red/error theme */
.duplicate-start-over-btn {
    margin-top: 40px;
    padding: 16px 48px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #fff;
    background: linear-gradient(135deg, var(--error), var(--primary-pink));
    border: 2px solid var(--error);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: duplicateBtnFadeIn 1.5s 1.5s ease-out both;
    z-index: 5;
}

.duplicate-start-over-btn:hover {
    box-shadow: 0 0 30px rgba(255, 51, 102, 0.6), 0 0 60px rgba(255, 46, 151, 0.3);
    transform: translateY(-3px) scale(1.03);
    letter-spacing: 6px;
}

.duplicate-start-over-btn:active {
    transform: translateY(0) scale(0.98);
}

.duplicate-start-over-btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    animation: duplicateBtnSweep 2.5s 2s ease-in-out infinite;
}

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

@keyframes duplicateBtnSweep {
    0%   { left: -100%; }
    50%  { left: 100%; }
    100% { left: 100%; }
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .duplicate-popup-title {
        font-size: 1.5rem;
        letter-spacing: 4px;
    }

    .duplicate-popup-subtitle {
        font-size: 0.65rem;
        letter-spacing: 3px;
    }

    .duplicate-popup-icon {
        width: 50px;
        height: 50px;
    }

    .duplicate-popup-badge {
        font-size: 0.7rem;
        letter-spacing: 2px;
    }

    .duplicate-start-over-btn {
        padding: 12px 28px;
        font-size: 0.9rem;
        letter-spacing: 3px;
    }
}

/* ================================================
   BREACH SUCCESS ANIMATION
   ================================================ */

/* Full-screen persistent breach overlay (covers everything) */
.breach-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: breachOverlayIn 1s ease-out forwards;
}

@keyframes breachOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Green CRT pulse — loops */
.breach-flash-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0, 255, 136, 0.4), rgba(0, 200, 100, 0.1));
    pointer-events: none;
    z-index: 1;
    animation: breachFlash 3s ease-in-out infinite;
}

@keyframes breachFlash {
    0%, 100% { opacity: 0.05; }
    15%  { opacity: 0.5; }
    30%  { opacity: 0.1; }
    50%  { opacity: 0.4; }
    70%  { opacity: 0.08; }
    85%  { opacity: 0.35; }
}

/* Scanlines */
.breach-flash-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.12) 0px,
        rgba(0, 0, 0, 0.12) 2px,
        transparent 2px,
        transparent 4px
    );
    pointer-events: none;
}

/* Green matrix rain canvas — runs forever behind popup */
.breach-matrix-canvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0.55;
}

/* Particle burst canvas — loops */
.breach-particles-canvas {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

/* Success popup content — centered over everything */
.breach-popup {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: breachPopupIn 1.2s ease-out forwards;
}

@keyframes breachPopupIn {
    0%   { opacity: 0; transform: scale(0.5); }
    40%  { opacity: 1; transform: scale(1.06); }
    60%  { transform: scale(0.98); }
    80%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Breach icon — Straiker logo */
.breach-popup-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 30px rgba(0, 255, 136, 0.9))
            drop-shadow(0 0 60px rgba(0, 255, 136, 0.5));
    animation: breachIconPulse 0.6s ease-in-out infinite alternate;
}

@keyframes breachIconPulse {
    from { transform: scale(1) rotate(-2deg); filter: drop-shadow(0 0 30px rgba(0, 255, 136, 0.9)); }
    to   { transform: scale(1.12) rotate(2deg); filter: drop-shadow(0 0 50px rgba(0, 255, 136, 1)) drop-shadow(0 0 80px rgba(0, 244, 255, 0.5)); }
}

/* Main title */
.breach-popup-title {
    font-family: 'Courier New', monospace;
    font-size: 3.5rem;
    font-weight: bold;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 10px;
    position: relative;
    text-shadow:
        0 0 20px rgba(0, 255, 136, 0.9),
        0 0 40px rgba(0, 255, 136, 0.6),
        0 0 80px rgba(0, 255, 136, 0.3),
        0 0 120px rgba(0, 244, 255, 0.2);
    animation: breachGlitchText 0.12s infinite;
}

.breach-popup-title::before,
.breach-popup-title::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.breach-popup-title::before {
    color: var(--accent-cyan);
    animation: breachGlitchClip1 0.25s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
}

.breach-popup-title::after {
    color: var(--primary-mango);
    animation: breachGlitchClip2 0.25s infinite;
    clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
}

@keyframes breachGlitchText {
    0%   { transform: translate(0); }
    20%  { transform: translate(-2px, 2px); }
    40%  { transform: translate(2px, -1px); }
    60%  { transform: translate(-1px, -2px); }
    80%  { transform: translate(1px, 1px); }
    100% { transform: translate(0); }
}

@keyframes breachGlitchClip1 {
    0%   { transform: translate(0); }
    25%  { transform: translate(-3px, -1px); }
    50%  { transform: translate(3px, 1px); }
    75%  { transform: translate(-1px, 3px); }
    100% { transform: translate(0); }
}

@keyframes breachGlitchClip2 {
    0%   { transform: translate(0); }
    25%  { transform: translate(3px, 1px); }
    50%  { transform: translate(-3px, -1px); }
    75%  { transform: translate(1px, -3px); }
    100% { transform: translate(0); }
}

/* Subtitle line */
.breach-popup-subtitle {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--accent-cyan);
    letter-spacing: 8px;
    text-transform: uppercase;
    margin-top: 20px;
    text-shadow: 0 0 15px rgba(0, 244, 255, 0.6);
    animation: breachSubType 3s steps(40, end) forwards, breachSubBlink 0.7s step-end infinite;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    border-right: 2px solid var(--accent-cyan);
}

@keyframes breachSubType {
    0%   { width: 0; }
    100% { width: 32ch; }
}

@keyframes breachSubBlink {
    50% { border-color: transparent; }
}

/* Rank-up badge line */
.breach-popup-badge {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--primary-mango);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 24px;
    padding: 8px 24px;
    border: 1px solid rgba(255, 158, 68, 0.4);
    border-radius: 4px;
    background: rgba(255, 158, 68, 0.08);
    text-shadow: 0 0 10px var(--shadow-mango);
    animation: breachBadgeFadeIn 1s 0.8s ease-out both;
}

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

/* Start Over button */
.breach-start-over-btn {
    margin-top: 40px;
    padding: 16px 48px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--success), var(--accent-cyan));
    border: 2px solid var(--success);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: breachBtnFadeIn 1.5s 1.5s ease-out both;
    z-index: 5;
}

.breach-start-over-btn:hover {
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.6), 0 0 60px rgba(0, 244, 255, 0.3);
    transform: translateY(-3px) scale(1.03);
    letter-spacing: 6px;
}

.breach-start-over-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Glow sweep on button */
.breach-start-over-btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: breachBtnSweep 2s 2s ease-in-out infinite;
}

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

@keyframes breachBtnSweep {
    0%   { left: -100%; }
    50%  { left: 100%; }
    100% { left: 100%; }
}

/* Disabled chat input state */
.chat-input-disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .breach-popup-title {
        font-size: 1.8rem;
        letter-spacing: 5px;
    }

    .breach-popup-subtitle {
        font-size: 0.65rem;
        letter-spacing: 3px;
    }

    .breach-popup-icon {
        width: 50px;
        height: 50px;
    }

    .breach-popup-badge {
        font-size: 0.7rem;
        letter-spacing: 2px;
    }

    .breach-start-over-btn {
        padding: 12px 28px;
        font-size: 0.9rem;
        letter-spacing: 3px;
    }
}

/* ================================================
   ERROR ANIMATIONS (429 Rate Limit / 500 Server Error)
   ================================================ */

/* Shared error overlay */
.error-overlay {
    position: fixed;
    inset: 0;
    z-index: 10010;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    animation: errorOverlayIn 0.4s ease-out forwards;
}

.error-overlay.rate-limit {
    background: rgba(255, 170, 0, 0.08);
}

.error-overlay.server-error {
    background: rgba(255, 51, 102, 0.08);
}

@keyframes errorOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Error card */
.error-card {
    max-width: 520px;
    width: 90%;
    padding: 40px 36px;
    border-radius: 12px;
    text-align: center;
    animation: errorCardBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    position: relative;
    overflow: hidden;
}

.rate-limit .error-card {
    background: rgba(10, 10, 15, 0.95);
    border: 2px solid rgba(255, 170, 0, 0.5);
    box-shadow: 0 0 40px rgba(255, 170, 0, 0.25),
                inset 0 0 30px rgba(255, 170, 0, 0.05);
}

.server-error .error-card {
    background: rgba(10, 10, 15, 0.95);
    border: 2px solid rgba(255, 51, 102, 0.5);
    box-shadow: 0 0 40px rgba(255, 51, 102, 0.25),
                inset 0 0 30px rgba(255, 51, 102, 0.05);
}

@keyframes errorCardBounce {
    0%   { opacity: 0; transform: scale(0.3) translateY(40px); }
    60%  { opacity: 1; transform: scale(1.05) translateY(-5px); }
    100% { transform: scale(1) translateY(0); }
}

/* Scanline overlay on card */
.error-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.06) 0px,
        rgba(0, 0, 0, 0.06) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    border-radius: 12px;
}

/* Straiker icon in error cards */
.error-straiker-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.error-icon-warn {
    filter: drop-shadow(0 0 20px rgba(255, 170, 0, 0.8))
            drop-shadow(0 0 40px rgba(255, 170, 0, 0.4));
    animation: meltWobble 1.5s ease-in-out infinite;
}

.error-icon-crit {
    filter: drop-shadow(0 0 20px rgba(255, 51, 102, 0.9))
            drop-shadow(0 0 40px rgba(255, 51, 102, 0.5));
    animation: fireShake 0.3s ease-in-out infinite;
}

@keyframes meltWobble {
    0%, 100% { transform: rotate(0deg) scale(1); }
    15%  { transform: rotate(-8deg) scale(1.05); }
    30%  { transform: rotate(6deg) scale(0.95); }
    45%  { transform: rotate(-4deg) scale(1.08); }
    60%  { transform: rotate(3deg) scale(1); }
    75%  { transform: rotate(-2deg) scale(1.03); }
}

@keyframes fireShake {
    0%, 100% { transform: translate(0) rotate(0); }
    25%  { transform: translate(-3px, 2px) rotate(-2deg); }
    50%  { transform: translate(2px, -2px) rotate(1deg); }
    75%  { transform: translate(-2px, 1px) rotate(-1deg); }
}

/* Error code badge */
.error-code {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 4px 16px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 16px;
}

.rate-limit .error-code {
    color: var(--warning);
    background: rgba(255, 170, 0, 0.1);
    border: 1px solid rgba(255, 170, 0, 0.3);
}

.server-error .error-code {
    color: var(--error);
    background: rgba(255, 51, 102, 0.1);
    border: 1px solid rgba(255, 51, 102, 0.3);
}

/* Error title */
.error-title {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.rate-limit .error-title {
    color: var(--warning);
    text-shadow: 0 0 15px rgba(255, 170, 0, 0.5);
}

.server-error .error-title {
    color: var(--error);
    text-shadow: 0 0 15px rgba(255, 51, 102, 0.5);
}

/* Funny joke text */
.error-joke {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 8px;
}

/* Smaller sub-joke */
.error-subjoke {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 24px;
    font-style: italic;
}

/* ASCII art (optional flair) */
.error-ascii {
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    white-space: pre;
    line-height: 1.2;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Dismiss button */
.error-dismiss-btn {
    padding: 12px 36px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.rate-limit .error-dismiss-btn {
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--warning), var(--primary-mango));
    border: 2px solid var(--warning);
}

.rate-limit .error-dismiss-btn:hover {
    box-shadow: 0 0 25px rgba(255, 170, 0, 0.5);
    transform: translateY(-2px);
}

.server-error .error-dismiss-btn {
    color: #fff;
    background: linear-gradient(135deg, var(--error), var(--primary-pink));
    border: 2px solid var(--error);
}

.server-error .error-dismiss-btn:hover {
    box-shadow: 0 0 25px rgba(255, 51, 102, 0.5);
    transform: translateY(-2px);
}

/* Countdown text */
.error-countdown {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-top: 16px;
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .error-card {
        padding: 28px 20px;
    }

    .error-emoji {
        font-size: 3rem;
    }

    .error-title {
        font-size: 1.1rem;
        letter-spacing: 2px;
    }

    .error-joke {
        font-size: 0.85rem;
    }

    .error-ascii {
        font-size: 0.55rem;
    }

    .error-dismiss-btn {
        padding: 10px 24px;
        font-size: 0.85rem;
    }
}

/* --- Small mobile (≤ 380px) --- */
@media (max-width: 380px) {
    .logo-text {
        font-size: 1.8rem;
        letter-spacing: 4px;
    }

    .logo-img {
        height: 30px;
    }

    .logo-img-small {
        height: 18px;
    }

    .glitch-text {
        font-size: 0.95rem;
    }

    .user-email {
        max-width: 90px;
    }
}

/* ========== CONTEXT CLEARED TOAST ========== */

.context-cleared-toast {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 10001;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent-cyan);
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(0, 244, 255, 0.4);
    padding: 8px 16px;
    border-radius: 4px;
    box-shadow: 0 0 12px rgba(0, 244, 255, 0.2);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

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

/* ========== END CONTEXT CLEARED TOAST ========== */
