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

:root {
    --void: #050508;
    --deep: #08080d;
    --surface: #0c0c14;
    --card: #0f0f1a;
    --blood: #8b1a1a;
    --blood-bright: #c41e3a;
    --blood-glow: rgba(139, 26, 26, 0.4);
    --eye-blue: #2a6fdb;
    --eye-glow: rgba(42, 111, 219, 0.5);
    --bone: #d4c5a9;
    --bone-dim: #8a7e68;
    --ink: #c8bfa0;
    --ink-dim: #6b6352;
    --ink-faint: #3d3a30;
    --purple: #1a0a2e;
    --gold: #d4a017;
    --font-title: 'Cinzel', serif;
    --font-prose: 'EB Garamond', Georgia, serif;
    --font-horror: 'Creepster', cursive;
    --font-ui: 'Special Elite', cursive;
}

html { scroll-behavior: smooth; }
body {
    background: var(--void);
    color: var(--ink);
    font-family: var(--font-prose);
    font-size: 17px;
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
}

::selection { background: var(--blood); color: var(--bone); }

/* ==================== GRAIN + VIGNETTE ==================== */
#grain {
    position: fixed; inset: 0; z-index: 9998;
    pointer-events: none; opacity: 0.04; mix-blend-mode: overlay;
}
#vignette {
    position: fixed; inset: 0; z-index: 9997; pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.7) 100%);
}

/* ==================== PARTICLES CANVAS ==================== */
#game-particles {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

