:root {
    --bg-color: #0a0a0a;
    --text-color: #d1d1d1;
    --accent-color: #9c0000; /* Deep Blood red */
    --accent-glow: #ff0000;
    --card-bg: #141414;
    --border-color: #2a2a2a;
    --font-horror: 'Creepster', cursive;
    --font-main: 'Special Elite', system-ui;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Vignette Effect linked to Sanity */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 150px rgba(0,0,0,0.9);
    pointer-events: none;
    z-index: 1000;
    transition: box-shadow 0.5s;
}

#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5; /* Behind UI (10) but above body */
}

.container {
    width: 100%;
    max-width: 1000px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    z-index: 10;
}

header {
    text-align: center;
    padding-bottom: 20px;
    position: relative;
}

header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 25%;
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
}

h1 {
    font-family: var(--font-horror);
    font-size: 4em;
    color: var(--accent-color);
    margin: 0;
    letter-spacing: 5px;
    text-shadow: 0 0 10px rgba(156, 0, 0, 0.5);
    animation: glitch 5s infinite;
}

.subtitle {
    font-size: 1.2em;
    color: #666;
    margin-top: -10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Omen Styling */
.omen-container {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.omen-container.hidden {
    display: none !important;
}

/* Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 30px;
}

@media (max-width: 800px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

/* Resource Section */
.overview {
    background: var(--card-bg);
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    /* Sticky positioning */
    position: sticky;
    top: 20px;
    align-self: start;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Scrollbar for overview if it gets too tall */
.overview::-webkit-scrollbar { width: 4px; }

.resource-display {
    font-size: 3em;
    font-family: var(--font-horror);
    color: #fff;
    margin-bottom: 10px;
}

.currency-label {
    display: block;
    font-size: 0.4em;
    color: var(--accent-color);
    text-transform: uppercase;
    font-family: var(--font-main);
    letter-spacing: 2px;
}

/* Sanity Bar */
.sanity-container {
    width: 100%;
    margin: 20px 0;
}

.sanity-bar-bg {
    width: 100%;
    height: 12px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.sanity-bar-fill {
    height: 100%;
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Dread Orb */
.clicker-area {
    margin-top: 20px;
}

.orb {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #444, #000);
    border: 2px solid #222;
    cursor: pointer;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,1), inset 0 0 50px rgba(0,0,0,1);
    transition: transform 0.05s;
    outline: none;
}

.orb::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: var(--accent-color);
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.3;
    animation: pulse 4s infinite;
}

.orb:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 30px var(--accent-color);
}

.orb:active {
    transform: scale(0.92);
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.2; }
    50% { transform: translate(-50%, -50%) scale(2); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0.2; }
}

/* Shop Section */
.shop h2 {
    font-family: var(--font-horror);
    color: var(--accent-color);
    font-size: 2em;
    margin-top: 0;
}

.buy-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.9em;
}

.buy-mult {
    background: #1a1a1a;
    border: 1px solid var(--border-color);
    color: #888;
    padding: 5px 15px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

.buy-mult:hover {
    border-color: var(--accent-color);
    color: #fff;
}

.buy-mult.active {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-glow);
    font-weight: bold;
    box-shadow: 0 0 10px var(--accent-glow);
}

