@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
    --bg-theme: radial-gradient(circle at center, #111 0%, #000 100%);
    --paper-bg: #e6dfd1;
    --paper-line: rgba(0, 0, 0, 0.05);
    --ink-black: #1f1f1f;
    --ink-faded: #4d4d4d;
    --blood-red: #731212;
    --blood-faded: rgba(115, 18, 18, 0.08);
}

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

body {
    background: var(--bg-theme);
    font-family: 'Lora', "Palatino Linotype", "Book Antiqua", Palatino, serif;
    color: var(--ink-black);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    line-height: 1.6;
    transition: background 1s ease;
}

h1, h2, h3, h4, h5, h6, .case-title, .section-title, .stats-title, .blood-title, .btn, .tab-btn {
    font-family: 'Cormorant Garamond', serif;
}

/* Animations Overlays */
#animation-layer {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 9999;
}

.anim-murder { animation: slashBlood 1s ease forwards; }
.anim-theft { animation: smokeVanish 1.5s ease forwards; }
.anim-fail { animation: tauntLaugh 2s ease forwards; }
.anim-win { animation: trophyWin 3s ease forwards; }

@keyframes slashBlood {
    0% { background: transparent; transform: scale(1); opacity: 0; }
    10% { background: linear-gradient(135deg, transparent 40%, red 50%, transparent 60%); opacity: 1; transform: scale(1.1); }
    50% { background: rgba(255, 0, 0, 0.4); }
    100% { background: transparent; opacity: 0; transform: scale(1); }
}

@keyframes smokeVanish {
    0% { background: transparent; box-shadow: inset 0 0 0 rgba(0,0,0,0); }
    30% { background: rgba(0,0,0,0.8); box-shadow: inset 0 0 100px #000; }
    80% { background: rgba(0,0,0,0.8); box-shadow: inset 0 0 200px #000; }
    100% { background: transparent; box-shadow: inset 0 0 0 rgba(0,0,0,0); }
}

@keyframes tauntLaugh {
    0% { filter: contrast(1); background: transparent; }
    50% { filter: contrast(2) invert(1) hue-rotate(180deg); background: rgba(255,0,0,0.2); transform: scale(1.05); }
    100% { filter: contrast(1); background: transparent; transform: scale(1); }
}

@keyframes trophyWin {
    0% { background: transparent; }
    20% { background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, transparent 70%); }
    80% { background: radial-gradient(circle, rgba(255,215,0,0.5) 0%, transparent 100%); }
    100% { background: transparent; }
}

.fog {
    position: absolute;
    width: 200vw;
    height: 100vh;
    background: transparent;
    opacity: 0.25;
    z-index: 1;
    pointer-events: none;
}
.fog-1 {
    background: radial-gradient(ellipse at center, rgba(200, 200, 200, 0.15) 0%, rgba(0, 0, 0, 0) 60%);
    animation: fog-drift 40s linear infinite;
    top: 0; left: -50vw;
}
.fog-2 {
    background: radial-gradient(ellipse at center, rgba(150, 150, 150, 0.2) 0%, rgba(0, 0, 0, 0) 50%);
    animation: fog-drift 60s linear infinite alternate;
    top: 20%; right: -50vw;
}
@keyframes fog-drift {
    0% { transform: translateX(0); }
    100% { transform: translateX(50vw); }
}

@keyframes shakeScreen {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.anim-shake { animation: shakeScreen 0.5s; }
.anim-wrong-guess { animation: redFlash 0.5s ease forwards; }

@keyframes redFlash {
    0% { background: transparent; }
    50% { background: rgba(255, 0, 0, 0.6); }
    100% { background: transparent; }
}

/* Notebook Container */
#game-notebook {
    position: relative;
    width: 100%;
    max-width: 650px;
    height: 90vh;
    background-color: var(--paper-bg);
    border-radius: 2px 8px 8px 2px;
    box-shadow: inset -5px 0 15px rgba(0,0,0,0.05), 0 30px 60px rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
    padding-left: 20px;
}

#game-notebook::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0; width: 45px;
    background: #2a2a2a;
    border-right: 1px solid #111;
    box-shadow: inset 10px 0 20px rgba(0,0,0,0.8);
    z-index: 2;
}

