:root {
    --bg-dark: #030303;
    --paper-dark: #080808;
    --paper-light: #f4efe2;
    --line-color: #c0b49f;
    --ink-black: #111111;
    --ink-red: #8b0000;
    --death-font: 'UnifrakturMaguntia', 'Cloister Black', serif;
    --cover-font: 'Cloister Black', 'UnifrakturMaguntia', serif;
    --hand-font1: 'Covered By Your Grace', cursive;
    --hand-font2: 'Gloria Hallelujah', cursive;
    --hand-font3: 'Rock Salt', cursive;
}

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

body {
    background: var(--bg-dark);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: var(--hand-font1);
    user-select: none;
    position: relative;
}

.bg-logo-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--cover-font);
    font-size: clamp(6rem, 18vw, 22rem);
    color: rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
    letter-spacing: 20px;
}

.cursor-light {
    position: fixed;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.01) 40%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.scene {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    perspective: 1500px;
}

.lang-switch {
    position: fixed;
    top: 20px;
    right: 25px;
    z-index: 100;
    display: flex;
    gap: 6px;
}

.lang-btn {
    background: #111;
    color: #666;
    border: 1px solid #333;
    padding: 6px 12px;
    cursor: pointer;
    transition: 0.3s;
}

.lang-btn.active, .lang-btn:hover {
    color: #fff;
    border-color: var(--ink-red);
    background: var(--ink-red);
}

.single-book {
    position: relative;
    width: min(92vw, 540px);
    height: min(88vh, 790px);
    background: var(--paper-dark);
    border-radius: 4px 14px 14px 4px;
    box-shadow: -20px 20px 50px rgba(0,0,0,0.95), 0 0 25px rgba(0,0,0,0.8);
    transform-style: preserve-3d;
}

.book-spine-left {
    position: absolute;
    left: -14px;
    top: 0;
    width: 18px;
    height: 100%;
    background: #050505;
    border-radius: 5px 0 0 5px;
    box-shadow: inset -2px 0 6px rgba(255,255,255,0.15);
}

