/* ==========================================
   NERVEJACK GAME UI
   ========================================== */

:root {
    --bg: #050505;
    --term: #4af626;
    --alert: #ff4444;
    --rule: #ffaa00;
    --debug: #00ffff;
    --state: #d633ff;
    --neon-blue: #00d4ff;
    --border: #222;
    --font: 'JetBrains Mono', 'Consolas', monospace;
}

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

html {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    background: var(--bg);
    color: #ccc;
    font-family: var(--font);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ==========================================
   ACCESSIBILITY: SCREEN-READER ONLY
   ========================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:focus {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    width: auto;
    height: auto;
    padding: 0.8rem 1.5rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--bg);
    color: var(--term);
    border: 2px solid var(--term);
    font-family: var(--font);
    font-size: 0.85rem;
    text-decoration: none;
}

/* ==========================================
   ACCESSIBILITY: FOCUS STYLES
   ========================================== */
:focus-visible {
    outline: 2px solid var(--term);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================
   AUTH GATE
   ========================================== */
#auth-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    gap: 1.5rem;
    text-align: center;
    padding: 2rem;
}

#auth-gate h1 {
    font-size: 2.5rem;
    color: var(--term);
    letter-spacing: 4px;
}

#auth-gate p {
    color: #8a8a8a;
    font-size: 0.9rem;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    max-width: 300px;
}

.auth-btn {
    display: block;
    padding: 0.8rem 1.5rem;
    text-decoration: none;
    font-family: var(--font);
    font-size: 0.8rem;
    outline: none;
    text-align: center;
    border: 1px solid var(--border);
    letter-spacing: 1px;
    transition: all 0.2s;
}

.auth-btn.google {
    background: #fff;
    color: #333;
}

.auth-btn.google:hover {
    background: #f0f0f0;
}

.auth-btn.discord {
    background: #5865F2;
    color: #fff;
    border-color: #5865F2;
}

.auth-btn.discord:hover {
    background: #4752C4;
}

.auth-btn.guest {
    background: transparent;
    color: #888;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.auth-btn.guest:hover {
    color: #ccc;
    border-color: #555;
}

.auth-btn.guest .guest-note {
    font-size: 0.6rem;
    color: #555;
    letter-spacing: 0.5px;
}

.auth-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #333;
    font-size: 0.65rem;
    letter-spacing: 1px;
}

.auth-separator::before,
.auth-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #222;
}

/* Anonymous banner */
#anon-banner {
    background: rgba(255, 170, 0, 0.08);
    text-align: center;
    font-size: 0.6rem;
    color: #aa8800;
    padding: 4px 10px;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 170, 0, 0.2);
    position: relative;
    z-index: 1;
}

#anon-banner a {
    color: var(--neon-blue);
    text-decoration: none;
    margin-left: 8px;
}

#anon-banner a:hover {
    text-decoration: underline;
}

/* Sign-in nudge */
.sign-in-nudge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 170, 0, 0.08);
    border: 1px solid rgba(255, 170, 0, 0.2);
    font-size: 0.75rem;
    color: #aa8800;
    margin: 0 8px 4px 8px;
    animation: nudge-in 0.3s ease;
}

.sign-in-nudge.blocking {
    background: rgba(255, 68, 68, 0.08);
    border-color: rgba(255, 68, 68, 0.3);
    color: var(--alert);
}

.nudge-msg {
    flex: 1;
}

.nudge-btn {
    background: transparent;
    border: 1px solid currentColor;
    color: var(--neon-blue);
    padding: 4px 12px;
    font-family: var(--font);
    font-size: 0.7rem;
    cursor: pointer;
    letter-spacing: 1px;
    white-space: nowrap;
}

.nudge-btn:hover {
    background: rgba(0, 212, 255, 0.1);
}

.nudge-dismiss {
    background: transparent;
    border: none;
    color: #555;
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.nudge-dismiss:hover {
    color: #888;
}

.turns-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 170, 0, 0.08);
    border: 1px solid rgba(255, 170, 0, 0.2);
    font-size: 0.75rem;
    color: #aa8800;
    margin: 0 8px 4px 8px;
    animation: nudge-in 0.3s ease;
}

.upgrade-link {
    color: var(--neon-blue);
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
}

.upgrade-link:hover {
    border-bottom-color: var(--neon-blue);
}

@keyframes nudge-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.back-link {
    color: #8a8a8a;
    text-decoration: none;
    font-size: 0.75rem;
    margin-top: 1rem;
}

.back-link:hover {
    color: #b0b0b0;
}

/* ==========================================
   GAME CONTAINER
   ========================================== */
#game-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    width: 100%;
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Header */
header {
    padding: 10px 15px;
    background: #0a0a0a;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

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

h1.title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--term);
    letter-spacing: 2px;
}

.arch-title {
    font-weight: 700;
}

.subtitle {
    font-size: 0.65rem;
    color: #8a8a8a;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 2px 8px;
    border: 1px solid #333;
}