.generator-item {
    background: #1a1a1a;
    border-left: 4px solid var(--border-color);
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.generator-item:hover {
    background: #222;
    border-left-color: var(--accent-color);
    transform: translateX(5px);
}

.generator-item.disabled {
    opacity: 0.4;
    filter: grayscale(1);
    cursor: not-allowed;
}

.gen-info h4 {
    margin: 0;
    font-family: var(--font-horror);
    font-size: 1.4em;
    color: #fff;
}

.gen-desc {
    font-size: 0.8em;
    color: #888;
    font-style: italic;
}

.gen-cost {
    font-weight: bold;
    color: var(--accent-color);
}

.gen-count {
    font-size: 2em;
    font-family: var(--font-horror);
    color: #333;
}

/* Anomalies */
.anomaly {
    position: fixed;
    width: 60px;
    height: 60px;
    background: transparent;
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-horror);
    font-size: 1.5em;
    cursor: crosshair;
    z-index: 2000;
    user-select: none;
    animation: anomalyPulse 0.5s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.anomaly::before {
    content: "ERR";
    position: absolute;
    animation: glitchText 0.3s infinite;
}

@keyframes anomalyPulse {
    0% { transform: scale(1) rotate(0deg); border-color: #f00; opacity: 0.8; }
    50% { transform: scale(1.1) rotate(5deg); border-color: #fff; opacity: 1; }
    100% { transform: scale(1) rotate(0deg); border-color: #f00; opacity: 0.8; }
}

@keyframes glitchText {
    0% { transform: translate(0,0); }
    25% { transform: translate(2px, -2px); }
    50% { transform: translate(-2px, 2px); }
    75% { transform: translate(2px, 2px); }
    100% { transform: translate(0,0); }
}

/* Void Market */
.market-section {
    background: #0f0f15;
    border: 1px solid #444;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.market-display {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    background: #050505;
    padding: 10px;
    border-radius: 4px;
}

.market-label {
    display: block;
    color: #666;
    font-size: 0.8em;
    text-transform: uppercase;
}

.market-price-row {
    font-family: var(--font-horror);
    font-size: 1.5em;
    color: var(--accent-color);
}

#market-owned {
    font-family: var(--font-horror);
    font-size: 1.5em;
    color: #fff;
}

.market-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.market-btn {
    background: #222;
    border: 1px solid #444;
    color: #ccc;
    padding: 8px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

.market-btn:hover {
    border-color: var(--accent-color);
    color: #fff;
    background: #333;
}

.market-warning {
    margin-top: 10px;
    font-size: 0.7em;
    color: #a00;
    text-align: center;
    font-style: italic;
}

.trend-up { color: #00ff00; }
.trend-down { color: #ff0000; }
.trend-flat { color: #888; }

/* Artifacts */
.upgrade-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.upgrade-item {
    background: #1a1a1a;
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upgrade-item:hover:not(.disabled) {
    border-color: var(--accent-color);
    background: #222;
    box-shadow: 0 0 15px rgba(156, 0, 0, 0.3);
}

.upgrade-name {
    font-family: var(--font-horror);
    color: #fff;
    margin-bottom: 5px;
}

/* Rituals */
#ritual-section {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    animation: fadeIn 2s;
}

.ritual-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.essence-display {
    font-size: 1.5em;
    font-family: var(--font-horror);
}

.btn-prestige {
    background: #000;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 10px 20px;
    font-family: var(--font-horror);
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(156,0,0,0.2);
}

.btn-prestige:hover {
    background: var(--accent-color);
    color: #000;
    box-shadow: 0 0 20px var(--accent-glow);
}

.ritual-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.ritual-item {
    background: #0e0e0e;
    border: 1px solid #333;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ritual-item:hover {
    border-color: #555;
}

.ritual-info h4 {
    margin: 0;
    color: #bbb;
    font-family: var(--font-main);
}

.ritual-cost {
    color: #888;
    font-size: 0.9em;
}

.ritual-buy {
    background: #222;
    border: 1px solid #444;
    color: #eee;
    padding: 5px 15px;
    cursor: pointer;
}

.ritual-buy:hover:not(:disabled) {
    border-color: var(--accent-color);
}

.ritual-buy:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Achievements */
.achievement-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.achievement-item {
    background: #0a0a0a;
    border: 1px solid #222;
    padding: 10px;
    border-radius: 4px;
    font-size: 0.8em;
    opacity: 0.4;
    filter: grayscale(1);
    transition: all 0.5s ease;
}

.achievement-item.unlocked {
    opacity: 1;
    filter: grayscale(0);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(156,0,0,0.3);
    background: #141414;
}

.ach-name {
    font-family: var(--font-horror);
    font-size: 1.2em;
    color: var(--accent-color);
    margin-bottom: 3px;
}

.ach-text {
    color: #888;
    line-height: 1.2;
}

.ach-status {
    margin-top: 5px;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ach-progress-container {
    margin-top: 8px;
    background: #111;
    height: 14px;
    border: 1px solid #333;
    position: relative;
    border-radius: 2px;
}

.ach-progress-bar {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.3s;
    opacity: 0.6;
}

.ach-progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7em;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid var(--accent-color);
    padding: 10px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10000;
    font-size: 0.85em;
    color: #ccc;
    box-shadow: 0 0 15px rgba(0,0,0,0.8);
    max-width: 250px;
}

.tooltip.hidden {
    opacity: 0;
    visibility: hidden;
}

.tooltip h4 {
    margin: 0 0 5px 0;
    color: var(--accent-color);
    font-family: var(--font-horror);
    border-bottom: 1px solid #333;
    padding-bottom: 3px;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.tooltip-val {
    color: #fff;
    font-weight: bold;
}

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

/* Log Area */
.log-area {
    background: #050505;
    border: 1px solid var(--border-color);
    padding: 15px;
    height: 150px; /* Fixed height for consistency */
    font-size: 0.8em;
    border-radius: 4px;
    text-align: left;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
    margin-top: auto; /* Push to bottom of flex container if space allows */
}

.log-area h3 {
    margin: 0 0 10px 0;
    color: #444;
    font-family: var(--font-main);
    text-transform: uppercase;
    font-size: 0.9em;
    border-bottom: 1px solid #111;
}

.log-entry {
    color: #666;
    margin-bottom: 5px;
    border-bottom: 1px solid #111;
}

/* Click Floater */
.click-floater {
    position: fixed;
    pointer-events: none;
    font-family: var(--font-horror);
    font-size: 1.5em;
    color: var(--accent-color);
    text-shadow: 0 0 5px #000;
    z-index: 2000;
    animation: floatAndFade 1s ease-out forwards;
}

@keyframes floatAndFade {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-100px); opacity: 0; }
}

/* Glitch Animation */
@keyframes glitch {
    0% { transform: skew(0deg); }
    1% { transform: skew(10deg); opacity: 0.8; }
    2% { transform: skew(-10deg); opacity: 0.8; }
    3% { transform: skew(0deg); }
    100% { transform: skew(0deg); }
}

/* Low Sanity effects */
body.low-sanity .vignette {
    box-shadow: inset 0 0 250px rgba(156,0,0,0.6);
}

/* Omen Effects */
body.omen-blood-moon { background-color: #1a0000; }
body.omen-silence { filter: grayscale(100%); }
body.omen-void-leak { animation: glitch 0.2s infinite; }
body.omen-void-stare .vignette { box-shadow: inset 0 0 400px #000; opacity: 1; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #111;
    border: 1px solid var(--accent-color);
    padding: 30px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 0 30px rgba(156, 0, 0, 0.4);
}

.modal-content h2 {
    font-family: var(--font-horror);
    color: var(--accent-color);
    margin-top: 0;
}

.text-accent {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.2em;
}

#btn-close-modal {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 10px 20px;
    margin-top: 20px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

#btn-close-modal:hover {
    background: var(--accent-color);
    color: #000;
}

.settings-content {
    text-align: left;
    min-width: 300px;
}

.setting-row {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-row label {
    color: #ccc;
    font-family: var(--font-main);
}

.setting-row input[type="range"] {
    width: 150px;
    accent-color: var(--accent-color);
}

.setting-row input[type="checkbox"] {
    accent-color: var(--accent-color);
    transform: scale(1.5);
}

/* Grimoire */
.grimoire-content {
    width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.grimoire-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.lore-entry {
    background: #0a0a0a;
    border: 1px solid #333;
    padding: 10px;
}

.lore-entry.locked {
    opacity: 0.5;
    filter: blur(2px);
    pointer-events: none;
}

.lore-title {
    color: var(--accent-color);
    font-family: var(--font-horror);
    font-size: 1.2em;
    margin-bottom: 5px;
    border-bottom: 1px solid #222;
}

/* Event Modal */
.event-content {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 50px rgba(156,0,0,0.5);
}

#event-title {
    color: var(--accent-color);
    font-size: 2em;
    margin-bottom: 10px;
}

#event-text {
    font-size: 1.1em;
    line-height: 1.5;
    margin-bottom: 20px;
}

.event-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-btn {
    background: #111;
    border: 1px solid #444;
    color: #ccc;
    padding: 15px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
    text-align: left;
}

.choice-btn:hover {
    border-color: var(--accent-color);
    color: #fff;
    background: #222;
}

/* Ascension */
#ascension-section {
    margin-top: 40px;
    border-top: 2px solid #4b0082; /* Indigo */
    padding-top: 20px;
    animation: fadeIn 2s;
}

.ascension-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ascension-progress-container {
    width: 100%;
    height: 24px;
    background: #1a0a2a;
    border: 1px solid #4b0082;
    margin-bottom: 20px;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

.ascension-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4b0082, #9370db);
    width: 0%;
    transition: width 0.2s;
    box-shadow: 0 0 15px #9370db;
}

.ascension-progress-text {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    color: #fff; font-size: 0.8em; text-shadow: 0 0 5px #000;
    font-family: var(--font-main);
    z-index: 2;
}

.truths-display {
    font-size: 1.5em;
    font-family: var(--font-horror);
    color: #9370db; /* Medium Purple */
}

.btn-ascend {
    background: #000;
    border: 1px solid #9370db;
    color: #9370db;
    padding: 10px 20px;
    font-family: var(--font-horror);
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-ascend:hover:not(:disabled) {
    background: #9370db;
    color: #000;
    box-shadow: 0 0 20px #9370db;
}

.btn-ascend:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ascension-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.ascension-item {
    background: #0a0510;
    border: 1px solid #301934;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ascension-item.owned {
    border-color: #9370db;
    box-shadow: inset 0 0 10px rgba(147, 112, 219, 0.2);
}

.ascension-info h4 {
    margin: 0;
    color: #9370db;
}

.ascension-buy {
    background: #1a0a2a;
    border: 1px solid #4b0082;
    color: #9370db;
    padding: 5px 15px;
    cursor: pointer;
}

.ascension-buy:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #222; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }