*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --gold: #d4a847;
    --gold-light: #f0c860;
    --gold-dark: #a07820;
    --accent: #4a9eff;
    --accent-dim: #2a5a9a;
    --danger: #e04040;
    --success: #40c060;
    --purple: #9b59b6;
    --bg: #0a0c14;
    --bg-card: rgba(14, 18, 30, 0.92);
    --bg-glass: rgba(10, 14, 24, 0.75);
    --border: rgba(100, 140, 200, 0.15);
    --border-gold: rgba(212, 168, 71, 0.3);
    --text: #e0e4f0;
    --text-dim: #6a7090;
    --text-muted: #3a4060;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --level-color: var(--accent);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

#screen-shake-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}
#screen-shake-wrapper.shake {
    animation: screenShake 0.4s ease-out;
}
@keyframes screenShake {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-4px, 2px); }
    20% { transform: translate(3px, -3px); }
    30% { transform: translate(-2px, 1px); }
    40% { transform: translate(2px, -1px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(1px, -1px); }
}

/* ═══════════════════════════════════════════
   AMBIENT BACKGROUND
   ═══════════════════════════════════════════ */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    transition: background-image 1.5s ease, opacity 1.5s ease;
    opacity: 0.35;
    filter: blur(2px) saturate(0.7);
}
.ambient-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(10,12,20,0.6) 0%, rgba(10,12,20,0.3) 40%, rgba(10,12,20,0.8) 100%);
}

#particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════ */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--bg);
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease;
}
#loading-screen.active { display: flex; }
#loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loader-content { text-align: center; }
.loader-icon {
    font-family: 'Cinzel', serif;
    font-size: 4rem;
    font-weight: 900;
    color: var(--gold);
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}
.loader-title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    color: var(--gold);
    text-shadow: 0 0 40px rgba(212, 168, 71, 0.3);
}
.loader-subtitle {
    font-size: 0.8rem;
    letter-spacing: 0.5em;
    color: var(--text-dim);
    margin-top: 8px;
}
.loader-bar-container {
    width: 280px;
    height: 3px;
    background: rgba(100, 140, 200, 0.1);
    border-radius: 3px;
    margin: 32px auto 16px;
    overflow: hidden;
}
.loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
    transition: width 0.3s ease;
    border-radius: 3px;
}
.loader-status {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

/* ═══════════════════════════════════════════
   VIEWS
   ═══════════════════════════════════════════ */
.view {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    flex-direction: column;
}
.view.active { display: flex; }

/* ═══════════════════════════════════════════
   XP BAR
   ═══════════════════════════════════════════ */
.xp-bar-container { width: 100%; max-width: 400px; }
.xp-bar-track {
    width: 100%;
    height: 8px;
    background: rgba(100, 140, 200, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.xp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--level-color), var(--gold-light));
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.xp-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
    border-radius: 0 4px 4px 0;
}
.xp-bar-label {
    display: flex;
    justify-content: center;
    margin-top: 4px;
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    font-family: 'JetBrains Mono', monospace;
}

.game-xp-mini {
    padding: 0 20px;
    position: relative;
    z-index: 14;
}
.xp-mini-track {
    width: 100%;
    height: 2px;
    background: rgba(100, 140, 200, 0.06);
    border-radius: 1px;
    overflow: hidden;
}
.xp-mini-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
    border-radius: 1px;
    transition: width 0.8s ease;
}

/* ═══════════════════════════════════════════
   LOBBY
   ═══════════════════════════════════════════ */
#view-lobby {
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    padding-top: calc(20px + var(--safe-top));
    position: relative;
    z-index: 10;
}