#notebook-header {
    padding: 30px 30px 15px 40px;
    border-bottom: 1px solid var(--ink-faded);
    background: var(--paper-bg);
    z-index: 3;
    text-align: center;
}

.case-title {
    font-size: 2rem;
    color: var(--ink-black);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: bold;
    border-bottom: 2px solid var(--ink-black);
    display: inline-block;
    padding-bottom: 5px;
}

.status-bar {
    font-size: 0.85rem;
    color: var(--blood-red);
    margin-top: 5px;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-around;
    padding: 5px 0;
    background: rgba(0,0,0,0.05);
}
.ap-text { font-weight: bold; }

.narrative {
    font-size: 1.15rem;
    color: var(--ink-faded);
    text-align: justify;
    margin-top: 15px;
}

#content-container {
    flex: 1;
    position: relative;
    overflow-y: auto;
    padding: 20px 30px 80px 40px;
    z-index: 3;
}

.tab-content { display: none; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-size: 1.5rem;
    color: var(--ink-black);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    text-align: center;
}

.handwriting {
    font-style: italic;
    font-size: 1.25rem;
    color: var(--ink-faded);
    border-left: 2px solid var(--ink-faded);
    padding-left: 15px;
    margin: 15px 0;
    text-align: justify;
}

.locations-grid, .suspects-list, .accuse-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.location-item, .suspect-item, .accuse-item {
    background: transparent;
    border: 1px solid var(--ink-black);
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    text-transform: capitalize;
}

.location-item:hover, .suspect-item:hover, .accuse-item:hover {
    background: rgba(138, 3, 3, 0.05); /* Soft red tint instead of full black */
    border-color: var(--blood-red);
    box-shadow: 0 0 10px rgba(138, 3, 3, 0.1);
}

.location-item.visited, .suspect-item.dead {
    opacity: 0.4;
    text-decoration: line-through;
    pointer-events: none;
    border-style: dashed;
}

.suspect-item.dead {
    color: var(--blood-red);
    border-color: var(--blood-red);
}

.clue-list { list-style: none; }
.clue-list li {
    padding: 12px 0;
    border-bottom: 1px dotted var(--ink-faded);
    font-size: 1.15rem;
    text-align: justify;
}

.result-box {
    margin-top: 25px;
    padding: 20px;
    background: var(--blood-faded);
    border: 1px solid var(--blood-red);
}

.btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background: transparent;
    border: 1px solid var(--ink-black);
    color: var(--ink-black);
    font-family: inherit;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover { background: var(--ink-black); color: var(--paper-bg); }

.dropdown-style {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    font-family: inherit;
    font-size: 1.1rem;
    background: transparent;
    border: 1px solid var(--blood-red);
    color: var(--blood-red);
}

.danger-btn { border-color: var(--blood-red); color: var(--blood-red); }
.danger-btn:hover { background: var(--blood-red); color: white; }

#notebook-tabs {
    position: absolute;
    bottom: 0; left: 45px; right: 0;
    display: flex;
    background: var(--ink-black);
    z-index: 10;
}

.tab-btn {
    flex: 1;
    padding: 18px 5px;
    background: transparent;
    border: none;
    font-family: inherit;
    color: #aaa;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s;
    border-right: 1px solid #333;
}
.tab-btn:hover { color: white; }
.tab-btn.active {
    background: var(--paper-bg);
    color: var(--ink-black);
    font-weight: bold;
    border-top: 4px solid var(--blood-red);
}

/* Modal overlays */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    text-align: center;
    color: white;
}

.hidden { display: none !important; }

.screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

#game-layout.screen {
    flex-direction: row;
    justify-content: center;
}

.blood-title {
    color: var(--blood-red);
    font-size: 3rem;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
    border-bottom: 1px solid var(--blood-red);
    padding-bottom: 10px;
}
.win-title { color: gold; text-shadow: 0 0 20px rgba(255,215,0,0.5); border-color: gold; }
.night-desc { color: #ddd; font-size: 1.3rem; margin-bottom: 35px; line-height: 1.8; }

.white-btn { border-color: white; color: white; max-width: 250px; margin: 10px auto; }
.white-btn:hover { background: white; color: black; }

/* Screens: Campaign & Map */
#campaign-select-screen {
    justify-content: center;
}