/* ==================== SCREENS ==================== */
.screen {
    position: fixed;
    inset: 0;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--void);
}
.screen.active {
    opacity: 1;
    pointer-events: all;
}
/* Subtle slide-up on non-title screens (title has fixed children that break with transform) */
.screen:not(#screen-title) {
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.screen:not(#screen-title).active {
    transform: translateY(0);
}
.screen-content {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 60px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* ==================== TITLE SCREEN ==================== */
/* ==================== TITLE CINEMATIC LOOP ==================== */
.title-video {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.3s ease;
    -webkit-animation: kenBurns 25s ease-in-out infinite alternate;
    animation: kenBurns 25s ease-in-out infinite alternate;
    -webkit-transform-origin: center center;
    transform-origin: center center;
}
@-webkit-keyframes kenBurns {
    0% { -webkit-transform: scale(1); transform: scale(1); }
    100% { -webkit-transform: scale(1.08); transform: scale(1.08); }
}
@keyframes kenBurns {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}
.title-video.hidden { opacity: 0; pointer-events: none; }

.title-flash {
    position: fixed;
    inset: 0;
    z-index: 3;
    background: white;
    opacity: 0;
    pointer-events: none;
    -webkit-transition: opacity 0.02s;
    transition: opacity 0.02s;
}
.title-flash.active {
    opacity: 1;
    -webkit-animation: flashBang 0.35s cubic-bezier(0.22, 0, 0.36, 1) forwards;
    animation: flashBang 0.35s cubic-bezier(0.22, 0, 0.36, 1) forwards;
}
@-webkit-keyframes flashBang {
    0% { opacity: 1; background: #fff; }
    8% { opacity: 1; background: #fff; }
    12% { opacity: 0.95; background: rgba(200,30,30,0.9); }
    30% { opacity: 0.6; background: rgba(139,26,26,0.5); }
    60% { opacity: 0.2; background: rgba(139,26,26,0.15); }
    100% { opacity: 0; background: transparent; }
}
@keyframes flashBang {
    0% { opacity: 1; background: #fff; }
    8% { opacity: 1; background: #fff; }
    12% { opacity: 0.95; background: rgba(200,30,30,0.9); }
    30% { opacity: 0.6; background: rgba(139,26,26,0.5); }
    60% { opacity: 0.2; background: rgba(139,26,26,0.15); }
    100% { opacity: 0; background: transparent; }
}

.title-card {
    position: fixed;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 40px 24px;
    opacity: 0;
    pointer-events: none;
    -webkit-transition: opacity 0.8s ease;
    transition: opacity 0.8s ease;
}
.title-card.visible {
    opacity: 1;
    pointer-events: all;
}
.title-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 600px;
}

.title-card.visible .game-title {
    -webkit-animation: titleReveal 1s ease-out forwards;
    animation: titleReveal 1s ease-out forwards;
}
@-webkit-keyframes titleReveal {
    0% { -webkit-transform: scale(1.3); transform: scale(1.3); opacity: 0; -webkit-filter: blur(10px); filter: blur(10px); }
    40% { -webkit-transform: scale(1.05); transform: scale(1.05); opacity: 0.8; -webkit-filter: blur(2px); filter: blur(2px); }
    100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; -webkit-filter: blur(0); filter: blur(0); }
}
@keyframes titleReveal {
    0% { transform: scale(1.3); opacity: 0; filter: blur(10px); }
    40% { transform: scale(1.05); opacity: 0.8; filter: blur(2px); }
    100% { transform: scale(1); opacity: 1; filter: blur(0); }
}
.title-card.visible .game-subtitle {
    -webkit-animation: fadeIn 1s ease 0.3s both;
    animation: fadeIn 1s ease 0.3s both;
}
.title-card.visible .title-lore {
    -webkit-animation: fadeIn 1s ease 0.6s both;
    animation: fadeIn 1s ease 0.6s both;
}
.title-card.visible .btn-main {
    -webkit-animation: fadeIn 1s ease 1s both;
    animation: fadeIn 1s ease 1s both;
}
.title-card.visible .title-footer {
    -webkit-animation: fadeIn 1s ease 1.3s both;
    animation: fadeIn 1s ease 1.3s both;
}
.title-card.visible .title-eyes {
    -webkit-animation: fadeIn 0.6s ease 0.1s both;
    animation: fadeIn 0.6s ease 0.1s both;
}

/* Fade out title card before video restart */
.title-card.fading {
    opacity: 0;
    pointer-events: none;
    -webkit-transition: opacity 1s ease;
    transition: opacity 1s ease;
}

.title-eyes {
    display: flex; gap: 12px; margin-bottom: 30px;
}
.eye {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--eye-blue);
    box-shadow: 0 0 10px var(--eye-blue), 0 0 25px var(--eye-glow);
    -webkit-animation: eyePulse 3s ease-in-out infinite;
    animation: eyePulse 3s ease-in-out infinite;
}
.eye:nth-child(2) { -webkit-animation-delay: 0.5s; animation-delay: 0.5s; width: 16px; height: 16px; }
.eye:nth-child(3) { -webkit-animation-delay: 1s; animation-delay: 1s; }
.eye.dead {
    background: var(--blood-bright);
    box-shadow: 0 0 10px var(--blood-glow);
    animation: none; opacity: 0.5;
}
@keyframes eyePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    30% { opacity: 0.3; transform: scale(0.6); }
    32% { opacity: 0; }
    34% { opacity: 1; }
}

.game-title {
    font-family: var(--font-horror);
    font-size: clamp(60px, 12vw, 120px);
    color: var(--blood-bright);
    text-shadow: 0 0 20px var(--blood-glow), 0 0 60px rgba(139,26,26,0.3);
    letter-spacing: 10px;
    text-align: center;
}

.game-subtitle {
    font-family: var(--font-title);
    font-size: 11px; letter-spacing: 8px;
    color: var(--ink-dim); margin: 15px 0 30px;
    text-transform: uppercase;
}

.title-lore {
    font-size: 16px; color: var(--ink-dim);
    text-align: center; max-width: 450px;
    margin-bottom: 12px; font-style: italic; line-height: 1.8;
}
.title-lore.accent { color: var(--bone); font-weight: 600; margin-bottom: 40px; }

.title-footer { margin-top: 30px; }
.permadeath-warning {
    font-family: var(--font-title);
    font-size: 9px; letter-spacing: 4px;
    color: var(--blood); text-transform: uppercase;
    -webkit-animation: permadeathPulse 3s ease-in-out infinite;
    animation: permadeathPulse 3s ease-in-out infinite;
}
@-webkit-keyframes permadeathPulse {
    0%, 100% { text-shadow: 0 0 4px transparent; color: var(--blood); }
    50% { text-shadow: 0 0 12px var(--blood-glow), 0 0 24px rgba(139,26,26,0.2); color: var(--blood-bright); }
}
@keyframes permadeathPulse {
    0%, 100% { text-shadow: 0 0 4px transparent; color: var(--blood); }
    50% { text-shadow: 0 0 12px var(--blood-glow), 0 0 24px rgba(139,26,26,0.2); color: var(--blood-bright); }
}

/* ==================== BUTTONS ==================== */
.btn-main {
    font-family: var(--font-title);
    font-size: 12px; letter-spacing: 4px; text-transform: uppercase;
    color: var(--bone-dim); background: transparent;
    border: 1px solid var(--blood);
    padding: 14px 32px; cursor: pointer;
    min-height: 44px;
    -webkit-transition: all 0.4s ease;
    transition: all 0.4s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn-main:hover {
    color: var(--bone); background: rgba(139,26,26,0.1);
    box-shadow: 0 0 20px var(--blood-glow);
}
.btn-main:disabled {
    opacity: 0.3; cursor: not-allowed;
    border-color: var(--ink-faint);
}

.btn-choice {
    font-family: var(--font-prose);
    font-size: 15px; color: var(--ink);
    background: var(--surface);
    border: 1px solid rgba(139,26,26,0.15);
    padding: 14px 20px; cursor: pointer;
    min-height: 44px;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    text-align: left; width: 100%;
    border-radius: 2px;
    -webkit-tap-highlight-color: transparent;
}
.btn-choice:hover {
    border-color: var(--blood);
    background: rgba(139,26,26,0.06);
    -webkit-transform: translateX(4px);
    transform: translateX(4px);
}
.btn-choice .choice-cost {
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 2px;
    color: var(--gold); display: block; margin-top: 4px;
}

/* ==================== COMPACT HUB MENU ==================== */
.hub-group.compact { gap: 4px; }
.hub-row {
    display: flex; gap: 4px;
}
.btn-compact {
    font-family: var(--font-title);
    font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
    color: var(--ink-dim);
    background: rgba(12, 12, 20, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 26, 26, 0.12);
    padding: 10px 14px; cursor: pointer;
    transition: all 0.3s; flex: 1;
    min-height: 40px;
    white-space: nowrap;
    border-radius: 2px;
}
.btn-compact:hover {
    border-color: var(--blood);
    color: var(--bone);
    background: rgba(139,26,26,0.1);
    box-shadow: 0 0 15px rgba(139, 26, 26, 0.1);
}
.btn-compact.menacing {
    border-color: rgba(139,26,26,0.3);
    color: var(--blood-bright);
    background: linear-gradient(135deg, rgba(139,26,26,0.1), transparent);
}
.btn-compact.menacing:hover {
    background: rgba(139,26,26,0.15);
    box-shadow: 0 0 12px var(--blood-glow);
}
.hub-meta {
    display: flex; gap: 8px; justify-content: center;
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid rgba(139,26,26,0.08);
}
.hub-link {
    font-family: var(--font-title);
    font-size: 9px; letter-spacing: 3px; text-transform: uppercase;
    color: var(--ink-faint); text-decoration: none;
    padding: 6px 10px;
    transition: color 0.3s;
}
.hub-link:hover { color: var(--bone-dim); }

/* ==================== CREATE FLOW ==================== */
.create-flow { justify-content: center; }
.create-step { display: none; width: 100%; text-align: center; }
.create-step.active { display: block; animation: fadeIn 0.6s ease; }

@-webkit-keyframes fadeIn {
    from { opacity: 0; -webkit-transform: translateY(15px); transform: translateY(15px); }
    to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-label {
    font-family: var(--font-title);
    font-size: 9px; letter-spacing: 6px;
    color: var(--blood); margin-bottom: 20px;
}

.create-step h2 {
    font-family: var(--font-title);
    font-size: clamp(20px, 4vw, 28px);
    color: var(--bone); font-weight: 400;
    letter-spacing: 3px; margin-bottom: 20px;
}

.lore-text {
    font-size: 16px; color: var(--ink-dim);
    font-style: italic; margin-bottom: 12px;
    max-width: 480px; margin-left: auto; margin-right: auto;
    line-height: 1.8;
}
.lore-text.accent { color: var(--bone); }

.demon-speech {
    background: linear-gradient(135deg, rgba(26,10,46,0.3), transparent);
    border-left: 2px solid var(--purple);
    padding: 16px 20px; margin: 20px auto 30px;
    max-width: 400px; text-align: left;
}
.demon-speech p {
    color: var(--bone); font-style: italic; font-size: 17px;
}

/* ==================== ORIGINS ==================== */
.origin-grid {
    width: 100%; max-width: 450px;
    display: flex; flex-direction: column;
    gap: 16px; margin: 20px auto;
    text-align: left;
}
.origin-field { width: 100%; }
.origin-input {
    width: 100%; background: var(--deep);
    border: 1px solid rgba(139,26,26,0.2);
    color: var(--bone); font-family: var(--font-horror);
    font-size: 22px; padding: 12px 14px;
    min-height: 44px;
    text-align: center; letter-spacing: 3px;
    outline: none; border-radius: 0;
    -webkit-transition: border-color 0.3s;
    transition: border-color 0.3s;
}
.origin-input:focus { border-color: var(--blood); }
.origin-input::placeholder { color: var(--ink-faint); font-size: 14px; }

.origin-select {
    width: 100%; background: var(--deep);
    border: 1px solid rgba(139,26,26,0.15);
    color: var(--ink); font-family: var(--font-prose);
    font-size: 16px; padding: 12px 14px;
    min-height: 44px;
    outline: none; cursor: pointer;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b6352'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    border-radius: 0;
}
.origin-select:focus { border-color: var(--blood); }
.origin-select option { background: var(--deep); color: var(--ink); }

/* Social class buttons */
.social-options {
    display: flex; flex-direction: column; gap: 10px;
}
.social-btn {
    display: flex; flex-direction: column;
    padding: 16px 18px; text-align: left;
    min-height: 44px;
    background: var(--surface);
    border: 1px solid rgba(139,26,26,0.15);
    border-left: 3px solid rgba(139,26,26,0.2);
    border-radius: 2px;
    cursor: pointer;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    color: var(--ink);
    font-family: var(--font-prose);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.social-btn:hover {
    border-color: rgba(139,26,26,0.4);
    border-left-color: var(--blood);
    -webkit-transform: translateX(3px);
    transform: translateX(3px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3), inset 0 0 30px rgba(139,26,26,0.03);
    background: linear-gradient(135deg, var(--surface), rgba(139,26,26,0.04));
}
.social-btn.active {
    border-color: var(--blood);
    border-left-color: var(--blood-bright);
    background: linear-gradient(135deg, rgba(139,26,26,0.1), rgba(139,26,26,0.04));
    box-shadow: 0 4px 20px rgba(139,26,26,0.15), inset 0 0 40px rgba(139,26,26,0.05);
}
.social-btn.locked {
    opacity: 0.4; cursor: not-allowed;
}
.social-btn.locked.unlocked {
    opacity: 1; cursor: pointer;
}
.social-icon {
    font-size: 16px; margin-bottom: 2px;
}
.social-name {
    font-family: var(--font-title);
    font-size: 12px; letter-spacing: 3px;
    color: var(--bone); text-transform: uppercase;
}
.social-desc {
    font-size: 12px; color: var(--ink-dim);
    font-style: italic; margin-top: 2px;
}
.lock-tag {
    font-size: 9px; letter-spacing: 2px;
    color: var(--gold); margin-left: 6px;
    font-family: var(--font-title);
}

/* Power Input */
.power-input-zone { margin: 20px 0 30px; width: 100%; max-width: 400px; }
.input-label {
    font-family: var(--font-title);
    font-size: 11px; letter-spacing: 3px;
    color: var(--bone-dim); display: block;
    margin-bottom: 10px; text-transform: uppercase;
}
.char-count { color: var(--ink-faint); font-size: 10px; }

.power-input {
    width: 100%; background: var(--deep);
    border: 1px solid rgba(139,26,26,0.2);
    color: var(--bone); font-family: var(--font-horror);
    font-size: 28px; padding: 14px 16px;
    min-height: 44px;
    text-align: center; letter-spacing: 4px;
    outline: none; border-radius: 0;
    -webkit-transition: border-color 0.3s;
    transition: border-color 0.3s;
}
.power-input:focus { border-color: var(--blood); }
.power-input::placeholder { color: var(--ink-faint); font-size: 16px; letter-spacing: 2px; }

.char-upgrade {
    font-size: 12px; color: var(--ink-faint);
    margin-top: 10px; font-style: italic;
}
.lock-icon { font-size: 14px; }

/* Hero Prompt */
.prompt-zone, .name-zone {
    margin: 16px 0; width: 100%; max-width: 450px; text-align: left;
}
.hero-textarea {
    width: 100%; background: var(--deep);
    border: 1px solid rgba(139,26,26,0.15);
    color: var(--ink); font-family: var(--font-prose);
    font-size: 15px; padding: 14px;
    resize: none; outline: none; line-height: 1.7;
    transition: border-color 0.3s;
}
.hero-textarea:focus { border-color: var(--blood); }
.hero-textarea::placeholder { color: var(--ink-faint); }
.char-count-area {
    font-size: 11px; color: var(--ink-faint);
    text-align: right; margin-top: 4px;
}

/* ==================== PROFILE CARD ==================== */
.profile-card {
    background: rgba(12, 12, 20, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 26, 26, 0.15);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), inset 0 0 30px rgba(139, 26, 26, 0.03);
    width: 100%; max-width: 400px;
    margin: 20px auto 30px;
    overflow: hidden;
}
.profile-header {
    background: linear-gradient(135deg, rgba(139,26,26,0.15), transparent);
    padding: 20px; text-align: center;
    border-bottom: 1px solid rgba(139,26,26,0.1);
}
.profile-rank {
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 5px;
    color: var(--blood); margin-bottom: 6px;
}
.profile-name {
    font-family: var(--font-horror);
    font-size: 32px; color: var(--bone);
    letter-spacing: 4px;
}
.profile-body { padding: 20px; }
.profile-section { margin-bottom: 14px; }
.profile-label {
    font-family: var(--font-title);
    font-size: 9px; letter-spacing: 4px;
    color: var(--blood); display: block; margin-bottom: 4px;
}
.profile-value {
    font-family: var(--font-horror);
    font-size: 20px; color: var(--bone);
    letter-spacing: 2px;
}
.profile-bio {
    font-size: 14px; color: var(--ink-dim);
    font-style: italic; line-height: 1.6;
}

/* Demon portrait */
.demon-portrait-wrap {
    position: relative;
    width: 100%; max-width: 200px;
    margin: 8px auto 12px;
    overflow: hidden;
}
.demon-portrait-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(5,5,8,0.7) 100%);
    pointer-events: none;
    z-index: 1;
}
.demon-portrait {
    width: 100%; max-width: 200px; height: auto;
    display: block; margin: 0 auto;
    border: 1px solid rgba(139,26,26,0.2);
    -webkit-filter: grayscale(20%) contrast(1.1);
    filter: grayscale(20%) contrast(1.1);
    -webkit-transition: filter 0.4s;
    transition: filter 0.4s;
}
.demon-portrait:hover {
    -webkit-filter: grayscale(0%) contrast(1.2) brightness(1.1);
    filter: grayscale(0%) contrast(1.2) brightness(1.1);
}

.profile-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 8px; margin-top: 16px;
}
.stat {
    text-align: center; padding: 10px 0;
    background: rgba(139,26,26,0.05);
    border: 1px solid rgba(139,26,26,0.08);
}
.stat-label {
    font-family: var(--font-title);
    font-size: 9px; letter-spacing: 3px;
    color: var(--ink-faint); display: block;
}
.stat-value {
    font-family: var(--font-horror);
    font-size: 22px; color: var(--bone);
}

.profile-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(139,26,26,0.1);
    text-align: center;
}
.prestige-display {
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 4px;
    color: var(--gold);
}