.header-discord {
    display: flex;
    align-items: center;
    color: #444;
    transition: color 0.2s;
}

.header-discord:hover {
    color: var(--term);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.usage {
    font-size: 0.7rem;
    color: #8a8a8a;
}

.header-btn {
    background: #1a1a1a;
    color: #888;
    border: 1px solid #333;
    padding: 4px 12px;
    font-size: 0.7rem;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.2s;
}

@media (hover: hover) {
    .header-btn:hover {
        color: var(--term);
        border-color: var(--term);
    }
}

/* TTS toggle switch */
.tts-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.tts-label {
    font-size: 0.7rem;
    color: #888;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.tts-switch input {
    display: none;
}

.tts-slider {
    position: relative;
    width: 28px;
    height: 14px;
    background: #333;
    border-radius: 7px;
    transition: background 0.2s;
}

.tts-slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: #888;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.tts-switch input:checked + .tts-slider {
    background: #1a3a1a;
}

.tts-switch input:checked + .tts-slider::after {
    transform: translateX(14px);
    background: var(--term);
}

/* Beta banner */
#beta-banner {
    background: #111;
    text-align: center;
    font-size: 0.6rem;
    color: #555;
    padding: 4px 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 1;
}

#beta-banner a {
    color: var(--neon-blue);
    text-decoration: none;
    margin-left: 12px;
}

#beta-banner a:hover {
    text-decoration: underline;
}

/* State display */
#state-display {
    font-size: 0.8rem;
    color: var(--state);
    padding: 4px 10px;
    border-bottom: 1px solid var(--border);
    background: #0a050a;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.state-row-top {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.75rem;
}

.state-row-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
}

#st-loc {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#st-credits {
    color: var(--rule);
}

.inv-btn {
    background: rgba(214, 51, 255, 0.08);
    border: 1px solid var(--state);
    color: var(--state);
    font-family: var(--font);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 8px;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.inv-btn:hover {
    background: rgba(214, 51, 255, 0.18);
    border-color: var(--neon-blue);
}

.inv-btn:active {
    border-color: var(--neon-blue);
    background: rgba(214, 51, 255, 0.25);
}

#inv-count {
    display: inline-block;
    background: var(--state);
    color: var(--bg);
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 14px;
    text-align: center;
    padding: 0 3px;
    border-radius: 2px;
    margin-left: 3px;
    vertical-align: middle;
}

#st-time {
    color: var(--rule);
    font-size: 0.75rem;
}

#model-status {
    margin-left: auto;
    color: #767676;
    font-size: 0.65rem;
    text-transform: uppercase;
}

/* Game log */
#game-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    font-size: 1.05rem;
    line-height: 1.6;
}

.role-user {
    color: #5c9eff;
    font-weight: bold;
    margin-top: 25px;
    border-top: 1px solid var(--border);
    padding-top: 15px;
}

.role-dm {
    color: #e0e0e0;
    margin-bottom: 10px;
    position: relative;
}

/* Share turn button */
.share-turn-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 26px;
    height: 26px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #444;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 1;
}
.role-dm:hover .share-turn-btn,
.share-turn-btn:focus-visible {
    opacity: 1;
}
.share-turn-btn:hover {
    color: var(--term);
    border-color: var(--border);
    background: #111;
}
.share-turn-btn:active {
    color: var(--neon-blue);
}
.share-toast {
    position: absolute;
    top: -4px;
    right: 30px;
    background: #111;
    border: 1px solid var(--term);
    color: var(--term);
    font-size: 0.65rem;
    font-family: var(--font);
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    animation: share-toast-fade 1.5s ease forwards;
}
@keyframes share-toast-fade {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
}
@media (hover: none) {
    .share-turn-btn { opacity: 0.3; }
}

.role-ooc {
    font-style: italic;
    opacity: 0.7;
}
.role-user.role-ooc::before {
    content: "[OOC] ";
}

.role-sys {
    color: #8a8a8a;
    font-size: 0.75rem;
    font-style: italic;
    margin-top: 5px;
    border-left: 2px solid var(--state);
    padding-left: 10px;
}

.state-tick {
    color: var(--state);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: 4px 0 8px;
    opacity: 0.6;
}

.error-msg {
    color: var(--alert);
    font-style: italic;
}

/* Input area */
#input-area {
    padding: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #333;
    display: flex;
    gap: 10px;
    background: #0a0a0a;
    align-items: flex-end;
}

#user-input {
    flex: 1;
    background: #111;
    border: 1px solid #333;
    color: white;
    padding: 12px;
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    resize: none;
    overflow-y: hidden;
    line-height: 1.4;
    min-height: 42px;
    max-height: 120px;
}

#user-input:focus {
    border-color: var(--term);
}

#user-input:disabled {
    opacity: 0.5;
}

#send-btn {
    background: #1a1a1a;
    color: var(--term);
    border: 1px solid #333;
    padding: 0 25px;
    align-self: stretch;
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.2s;
}

#send-btn:hover {
    background: var(--term);
    color: var(--bg);
}

/* ==========================================
   DRAWER
   ========================================== */
#drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#drawer-backdrop.open {
    opacity: 1;
    visibility: visible;
}

#drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 101;
    background: #0a0a0a;
    border-top: 1px solid var(--state);
    max-height: 75vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease-out, visibility 0.3s;
    visibility: hidden;
    padding: 0 16px 24px;
    -webkit-overflow-scrolling: touch;
}

#drawer.open {
    transform: translateY(0);
    visibility: visible;
}

.drawer-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 8px;
    cursor: grab;
}

.drawer-handle span {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #444;
}

.drawer-section {
    margin-bottom: 20px;
}

.drawer-heading {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--neon-blue);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid #1a1a1a;
}

/* Status rows */
.drawer-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.85rem;
}

.drawer-label {
    color: #8a8a8a;
    min-width: 70px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.drawer-credits {
    color: var(--rule);
}

.drawer-location {
    color: #ccc;
}

/* HP bar */
.drawer-hp-track {
    flex: 1;
    height: 8px;
    background: #1a1a1a;
    border-radius: 4px;
    overflow: hidden;
}

.drawer-hp-fill {
    height: 100%;
    background: var(--term);
    border-radius: 4px;
    transition: width 0.4s ease, background-color 0.3s;
}

.drawer-hp-fill.low {
    background: var(--rule);
}

.drawer-hp-fill.critical {
    background: var(--alert);
}

.drawer-hp-text {
    font-size: 0.8rem;
    color: #999;
    min-width: 70px;
    text-align: right;
}

/* Inventory items */
.drawer-item {
    padding: 8px 10px;
    border-bottom: 1px solid #151515;
    font-size: 0.85rem;
    color: #ccc;
}

.drawer-item:last-child {
    border-bottom: none;
}

.drawer-logout {
    background: none;
    border: 1px solid #333;
    color: #888;
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 6px 16px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    width: 100%;
}

.drawer-empty {
    color: #767676;
    font-style: italic;
    font-size: 0.8rem;
    padding: 8px 0;
}

/* Inventory item tags */
.item-tag {
    display: inline-block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1px 6px;
    border-radius: 2px;
    margin-left: 8px;
    vertical-align: middle;
}

.tag-melee-weapon {
    color: #ff4444;
    border: 1px solid #ff4444;
}

.tag-ranged-weapon {
    color: #ff6b35;
    border: 1px solid #ff6b35;
}

.tag-armor {
    color: #00ffff;
    border: 1px solid #00ffff;
}

.tag-hacking {
    color: #4af626;
    border: 1px solid #4af626;
}

.tag-medical {
    color: #ff69b4;
    border: 1px solid #ff69b4;
}

.tag-utility {
    color: #ffaa00;
    border: 1px solid #ffaa00;
}

.tag-junk {
    color: #8a8a8a;
    border: 1px solid #666;
}

/* Quests */
.drawer-quest {
    padding: 8px 10px;
    border-bottom: 1px solid #151515;
}

.drawer-quest:last-child {
    border-bottom: none;
}

.quest-badge {
    display: inline-block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1px 6px;
    border-radius: 2px;
    vertical-align: middle;
}

.quest-badge.active {
    color: var(--term);
    border: 1px solid var(--term);
}

.quest-badge.completed {
    color: var(--neon-blue);
    border: 1px solid var(--neon-blue);
}

.quest-badge.failed {
    color: var(--alert);
    border: 1px solid var(--alert);
}

.quest-name {
    font-size: 0.85rem;
    color: #ccc;
    margin-left: 6px;
}

.quest-desc {
    font-size: 0.75rem;
    color: #8a8a8a;
    margin-top: 4px;
    padding-left: 2px;
}

/* NPCs */
.drawer-npc {
    padding: 8px 10px;
    border-bottom: 1px solid #151515;
}

.drawer-npc:last-child {
    border-bottom: none;
}

.npc-name {
    font-size: 0.85rem;
    color: #ccc;
}

.npc-rel {
    font-size: 0.75rem;
    color: var(--state);
    margin-top: 2px;
}

.npc-seen {
    font-size: 0.7rem;
    color: #8a8a8a;
    margin-top: 2px;
}

.npc-notes {
    font-size: 0.75rem;
    color: #8a8a8a;
    margin-top: 2px;
}

.drawer-npc-dead { opacity: 0.4; }
.npc-dead-tag { color: var(--alert); font-size: 0.65rem; }

/* Factions */
.drawer-faction {
    padding: 8px 10px;
    border-bottom: 1px solid #151515;
}

.drawer-faction:last-child {
    border-bottom: none;
}

.faction-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.faction-name {
    font-size: 0.85rem;
    color: #ccc;
    text-transform: capitalize;
}

.faction-tier {
    font-size: 0.65rem;
    letter-spacing: 1px;
    padding: 1px 6px;
    border-radius: 2px;
}

.tier-unknown { color: #666; }
.tier-known { color: var(--neon-blue); }
.tier-trusted { color: #4af626; }
.tier-inner-circle { color: #d633ff; }
.tier-unfriendly { color: #ffaa00; }
.tier-hostile { color: var(--alert); }

.faction-rep-bar {
    height: 3px;
    background: #1a1a1a;
    border-radius: 2px;
    overflow: hidden;
}

.faction-rep-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.faction-rep-fill.tier-unknown { background: #333; }
.faction-rep-fill.tier-known { background: var(--neon-blue); }
.faction-rep-fill.tier-trusted { background: #4af626; }
.faction-rep-fill.tier-inner-circle { background: #d633ff; }
.faction-rep-fill.tier-unfriendly { background: #ffaa00; }
.faction-rep-fill.tier-hostile { background: var(--alert); }

/* Heat indicator */
.heat-indicator {
    font-size: 0.7rem;
    letter-spacing: 1px;
    color: #666;
}
.heat-indicator.heat-rising { color: #ffaa00; }
.heat-indicator.heat-high { color: #ff6600; }
.heat-indicator.heat-extreme { color: var(--alert); animation: heat-pulse 1s ease-in-out infinite; }

@keyframes heat-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==========================================
   UPGRADE MODAL
   ========================================== */
#upgrade-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#upgrade-backdrop.open {
    opacity: 1;
    visibility: visible;
}

#upgrade-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 301;
    background: #0a0a0a;
    border: 1px solid #222;
    padding: 28px 24px 24px;
    width: 92%;
    max-width: 480px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

#upgrade-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.upgrade-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #555;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
}

.upgrade-close:hover {
    color: #ccc;
}

.upgrade-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #666;
    letter-spacing: 3px;
    text-align: center;
    margin-bottom: 20px;
}

.upgrade-accent {
    color: var(--term);
}

.upgrade-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.upgrade-card {
    border: 1px solid #222;
    padding: 20px 16px;
    text-align: center;
    position: relative;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.upgrade-card.plus {
    border-color: var(--term);
    box-shadow:
        0 0 20px rgba(74, 246, 38, 0.08),
        inset 0 0 20px rgba(74, 246, 38, 0.02);
}

.upgrade-card.plus:hover {
    box-shadow:
        0 0 30px rgba(74, 246, 38, 0.15),
        inset 0 0 30px rgba(74, 246, 38, 0.04);
}

.upgrade-card.pro {
    border-color: var(--neon-blue);
    box-shadow:
        0 0 20px rgba(0, 212, 255, 0.08),
        inset 0 0 20px rgba(0, 212, 255, 0.02);
}

.upgrade-card.pro:hover {
    box-shadow:
        0 0 30px rgba(0, 212, 255, 0.15),
        inset 0 0 30px rgba(0, 212, 255, 0.04);
}

.upgrade-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--term);
    color: var(--bg);
    font-size: 0.55rem;
    font-weight: 700;
    padding: 3px 10px;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

.upgrade-tier {
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: #666;
    margin-bottom: 8px;
    margin-top: 4px;
}

.upgrade-price {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
}

.upgrade-period {
    font-size: 0.8rem;
    color: #555;
    font-weight: 400;
}

.upgrade-features {
    list-style: none;
    margin-bottom: 16px;
    padding: 0;
}

.upgrade-features li {
    padding: 5px 0;
    font-size: 0.75rem;
    color: #999;
    border-bottom: 1px solid #111;
}

.upgrade-features li:last-child {
    border-bottom: none;
}

.upgrade-btn {
    display: block;
    width: 100%;
    font-family: var(--font);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 10px 0;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    border: 1px solid;
}

.upgrade-btn-plus {
    background: var(--term);
    color: var(--bg);
    border-color: var(--term);
}

.upgrade-btn-plus:hover {
    background: transparent;
    color: var(--term);
    box-shadow: 0 0 15px rgba(74, 246, 38, 0.3);
}

.upgrade-btn-pro {
    background: transparent;
    color: var(--neon-blue);
    border-color: var(--neon-blue);
}

.upgrade-btn-pro:hover {
    background: var(--neon-blue);
    color: var(--bg);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

/* Mobile: stack cards vertically on very small screens */
@media (max-width: 360px) {
    .upgrade-cards {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ==========================================
   REPORT ISSUE MODAL
   ========================================== */
#report-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#report-backdrop.open {
    opacity: 1;
    visibility: visible;
}

#report-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 201;
    background: #0a0a0a;
    border: 1px solid var(--state);
    padding: 20px;
    width: 90%;
    max-width: 420px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

#report-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.report-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--neon-blue);
    letter-spacing: 2px;
    margin-bottom: 12px;
}

#report-message {
    width: 100%;
    background: #111;
    border: 1px solid #333;
    color: #ccc;
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 10px;
    outline: none;
    resize: vertical;
    min-height: 80px;
}

#report-message:focus {
    border-color: var(--state);
}

#report-message::placeholder {
    color: #555;
}

.report-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.report-btn {
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 6px 16px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.2s;
}

.report-btn-cancel {
    background: transparent;
    border: 1px solid #333;
    color: #888;
}

.report-btn-cancel:hover {
    color: #ccc;
    border-color: #555;
}

.report-btn-send {
    background: transparent;
    border: 1px solid var(--state);
    color: var(--state);
}

.report-btn-send:hover {
    background: var(--state);
    color: var(--bg);
}

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

#report-flash {
    font-size: 0.75rem;
    margin-top: 8px;
}

#report-flash .flash-success {
    color: var(--term);
}

#report-flash .flash-error {
    color: var(--alert);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
    #game-container {
        border: none;
    }

    header {
        padding: 8px 10px;
    }

    #game-log {
        padding: 12px;
        font-size: 0.95rem;
    }

    #input-area {
        padding: 10px;
    }

    /* Prevent iOS Safari auto-zoom on input focus */
    #user-input {
        font-size: 16px;
    }

    #state-display {
        font-size: 0.7rem;
    }

    .state-row-top {
        gap: 8px;
        font-size: 0.65rem;
    }

    .inv-btn {
        font-size: 0.65rem;
    }
}