.lobby-bg-gallery {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}
.lobby-bg-gallery .gallery-slide {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 2s ease-in-out;
}
.lobby-bg-gallery .gallery-slide.active {
    opacity: 0.3;
}
.lobby-bg-gallery::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(10,12,20,0.3) 0%, rgba(10,12,20,0.85) 70%, rgba(10,12,20,0.95) 100%);
    z-index: 1;
}
.lobby-avatar-slot {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50vh;
    z-index: 1;
    pointer-events: none;
}
.lobby-avatar-slot .avatar-container {
    position: absolute;
    inset: 0;
}
.lobby-avatar-slot .avatar-container canvas {
    pointer-events: auto;
}
.lobby-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 500px;
    width: 100%;
    position: relative;
    z-index: 2;
}
.lobby-header { text-align: center; }
.lobby-level-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, rgba(212,168,71,0.15), rgba(212,168,71,0.05));
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 8px 20px;
    margin-bottom: 12px;
}
.lobby-level-badge .level-number {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    font-weight: 900;
    color: var(--gold-light);
    line-height: 1;
}
.lobby-level-badge .level-label {
    font-size: 0.55rem;
    letter-spacing: 0.3em;
    color: var(--gold);
    margin-top: 2px;
}
.lobby-title {
    font-family: 'Cinzel', serif;
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: 0.25em;
    color: var(--gold);
    text-shadow: 0 0 60px rgba(212, 168, 71, 0.2);
    margin-top: 8px;
}
.lobby-tagline {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 8px;
    max-width: 420px;
    line-height: 1.6;
}
.lobby-badges {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.lobby-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--gold-light);
    border: 1px solid rgba(212,168,71,0.3);
    background: rgba(212,168,71,0.08);
}
.lobby-badge.soon {
    color: var(--accent);
    border-color: rgba(74,158,255,0.3);
    background: rgba(74,158,255,0.08);
    animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 rgba(74,158,255,0); }
    50% { box-shadow: 0 0 12px rgba(74,158,255,0.15); }
}

.lobby-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
}
.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 8px;
}
.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold-light);
}
.stat-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-dim);
}

.lobby-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 28px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    flex: 1;
}
.btn-primary {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #0a0c14;
    border-color: var(--gold);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(212, 168, 71, 0.3);
}
.btn-glow {
    animation: btnGlow 3s ease-in-out infinite;
}
@keyframes btnGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(212, 168, 71, 0.1); }
    50% { box-shadow: 0 0 25px rgba(212, 168, 71, 0.25); }
}
.btn-secondary {
    background: var(--bg-glass);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover {
    border-color: var(--gold);
    color: var(--gold-light);
}

.level-preview {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 14px;
    padding: 16px 20px;
    text-align: center;
}
.level-preview-title {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gold-light);
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}
.level-preview-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 8px;
}
.level-preview-modifiers {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}
.modifier-tag {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.modifier-tag.buff {
    background: rgba(64, 192, 96, 0.15);
    color: var(--success);
    border: 1px solid rgba(64, 192, 96, 0.3);
}
.modifier-tag.debuff {
    background: rgba(224, 64, 64, 0.15);
    color: var(--danger);
    border: 1px solid rgba(224, 64, 64, 0.3);
}
.modifier-tag.neutral {
    background: rgba(155, 89, 182, 0.15);
    color: var(--purple);
    border: 1px solid rgba(155, 89, 182, 0.3);
}

/* ═══════════════════════════════════════════
   LEVEL TRANSITION
   ═══════════════════════════════════════════ */
#view-transition {
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 100;
}
.transition-content {
    text-align: center;
    animation: transitionIn 0.6s ease-out;
}
@keyframes transitionIn {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.transition-level-num {
    font-family: 'Cinzel', serif;
    font-size: 8rem;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 80px rgba(212, 168, 71, 0.4);
    line-height: 1;
    animation: numPulse 1.5s ease-in-out infinite;
}
@keyframes numPulse {
    0%, 100% { text-shadow: 0 0 40px rgba(212, 168, 71, 0.2); }
    50% { text-shadow: 0 0 80px rgba(212, 168, 71, 0.5); }
}
.transition-level-name {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--text);
    margin-top: 8px;
}
.transition-modifiers {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}
.transition-bar {
    width: 200px;
    height: 3px;
    background: rgba(100, 140, 200, 0.1);
    border-radius: 3px;
    margin: 30px auto 0;
    overflow: hidden;
}
.transition-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--gold);
    border-radius: 3px;
    transition: width 1.8s ease-in-out;
}

/* ═══════════════════════════════════════════
   GAME VIEW — 3-column grid layout
   ═══════════════════════════════════════════ */
