/* CSS Variables for easy theming */
:root {
    --bg-primary: #080808;
    --bg-secondary: #141414;
    --bg-tertiary: #1c1c1c;
    --text-primary: #e8e0d4;
    --text-secondary: #b0a898;
    --text-muted: #6a6258;
    --accent-gold: #c8a44e;
    --accent-gold-dim: rgba(200,164,78,0.15);
    --accent-gold-hover: #dab95e;
    --accent-red: #a04040;
    --border-color: #2a2a2a;
    --serif-font: "Georgia", "Times New Roman", "Palatino", serif;
    --sans-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono-font: "SF Mono", "Fira Code", monospace;
    --transition-speed: 0.25s;
    --max-width: 720px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--serif-font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* Container */
#game-container {
    height: 100vh;
    max-width: var(--max-width);
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* ─── Screen Management ─── */
.screen {
    display: none;
    height: 100vh;
    opacity: 0;
    transition: opacity 0.5s ease;
    overflow: hidden;
}
.screen.active {
    display: block;
    opacity: 1;
}
.screen.fading-out {
    opacity: 0;
}

/* ─── Animated Fog Layer ─── */
.fog-layer {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 300px;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(200,164,78,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 30%, rgba(200,164,78,0.04) 0%, transparent 50%),
        linear-gradient(180deg, rgba(20,20,20,0.8) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

/* ─── Title Screen ─── */
#title-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    position: relative;
    background: var(--bg-primary);
    overflow-y: auto;
}

.title-content {
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.title-ornament {
    color: var(--text-muted);
    font-size: 1rem;
    letter-spacing: 8px;
    margin: 1.5rem 0;
}

.game-title {
    font-size: 2.4rem;
    color: var(--accent-gold);
    text-shadow: 0 2px 20px rgba(200,164,78,0.3);
    margin-bottom: 0.5rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 400;
}

.game-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    letter-spacing: 1px;
}

.title-menu {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* ─── Buttons ─── */
.menu-btn {
    background: transparent;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 0.9rem 2.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 2px;
    transition: all var(--transition-speed) ease;
    font-family: var(--sans-font);
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 500;
}

.menu-btn:hover {
    background: var(--accent-gold);
    color: var(--bg-primary);
    box-shadow: 0 0 20px rgba(200,164,78,0.2);
}

.menu-btn.secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.menu-btn.secondary:hover {
    border-color: var(--text-secondary);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: none;
}

/* ─── Game Screen Layout ─── */
#game-screen {
    display: flex;
    flex-direction: column;
}
#game-screen.active {
    display: flex;
}

/* ─── Fog Header ─── */
.fog-header {
    background: linear-gradient(180deg, rgba(200,164,78,0.08) 0%, transparent 100%);
    padding: 1.8rem 1.5rem 1.2rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

#game-header-title {
    font-size: 1.4rem;
    color: var(--accent-gold);
    text-shadow: 0 1px 10px rgba(200,164,78,0.2);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 400;
}

/* ─── Status Bar ─── */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--sans-font);
    font-size: 0.8rem;
    flex-wrap: wrap;
    gap: 0.4rem;
    position: sticky;
    top: 0;
    z-index: 9;
    flex-shrink: 0;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#chapter-indicator {
    font-weight: 600;
    color: var(--accent-gold);
    letter-spacing: 1px;
}

#location-indicator { color: var(--text-secondary); }

.status-stat {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.status-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 2px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 0.8rem;
}

.status-btn:hover {
    background: var(--accent-gold-dim);
    border-color: var(--accent-gold);
    color: var(--text-primary);
}

/* ─── Main Game Content ─── */
.game-content {
    padding: 2.5rem 2rem 4rem;
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Hide scrollbar on game content */
.game-content::-webkit-scrollbar { display: none; }
.game-content { scrollbar-width: none; }

#scene-container {
    max-width: 100%;
}

.scene-enter {
    animation: sceneIn 0.5s ease;
}

@keyframes sceneIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

#scene-title {
    font-size: 1.3rem;
    color: var(--accent-gold);
    margin-bottom: 2rem;
    text-align: center;
    font-weight: 400;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 1rem;
}

#scene-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: var(--accent-gold);
    opacity: 0.4;
}

/* ─── Narrative Text ─── */
.narrative {
    font-size: 1.05rem;
    line-height: 1.9;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.narrative p {
    margin-bottom: 1.2rem;
    text-indent: 1.5em;
}

.narrative p:first-child {
    text-indent: 0;
}

/* Clue Highlighting */
.clue-highlight {
    color: var(--accent-gold);
    cursor: pointer;
    border-bottom: 1px dashed rgba(200,164,78,0.5);
    transition: all var(--transition-speed) ease;
    padding: 0 1px;
}

.clue-highlight:hover {
    background: var(--accent-gold-dim);
    border-bottom-style: solid;
}

.clue-found {
    color: var(--text-secondary);
    border-bottom-color: transparent;
    cursor: default;
}

/* Typewriter */
.typewriter {
    border-right: 2px solid var(--accent-gold);
    animation: blink-caret 0.8s infinite;
}

@keyframes blink-caret {
    0%, 40% { border-color: var(--accent-gold); }
    41%, 100% { border-color: transparent; }
}

.typewriter-complete {
    border-right: none;
    animation: none;
}

/* ─── Choices ─── */
.choices {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2.5rem;
    transition: opacity 0.4s ease;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.choice {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.9rem 1.2rem;
    text-align: left;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s ease;
    font-family: var(--serif-font);
    font-size: 0.95rem;
    position: relative;
    line-height: 1.5;
}

.choice:before {
    content: "▸ ";
    color: var(--accent-gold);
    font-weight: bold;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.choice:hover {
    background: var(--accent-gold-dim);
    border-color: var(--accent-gold);
    padding-left: 1.6rem;
}

.choice:hover:before {
    opacity: 1;
}

.choice:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.choice:disabled:hover {
    background: transparent;
    border-color: var(--border-color);
    padding-left: 1.2rem;
}

.choice:disabled:before {
    content: "🔒 ";
    color: var(--text-muted);
    opacity: 0.5;
}

/* ─── Toast Notifications ─── */
.game-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 0.7rem 1.5rem;
    border-radius: 2px;
    font-family: var(--sans-font);
    font-size: 0.85rem;
    letter-spacing: 1px;
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s ease;
    pointer-events: none;
    white-space: nowrap;
}

.game-toast.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-save { border-color: var(--text-muted); color: var(--text-secondary); }

/* ─── Overlay Screens ─── */
.overlay-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding: 2rem 1rem;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.overlay-screen.active {
    display: flex;
}

.overlay-content {
    background: var(--bg-primary);
    border: 1px solid var(--accent-gold);
    border-radius: 2px;
    max-width: 580px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    margin-top: 2rem;
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.overlay-header h3 {
    color: var(--accent-gold);
    font-family: var(--sans-font);
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color var(--transition-speed) ease;
}

.close-btn:hover { color: var(--accent-gold); }

/* ─── Evidence Board ─── */
.evidence-board { padding: 1.5rem; }

.evidence-category { margin-bottom: 1.5rem; }

.evidence-category h4 {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-family: var(--sans-font);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.evidence-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.evidence-item {
    background: var(--bg-secondary);
    padding: 0.8rem 1rem;
    border-radius: 2px;
    border-left: 2px solid var(--accent-gold);
}

.evidence-item h5 {
    color: var(--accent-gold);
    margin-bottom: 0.3rem;
    font-family: var(--sans-font);
    font-size: 0.85rem;
}

.evidence-item p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ─── Character Notes ─── */
.character-notes { padding: 1.5rem; }

.character-card {
    background: var(--bg-secondary);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 2px;
    border-left: 2px solid var(--accent-gold);
}

.character-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.character-portrait { font-size: 1.8rem; }

.character-info h4 {
    color: var(--accent-gold);
    font-family: var(--sans-font);
    font-size: 0.9rem;
}

.character-title {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
}

.suspicion-meter { margin: 0.5rem 0; }

.suspicion-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--sans-font);
    margin-bottom: 0.2rem;
}

.suspicion-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
}

.suspicion-fill {
    height: 100%;
    background: var(--accent-gold);
    transition: width 0.5s ease;
    border-radius: 2px;
}

/* ─── Ending Screen ─── */
#ending-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    position: relative;
    background: var(--bg-primary);
    overflow-y: auto;
}