/* ==================== GAME SCREEN ==================== */
.game-layout {
    justify-content: flex-start;
    padding-top: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.game-topbar {
    position: sticky; top: 0; z-index: 10;
    background: var(--void);
    border-bottom: 1px solid rgba(139,26,26,0.15);
    padding: 12px 0; width: 100%;
    display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap;
    gap: 6px;
}
.topbar-name {
    font-family: var(--font-horror);
    font-size: 18px; color: var(--bone);
    letter-spacing: 2px;
}
.topbar-stats { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.mini-stat {
    font-family: var(--font-title);
    font-size: 9px; letter-spacing: 2px;
    color: var(--ink-faint); text-transform: uppercase;
}
.mini-stat strong {
    color: var(--bone); font-size: 12px;
    margin-left: 3px;
}
.penalty-countdown {
    color: var(--ink-faint);
    -webkit-transition: color 0.5s;
    transition: color 0.5s;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 2px;
}
.penalty-countdown strong {
    -webkit-transition: color 0.5s;
    transition: color 0.5s;
}
.penalty-countdown.urgent {
    -webkit-animation: penaltyPulse 1.2s ease-in-out infinite;
    animation: penaltyPulse 1.2s ease-in-out infinite;
}
@-webkit-keyframes penaltyPulse {
    0%, 100% { border-color: rgba(196,30,58,0.3); box-shadow: none; }
    50% { border-color: var(--blood-bright); box-shadow: 0 0 10px var(--blood-glow), inset 0 0 6px rgba(139,26,26,0.15); }
}
@keyframes penaltyPulse {
    0%, 100% { border-color: rgba(196,30,58,0.3); box-shadow: none; }
    50% { border-color: var(--blood-bright); box-shadow: 0 0 10px var(--blood-glow), inset 0 0 6px rgba(139,26,26,0.15); }
}

/* ==================== HUB ==================== */
.hub-layout {
    justify-content: flex-start;
    padding-top: 0;
}
.hub-location {
    text-align: center; padding: 14px 0;
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 8px;
    text-transform: uppercase;
    transition: color 0.4s;
}
.hub-location.earth { color: var(--bone-dim); }
.hub-location.hell { color: var(--blood-bright); }

/* World backgrounds */
.hub-layout {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.8s ease;
}
.hub-layout.world-earth {
    background-image: linear-gradient(to bottom, rgba(5,5,8,0.75), rgba(5,5,8,0.9)), url('../assets/backgrounds/banlieue1.png');
    animation: hubKenBurns 30s ease-in-out infinite alternate;
    -webkit-animation: hubKenBurns 30s ease-in-out infinite alternate;
}
.hub-layout.world-hell {
    background-image: linear-gradient(to bottom, rgba(5,5,8,0.7), rgba(5,5,8,0.88)), url('../assets/backgrounds/salonEnfer.png');
    animation: hubKenBurns 25s ease-in-out infinite alternate;
    -webkit-animation: hubKenBurns 25s ease-in-out infinite alternate;
}
@-webkit-keyframes hubKenBurns {
    0% { background-size: 100% auto; background-position: center center; }
    100% { background-size: 110% auto; background-position: center 40%; }
}
@keyframes hubKenBurns {
    0% { background-size: 100% auto; background-position: center center; }
    100% { background-size: 110% auto; background-position: center 40%; }
}

/* Shop background */
.shop-layout {
    background-image: linear-gradient(to bottom, rgba(5,5,8,0.85), rgba(5,5,8,0.95)), url('../assets/backgrounds/boutique.png');
    background-size: cover;
    background-position: center;
}

/* Combat background */
.combat-layout {
    background-image: linear-gradient(to bottom, rgba(5,5,8,0.8), rgba(5,5,8,0.9)), url('../assets/scenes/Arene.png');
    background-size: cover;
    background-position: center;
}

.hub-choices {
    width: 100%; padding: 10px 0;
    display: flex; flex-direction: column; gap: 8px;
}
.hub-group { display: flex; flex-direction: column; gap: 8px; }
.hub-btn {
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.hub-btn.menacing {
    border-color: rgba(196,30,58,0.25);
    background: linear-gradient(135deg, rgba(139,26,26,0.08), var(--surface));
    box-shadow: inset 0 0 20px rgba(139,26,26,0.05);
}
.hub-btn.menacing:hover {
    border-color: var(--blood-bright);
    background: linear-gradient(135deg, rgba(139,26,26,0.15), rgba(139,26,26,0.06));
    box-shadow: 0 0 20px rgba(139,26,26,0.15), inset 0 0 30px rgba(139,26,26,0.08);
    color: var(--bone);
}
.demon-name-slot { color: var(--blood-bright); }

/* ==================== SHOP ==================== */
.shop-layout {
    justify-content: flex-start; padding-top: 20px;
    min-height: 100vh;
}
.shop-header {
    text-align: center; width: 100%;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(139,26,26,0.15);
    margin-bottom: 16px;
}
.shop-title {
    font-family: var(--font-title);
    font-size: 16px; letter-spacing: 6px;
    color: var(--bone); margin-bottom: 8px;
    font-weight: 400; text-transform: uppercase;
}
.shop-points {
    font-family: var(--font-title);
    font-size: 11px; letter-spacing: 3px;
    color: var(--gold); margin-bottom: 12px;
}
.shop-tiers {
    display: flex; gap: 4px; flex-wrap: wrap;
    justify-content: center;
}
.tier-tab {
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 2px;
    padding: 8px 12px; cursor: pointer;
    min-height: 44px;
    border: 1px solid rgba(139,26,26,0.15);
    background: transparent; color: var(--ink-faint);
    -webkit-transition: all 0.3s;
    transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    flex-shrink: 0;
}
.tier-tab:hover, .tier-tab.active {
    border-color: var(--blood);
    color: var(--bone);
    background: rgba(139,26,26,0.06);
}
.tier-tab.tier-s { color: var(--gold); border-color: rgba(212,160,23,0.3); }
.tier-tab.tier-ss { color: #ff6600; border-color: rgba(255,102,0,0.3); }
.tier-tab.tier-sss { color: var(--blood-bright); border-color: var(--blood); }

.shop-items {
    width: 100%; display: flex;
    flex-direction: column; gap: 8px;
    max-height: 60vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}
.shop-item {
    background: rgba(12, 12, 20, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 26, 26, 0.12);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    padding: 14px 16px;
    transition: all 0.3s; cursor: default;
    border-radius: 2px;
}
.shop-item:hover {
    border-color: rgba(139,26,26,0.3);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(139, 26, 26, 0.08);
}
.shop-item-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 6px;
}
.shop-item-name {
    font-family: var(--font-title);
    font-size: 13px; letter-spacing: 2px;
    color: var(--bone); font-weight: 400;
}
.shop-item-tier {
    font-family: var(--font-horror);
    font-size: 16px; letter-spacing: 2px;
}
.shop-item-tier.tier-e { color: var(--ink-faint); }
.shop-item-tier.tier-d { color: var(--ink-dim); }
.shop-item-tier.tier-c { color: var(--bone-dim); }
.shop-item-tier.tier-b { color: var(--eye-blue); }
.shop-item-tier.tier-a { color: var(--gold); }
.shop-item-tier.tier-aplus { color: #ff8800; }
.shop-item-tier.tier-s { color: var(--blood-bright); text-shadow: 0 0 8px var(--blood-glow); }
.shop-item-tier.tier-ss { color: #ff4400; text-shadow: 0 0 10px rgba(255,68,0,0.4); }
.shop-item-tier.tier-sss { color: #ff0044; text-shadow: 0 0 15px rgba(255,0,68,0.5); font-size: 18px; }

.shop-item-desc {
    font-size: 13px; color: var(--ink-dim);
    font-style: italic; line-height: 1.5;
    margin-bottom: 8px;
}
.shop-item-effect {
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 2px;
    color: var(--eye-blue); margin-bottom: 8px;
}
.shop-item-footer {
    display: flex; justify-content: space-between;
    align-items: center;
}
.shop-item-price {
    font-family: var(--font-horror);
    font-size: 18px; color: var(--gold);
}
.btn-buy {
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 3px;
    padding: 10px 16px; border: 1px solid var(--blood);
    background: transparent; color: var(--bone-dim);
    cursor: pointer; min-height: 44px;
    -webkit-transition: all 0.3s;
    transition: all 0.3s;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
}
.btn-buy:hover {
    background: rgba(139,26,26,0.1);
    color: var(--bone);
}
.btn-buy:disabled {
    opacity: 0.25; cursor: not-allowed;
    border-color: var(--ink-faint);
}
.btn-buy.owned {
    border-color: var(--ink-faint);
    color: var(--ink-faint);
}

/* ==================== DEMON ADVICE ==================== */
.demon-advice {
    border-left: 2px solid #1a0a2e;
    padding-left: 12px;
    color: var(--bone-dim) !important;
    font-style: italic;
    background: linear-gradient(90deg, rgba(26,10,46,0.15), transparent);
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: 14px !important;
}
.demon-advice-name {
    color: #6633aa;
    font-family: var(--font-title);
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

/* Story Feed */
.story-feed {
    flex: 1; width: 100%;
    padding: 20px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
.story-event {
    background: rgba(12, 12, 20, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-left: 2px solid rgba(139, 26, 26, 0.15);
    border-bottom: 1px solid rgba(139,26,26,0.04);
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
    animation: eventAppear 0.5s ease both;
    -webkit-animation: eventAppear 0.5s ease both;
}
@-webkit-keyframes eventAppear {
    from { opacity: 0; -webkit-transform: translateX(-10px); transform: translateX(-10px); border-left-color: rgba(139,26,26,0.5); }
    to { opacity: 1; -webkit-transform: translateX(0); transform: translateX(0); border-left-color: rgba(139,26,26,0.15); }
}
@keyframes eventAppear {
    from { opacity: 0; transform: translateX(-10px); border-left-color: rgba(139,26,26,0.5); }
    to { opacity: 1; transform: translateX(0); border-left-color: rgba(139,26,26,0.15); }
}
.story-event.danger-low { border-left-color: var(--bone-dim); }
.story-event.danger-medium { border-left-color: var(--gold); }
.story-event.danger-high { border-left-color: var(--blood); }
.story-event.danger-critical { border-left-color: var(--blood-bright); box-shadow: inset 4px 0 12px -4px rgba(196,30,58,0.15); }
.story-event.danger-demon { border-left-color: #6633aa; }
.event-day {
    font-family: var(--font-title);
    font-size: 9px; letter-spacing: 4px;
    color: var(--blood); margin-bottom: 6px;
}
.event-text {
    font-size: 16px; color: var(--ink-dim);
    line-height: 1.8; font-style: italic;
}
.event-text.important { color: var(--bone); font-weight: 500; }
.event-text.danger { color: var(--blood-bright); }
.event-text .highlight { color: var(--bone); font-weight: 600; }

/* Choice Area */
.choice-area {
    width: 100%; padding: 16px 0 30px;
    display: flex; flex-direction: column; gap: 8px;
    border-top: 1px solid rgba(139,26,26,0.1);
}

/* ==================== COMBAT ==================== */
.combat-layout { justify-content: flex-start; padding-top: 40px; }
.combat-header { text-align: center; margin-bottom: 30px; width: 100%; }
.combat-header h2 {
    font-family: var(--font-title);
    font-size: 12px; letter-spacing: 8px;
    color: var(--blood); margin-bottom: 10px;
}
.combat-vs {
    display: flex; justify-content: center;
    align-items: center; gap: 20px;
}
.combat-vs span {
    font-family: var(--font-horror);
    font-size: 24px; color: var(--bone);
    letter-spacing: 2px;
}
.vs-text {
    font-family: var(--font-title) !important;
    font-size: 10px !important; letter-spacing: 5px !important;
    color: var(--blood) !important;
}

.combat-feed {
    flex: 1; width: 100%; padding: 10px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
.combat-line {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(139,26,26,0.04);
    background: rgba(12, 12, 20, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 2px;
    margin-bottom: 4px;
    -webkit-animation: combatLineAppear 0.4s ease both;
    animation: combatLineAppear 0.4s ease both;
}
@-webkit-keyframes combatLineAppear {
    0% { opacity: 0; -webkit-transform: translateY(8px); transform: translateY(8px); -webkit-filter: blur(2px); filter: blur(2px); }
    60% { opacity: 0.7; -webkit-filter: blur(0.5px); filter: blur(0.5px); }
    100% { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); -webkit-filter: blur(0); filter: blur(0); }
}
@keyframes combatLineAppear {
    0% { opacity: 0; transform: translateY(8px); filter: blur(2px); }
    60% { opacity: 0.7; filter: blur(0.5px); }
    100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.combat-line p {
    font-size: 15px; color: var(--ink-dim);
    line-height: 1.7; font-style: italic;
}
.combat-line.you p { color: var(--eye-blue); border-left: 2px solid var(--eye-blue); padding-left: 12px; }
.combat-line.enemy p { color: var(--blood-bright); border-left: 2px solid var(--blood); padding-left: 12px; }
.combat-line.narrator p { color: var(--bone-dim); text-align: center; font-size: 14px; }
.combat-line.dialogue_you p {
    color: var(--eye-blue); border-left: 2px solid var(--eye-blue); padding-left: 12px;
    font-style: italic; font-size: 16px;
}
.combat-line.dialogue_enemy p {
    color: var(--blood-bright); border-left: 2px solid var(--blood); padding-left: 12px;
    font-style: italic; font-size: 16px;
}
.combat-line.demon p {
    color: #8844cc; border-left: 2px solid #6633aa; padding-left: 12px;
    font-style: italic; font-size: 13px; opacity: 0.85;
}

.combat-actions {
    width: 100%; padding: 16px 0;
    display: flex; flex-direction: column; gap: 8px;
    border-top: 1px solid rgba(139,26,26,0.1);
}

/* ==================== COMBAT VISUAL EFFECTS ==================== */
/* Screen shake on hit */
@-webkit-keyframes combatShake {
    0%, 100% { -webkit-transform: translate(0); transform: translate(0); }
    10% { -webkit-transform: translate(-3px, -2px); transform: translate(-3px, -2px); }
    30% { -webkit-transform: translate(3px, 1px); transform: translate(3px, 1px); }
    50% { -webkit-transform: translate(-2px, 2px); transform: translate(-2px, 2px); }
    70% { -webkit-transform: translate(2px, -1px); transform: translate(2px, -1px); }
}
@keyframes combatShake {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-3px, -2px); }
    30% { transform: translate(3px, 1px); }
    50% { transform: translate(-2px, 2px); }
    70% { transform: translate(2px, -1px); }
}
.screen-shake {
    animation: combatShake 0.4s ease !important;
    -webkit-animation: combatShake 0.4s ease !important;
}

/* Heavy shake for death/kill moments */
@-webkit-keyframes combatShakeHeavy {
    0%, 100% { -webkit-transform: translate(0); transform: translate(0); }
    10% { -webkit-transform: translate(-6px, -4px); transform: translate(-6px, -4px); }
    20% { -webkit-transform: translate(5px, 3px); transform: translate(5px, 3px); }
    30% { -webkit-transform: translate(-4px, -3px); transform: translate(-4px, -3px); }
    40% { -webkit-transform: translate(4px, 2px); transform: translate(4px, 2px); }
    50% { -webkit-transform: translate(-3px, 3px); transform: translate(-3px, 3px); }
    60% { -webkit-transform: translate(3px, -2px); transform: translate(3px, -2px); }
    70% { -webkit-transform: translate(-2px, 1px); transform: translate(-2px, 1px); }
    80% { -webkit-transform: translate(1px, -1px); transform: translate(1px, -1px); }
}
@keyframes combatShakeHeavy {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-6px, -4px); }
    20% { transform: translate(5px, 3px); }
    30% { transform: translate(-4px, -3px); }
    40% { transform: translate(4px, 2px); }
    50% { transform: translate(-3px, 3px); }
    60% { transform: translate(3px, -2px); }
    70% { transform: translate(-2px, 1px); }
    80% { transform: translate(1px, -1px); }
}
.screen-shake-heavy {
    animation: combatShakeHeavy 0.6s ease !important;
    -webkit-animation: combatShakeHeavy 0.6s ease !important;
}

/* Red flash on damage */
@-webkit-keyframes damageFlash {
    0% { box-shadow: inset 0 0 60px rgba(139, 26, 26, 0.4); }
    100% { box-shadow: inset 0 0 60px rgba(139, 26, 26, 0); }
}
@keyframes damageFlash {
    0% { box-shadow: inset 0 0 60px rgba(139, 26, 26, 0.4); }
    100% { box-shadow: inset 0 0 60px rgba(139, 26, 26, 0); }
}
.damage-flash {
    animation: damageFlash 0.5s ease !important;
    -webkit-animation: damageFlash 0.5s ease !important;
}

/* Blue glow on player action */
@-webkit-keyframes playerGlow {
    0% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0.2); }
    100% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0); }
}
@keyframes playerGlow {
    0% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0.2); }
    100% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0); }
}
.player-glow {
    animation: playerGlow 0.6s ease !important;
    -webkit-animation: playerGlow 0.6s ease !important;
}

/* Victory glow */
@-webkit-keyframes victoryGlow {
    0% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0.3); }
    50% { box-shadow: inset 0 0 80px rgba(42, 111, 219, 0.15); }
    100% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0); }
}
@keyframes victoryGlow {
    0% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0.3); }
    50% { box-shadow: inset 0 0 80px rgba(42, 111, 219, 0.15); }
    100% { box-shadow: inset 0 0 40px rgba(42, 111, 219, 0); }
}
.victory-glow {
    animation: victoryGlow 1.5s ease !important;
    -webkit-animation: victoryGlow 1.5s ease !important;
}

/* ==================== DEATH ==================== */
.death-layout { text-align: center; }
.death-eyes { display: flex; gap: 12px; justify-content: center; margin-bottom: 30px; }
.death-title {
    font-family: var(--font-horror);
    font-size: clamp(36px, 8vw, 56px);
    color: var(--blood-bright);
    text-shadow: 0 0 30px var(--blood-glow);
    letter-spacing: 6px; margin-bottom: 30px;
}
.death-summary {
    margin-bottom: 24px;
}
.death-summary p {
    font-size: 15px; color: var(--ink-dim);
    margin-bottom: 6px;
}
.death-summary strong { color: var(--bone); }

.prestige-earned {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; margin-bottom: 30px;
}
.prestige-earned span:first-child {
    font-family: var(--font-title);
    font-size: 10px; letter-spacing: 5px;
    color: var(--gold);
}
.prestige-number {
    font-family: var(--font-horror);
    font-size: 42px; color: var(--gold);
    text-shadow: 0 0 20px rgba(212,160,23,0.3);
    -webkit-animation: prestigeGlow 2s ease-in-out infinite;
    animation: prestigeGlow 2s ease-in-out infinite;
}
@-webkit-keyframes prestigeGlow {
    0%, 100% { text-shadow: 0 0 20px rgba(212,160,23,0.3); color: var(--gold); }
    50% { text-shadow: 0 0 30px rgba(212,160,23,0.6), 0 0 60px rgba(212,160,23,0.2); color: #e8b820; }
}
@keyframes prestigeGlow {
    0%, 100% { text-shadow: 0 0 20px rgba(212,160,23,0.3); color: var(--gold); }
    50% { text-shadow: 0 0 30px rgba(212,160,23,0.6), 0 0 60px rgba(212,160,23,0.2); color: #e8b820; }
}

.death-lore {
    font-size: 15px; color: var(--ink-dim);
    font-style: italic; max-width: 400px;
    margin: 0 auto 30px; line-height: 1.8;
}

/* ==================== VFX: CURSOR TRAIL CANVAS ==================== */
#cursor-trail-canvas {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

/* ==================== VFX: GLITCH OVERLAY ==================== */
#game-glitch {
    mix-blend-mode: screen;
}
#game-glitch.glitch-active {
    opacity: 1 !important;
}
#game-glitch .glitch-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(139,26,26,0.03) 2px,
        rgba(139,26,26,0.03) 4px
    );
    animation: glitchScanlines 0.1s linear infinite;
}
@keyframes glitchScanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}
#game-glitch .glitch-rgb {
    position: absolute;
    inset: 0;
    animation: glitchRGB 0.15s steps(2) infinite;
}
@keyframes glitchRGB {
    0% { box-shadow: -2px 0 0 rgba(255,0,0,0.3), 2px 0 0 rgba(0,0,255,0.3); }
    25% { box-shadow: 2px 0 0 rgba(255,0,0,0.3), -2px 0 0 rgba(0,0,255,0.3); }
    50% { box-shadow: -1px 1px 0 rgba(255,0,0,0.3), 1px -1px 0 rgba(0,0,255,0.3); }
    75% { box-shadow: 1px -1px 0 rgba(255,0,0,0.3), -1px 1px 0 rgba(0,0,255,0.3); }
    100% { box-shadow: -2px 0 0 rgba(255,0,0,0.3), 2px 0 0 rgba(0,0,255,0.3); }
}
#game-glitch .glitch-noise {
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.15'/%3E%3C/svg%3E");
    opacity: 0.5;
    mix-blend-mode: overlay;
    animation: glitchNoise 0.2s steps(3) infinite;
}
@keyframes glitchNoise {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-5px, 2px); }
    66% { transform: translate(3px, -3px); }
    100% { transform: translate(0, 0); }
}
#game-glitch .glitch-tear {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(196,30,58,0.6);
    animation: glitchTear 0.3s steps(4) infinite;
}
@keyframes glitchTear {
    0% { top: 10%; transform: translateX(0); }
    25% { top: 30%; transform: translateX(-10px); }
    50% { top: 60%; transform: translateX(8px); }
    75% { top: 80%; transform: translateX(-5px); }
    100% { top: 10%; transform: translateX(0); }
}

/* ==================== VFX: COMBAT BORDER PULSE ==================== */
#combat-border-pulse.active {
    animation: combatBorderPulse 2s ease-in-out infinite;
}
@keyframes combatBorderPulse {
    0%, 100% {
        opacity: 0.3;
        border-color: rgba(139,26,26,0.4);
        box-shadow: inset 0 0 30px rgba(139,26,26,0.1);
    }
    50% {
        opacity: 0.7;
        border-color: rgba(196,30,58,0.7);
        box-shadow: inset 0 0 60px rgba(139,26,26,0.25), inset 0 0 120px rgba(139,26,26,0.1);
    }
}

/* ==================== VFX: SCREEN FLASH ==================== */
#screen-flash-overlay.flash-red {
    background: rgba(196,30,58,0.6);
    animation: screenFlashRed 0.3s ease-out forwards;
}
#screen-flash-overlay.flash-blue {
    background: rgba(42,111,219,0.4);
    animation: screenFlashBlue 0.3s ease-out forwards;
}
#screen-flash-overlay.flash-white {
    background: rgba(255,255,255,0.9);
    animation: screenFlashWhite 0.5s ease-out forwards;
}
#screen-flash-overlay.flash-gold {
    background: rgba(212,160,23,0.4);
    animation: screenFlashGold 0.4s ease-out forwards;
}
@keyframes screenFlashRed {
    0% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes screenFlashBlue {
    0% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes screenFlashWhite {
    0% { opacity: 1; }
    30% { opacity: 0.8; }
    100% { opacity: 0; }
}
@keyframes screenFlashGold {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ==================== VFX: SCREEN SHAKE ==================== */
@keyframes screenShakeLight {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-1px, 1px); }
    20% { transform: translate(1px, -1px); }
    30% { transform: translate(-1px, 0); }
    40% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, -1px); }
    60% { transform: translate(1px, 0); }
    70% { transform: translate(0, 1px); }
    80% { transform: translate(-1px, -1px); }
    90% { transform: translate(1px, 1px); }
}
@keyframes screenShakeHeavy {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-4px, 3px); }
    20% { transform: translate(3px, -4px); }
    30% { transform: translate(-3px, 1px); }
    40% { transform: translate(4px, 3px); }
    50% { transform: translate(-2px, -3px); }
    60% { transform: translate(3px, 2px); }
    70% { transform: translate(-1px, 4px); }
    80% { transform: translate(-3px, -2px); }
    90% { transform: translate(2px, 3px); }
}
body.shake-light {
    animation: screenShakeLight 0.2s ease-in-out;
}
body.shake-heavy {
    animation: screenShakeHeavy 0.4s ease-in-out;
}
body.shake-micro {
    animation: screenShakeLight 0.15s ease-in-out;
}

/* ==================== VFX: VIGNETTE BREATHING ==================== */
#vignette {
    animation: vignetteBreathe 8s ease-in-out infinite;
}
@keyframes vignetteBreathe {
    0%, 100% {
        background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.7) 100%);
    }
    50% {
        background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.85) 100%);
    }
}

/* ==================== VFX: TYPING CURSOR ==================== */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--blood-bright);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: typingCursorBlink 0.5s step-end infinite;
}
@keyframes typingCursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ==================== VFX: PROFILE 3D TILT ==================== */
#profile-card {
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
    transform-style: preserve-3d;
    perspective: 800px;
}
#profile-card .profile-light-reflection {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06) 0%, transparent 60%);
    transition: background 0.15s ease-out;
    border-radius: inherit;
}

/* ==================== VFX: GOLDEN TEXT GLOW (VICTORY) ==================== */
.combat-line.victory-glow p {
    color: var(--gold) !important;
    text-shadow: 0 0 10px rgba(212,160,23,0.5), 0 0 30px rgba(212,160,23,0.3), 0 0 60px rgba(212,160,23,0.15);
    animation: victoryTextGlow 1.5s ease-in-out infinite;
}
@keyframes victoryTextGlow {
    0%, 100% { text-shadow: 0 0 10px rgba(212,160,23,0.5), 0 0 30px rgba(212,160,23,0.3); }
    50% { text-shadow: 0 0 20px rgba(212,160,23,0.8), 0 0 50px rgba(212,160,23,0.5), 0 0 80px rgba(212,160,23,0.2); }
}

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