#view-game {
    z-index: 10;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    padding-top: calc(10px + var(--safe-top));
    background: linear-gradient(180deg, rgba(10, 12, 20, 0.95) 0%, rgba(10,12,20,0.6) 100%);
    position: relative;
    z-index: 25;
    flex-shrink: 0;
}
.game-back-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.game-back-btn:hover { border-color: var(--gold); color: var(--gold); }

.game-level-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.game-level-badge {
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, rgba(212,168,71,0.2), rgba(212,168,71,0.05));
    border: 1px solid var(--border-gold);
    color: var(--gold-light);
}
.round-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.game-scores { display: flex; gap: 6px; }
.score-pill {
    padding: 4px 12px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.score-pill.you {
    background: linear-gradient(135deg, rgba(212,168,71,0.12) 0%, rgba(212,168,71,0.04) 100%);
    color: var(--gold-light);
    border: 1px solid rgba(212,168,71,0.45);
}
.score-pill.ai {
    background: linear-gradient(135deg, rgba(140,130,170,0.12) 0%, rgba(90,85,110,0.06) 100%);
    color: #c4bdd8;
    border: 1px solid rgba(155,145,185,0.35);
}

/* ── Game Body: sidebar | avatar | chat ── */
.game-body {
    display: grid;
    grid-template-columns: 220px 1fr 300px;
    grid-template-rows: 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── LEFT SIDEBAR: Mission Briefing ── */
.game-sidebar {
    display: flex;
    flex-direction: column;
    padding: 10px;
    overflow-y: auto;
    border-right: 1px solid rgba(100,140,200,0.06);
}
.sidebar-panel {
    position: relative;
    background: rgba(8,10,22,0.88);
    border: 1px solid rgba(212,168,71,0.18);
    border-radius: 14px;
    overflow: hidden;
    animation: panelSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.03) inset,
        0 4px 24px rgba(0,0,0,0.4);
}
.sidebar-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 5%, rgba(212,168,71,0.5) 45%, rgba(180,200,255,0.25) 75%, transparent 95%);
}
@keyframes panelSlideIn {
    0% { opacity: 0; transform: translateX(-20px) scale(0.96); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}
.sidebar-panel-scanline {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(180,200,255,0.35), transparent);
    animation: scanline 4s linear infinite;
    pointer-events: none;
    z-index: 2;
}
@keyframes scanline {
    0% { top: -1px; opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.2; }
    100% { top: calc(100% + 1px); opacity: 0; }
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 6px;
    border-bottom: 1px solid rgba(100,140,200,0.08);
}
.sidebar-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-body {
    padding: 10px 12px 12px;
}
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 8px;
}
.cyber-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.48rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: rgba(200,210,240,0.7);
}
.cyber-exchanges {
    display: flex;
    align-items: center;
    gap: 4px;
}
.exchange-pip {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1px solid rgba(212,168,71,0.5);
    background: transparent;
    transition: all 0.3s ease;
}
.exchange-pip.active {
    background: var(--gold);
    box-shadow: 0 0 6px rgba(212,168,71,0.5);
}
.exchange-pip.used {
    background: rgba(100,90,120,0.4);
    border-color: rgba(100,90,120,0.3);
}
.cyber-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--gold-light);
    letter-spacing: 0.05em;
    margin-left: 4px;
    min-width: 28px;
    text-align: right;
}
.cyber-timer.warning { color: var(--danger); animation: timerPulse 0.5s ease-in-out infinite; }
@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.cyber-objective-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
    line-height: 1.5;
}
.cyber-objective-text.typing::after,
.cyber-context-text.typing::after {
    content: '\2588';
    color: var(--gold);
    animation: cursorBlink 0.6s step-end infinite;
    margin-left: 1px;
}
@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.cyber-context-text {
    font-size: 0.72rem;
    color: rgba(180,190,220,0.65);
    line-height: 1.6;
}
.cyber-line {
    flex: 1;
    height: 1px;
    background: rgba(120,130,170,0.1);
}
.cyber-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.42rem;
    letter-spacing: 0.3em;
    color: var(--success);
    opacity: 0.5;
}

/* ── CENTER: Avatar (big, dominant, centered) ── */
.game-center {
    position: relative;
    pointer-events: none;
    min-height: 0;
}

/* ── RIGHT: Chat log ── */
.game-chat-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1px solid rgba(100,140,200,0.06);
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    padding-bottom: 70px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