@media (min-width: 769px) {
    #drawer {
        top: 0;
        bottom: 0;
        right: 0;
        left: auto;
        max-height: none;
        width: 380px;
        max-width: 40vw;
        border-top: none;
        border-left: 1px solid var(--state);
        transform: translateX(100%);
        transition: transform 0.3s ease-out;
        padding-top: 16px;
    }

    #drawer.open {
        transform: translateX(0);
    }

    .drawer-handle {
        display: none;
    }
}

/* ==========================================
   ARCHETYPE PICKER
   ========================================== */
#archetype-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    padding: 2rem;
    gap: 2rem;
}

.arch-header {
    text-align: center;
}

.arch-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--term);
    letter-spacing: 4px;
    margin-bottom: 0.5rem;
}

.arch-subtitle {
    font-size: 0.8rem;
    color: #8a8a8a;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 400;
}

.arch-tagline {
    font-size: 0.75rem;
    color: #555;
    margin-top: 0.25rem;
    letter-spacing: 1px;
}

/* Terminal intro typewriter */
.arch-intro {
    text-align: left;
    max-width: 600px;
    width: 100%;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.arch-intro-line {
    font-size: 0.8rem;
    color: var(--term);
    line-height: 1.8;
}

.arch-intro-line.amber {
    color: var(--rule);
}

.arch-cursor::after {
    content: "▊";
    animation: cursor-blink 0.6s step-end infinite;
    color: inherit;
    margin-left: 1px;
}

/* Grid hidden until intro finishes */
.arch-grid--hidden {
    opacity: 0;
    pointer-events: none;
}

.arch-grid--reveal {
    animation: fade-in 0.3s ease forwards;
    pointer-events: auto;
}

/* Footer link */
.arch-footer {
    font-size: 0.7rem;
    color: #555;
    opacity: 0;
    transition: opacity 0.4s;
}

.arch-footer.visible {
    opacity: 1;
}

.arch-info-link {
    color: var(--term);
    text-decoration: none;
}

.arch-info-link:hover {
    text-decoration: underline;
}

/* Jack-in transition */
.arch-card--selected {
    border-color: var(--term) !important;
    box-shadow: 0 0 25px rgba(74, 246, 38, 0.3);
}

.arch-card--fade {
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#arch-jackin {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 25vh calc(50vw - 300px) 2rem;
    opacity: 0;
    transition: opacity 0.2s;
    overflow: hidden;
}

#arch-jackin.visible {
    opacity: 1;
}

.jackin-line {
    font-size: 0.8rem;
    color: var(--term);
    line-height: 1.8;
}

.jackin-line.ok {
    color: var(--state);
}

.jackin-line.warn {
    color: var(--rule);
}

.jackin-line.err {
    color: var(--alert);
    font-weight: 700;
}

/* Glitch on archetype screen before transition */
@keyframes arch-glitch {
    0%   { clip-path: inset(0 0 0 0); transform: translate(0); filter: none; }
    15%  { clip-path: inset(30% 0 40% 0); transform: translate(-6px, 3px); filter: hue-rotate(40deg) brightness(1.5); }
    30%  { clip-path: inset(70% 0 5% 0); transform: translate(5px, -3px); filter: hue-rotate(-30deg) brightness(1.3); }
    45%  { clip-path: inset(10% 0 60% 0); transform: translate(-3px, 1px); filter: hue-rotate(20deg); }
    60%  { clip-path: inset(0 0 0 0); transform: translate(0); filter: none; }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); filter: none; }
}

.arch-glitch {
    animation: arch-glitch 0.2s ease;
}

/* Screen shake — mild (during error cascade) */
@keyframes jackin-shake {
    0%, 100% { transform: translate(0); }
    25% { transform: translate(-1px, 1px); }
    50% { transform: translate(1px, -1px); }
    75% { transform: translate(-1px, 0); }
}

.jackin-shake {
    animation: jackin-shake 0.18s linear infinite;
}

/* Screen glitch — hard (meltdown phase): less movement, more color corruption */
@keyframes jackin-shake-hard {
    0%, 100% { transform: translate(0); filter: none; }
    10% { transform: translate(-3px, 2px); filter: hue-rotate(60deg) saturate(3) brightness(1.6); }
    20% { transform: translate(2px, -2px); filter: hue-rotate(-80deg) saturate(4) brightness(1.8) contrast(1.4); }
    30% { transform: translate(-2px, 3px); filter: hue-rotate(40deg) saturate(2) brightness(1.3); }
    40% { transform: translate(3px, -1px); filter: hue-rotate(-50deg) saturate(5) brightness(2) contrast(1.6); }
    50% { transform: translate(-1px, 2px); filter: hue-rotate(90deg) saturate(3) brightness(1.5); }
    60% { transform: translate(2px, -3px); filter: hue-rotate(-70deg) saturate(4) brightness(1.9) contrast(1.5); }
    70% { transform: translate(-3px, 1px); filter: hue-rotate(70deg) saturate(3) brightness(1.7); }
    80% { transform: translate(1px, -2px); filter: hue-rotate(-90deg) saturate(5) brightness(2) contrast(1.8); }
    90% { transform: translate(-2px, 2px); filter: hue-rotate(50deg) saturate(4) brightness(1.6); }
}

.jackin-shake-hard {
    animation: jackin-shake-hard 0.1s linear infinite;
}

.jackin-line.hex {
    font-size: 0.65rem;
    color: var(--alert);
    opacity: 0.7;
    letter-spacing: 1px;
    line-height: 1.4;
}

.jackin-line.binary {
    font-size: 0.6rem;
    color: var(--term);
    opacity: 0.5;
    letter-spacing: 0.5px;
    line-height: 1.3;
}

.jackin-line.blocks {
    font-size: 0.75rem;
    color: var(--alert);
    line-height: 1.2;
    letter-spacing: -1px;
}

/* Meltdown canvas overlay */
#jackin-melt-canvas {
    position: fixed;
    inset: 0;
    z-index: 201;
    width: 100%;
    height: 100%;
}

/* Hard black after crash */
.jackin-black {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 200;
}

@media (max-width: 500px) {
    #arch-jackin {
        padding: 15vh 1.5rem 2rem;
    }
}

.arch-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    max-width: 600px;
    width: 100%;
}

.arch-card {
    background: #0a0a0a;
    border: 1px solid #222;
    padding: 1.25rem;
    text-align: left;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.arch-card:hover {
    border-color: var(--term);
    box-shadow: 0 0 15px rgba(74, 246, 38, 0.1);
}

.arch-card:active {
    background: #111;
}

.arch-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--term);
    letter-spacing: 1px;
}

.arch-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
}

.arch-hp {
    color: var(--state);
}

.arch-cr {
    color: var(--rule);
}

.arch-gear {
    font-size: 0.75rem;
    color: var(--neon-blue);
}

.arch-desc {
    font-size: 0.7rem;
    color: #8a8a8a;
    line-height: 1.4;
}

@media (max-width: 500px) {
    .arch-grid {
        grid-template-columns: 1fr;
    }

    #archetype-screen {
        padding: 1.5rem;
        justify-content: flex-start;
        padding-top: 3rem;
        overflow-y: auto;
    }

    .arch-intro-line {
        font-size: 0.75rem;
    }

    .arch-intro {
        min-height: 160px;
    }
}

/* ==========================================
   LIFEPATH CHARACTER CREATION
   ========================================== */
.lifepath-container {
    max-width: 600px;
    width: 100%;
    animation: fade-in 0.3s ease forwards;
    overflow-y: auto;
}

.lp-step-indicator {
    font-size: 0.6rem;
    color: #555;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.lp-step-title {
    font-size: 0.7rem;
    color: var(--rule);
    letter-spacing: 2px;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.lp-prompt {
    font-size: 0.8rem;
    color: var(--term);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.lp-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    animation: fade-in 0.3s ease forwards;
}

.lp-option {
    background: #0a0a0a;
    border: 1px solid #222;
    padding: 0.7rem 1rem;
    text-align: left;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.lp-option:hover {
    border-color: var(--term);
    box-shadow: 0 0 15px rgba(74, 246, 38, 0.1);
}

.lp-option--selected {
    border-color: var(--term);
    box-shadow: 0 0 20px rgba(74, 246, 38, 0.15);
    background: #0d0d0d;
}

.lp-option--fade {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    overflow: hidden;
    transition: all 0.3s;
}

.lp-option-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--term);
    letter-spacing: 1px;
}

.lp-option-desc {
    font-size: 0.65rem;
    color: #8a8a8a;
}

/* Dice animation */
.lp-dice {
    width: 72px;
    height: 72px;
    border: 1px solid #333;
    display: grid;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    place-items: center;
    margin: 1.25rem auto;
    transition: border-color 0.3s, color 0.3s;
}

.lp-dice .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.05s;
}

.lp-dice .dot.active {
    background: currentColor;
}

.lp-dice--good {
    color: var(--term);
    border-color: var(--term);
}

.lp-dice--mixed {
    color: var(--rule);
    border-color: var(--rule);
}

.lp-dice--bad {
    color: var(--alert);
    border-color: var(--alert);
}

@keyframes dice-land {
    0% { transform: scale(1.15); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.lp-dice--landed {
    animation: dice-land 0.25s ease-out;
}

.lp-roll-label {
    text-align: center;
    font-size: 0.7rem;
    letter-spacing: 2px;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.lp-roll-label--good { color: var(--term); }
.lp-roll-label--mixed { color: var(--rule); }
.lp-roll-label--bad { color: var(--alert); }

/* Outcome text */
.lp-outcome {
    font-size: 0.75rem;
    line-height: 1.6;
    color: #ccc;
    margin: 0.75rem 0 1rem;
    padding-left: 0.75rem;
    border-left: 2px solid #333;
}

.lp-outcome--good { border-left-color: var(--term); }
.lp-outcome--mixed { border-left-color: var(--rule); }
.lp-outcome--bad { border-left-color: var(--alert); }

.lp-outcome-bonus {
    font-size: 0.65rem;
    color: var(--neon-blue);
    margin-top: 0.3rem;
}

.lp-divider {
    border: none;
    border-top: 1px solid #1a1a1a;
    margin: 1rem 0;
}

/* Summary screen */
.lp-summary-title {
    font-size: 0.7rem;
    color: var(--rule);
    letter-spacing: 2px;
    font-weight: 700;
    margin-bottom: 1rem;
}

.lp-summary-bg {
    font-size: 0.7rem;
    color: #bbb;
    line-height: 1.7;
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid #1a1a1a;
    background: #050505;
}

.lp-summary-detail {
    font-size: 0.65rem;
    color: var(--neon-blue);
    margin-bottom: 0.25rem;
}

.lp-summary-detail--bad {
    color: var(--alert);
}

.lp-name-row {
    margin: 1.25rem 0 1rem;
}

.lp-name-label {
    display: block;
    font-size: 0.65rem;
    color: var(--rule);
    letter-spacing: 1px;
    margin-bottom: 0.35rem;
}

.lp-name-optional {
    color: #555;
    font-weight: 400;
}

.lp-name-input {
    width: 100%;
    background: #0a0a0a;
    border: 1px solid #333;
    color: var(--term);
    font-family: var(--font);
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.lp-name-input:focus {
    border-color: var(--term);
}

.lp-name-input::placeholder {
    color: #444;
}

.lp-actions {
    display: flex;
    gap: 0.75rem;
}

.lp-jackin-btn {
    flex: 1;
    background: none;
    border: 1px solid var(--term);
    color: var(--term);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.7rem 1rem;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
}

.lp-jackin-btn:hover {
    background: rgba(74, 246, 38, 0.1);
    box-shadow: 0 0 15px rgba(74, 246, 38, 0.15);
}

.lp-skip-link {
    font-size: 0.6rem;
    color: #555;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 1px;
    transition: color 0.2s;
    background: none;
    border: none;
    font-family: var(--font);
    padding: 0;
    margin-bottom: 1rem;
    display: inline-block;
}

.lp-continue-btn {
    display: block;
    margin: 1.5rem 0 0.5rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--term);
    color: var(--term);
    font-family: var(--font);
    font-size: 0.85rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

.lp-continue-btn:hover {
    background: rgba(74, 246, 38, 0.08);
    box-shadow: 0 0 12px rgba(74, 246, 38, 0.3);
}

.lp-continue-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.lp-skip-link:hover {
    color: #888;
}

.lp-back-btn {
    font-size: 0.6rem;
    color: #555;
    cursor: pointer;
    background: none;
    border: 1px solid #333;
    font-family: var(--font);
    padding: 0.25rem 0.5rem;
    letter-spacing: 1px;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.lp-back-btn:hover {
    border-color: var(--term);
    color: var(--term);
}

@media (max-width: 500px) {
    .lp-dice {
        width: 60px;
        height: 60px;
    }

    .lp-dice .dot {
        width: 8px;
        height: 8px;
    }
}

/* ==========================================
   GAME OVER — DEATH CARD
   ========================================== */
#game-over-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 5, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: go-fadein 0.6s ease;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.go-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(255, 255, 255, 0.015) 3px,
        rgba(255, 255, 255, 0.015) 4px
    );
    pointer-events: none;
    z-index: 1;
}

@keyframes go-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes go-glitch {
    0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
    10% { clip-path: inset(20% 0 60% 0); transform: translate(-4px, 2px); }
    20% { clip-path: inset(60% 0 10% 0); transform: translate(4px, -2px); }
    30% { clip-path: inset(40% 0 30% 0); transform: translate(-2px, 1px); }
    40% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

.go-card {
    position: relative;
    z-index: 2;
    max-width: 420px;
    width: 100%;
    padding: 2.5rem 2rem;
    text-align: center;
    font-family: var(--font);
    background: #0a0a0a;
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 6px;
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.1), inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.go-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--alert);
    letter-spacing: 0.3em;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px var(--alert);
    animation: go-glitch 0.6s ease forwards;
}

.go-archetype {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--term);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.go-turns {
    font-size: 0.8rem;
    color: #8a8a8a;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.go-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: left;
}

.go-stat {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid #1a1a1a;
}

.go-stat:last-child {
    border-bottom: none;
}

.go-stat-label {
    color: #666;
    flex-shrink: 0;
}

.go-stat-value {
    color: #bbb;
    text-align: right;
}

.go-highlights {
    margin-bottom: 1.25rem;
    text-align: left;
}

.go-highlights-title {
    font-size: 0.6rem;
    color: #666;
    letter-spacing: 0.25em;
    margin-bottom: 0.4rem;
}

.go-highlight {
    font-size: 0.75rem;
    color: #fff;
    padding: 0.3rem 0;
    border-bottom: 1px solid #1a1a1a;
}

.go-highlight:last-child {
    border-bottom: none;
}

.go-epitaph {
    color: #ccc;
    font-size: 0.85rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    white-space: pre-wrap;
    text-align: left;
    border-left: 3px solid rgba(255, 68, 68, 0.4);
    padding-left: 12px;
}

.go-epitaph-loading {
    color: #8a8a8a;
    font-size: 0.8rem;
    font-style: italic;
    margin-bottom: 1.5rem;
    text-align: left;
}

.go-epitaph-loading::after {
    content: '|';
    animation: go-blink 0.7s step-end infinite;
}

@keyframes go-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.go-branding {
    font-size: 0.65rem;
    color: #444;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.go-btn {
    background: transparent;
    color: var(--term);
    border: 1px solid var(--term);
    padding: 0.6rem 2rem;
    font-family: var(--font);
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all 0.2s;
}

.go-btn:hover:not(:disabled) {
    background: var(--term);
    color: #000;
}

.go-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.go-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.go-btn-share {
    border-color: var(--state);
    color: var(--state);
}

.go-btn-share:hover:not(:disabled) {
    background: var(--state);
    color: #000;
}

.go-btn-hidden {
    visibility: hidden;
    opacity: 0;
}

@media (max-width: 500px) {
    .go-card {
        padding: 2rem 1.25rem;
    }

    .go-title {
        font-size: 2rem;
        letter-spacing: 0.2em;
    }

    .go-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ==========================================
   ANIMATIONS & ATMOSPHERE
   ========================================== */

/* 1. Typing cursor during DM streaming */
.typing::after {
    content: "▊";
    animation: cursor-blink 0.6s step-end infinite;
    color: var(--term);
    margin-left: 2px;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* 2. State bar flash on change */
@keyframes flash-gain {
    0% { background: rgba(74, 246, 38, 0.3); }
    100% { background: transparent; }
}

@keyframes flash-loss {
    0% { background: rgba(255, 68, 68, 0.3); }
    100% { background: transparent; }
}

.flash-gain {
    animation: flash-gain 0.6s ease-out;
}

.flash-loss {
    animation: flash-loss 0.6s ease-out;
}

/* Floating credit delta */
.credit-delta {
    position: absolute;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font);
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
    z-index: 10;
}

.credit-delta.gain { color: var(--term); }
.credit-delta.loss { color: var(--alert); }

@keyframes float-up {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-24px); }
}

/* 3. Message entrance animations */
.role-user {
    animation: slide-in-right 0.3s ease-out;
}

.role-dm {
    animation: fade-in 0.4s ease-out;
}

.role-sys,
.state-tick {
    animation: slide-in-left 0.3s ease-out;
}

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-in-left {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 4. Game container positioning (for death overlay) */
#game-container {
    position: relative;
}

/* 5. Damage glitch */
@keyframes damage-glitch {
    0%, 100% { transform: translate(0); filter: none; }
    10% { transform: translate(-3px, 1px); filter: hue-rotate(30deg); }
    20% { transform: translate(2px, -1px); filter: hue-rotate(-20deg); }
    30% { transform: translate(-1px, 0); filter: none; }
    40% { transform: translate(0); filter: none; }
}

.damage-glitch {
    animation: damage-glitch 0.4s ease;
}

/* 6. Particle canvas */
#particles {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

#game-log, header, #beta-banner, #anon-banner, #state-display, #input-area {
    position: relative;
    z-index: 1;
}

/* State display needs relative for floating credit delta */
#state-display {
    position: relative;
}

/* ==========================================
   ACCESSIBILITY: REDUCED MOTION
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .typing::after,
    .flash-gain,
    .flash-loss,
    .credit-delta,
    .role-user,
    .role-dm,
    .role-sys,
    .state-tick,
    .damage-glitch,
    .go-title,
    #game-over-overlay {
        animation: none !important;
    }

    .go-scanlines {
        display: none !important;
    }

    #game-container::before {
        animation: none !important;
    }

    #particles {
        display: none !important;
    }
}