/* Tablet and below */
@media (max-width: 768px) {
    .combat-vs span { font-size: 20px; }
    .shop-items { max-height: 55vh; }
}

/* Mobile — 480px and below */
@media (max-width: 480px) {
    body { font-size: 16px; }

    .screen-content { padding: 40px 16px; }

    /* Title */
    .game-title { letter-spacing: 6px; }
    .game-subtitle { letter-spacing: 5px; font-size: 10px; }
    .title-lore { font-size: 14px; line-height: 1.7; max-width: 300px; }
    .title-card { padding: 30px 16px; }
    .title-card-inner { max-width: 100%; }

    /* Create flow */
    .origin-grid { max-width: 100%; }
    .power-input { font-size: 22px; letter-spacing: 3px; }
    .power-input::placeholder { font-size: 14px; }
    .power-input-zone { max-width: 100%; }
    .demon-speech { max-width: 100%; margin-left: 0; margin-right: 0; }
    .lore-text { font-size: 14px; max-width: 100%; }
    .social-name { font-size: 11px; letter-spacing: 2px; }

    /* Profile */
    .profile-card { max-width: 100%; }
    .profile-stats { grid-template-columns: repeat(2, 1fr); }
    .profile-name { font-size: 26px; letter-spacing: 3px; }
    .stat-value { font-size: 20px; }

    /* Topbar */
    .game-topbar { padding: 10px 0; gap: 4px; }
    .topbar-name { font-size: 15px; letter-spacing: 1px; }
    .topbar-stats { gap: 8px; }
    .mini-stat { font-size: 8px; letter-spacing: 1px; }
    .mini-stat strong { font-size: 11px; }

    /* Hub */
    .hub-choices { gap: 8px; }
    .hub-btn { padding: 14px 16px; font-size: 14px; }

    /* Story feed */
    .story-feed { padding: 14px 0; }
    .event-text { font-size: 15px; line-height: 1.7; }
    .event-day { font-size: 8px; letter-spacing: 3px; }
    .story-event { padding: 12px 0 12px 10px; }

    /* Choice area */
    .choice-area { padding: 12px 0 24px; gap: 8px; }
    .btn-choice { padding: 14px 16px; font-size: 14px; }

    /* Combat */
    .combat-layout { padding-top: 20px; }
    .combat-header { margin-bottom: 20px; }
    .combat-vs span { font-size: 18px; letter-spacing: 1px; }
    .combat-feed { padding: 8px 0; }
    .combat-line p { font-size: 14px; line-height: 1.6; }
    .combat-line.narrator p { font-size: 13px; }
    .combat-actions { gap: 8px; }

    /* Shop */
    .shop-layout { padding-top: 14px; }
    .shop-title { font-size: 14px; letter-spacing: 4px; }
    .shop-tiers {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        padding-bottom: 8px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .shop-tiers::-webkit-scrollbar { display: none; }
    .shop-item { padding: 12px 14px; }
    .shop-item-name { font-size: 12px; }
    .shop-item-desc { font-size: 12px; }
    .shop-item-price { font-size: 16px; }
    .shop-item-footer { flex-wrap: wrap; gap: 8px; }
    .shop-items { max-height: 50vh; }

    /* Death */
    .death-layout .screen-content {
        justify-content: center;
        padding: 30px 16px;
    }
    .death-title { letter-spacing: 4px; margin-bottom: 20px; }
    .death-summary p { font-size: 14px; }
    .prestige-number { font-size: 36px; }
    .death-lore { font-size: 14px; max-width: 100%; }
}

/* Very small phones — 320px and below */
@media (max-width: 320px) {
    body { font-size: 15px; line-height: 1.6; }

    .screen-content { padding: 30px 10px; }

    /* Title */
    .game-title { letter-spacing: 3px; }
    .game-subtitle { letter-spacing: 3px; font-size: 9px; }
    .title-lore { font-size: 13px; max-width: 260px; }
    .title-card { padding: 20px 10px; }
    .title-eyes { gap: 8px; margin-bottom: 20px; }
    .eye { width: 10px; height: 10px; }
    .eye:nth-child(2) { width: 14px; height: 14px; }
    .permadeath-warning { font-size: 8px; letter-spacing: 3px; }

    /* Create */
    .create-step h2 { font-size: 18px; letter-spacing: 2px; }
    .origin-input { font-size: 18px; padding: 10px 10px; }
    .origin-select { font-size: 14px; padding: 10px 10px; }
    .power-input { font-size: 18px; padding: 12px 10px; letter-spacing: 2px; }
    .power-input::placeholder { font-size: 12px; }
    .social-btn { padding: 14px 12px; }
    .social-name { font-size: 10px; letter-spacing: 2px; }
    .social-desc { font-size: 11px; }
    .demon-speech { padding: 12px 14px; }
    .demon-speech p { font-size: 15px; }
    .lore-text { font-size: 13px; }
    .step-label { font-size: 8px; letter-spacing: 4px; }

    /* Profile */
    .profile-name { font-size: 22px; letter-spacing: 2px; }
    .profile-value { font-size: 18px; }
    .stat-value { font-size: 18px; }
    .stat-label { font-size: 8px; letter-spacing: 2px; }
    .profile-header { padding: 14px; }
    .profile-body { padding: 14px; }

    /* Topbar */
    .game-topbar { padding: 8px 0; }
    .topbar-name { font-size: 13px; }
    .topbar-stats { gap: 6px; }
    .mini-stat { font-size: 7px; }
    .mini-stat strong { font-size: 10px; }

    /* Hub */
    .hub-btn { padding: 12px 12px; font-size: 13px; }
    .hub-location { font-size: 9px; letter-spacing: 5px; }

    /* Story */
    .event-text { font-size: 14px; }
    .btn-choice { padding: 12px 14px; font-size: 13px; }

    /* Combat */
    .combat-vs { gap: 12px; }
    .combat-vs span { font-size: 16px; }
    .combat-line p { font-size: 13px; }
    .combat-line.narrator p { font-size: 12px; }
    .combat-header h2 { font-size: 10px; letter-spacing: 5px; }

    /* Shop */
    .shop-title { font-size: 12px; letter-spacing: 3px; }
    .shop-points { font-size: 10px; }
    .tier-tab { font-size: 9px; padding: 8px 10px; }
    .shop-item { padding: 10px 12px; }
    .shop-item-name { font-size: 11px; letter-spacing: 1px; }
    .shop-item-desc { font-size: 11px; }
    .shop-item-price { font-size: 14px; }
    .btn-buy { font-size: 9px; padding: 8px 12px; }
    .shop-items { max-height: 45vh; }

    /* Death */
    .death-title { letter-spacing: 3px; }
    .death-summary p { font-size: 13px; }
    .prestige-number { font-size: 30px; }
    .death-lore { font-size: 13px; line-height: 1.7; }
    .death-eyes { gap: 8px; margin-bottom: 20px; }
}

/* Prevent horizontal overflow at all sizes */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .screen-content {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
    .game-topbar {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .choice-area, .combat-actions {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}