.book-thickness {
    position: absolute;
    right: -12px;
    top: 6px;
    width: 12px;
    height: calc(100% - 12px);
    background: linear-gradient(90deg, #111 0%, #333 50%, #111 100%);
    border-radius: 0 4px 4px 0;
}

.cover-page {
    position: absolute;
    inset: 0;
    background: #090909;
    z-index: 30;
    border-radius: 4px 14px 14px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 32%;
    border: 1px solid #222;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s;
    transform-origin: left center;
    cursor: pointer;
}

.cover-page.opened {
    transform: rotateY(-140deg);
    opacity: 0;
    pointer-events: none;
}

.cover-texture {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg, #050505 0, #050505 3px, #0e0e0e 3px, #0e0e0e 6px);
    opacity: 0.85;
}

.cover-logo-image {
    font-family: var(--cover-font);
    font-size: clamp(2rem, 5.2vw, 3.4rem);
    color: #f0f0f0;
    letter-spacing: 6px;
    white-space: nowrap;
    z-index: 2;
    text-shadow: 0 0 12px rgba(255,255,255,0.3);
    font-weight: normal;
    border-bottom: 2px solid rgba(255,255,255,0.15);
    padding-bottom: 12px;
    width: 86%;
    text-align: center;
}

.cover-corner-fold {
    position: absolute;
    bottom: 25px;
    right: 25px;
    color: #666;
    font-size: 0.85rem;
    z-index: 2;
    letter-spacing: 2px;
}

.online-badge {
    position: absolute;
    bottom: 25px;
    left: 25px;
    z-index: 2;
    font-size: 0.75rem;
    color: #755;
    font-family: Consolas, monospace;
}

.content-page {
    position: absolute;
    inset: 0;
    padding: 30px 25px 40px 25px;
    overflow-y: auto;
    border-radius: 4px 14px 14px 4px;
}

.content-page::-webkit-scrollbar { width: 8px; }
.content-page::-webkit-scrollbar-track { background: #0d0d0d; }
.content-page::-webkit-scrollbar-thumb { background: #2a2a2a; }

.page-dark-full {
    background-color: var(--paper-dark);
    color: #d1d1d1;
}

.rule-frame-full {
    border: 1px solid #2a2a2a;
    padding: 18px 16px;
    min-height: 100%;
}

.rule-block {
    border-bottom: 1px solid #1a1a1a;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.rule-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.rule-header-title {
    font-family: var(--death-font);
    font-size: 1.35rem;
    text-align: center;
    letter-spacing: 3px;
    color: #fff;
}

.rule-header-sub {
    font-family: var(--death-font);
    font-size: 0.85rem;
    text-align: center;
    color: #888;
    margin-bottom: 8px;
}

.rule-en {
    font-family: var(--death-font);
    font-size: 0.85rem;
    line-height: 1.35;
    color: #e0e0e0;
}

.rule-cn {
    font-family: 'Kaiti', 'STKaiti', serif;
    font-size: 0.82rem;
    line-height: 1.35;
    color: #999;
    margin-top: 4px;
}

.page-light-full {
    background-color: var(--paper-light);
    background-image: linear-gradient(var(--line-color) 1px, transparent 1px);
    background-size: 100% 32px;
    line-height: 32px;
    color: var(--ink-black);
    display: flex;
    flex-direction: column;
}

.single-name-page {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.giant-target-name {
    font-family: var(--hand-font3);
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    line-height: 1.2;
    color: #111111;
    margin-top: 40px;
    margin-bottom: 20px;
    word-break: break-all;
    font-weight: normal;
}

.single-death-detail {
    font-family: var(--hand-font1);
    font-size: 1.45rem;
    line-height: 32px;
    color: #1a1a1a;
    white-space: pre-line;
}

.normal-entry-block {
    margin-bottom: 28px;
}

.entry-title {
    font-family: var(--hand-font2);
    font-size: 1.5rem;
    color: #111111;
    font-weight: normal;
}

.entry-desc {
    font-family: var(--hand-font1);
    font-size: 1.25rem;
    line-height: 32px;
    color: #222222;
    white-space: pre-line;
}

.user-added-mark {
    font-family: var(--hand-font1), 'Covered By Your Grace', cursive !important;
    font-size: 1.45rem;
    color: #111111;
    font-weight: normal;
    letter-spacing: 1px;
}

.typing-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-family: var(--death-font);
    font-size: 1.1rem;
    color: #000;
}

.write-input-small {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--ink-black);
    outline: none;
    font-family: var(--hand-font1);
    font-size: 1.3rem;
    color: #111111;
    padding: 2px 4px;
}

.write-input {
    width: 100%;
    height: 130px;
    background: transparent;
    border: 1px dashed var(--line-color);
    outline: none;
    resize: none;
    font-family: var(--hand-font1);
    font-size: 1.2rem;
    line-height: 32px;
    color: #111111;
    padding: 6px;
}

.write-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.action-btn {
    flex: 1;
    background: #111;
    color: #fff;
    border: none;
    padding: 8px 4px;
    font-family: var(--hand-font1);
    font-size: 1.05rem;
    cursor: pointer;
    transition: 0.2s;
    text-align: center;
}

.action-btn.execute-btn { background: var(--ink-red); }
.action-btn.schedule-btn { background: #333; border: 1px solid #555; }
.action-btn.clear-btn { background: #444; border: 1px solid #666; }
.action-btn:hover { opacity: 0.85; }

.page-click-zone {
    position: absolute;
    top: 0;
    bottom: 35px;
    width: 20%;
    z-index: 40;
    cursor: pointer;
}

.click-left { left: 0; }
.click-right { right: 0; }

.page-indicator {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #666;
    z-index: 60;
    pointer-events: none;
}

.death-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.death-overlay.active { display: flex; }
.countdown-box { text-align: center; color: #fff; }

.shinigami-eyes-tag {
    color: var(--ink-red);
    letter-spacing: 3px;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.countdown-title {
    font-family: sans-serif;
    font-size: 0.85rem;
    letter-spacing: 4px;
    color: #777;
    margin-bottom: 12px;
}

.countdown-timer {
    font-family: monospace;
    font-size: 5rem;
    color: var(--ink-red);
    text-shadow: 0 0 25px rgba(139, 0, 0, 0.95);
    font-weight: bold;
}

.countdown-target { font-size: 1.5rem; margin-top: 12px; color: #eee; font-family: var(--hand-font1); }

.light-voice-subtitle {
    margin-top: 18px;
    font-style: italic;
    color: #ff4d4d;
    font-size: 1.05rem;
    min-height: 24px;
}

.cancel-btn {
    margin-top: 30px;
    background: transparent;
    border: 1px solid #555;
    color: #aaa;
    padding: 8px 20px;
    font-size: 0.85rem;
    cursor: pointer;
}

.cancel-btn:hover { background: #fff; color: #000; }

.death-logo {
    display: none;
    font-family: var(--cover-font);
    font-size: clamp(3rem, 8vw, 6rem);
    color: #fff;
    letter-spacing: 12px;
    text-shadow: 0 0 30px rgba(255,255,255,0.9), 0 0 60px rgba(139, 0, 0, 0.9);
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    padding: 0 12px;
}

.death-overlay.finished { background: #000; }
.death-overlay.finished .countdown-box { display: none; }
.death-overlay.finished .death-logo { display: block; }

.audio-controls {
    position: fixed;
    bottom: 20px;
    right: 25px;
    z-index: 100;
    display: flex;
    gap: 8px;
}

.sound-btn {
    background: #111;
    color: #aaa;
    border: 1px solid #333;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.sound-btn.active {
    border-color: var(--ink-red);
    color: #fff;
    background: rgba(139,0,0,0.3);
}

.write-flash {
    position: fixed;
    inset: 0;
    background: rgba(139, 0, 0, 0.25);
    z-index: 1500;
    pointer-events: none;
    animation: flashOut 0.9s ease forwards;
}
@keyframes flashOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.share-card-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 12000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.share-card-modal.active { display: flex; }
.share-card {
    background: #0a0a0a;
    border: 1px solid #333;
    width: 100%;
    max-width: 340px;
    padding: 24px 20px;
    color: #eee;
    text-align: center;
    box-shadow: 0 0 40px rgba(139,0,0,0.3);
}
.share-card-logo {
    font-family: var(--cover-font);
    font-size: 1.6rem;
    letter-spacing: 4px;
    margin-bottom: 16px;
    color: #fff;
}
.share-card-name {
    font-family: var(--hand-font3);
    font-size: 1.8rem;
    color: #fff;
    margin: 12px 0;
    word-break: break-all;
}
.share-card-meta {
    font-family: var(--hand-font1);
    font-size: 0.95rem;
    color: #aaa;
    line-height: 1.5;
    text-align: left;
    margin-top: 12px;
    border-top: 1px dashed #333;
    padding-top: 12px;
}
.share-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}
.share-card-actions button {
    flex: 1;
    background: #222;
    border: 1px solid #555;
    color: #ccc;
    padding: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}
.share-card-actions button.primary {
    background: #8b0000;
    border-color: #c00;
    color: #fff;
}
