:root {
    --bg-color: #0c1424; 
    --panel-bg: #1a2538;
    --text-color: #f4ecd8;
    --accent-color: #c9a44c; 
    --btn-bg: linear-gradient(145deg, #8b1c1c, #601010); 
    --btn-hover: linear-gradient(145deg, #a52a2a, #8b1c1c);
    --gold-border: ridge 5px var(--accent-color);
}

body { 
    margin: 0; 
    padding: 0; 
    background-color: var(--bg-color); 
    background-image: 
        radial-gradient(circle at center, rgba(26, 37, 56, 0.4) 0%, rgba(12, 20, 36, 1) 100%),
        url('https://www.transparenttextures.com/patterns/dark-leather.png');
    color: var(--text-color); 
    font-family: "Playfair Display", "Georgia", serif; 
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    box-shadow: inset 0 0 200px rgba(0,0,0,0.9);
    pointer-events: none;
    z-index: 999;
}
.panel { display: none; flex-direction: column; height: 100%; padding: 30px; box-sizing: border-box; position: relative; }
.panel.active { display: flex; }
h1, h2, h3 { text-align: center; color: var(--accent-color); margin-top: 0; font-family: "Cinzel", serif; letter-spacing: 2px; }
h1 { font-size: 3.5em; text-shadow: 3px 3px 6px #000, 0 0 20px rgba(201, 164, 76, 0.3); }
h2 { font-size: 2.8em; border-bottom: 2px solid var(--accent-color); display: inline-block; margin: 0 auto 20px; padding-bottom: 10px; }
h3 { font-size: 2.2em; }

.sys-btn { 
    background: var(--btn-bg); 
    color: var(--text-color); 
    border: 2px solid var(--accent-color); 
    padding: 15px 20px; 
    font-size: 1.8em; 
    border-radius: 4px; 
    cursor: pointer; 
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    width: 90%; 
    margin: 12px auto; 
    display: block; 
    font-weight: bold; 
    font-family: "Cinzel", serif;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    overflow: hidden;
}
.sys-btn::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    transition: 0.5s;
    pointer-events: none;
}
.sys-btn:hover::before {
    left: 100%;
}
.sys-btn:hover { 
    background: var(--btn-hover); 
    transform: translateY(-3px); 
    box-shadow: 0 8px 20px rgba(201, 164, 76, 0.4);
    border-color: #fff;
}

.group-input { 
    background: #f4ecd8; 
    background-image: url('https://www.transparenttextures.com/patterns/parchment.png');
    border: 3px solid var(--accent-color); 
    padding: 12px; 
    font-size: 1.5em; 
    border-radius: 4px; 
    text-align: center; 
    width: 250px; 
    color: #2c1e11;
    font-family: "Playfair Display", serif;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#status-bar { 
    background: rgba(26, 37, 56, 0.95); 
    border: var(--gold-border); 
    padding: 10px 20px; 
    border-radius: 0; 
    display: flex; 
    justify-content: space-around; 
    align-items: center;
    font-size: 1.4em; 
    margin-bottom: 20px; 
    font-weight: bold; 
    font-family: "Cinzel", serif;
    box-shadow: 0 5px 15px rgba(0,0,0,0.6);
    position: relative;
    flex-wrap: wrap;
    gap: 10px;
}
.stat-item { color: var(--accent-color); text-shadow: 1px 1px 2px #000; }
.stat-item span { color: var(--text-color); margin-left: 5px; }
#status-bar::after, #status-bar::before {
    content: '⚜';
    color: var(--accent-color);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
}
#status-bar::before { left: 10px; }
#status-bar::after { right: 10px; }

#story-text { 
    background-color: rgba(12, 20, 36, 0.85); 
    background-image: url('https://www.transparenttextures.com/patterns/p6.png');
    padding: 40px; 
    border-radius: 0; 
    font-size: 2.4em; 
    line-height: 1.6; 
    margin-bottom: 20px; 
    flex-grow: 1; 
    overflow-y: auto; 
    text-shadow: 2px 2px 4px #000; 
    border: var(--gold-border); 
    position: relative; 
    background-size: contain; 
    background-repeat: no-repeat; 
    background-position: center bottom; 
    transition: all 0.5s ease; 
}
#story-text::before { 
    content: ''; 
    position: absolute; 
    top: 0; left: 0; right: 0; bottom: 0; 
    background: linear-gradient(to bottom, rgba(12, 20, 36, 0.95) 0%, rgba(12, 20, 36, 0.6) 100%);
    z-index: 0; 
    transition: background 0.4s ease;
}
#story-text:hover::before { background: rgba(12, 20, 36, 0.3); }
#story-text * { position: relative; z-index: 1; }

#choices-area { display: flex; flex-direction: column; gap: 15px; max-height: 45%; overflow-y: auto; padding-right: 8px; }

#ai-chat-area { margin-top: 20px; display: none; flex-direction: column; height: 45%; max-height: 400px; }
#chat-history { 
    flex-grow: 1; 
    background: rgba(0,0,0,0.85); 
    background-image: url('https://www.transparenttextures.com/patterns/dark-leather.png');
    padding: 25px; 
    border-radius: 0; 
    overflow-y: auto; 
    border: 2px solid var(--accent-color); 
    font-size: 2.2em; 
    line-height: 1.5; 
    box-shadow: inset 0 0 30px rgba(0,0,0,0.7); 
}
.final-ending-text { font-size: 3.2em; font-weight: bold; color: var(--accent-color); text-align: center; padding: 25px; text-shadow: 4px 4px 10px #000; animation: fadeIn 2s; line-height: 1.3; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 100; justify-content: center; align-items: center; }
.modal-content { background: var(--panel-bg); border: 4px solid var(--accent-color); padding: 30px; border-radius: 15px; width: 80%; max-width: 800px; max-height: 80vh; overflow-y: auto; position: relative; font-size: 1.8em; line-height: 1.6; }
.modal-close { position: absolute; top: 10px; right: 10px; background: var(--btn-bg); color: #fff; border: none; padding: 10px; border-radius: 5px; cursor: pointer; }

#vol-ctrl { position: fixed; bottom: 20px; left: 20px; background: rgba(0,0,0,0.85); padding: 12px; border-radius: 10px; border: 1px solid var(--accent-color); z-index: 100; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 0 15px rgba(0,0,0,0.5); font-size: 1.1em; }
.vol-item { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.vol-item input { cursor: pointer; width: 100px; }
#custom-toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(201, 164, 76, 0.9); color: #000; padding: 15px 30px; border-radius: 10px; font-size: 2em; font-weight: bold; z-index: 1000; display: none; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }

#p-leaderboard { justify-content: center; }
#leaderboard-content { flex-grow: 1; overflow-y: auto; padding: 10px; background: rgba(0,0,0,0.4); border-radius: 10px; font-size: 1.5em; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }