:root {
    --blood: #8b0000;
    --blood-bright: #c41e3a;
    --bone: #e8dcc0;
    --bone-dim: #b8a98a;
    --night: #07070d;
    --card-w: 1920px;
    --card-h: 1080px;
    --moon: #f4ecd8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background:
        radial-gradient(ellipse 120% 80% at 78% -10%, rgba(70,60,90,0.18), transparent 60%),
        radial-gradient(ellipse 100% 100% at 50% 120%, rgba(40,10,10,0.15), transparent 70%),
        var(--night);
    color: #ccc;
    font-family: 'Exo 2', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
}

.moon {
    position: fixed; top: 40px; right: 100px;
    width: 110px; height: 110px;
    background: radial-gradient(circle at 38% 38%, #fffefa 0%, var(--moon) 45%, #d8cfb4 70%, rgba(200,190,160,0) 100%);
    border-radius: 50%;
    box-shadow: 0 0 70px rgba(244,236,216,0.35), 0 0 160px rgba(230,210,170,0.18);
    z-index: 0; pointer-events: none;
}

.fog {
    position: fixed; inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 200px, rgba(100,100,120,0.025) 200px, rgba(100,100,120,0.025) 201px);
    z-index: 0; pointer-events: none;
    animation: fogDrift 60s linear infinite;
}
@keyframes fogDrift { 0% { background-position: 0 0; } 100% { background-position: 0 400px; } }

.bat {
    position: fixed; z-index: 1; pointer-events: none;
    animation: batFly linear infinite; opacity: 0.7;
}
@keyframes batFly {
    0% { transform: translate(0,0) rotate(0deg) scaleX(1); }
    25% { transform: translate(60px,-40px) rotate(6deg) scaleX(0.85); }
    50% { transform: translate(120px,-10px) rotate(-4deg) scaleX(1); }
    75% { transform: translate(60px,30px) rotate(6deg) scaleX(0.85); }
    100% { transform: translate(0,0) rotate(0deg) scaleX(1); }
}

.panel {
    position: relative; z-index: 10;
    background: rgba(18,15,15,0.95); backdrop-filter: blur(20px);
    border: 1px solid var(--blood);
    border-radius: 20px;
    padding: 25px 30px;
    width: 90%; max-width: 900px;
    margin-bottom: 15px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    text-align: center;
}
.panel h1 {
    font-family: 'Cinzel', serif;
    font-size: 2rem; color: var(--bone);
    text-shadow: 0 0 30px rgba(139,0,0,0.5);
    letter-spacing: 4px; margin-bottom: 5px;
}
.subtitle {
    font-family: 'Jura', sans-serif; color: #777;
    font-size: 0.95rem; margin-bottom: 20px; font-style: italic;
}
.input-row { display: flex; justify-content: center; margin-bottom: 12px; }
.input-row input {
    background: #0b0b10; border: 2px solid #333; color: #fff;
    padding: 10px 18px; border-radius: 8px; font-size: 0.9rem;
    outline: none; flex: 1 1 200px; max-width: 500px;
    font-family: 'Exo 2', sans-serif; transition: 0.3s;
}
.input-row input:focus { border-color: var(--blood); box-shadow: 0 0 15px rgba(139,0,0,0.4); }

button#digBtn {
    background: linear-gradient(135deg, #3a0000, #6b0000);
    color: var(--bone); border: 2px solid #5a0000;
    padding: 10px 25px; border-radius: 8px; cursor: pointer;
    font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 700;
    letter-spacing: 2px; transition: 0.3s; text-transform: uppercase;
}
button#digBtn:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a0000, #8b0000);
    box-shadow: 0 0 25px rgba(139,0,0,0.5); transform: translateY(-2px);
}
button#digBtn:disabled { opacity: 0.4; cursor: not-allowed; }