.campaign-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 900px;
}

.campaign-card {
    background: #111;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 20px;
    width: 260px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}
.campaign-card:hover { border-color: var(--blood-red); transform: translateY(-5px); box-shadow: 0 10px 20px rgba(255,0,0,0.2); }
.campaign-card.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(100%); pointer-events: none; }

.campaign-avatar {
    width: 100px; height: 100px;
    border-radius: 50%;
    margin-bottom: 15px;
    border: 2px solid #555;
    object-fit: cover;
}

.campaign-name { color: #fff; font-size: 1.5rem; margin-bottom: 10px; border-bottom: 1px dotted #555; padding-bottom: 5px; }
.campaign-desc { color: #aaa; font-size: 1rem; }

/* Tutorial Box */
.tutorial-box {
    background: var(--paper-bg);
    color: var(--ink-black);
    padding: 40px;
    border-radius: 5px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 0 50px rgba(0,0,0,1);
    border: 3px solid var(--ink-black);
}

/* Map screen - PARCHMENT TREE MAP */
#map-screen {
    background-color: #d1c0a0; /* Parchment base */
    background-image: 
        linear-gradient(rgba(100,50,0, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100,50,0, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.6);
    color: var(--ink-black);
    justify-content: flex-start;
}

.map-header { 
    width: 100%; max-width: 900px; 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 30px; margin-top: 30px; 
    padding: 0 20px;
    border-bottom: 2px dashed rgba(0,0,0,0.3);
    padding-bottom: 10px;
}
.map-header .blood-title {
    color: var(--ink-black);
    border-color: var(--ink-black);
}

.map-nodes-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 40px 0 100px 0;
    gap: 40px;
    position: relative;
}

/* Tree Trunk Line */
.map-nodes-container::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: 50%;
    width: 4px;
    background: var(--ink-black);
    transform: translateX(-50%);
    opacity: 0.2;
    z-index: 1;
}

.node-card {
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid var(--ink-black);
    padding: 15px 20px;
    border-radius: 2px 10px 10px 2px;
    cursor: pointer;
    transition: all 0.2s;
    width: 260px;
    position: relative;
    z-index: 2;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.2);
    /* Alternating branches */
    margin-left: -200px; 
}

/* Alternating nodes to left and right */
.node-card:nth-child(even) {
    margin-left: 200px;
}

/* Connect branches to trunk */
.node-card::before {
    content: '';
    position: absolute;
    top: 50%;
    width: 100px;
    height: 4px;
    background: var(--ink-black);
    opacity: 0.2;
    z-index: -1;
}
.node-card:nth-child(odd)::before {
    right: -100px; /* Line to the trunk (right) */
}
.node-card:nth-child(even)::before {
    left: -100px; /* Line to the trunk (left) */
}

.node-card:hover { 
    background: var(--ink-black); 
    color: var(--paper-bg); 
    transform: scale(1.05);
}
.node-card.completed { 
    border-color: #8b0000; 
    opacity: 1; 
    box-shadow: 0 0 15px rgba(139,0,0,0.4);
}
.node-card.locked { opacity: 0.2; cursor: not-allowed; pointer-events: none; filter: grayscale(100%); }

.node-title { font-size: 1.25rem; font-weight: bold; margin-bottom: 5px; color: var(--ink-black); font-family: 'Cormorant Garamond', serif;}
.node-card:hover .node-title, .node-card:hover .node-loc { color: var(--paper-bg); }