.ending-content {
    max-width: 520px;
    position: relative;
    z-index: 1;
}

.ending-type-badge {
    font-family: var(--sans-font);
    font-size: 0.7rem;
    letter-spacing: 4px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

#ending-title {
    font-size: 2rem;
    color: var(--accent-gold);
    margin-bottom: 2rem;
    text-shadow: 0 2px 20px rgba(200,164,78,0.3);
    font-weight: 400;
    letter-spacing: 2px;
}

.ending-narrative {
    font-size: 1.05rem;
    margin-bottom: 2rem;
    text-align: left;
    line-height: 1.9;
}

.ending-narrative p {
    margin-bottom: 1rem;
}

.ending-stats {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-family: var(--sans-font);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.stat-row:last-child { border-bottom: none; }

.stat-row.rating span:last-child {
    font-size: 1.1rem;
}

.ending-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    #game-container { max-width: 100%; }
    .game-content { padding: 1.5rem 1.25rem 3rem; }
    .status-bar { padding: 0.5rem 1rem; font-size: 0.75rem; }
    .game-title { font-size: 1.8rem; }
    .overlay-content { margin: 0.5rem; max-height: 90vh; }
    .fog-header { padding: 1.2rem 1rem 0.8rem; }
}

@media (max-width: 480px) {
    .status-bar {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    .status-left, .status-right { justify-content: center; }
    .game-title { font-size: 1.5rem; }
    .narrative { font-size: 1rem; }
    .game-content { padding: 1.25rem 1rem 3rem; }
}

/* ─── Language Toggle (title screen) ─── */
.lang-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.35rem 0.8rem;
    font-size: 0.75rem;
    font-family: var(--sans-font);
    cursor: pointer;
    border-radius: 2px;
    z-index: 1500;
    transition: all var(--transition-speed) ease;
    letter-spacing: 1px;
}
.lang-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* ─── Language Toggle (inline in fog-header) ─── */
.lang-btn-inline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-family: var(--sans-font);
    cursor: pointer;
    border-radius: 2px;
    transition: all var(--transition-speed) ease;
    letter-spacing: 1px;
    position: absolute;
    right: 1rem;
}
.lang-btn-inline:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* ─── Scrollbar — hidden globally, thin on overlays ─── */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

.overlay-content::-webkit-scrollbar { display: block; width: 4px; }
.overlay-content::-webkit-scrollbar-track { background: transparent; }
.overlay-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
.overlay-content::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }
.overlay-content { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }

/* ─── Clue Tutorial Hint ─── */
.clue-tutorial-target {
    position: relative;
    animation: clue-pulse 1.5s ease-in-out infinite;
}

@keyframes clue-pulse {
    0%, 100% { text-shadow: 0 0 4px rgba(200,164,78,0.3); }
    50% { text-shadow: 0 0 12px rgba(200,164,78,0.7), 0 0 20px rgba(200,164,78,0.3); }
}

.clue-tutorial-hint {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 0.4rem 0.8rem;
    border-radius: 2px;
    font-family: var(--sans-font);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    animation: tutorial-float 2s ease-in-out infinite;
    box-shadow: 0 2px 12px rgba(200,164,78,0.2);
}

.clue-tutorial-hint::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--accent-gold);
}

@keyframes tutorial-float {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 1; }
    50% { transform: translateX(-50%) translateY(-4px); opacity: 0.85; }
}

.clue-tutorial-fade {
    opacity: 0 !important;
    transition: opacity 0.3s ease;
}

/* ─── Prefers Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}