.progress {
    display: none; margin: 12px 0 0; color: #999;
    font-family: 'Jura', sans-serif; justify-content: center;
    align-items: center; gap: 10px;
}
.spinner {
    width: 22px; height: 22px; border: 3px solid rgba(139,0,0,0.2);
    border-top-color: var(--blood); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error { display: none; color: #ff4444; margin-top: 12px; font-weight: bold; font-family: 'Exo 2', sans-serif; }

.download-btn {
    display: none; margin: 15px auto 0;
    background: linear-gradient(135deg, #5a3a3a, #8b0000);
    color: var(--bone); border: 2px solid #6b0000;
    padding: 10px 25px; border-radius: 8px; cursor: pointer;
    font-family: 'Cinzel', serif; font-weight: 900;
    font-size: 0.9rem; letter-spacing: 2px; transition: 0.3s;
}
.download-btn:hover { background: linear-gradient(135deg, #8b0000, #a00000); box-shadow: 0 0 25px rgba(139,0,0,0.5); transform: translateY(-2px); }
.download-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══════════ VIEWPORT ═══════════ */
.viewport {
    display: none;
    width: calc(var(--card-w) * 0.98);
    height: calc(var(--card-h) * 0.98);
    max-width: 96vw;
    aspect-ratio: 16/9;
    position: relative;
    background: #000;
    border-radius: 20px;
    box-shadow: 0 0 80px rgba(139,0,0,0.3);
    overflow: hidden;
    z-index: 5;
}

.graveyard-card {
    width: var(--card-w);
    height: var(--card-h);
    position: absolute;
    top: 0; left: 0;
    transform-origin: top left;
    font-family: 'Exo 2', sans-serif;
    overflow: hidden;
    background: #05050b;
}

/* ═══════════ ФОНОВАЯ SVG-СЦЕНА (поляна, склеп, дерево, луна) ═══════════ */
.scene { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.scene svg { width: 100%; height: 100%; display: block; }

.vignette {
    position: absolute; inset: 0;
    z-index: 1; pointer-events: none;
    background: radial-gradient(ellipse 95% 75% at 50% 60%, transparent 45%, rgba(0,0,0,0.5) 100%);
}

.card-bats { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.card-bat { position: absolute; will-change: transform; }

/* Светящиеся души заброшенных игр */
.soul-wisp {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(180,210,255,0.95) 0%, rgba(120,160,230,0.5) 40%, rgba(90,130,210,0) 75%);
    box-shadow: 0 0 12px 4px rgba(130,170,240,0.5);
    will-change: transform, opacity;
    animation-name: wispFloat;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}
@keyframes wispFloat {
    0%   { transform: translate(0,0) scale(0.8); opacity: 0; }
    15%  { opacity: 0.9; }
    50%  { transform: translate(28px,-46px) scale(1.15); opacity: 0.7; }
    85%  { opacity: 0.5; }
    100% { transform: translate(-10px,-92px) scale(0.7); opacity: 0; }
}

/* ═══════════ ПРОФИЛЬ + СТАТИСТИКА ═══════════ */
.grave-profile {
    position: absolute;
    top: 28px; right: 38px;
    z-index: 20;
    display: flex; align-items: center; gap: 16px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(139,0,0,0.4);
    border-radius: 16px;
    padding: 12px 22px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.grave-avatar {
    width: 64px; height: 64px;
    border-radius: 12px;
    border: 2px solid var(--blood);
    box-shadow: 0 0 18px rgba(139,0,0,0.4);
    object-fit: cover;
}
.grave-nick {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.45rem; font-weight: 900;
    color: var(--bone);
    text-shadow: 0 0 15px rgba(139,0,0,0.5);
    letter-spacing: 2px;
    max-width: 340px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.grave-stats {
    position: absolute;
    top: 28px; left: 38px;
    z-index: 20;
    display: flex; gap: 26px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(139,0,0,0.4);
    border-radius: 16px;
    padding: 14px 28px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    font-family: 'Jura', sans-serif;
}
.grave-stats .stat-item { text-align: center; }
.grave-stats .stat-value {
    font-family: 'Cinzel', serif;
    font-size: 1.9rem; font-weight: 900; color: var(--blood-bright);
    text-shadow: 0 0 14px rgba(196,30,58,0.5);
    line-height: 1;
}
.grave-stats .stat-label {
    font-size: 0.7rem; color: #9a8f80;
    text-transform: uppercase; letter-spacing: 2px; margin-top: 5px;
}

/* ═══════════ ПОЛЕ МОГИЛ ═══════════ */
/* Поле занимает всю карточку — позиции могил полностью задаёт JS по
   функции холма (ground curve). Так могилы садятся точно на склон. */
.graveyard-perspective {
    position: absolute;
    inset: 0;
    z-index: 10;
}
.graveyard-field { position: absolute; inset: 0; }

/* ═══════════ НАДГРОБИЕ ═══════════ */
/* Маленькое, аккуратное. На камне — только иконка + короткое имя.
   Эпитафия и R.I.P. — в тултипе при наведении. */
.tombstone {
    position: absolute;
    transform-origin: bottom center;
    transition: transform 0.25s ease, filter 0.25s ease;
    cursor: pointer;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.65));
}
.tombstone .stone-bg { position: absolute; inset: 0; z-index: 0; }
.tombstone .stone-bg svg { width: 100%; height: 100%; display: block; }

.tombstone .stone-inner {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24% 15% 18%;
    text-align: center;
}
.tombstone .icon-slot {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.tombstone .game-icon {
    border-radius: 6px;
    background: #14110d;
    border: 1px solid rgba(90,70,50,0.55);
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.6);
    flex-shrink: 0;
}
.tombstone .game-name {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--bone);
    line-height: 1.05;
    width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0,0,0,0.85);
    word-break: break-word;
}

/* Увеличение при наведении — крупно и поверх всех */
.tombstone:hover {
    transform: translateY(-10px) scale(3.6) !important;
    z-index: 99999 !important;
    filter: drop-shadow(0 16px 26px rgba(0,0,0,0.9)) drop-shadow(0 0 22px rgba(139,0,0,0.5));
}
/* Эпитафия в тултипе — появляется только при наведении */
.tombstone .epitaph-tip {
    position: absolute;
    left: 50%; bottom: 100%;
    transform: translateX(-50%) translateY(-6px);
    width: 150px;
    background: rgba(8,6,6,0.96);
    border: 1px solid rgba(139,0,0,0.55);
    border-radius: 8px;
    padding: 8px 10px;
    z-index: 5;
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s ease;
    pointer-events: none;
    box-shadow: 0 8px 26px rgba(0,0,0,0.8);
}
.tombstone:hover .epitaph-tip { opacity: 1; visibility: visible; }
.tombstone .epitaph-tip .rip {
    font-family: 'Cinzel', serif; font-weight: 700;
    font-size: 8px; letter-spacing: 0.2em; color: #8a7d68;
    margin-bottom: 4px;
}
.tombstone .epitaph-tip .tip-name {
    font-family: 'Cinzel', serif; font-weight: 700;
    font-size: 10px; color: var(--bone); margin-bottom: 5px; line-height: 1.15;
}
.tombstone .epitaph-tip .tip-text {
    font-family: 'Jura', sans-serif; font-style: italic;
    font-size: 9px; color: #b3a690; line-height: 1.3;
}

.tombstone.skeleton .game-name {
    background: rgba(60,52,42,0.5); border-radius: 3px;
    color: transparent !important; min-height: 7px;
    animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:0.5} 50%{opacity:0.85} }

@keyframes graveRise {
    from { opacity: 0; transform: translateY(16px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* базовое позиционирование боковых вкладок */
.nav-side-btn {
    position: absolute;
    top: 25px;
    display: flex;
    align-items: center;
    height: 46px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 5;
}

/* ═══════════ ЗАГОЛОВОК ═══════════ */
.nav-left {
    background: rgba(18, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--bone);
    left: -46px;
    width: 46px;
    border: 1px solid var(--blood);
    border-right: none;
    border-radius: 12px 0 0 12px;
    box-shadow: -5px 0 15px rgba(139, 0, 0, 0.3);
    flex-direction: row-reverse; /* Иконка прижата вправо (к плашке), текст слева */
}

.nav-left:hover {
    width: 190px;
    left: -190px;
    background: rgba(139, 0, 0, 0.15);
    box-shadow: -5px 0 20px var(--blood);
    border-color: var(--blood-bright);
}

.nav-icon {
    width: 46px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.nav-text {
    opacity: 0;
    transition: opacity 0.3s;
}

.nav-side-btn:hover .nav-text {
    opacity: 1;
    transition-delay: 0.1s;
}

/* Вкладка на чек (справа) */
.nav-right, .nav-right2 {
    background: rgba(18, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--bone);
    right: -46px;
    width: 46px;
    border: 1px solid var(--blood);
    border-left: none;
    border-radius: 0 12px 12px 0;
    box-shadow: 5px 0 15px rgba(139, 0, 0, 0.3);
    flex-direction: row;
}

.nav-right:hover, .nav-right2:hover {
    width: 190px;
    right: -190px;
    background: rgba(139, 0, 0, 0.15);
    box-shadow: 5px 0 20px var(--blood);
    border-color: var(--blood-bright);
}

.nav-right { top: 25px; }
.nav-right2 { top: 81px; }