/* ── FOOTER: Input bar ── */
.game-footer {
    position: fixed;
    bottom: 0;
    left: 220px;
    right: 300px;
    z-index: 30;
    padding: 10px 24px;
    padding-bottom: calc(10px + var(--safe-bottom));
    background: linear-gradient(0deg, rgba(10,12,20,0.92) 0%, rgba(10,12,20,0.6) 70%, transparent 100%);
    pointer-events: none;
}
.game-footer > * {
    pointer-events: auto;
}

/* ═══════════════════════════════════════════
   3D AVATAR CONTAINER
   ═══════════════════════════════════════════ */
.avatar-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: none;
}
.avatar-container canvas {
    pointer-events: auto;
    cursor: pointer;
    touch-action: none;
}
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    animation: msgIn 0.3s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
    align-self: flex-end;
    background: rgba(74, 158, 255, 0.15);
    border: 1px solid rgba(74, 158, 255, 0.2);
    color: var(--text);
}
.chat-msg.ai {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
}
.chat-msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
    border: none;
    padding: 4px;
}
.chat-msg .bias-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-top: 6px;
    text-transform: uppercase;
}
.bias-tag.detected {
    background: rgba(224, 64, 64, 0.2);
    color: var(--danger);
    border: 1px solid rgba(224, 64, 64, 0.3);
}
.bias-tag.used {
    background: rgba(74, 158, 255, 0.2);
    color: var(--accent);
    border: 1px solid rgba(74, 158, 255, 0.3);
}
.bias-tag.resisted {
    background: rgba(64, 192, 96, 0.2);
    color: var(--success);
    border: 1px solid rgba(64, 192, 96, 0.3);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.input-area {
    padding: 0;
}
.input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: rgba(10,14,26,0.65);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(212,168,71,0.15);
    border-radius: 16px;
    padding: 6px 6px 6px 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.input-wrap:focus-within {
    border-color: rgba(212,168,71,0.45);
    box-shadow: 0 0 24px rgba(212,168,71,0.1), 0 4px 20px rgba(0,0,0,0.3);
}
.input-wrap:focus-within #msg-input::placeholder {
    color: rgba(212,168,71,0.4);
}
#msg-input, #defense-freetext {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    padding: 8px 0;
    resize: none;
    max-height: 120px;
    min-width: 0;
}
#msg-input::placeholder, #defense-freetext::placeholder {
    color: var(--text-muted);
}
.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.btn-send:hover { box-shadow: 0 0 16px rgba(212,168,71,0.3); }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-send svg { width: 16px; height: 16px; color: #0a0c14; }
.btn-send:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 0 16px rgba(212,168,71,0.4);
}

.defense-choices {
    padding: 0;
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.defense-choices.hidden { display: none; }
.choice-option {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.5;
}
.choice-option:hover {
    border-color: var(--accent);
    background: rgba(74, 158, 255, 0.08);
    transform: translateX(4px);
}
.choice-freetext {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px 6px 6px 16px;
}

/* ═══════════════════════════════════════════
   DEBRIEF VIEW
   ═══════════════════════════════════════════ */
#view-debrief {
    align-items: center;
    padding: 20px;
    padding-top: calc(20px + var(--safe-top));
    overflow-y: auto;
    z-index: 10;
}
.debrief-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 600px;
    width: 100%;
}
.debrief-result { text-align: center; }
.debrief-title {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.15em;
}
.debrief-scores {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}
.debrief-vs {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
}
.debrief-score-card {
    padding: 16px 28px;
    border-radius: 12px;
    text-align: center;
}
.debrief-score-card.you {
    background: linear-gradient(145deg, rgba(212,168,71,0.1) 0%, rgba(20,18,28,0.6) 100%);
    border: 1px solid rgba(212,168,71,0.35);
    box-shadow: 0 0 20px rgba(212,168,71,0.06);
}
.debrief-score-card.ai {
    background: linear-gradient(145deg, rgba(120,110,150,0.12) 0%, rgba(20,18,28,0.6) 100%);
    border: 1px solid rgba(155,145,185,0.3);
    box-shadow: 0 0 20px rgba(100,90,130,0.06);
}
.dsc-label {
    display: block;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.dsc-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
}
.debrief-score-card.you .dsc-value { color: var(--gold-light); }
.debrief-score-card.ai .dsc-value { color: #c8c0dc; }

.debrief-xp-gain {
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.xp-gain-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold-light);
    margin-bottom: 8px;
    animation: xpPop 0.5s ease-out;
}
@keyframes xpPop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.debrief-transcript {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.debrief-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.8rem;
    line-height: 1.5;
}
.debrief-msg.user {
    align-self: flex-end;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.15);
    max-width: 85%;
}
.debrief-msg.ai {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    max-width: 85%;
}
.debrief-tips {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 16px;
}
.debrief-tips h3 {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: var(--gold);
    margin-bottom: 10px;
}
.debrief-tips ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.debrief-tips li {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.5;
    padding-left: 16px;
    position: relative;
}
.debrief-tips li::before {
    content: '\2192';
    position: absolute;
    left: 0;
    color: var(--gold);
}
.debrief-actions { display: flex; gap: 12px; width: 100%; }