.node-card.completed .node-title { color: #8b0000; text-decoration: underline; }
.node-card:hover.completed .node-title { color: #ff6666; }

.node-loc { font-size: 0.95rem; color: var(--ink-faded); font-style: italic; }

.help-btn { max-width: 150px; background: transparent; color: #aaa; border: 1px solid #555; margin: 0 auto 30px auto; }
.return-btn { max-width: 150px; margin: 0; background: var(--ink-black); color: var(--paper-bg);}

.item-badge { background: #5a3c00; color: #ffe066; padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; display: inline-block; margin-top: 5px; border: 1px solid gold;}

/* Layout stats panel */
.game-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
    max-width: 1200px;
    width: 98%;
    margin: 0 auto;
    left: 0; right: 0;
    z-index: 10;
}

.side-panel {
    width: 220px;
    background: var(--paper-bg);
    border: 3px solid #3d2314;
    border-radius: 5px;
    padding: 15px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5), 0 10px 20px rgba(0,0,0,0.8);
    position: relative;
    height: auto;
    flex-shrink: 0;
}
.side-panel::after {
    content: ''; position: absolute; top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 1px solid rgba(0,0,0,0.2); pointer-events: none;
}
.stats-title { font-size: 1.2rem; text-align: center; border-bottom: 2px solid var(--ink-black); padding-bottom: 5px; margin-bottom: 10px; color: var(--blood-red); }
.stats-content p { font-size: 1.1rem; margin-bottom: 8px; font-weight: bold; }
.win-color { color: #2d6a4f; }
.audio-btn { margin-top: 20px; background: #111; color: #eee; border: 1px solid #555; font-size: 1rem; }
.audio-btn:hover { background: #333; }

#fx-canvas { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1; opacity: 0.6; }


.suspect-info { display: flex; align-items: center; }

.clue-label { display: flex; align-items: flex-start; cursor: pointer; margin-bottom: 15px; }
.clue-checkbox { margin-top: 5px; margin-right: 12px; transform: scale(1.3); accent-color: var(--blood-red); }

/* Item Button */
.use-item-btn { margin-top: 5px; padding: 5px; font-size: 0.8rem; background: #ffcc0033; border: 1px solid #b8860b; color: #5a3c00; font-family: inherit; cursor: pointer;}
.use-item-btn:hover { background: #b8860b; color: white; }

/* Mobile panel toggle */
details.mobile-collapse summary::-webkit-details-marker { display: none; }
details.mobile-collapse summary { list-style: none; }
.mobile-only { display: none; }
.desktop-only { display: block; }

/* Responsive Mobile */
@media (max-width: 768px) {
    body { padding-top: 10px; align-items: flex-start; overflow-y: auto;}
    .mobile-only { display: inline; }
    .desktop-only { display: none !important; }
    
    #game-layout.screen {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        gap: 15px;
        padding-top: 20px;
    }
    
    .game-layout { flex-direction: column; align-items: center; justify-content: flex-start; gap: 15px; height: auto; }
    .side-panel { width: 100%; padding: 10px; order: 3; }
    .right-panel { order: 1; } /* Đưa lượt chơi lên trên ở mobile */
    #game-notebook { width: 100%; max-width: 100%; height: 85vh; flex: none; padding-left: 10px; order: 2; }
    #game-notebook::before { width: 15px; }
    #notebook-header { padding: 5px 10px 0px 15px; border-bottom: none; }
    .case-title { font-size: 1.15rem; margin-bottom: 0px; padding-bottom: 0; line-height: 1.2; border: none; }
    .narrative { font-size: 0.9rem; margin-top: 2px; line-height: 1.3; }
    #content-container { padding: 5px 10px 40px 15px; }
    .tab-btn { padding: 12px 2px; font-size: 0.75rem; }
    .btn { padding: 5px; font-size: 0.85rem; }
    
    .locations-grid, .suspects-list, .accuse-grid { gap: 8px; grid-template-columns: 1fr 1fr; }
    .location-item, .suspect-item { padding: 8px 10px; font-size: 0.9rem; flex-direction: column; align-items: stretch; text-align: left;}
    .suspect-info { flex-direction: column; align-items: flex-start; }
    .suspect-info div { display: flex; flex-direction: row; align-items: center; justify-content: space-between; width: 100%; margin-top: 5px; }
    .section-title { font-size: 1.2rem; margin-bottom: 10px; margin-top: -10px; }
    
    .node-card { margin-left: 0; width: 80%; text-align: center; }
    .node-card:nth-child(even) { margin-left: 0; }
    .node-card::before { display: none; }
    .map-nodes-container::before { display: none; }
}