/* ═══════════════════════════════════════════
   LEVEL UP OVERLAY
   ═══════════════════════════════════════════ */
.level-up-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 12, 20, 0.9);
    backdrop-filter: blur(10px);
}
.level-up-overlay.active { display: flex; }
.level-up-content {
    text-align: center;
    position: relative;
    animation: levelUpIn 0.6s ease-out;
}
@keyframes levelUpIn {
    0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
    60% { transform: scale(1.1) rotate(2deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}
.level-up-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212,168,71,0.3) 0%, transparent 70%);
    animation: burstPulse 1.5s ease-in-out infinite;
}
@keyframes burstPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.8; }
}
.level-up-text {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    letter-spacing: 0.4em;
    color: var(--gold);
    position: relative;
}
.level-up-number {
    font-family: 'Cinzel', serif;
    font-size: 10rem;
    font-weight: 900;
    color: var(--gold-light);
    text-shadow: 0 0 100px rgba(212, 168, 71, 0.5);
    line-height: 1;
    position: relative;
}
.level-up-name {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--text);
    margin-top: 8px;
    position: relative;
}
.level-up-unlock {
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--success);
    position: relative;
}

/* ═══════════════════════════════════════════
   XP POPUP & COMBO
   ═══════════════════════════════════════════ */
.xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow: 0 0 20px rgba(212, 168, 71, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: none;
}
.xp-popup.show {
    animation: xpFloat 1.5s ease-out forwards;
}
@keyframes xpFloat {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -70%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -150%) scale(0.8); }
}

.combo-counter {
    position: fixed;
    top: 15%;
    right: 20px;
    z-index: 500;
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    font-weight: 900;
    color: var(--gold-light);
    text-shadow: 0 0 30px rgba(212, 168, 71, 0.4);
    pointer-events: none;
    opacity: 0;
    text-align: right;
}
.combo-counter.show {
    animation: comboIn 0.4s ease-out forwards;
}
@keyframes comboIn {
    0% { opacity: 0; transform: scale(0.5) translateX(20px); }
    60% { transform: scale(1.1) translateX(-2px); }
    100% { opacity: 1; transform: scale(1) translateX(0); }
}
.combo-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    color: var(--gold);
    font-weight: 600;
}

/* ═══════════════════════════════════════════
   PROFILE VIEW
   ═══════════════════════════════════════════ */
#view-profile {
    padding: 20px;
    padding-top: calc(20px + var(--safe-top));
    overflow-y: auto;
    z-index: 10;
}
.profile-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}
.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
}
.profile-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    color: var(--gold);
    letter-spacing: 0.1em;
}
.profile-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
#profile-radar-big { max-width: 300px; }
.profile-bias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    width: 100%;
}
.bias-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}
.bias-card-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.bias-card-bar {
    height: 4px;
    background: rgba(100, 140, 200, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}
.bias-card-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}
.bias-card-stats {
    font-size: 0.6rem;
    color: var(--text-muted);
}
.profile-history { width: 100%; }
.profile-history h3 {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: var(--gold);
    margin-bottom: 10px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
    .game-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        position: relative;
    }
    .game-sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(100,140,200,0.06);
        padding: 6px 8px;
        max-height: 40vh;
        overflow-y: auto;
    }
    .game-center {
        position: absolute;
        inset: 0;
        z-index: 0;
        pointer-events: none;
        opacity: 0.35;
    }
    .game-chat-col {
        border-left: none;
        position: relative;
        z-index: 1;
    }
    .chat-area {
        background: linear-gradient(180deg, rgba(10,12,20,0.7) 0%, rgba(10,12,20,0.85) 100%);
    }
    .game-footer {
        left: 0;
        right: 0;
    }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE
   ═══════════════════════════════════════════ */
@media (max-width: 600px) {
    /* Lobby */
    .lobby-title { font-size: 1.6rem; letter-spacing: 0.1em; }
    .lobby-tagline { font-size: 0.7rem; }
    .lobby-stats-row { grid-template-columns: repeat(4, 1fr); gap: 4px; }
    .stat-card { padding: 8px 4px; border-radius: 8px; }
    .stat-value { font-size: 0.9rem; }
    .stat-label { font-size: 0.45rem; }
    .lobby-actions { flex-direction: column; gap: 8px; }
    .btn { width: 100%; padding: 14px 20px; font-size: 0.8rem; }
    .level-preview { padding: 10px 14px; }
    .level-preview-title { font-size: 0.8rem; }
    .level-preview-desc { font-size: 0.7rem; }
    .lobby-level-badge { padding: 6px 14px; }
    .lobby-level-badge .level-number { font-size: 1.6rem; }
    .xp-bar-container { max-width: 300px; }
    .lobby-container { gap: 14px; }

    /* Game header */
    .game-header { padding: 8px 10px; padding-top: calc(8px + var(--safe-top)); }
    .game-back-btn { width: 28px; height: 28px; font-size: 0.9rem; }
    .game-level-badge { font-size: 0.5rem; padding: 2px 7px; }
    .round-label { font-size: 0.55rem; }
    .score-pill { padding: 3px 8px; font-size: 0.5rem; }

    /* Sidebar on mobile */
    .game-sidebar { padding: 4px 6px; }
    .sidebar-panel { max-height: none; }
    .sidebar-header { padding: 6px 8px 4px; }
    .sidebar-body { padding: 4px 8px 6px; }
    .sidebar-footer { padding: 0 8px 4px; }
    .cyber-tag { font-size: 0.4rem; }
    .cyber-objective-text { font-size: 0.68rem; line-height: 1.35; margin-bottom: 3px; }
    .cyber-context-text { font-size: 0.62rem; line-height: 1.4; }

    /* Chat */
    .chat-area { padding: 6px 8px; padding-bottom: 60px; }
    .chat-msg { font-size: 0.78rem; padding: 8px 10px; max-width: 90%; }

    /* Footer input */
    .game-footer { padding: 6px 8px; padding-bottom: calc(6px + var(--safe-bottom)); }
    .input-wrap { border-radius: 12px; padding: 4px 4px 4px 12px; }
    #msg-input, #defense-freetext { font-size: 0.82rem; padding: 6px 0; }
    .btn-send { width: 36px; height: 36px; border-radius: 8px; }
    .btn-send svg { width: 14px; height: 14px; }

    /* Defense choices */
    .choice-option { padding: 10px 12px; font-size: 0.78rem; border-radius: 10px; }

    /* Debrief */
    .debrief-scores { flex-direction: column; gap: 8px; }
    .debrief-title { font-size: 1.3rem; }
    .dsc-value { font-size: 1.6rem; }
    .debrief-score-card { padding: 12px 20px; }
    .xp-gain-amount { font-size: 1.1rem; }
    .debrief-actions { flex-direction: column; gap: 8px; }

    /* Transitions */
    .transition-level-num { font-size: 5rem; }
    .transition-level-name { font-size: 1rem; }
    .level-up-number { font-size: 5rem; }
    .level-up-name { font-size: 1.1rem; }

    /* Profile */
    .profile-bias-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE
   ═══════════════════════════════════════════ */
@media (max-width: 380px) {
    .lobby-title { font-size: 1.3rem; }
    .lobby-stats-row { grid-template-columns: repeat(2, 1fr); }
    .game-header { gap: 4px; }
    .score-pill { padding: 2px 6px; font-size: 0.45rem; }
    .sidebar-panel { max-height: none; }
}
