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

:root {
    --theme-color: #d4af37;
    --font-head: 'Cinzel', serif;
    --font-body: 'Spectral', serif;
    --theme-shadow: rgba(212, 175, 55, 0.4);
}

* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    margin: 0; padding: 0; width: 100%; height: 100%;
    position: fixed;
    background-color: #050505; color: white;
    font-family: var(--font-body); overflow: hidden;
    overscroll-behavior: none;
}

#bg-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; opacity: 0.8; background-size: cover; background-position: center; transition: opacity 0.5s ease-in-out; background-image: url('assets/scribe.jpg'); }
#vignette { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(circle at center, rgba(0,0,0,0) 0%, #000 100%); z-index: 0; }

.screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; opacity: 0; pointer-events: none; transition: opacity 0.5s ease; z-index: 10; }
.screen.active { opacity: 1; pointer-events: auto; z-index: 20; }

#screen-game { height: 100vh; }
#screen-splash { justify-content: center; align-items: center; }
#screen-menu { justify-content: flex-start; align-items: center; overflow-y: auto; padding-top: 15vh; padding-bottom: 100px; box-sizing: border-box; }

.interaction-zone {
    position: absolute;
    top: calc(40px + env(safe-area-inset-top, 0px));
    left: 0;
    width: 100%;
    padding: 0 15px 0 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}
body.final-score-active .interaction-zone {
    top: 0;
    justify-content: center;
    height: 100%;
    padding-top: 0;
    padding-bottom: 50px;
}

/* THE GLASS PANEL */
.puzzle-container {
    width: 100%; max-width: 600px; padding: 20px 15px; box-sizing: border-box;
    min-height: 200px; display: flex; flex-direction: column; justify-content: center;
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(15px);
    border: 1px solid var(--theme-color); text-align: center; border-radius: 4px;
}

#clue-text { color: var(--theme-color); font-style: italic; margin-bottom: 12px; font-size: 20px; transition: color 0.3s; }
#puzzle-display { font-family: var(--font-head); font-size: 32px; margin: 10px 0; letter-spacing: 2px; line-height: 1.4; white-space: normal; word-wrap: break-word; color: var(--theme-color); }
.input-divider { height: 1px; background: rgba(212, 175, 55, 0.3); margin: 15px auto; width: 60%; }
#user-input-display { 
    font-family: var(--font-head); font-size: 24px; color: var(--theme-color); height: 50px; line-height: 50px;
    letter-spacing: 1px; width: 100%; max-width: 600px;
    background: rgba(0, 0, 0, 0.8); border: 1px solid var(--theme-color); border-radius: 4px;
    margin-bottom: 10px; padding: 0 10px; box-sizing: border-box; text-align: center;
    outline: none; caret-color: var(--theme-color);
    -webkit-user-select: text !important; user-select: text !important;
}

.vowel-gap { color: rgba(255,255,255,0.6); text-decoration: underline; font-weight: bold; }
.vowel-yellow { color: #f1c40f; text-shadow: 0 0 15px rgba(241, 196, 15, 0.6); }

/* FOOTER BUTTONS */
.game-footer { display: flex; gap: 10px; margin-top: 15px; width: 100%; max-width: 600px; }
.footer-btn { background: rgba(0, 0, 0, 0.6); border: 1px solid var(--theme-shadow); border-radius: 6px; color: var(--theme-color); padding: 12px 0; font-family: var(--font-head); font-size: 13px; flex: 1; transition: all 0.2s; }
.footer-btn:active { background: var(--theme-shadow); border-color: var(--theme-color); color: #fff; transform: scale(0.95); }
.footer-btn.disabled { opacity: 0.3; pointer-events: none; border-color: #333; color: #666; }

/* THE 3D STONE KEYBOARD */
#custom-keyboard {
    width: 100%; background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(15px); border-top: 1px solid var(--theme-shadow);
    padding: 15px 12px 8px 12px;
    box-sizing: border-box; align-items: center;
    display: flex; flex-direction: column; gap: 8px; z-index: 50;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
#custom-keyboard.hidden { transform: translateY(110%); }

.keyboard-row { display: flex; gap: 6px; width: 100%; justify-content: center; }

.rune-key {
    background: linear-gradient(to bottom, #3e2723, #281815);
    color: var(--theme-color); border: 1px solid #5d4037; border-bottom: 3px solid #1a100e;
    border-radius: 6px; width: calc((100% - 54px) / 10); height: 56px; font-size: 20px; font-family: var(--font-head);
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
}
.rune-key:active { transform: translateY(2px) scale(0.95); border-bottom-width: 1px; }

.key-del { background: linear-gradient(to bottom, #5a1a1a, #300); border-color: #500; color: #ffaaaa; }

/* 5 units + 4 gaps (24px) */
.key-space { width: calc(((100% - 54px) / 10) * 5 + 24px); }
/* 3 units + 2 gaps (12px) */
.key-enter { background: linear-gradient(to bottom, #2e7d32, #1b5e20); color: #fff; width: calc(((100% - 54px) / 10) * 3 + 12px); border-color: #1b5e20; font-size: 14px; }

/* SLIDER */
#scoreboard-panel { position: fixed; bottom: 0; width: 100%; height: 420px; background: rgba(17, 17, 17, 0.85); backdrop-filter: blur(15px); border-top: 3px solid var(--theme-color); display: flex; flex-direction: column; align-items: center; justify-content: center; transform: translateY(110%); transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); z-index: 60; padding: 25px; box-sizing: border-box; }
#scoreboard-panel.active { transform: translateY(0); }
.slide-title { font-family: var(--font-head); font-size: 20px; color: #fff; margin-bottom: 5px; letter-spacing: 2px; }
.slide-score-large { font-family: var(--font-head); font-size: 48px; color: var(--theme-color); margin-bottom: 10px; text-shadow: 0 0 20px var(--theme-shadow); line-height: 1; }
.slide-breakdown-container { color: #888; font-family: monospace; font-size: 14px; margin-bottom: 20px; text-align: center; cursor: pointer; }
.slide-breakdown-container summary { outline: none; margin-bottom: 10px; }
.slide-breakdown { text-transform: uppercase; letter-spacing: 1px; }
.slide-sub-text { color: #fff; text-align: center; margin: 0 auto 25px auto; font-size: 32px; font-weight: bold; max-width: 90%; font-family: var(--font-body); line-height: 1.3; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }

.menu-btn { background: rgba(0,0,0,0.6); border: 1px solid var(--theme-color); border-radius: 6px; color: var(--theme-color); padding: 18px; font-family: var(--font-head); font-size: 16px; width: 240px; margin-bottom: 12px; }
.menu-grid { display: flex; flex-direction: column; align-items: center; }
.primary-btn { background: var(--theme-color); color: #000; font-weight: bold; }
.menu-btn:active, .primary-btn:active { transform: scale(0.95); }

.beta-feedback-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-head);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.beta-feedback-btn:active {
    color: var(--theme-color);
    transform: translateX(-50%) scale(0.95);
}

.splash-logo { width: 80%; max-width: 350px; margin: 0 auto; transform: translateY(15vh) scale(1.3); }
body.is-desktop .splash-logo { transform: translateY(calc(15vh - 20px)) scale(1.6); }
.started .splash-logo { animation: slideUpLogo 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
body.is-desktop .started .splash-logo { animation: slideUpLogoDesktop 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
.section-title { font-family: var(--font-head); color: var(--theme-color); margin-bottom: 25px; text-align: center; }
#screen-menu .section-title {
    font-size: 26px;
    text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.5);
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 20px;
    width: 85%;
}

.splash-text-container { display: flex; flex-direction: column; align-items: center; width: 100%; margin-top: 20px; }
.tagline-container { text-align: center; font-size: 24px; line-height: 1.5; color: #eee; font-style: italic; padding: 0 20px; margin-bottom: 20px; }
.tagline-part { opacity: 0; margin: 0; }
.started .tagline-part:nth-child(1) { animation: fadeInText 1.0s ease-out forwards 0.5s; }
.started .tagline-part:nth-child(2) { animation: fadeInText 1.0s ease-out forwards 2.0s; }
.started .tagline-part:nth-child(3) { animation: fadeInText 1.0s ease-out forwards 3.5s; }

.tagline-cta { opacity: 0; font-family: var(--font-head); color: var(--theme-color); font-size: 20px; margin-bottom: 30px; font-weight: bold; text-align: center; letter-spacing: 1px; }
.started .tagline-cta { animation: fadeInText 1.0s ease-out forwards 6.0s; }
.splash-buttons { opacity: 0; display: flex; gap: 15px; justify-content: center; width: 100%; max-width: 600px; margin: 0 auto; padding: 0 20px; box-sizing: border-box; }
.started .splash-buttons { animation: fadeInText 1.0s ease-out forwards 6.0s; }
.splash-buttons .menu-btn { width: 100%; max-width: 240px; flex: 1; min-width: 0; padding: 18px 10px; }

.start-btn {
    position: absolute; bottom: 20%; left: 50%; transform: translateX(-50%);
    background: transparent; border: 2px solid var(--theme-color); color: var(--theme-color);
    padding: 15px 40px; font-family: var(--font-head); font-size: 20px; letter-spacing: 2px;
    cursor: pointer; transition: all 0.3s; z-index: 100;
}
.start-btn:active { background: var(--theme-color); color: #000; }

@keyframes slideUpLogo {
    0% { transform: translateY(15vh) scale(1.3); margin-bottom: 0; }
    100% { transform: translateY(0) scale(1); margin-bottom: 10px; }
}
@keyframes slideUpLogoDesktop {
    0% { transform: translateY(calc(15vh - 20px)) scale(1.6); margin-bottom: 0; }
    100% { transform: translateY(0) scale(1.2); margin-bottom: 10px; }
}
@keyframes fadeInText {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.4s ease; }
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-content-container { width: 95%; height: 85%; background: rgba(10, 10, 10, 0.95); border: 1px solid var(--theme-color); box-shadow: 0 0 50px rgba(0,0,0,0.8); display: flex; flex-direction: column-reverse; }
.console-sidebar { background: rgba(0,0,0,0.5); border-top: 1px solid var(--theme-shadow); border-right: none; display: flex; flex-direction: row; padding: 0; height: 60px; flex-shrink: 0; }
.nav-btn { background: transparent; border: none; border-top: 3px solid transparent; border-left: none; color: #888; font-family: var(--font-head); font-size: 13px; padding: 5px; text-align: center; cursor: pointer; text-transform: uppercase; transition: 0.3s; flex: 1; display: flex; align-items: center; justify-content: center; line-height: 1.1; white-space: normal; }
.nav-btn.active { color: var(--theme-color); border-top-color: var(--theme-color); border-left-color: transparent; background: rgba(212, 175, 55, 0.1); text-shadow: 0 0 10px var(--theme-shadow); }
.return-btn { margin-top: 0; border-top: 3px solid transparent; border-left: 1px solid var(--theme-shadow); color: #fff; text-align: center; background: #2e7d32; border: 1px solid #1b5e20; }
.console-content { padding: 20px; overflow-y: auto; flex: 1; width: 100%; box-sizing: border-box; }
.console-body { font-size: 18px; color: #ddd; line-height: 1.7; }

/* Stats Modal Styles */
.dossier-header h2 { color: #c4a265; letter-spacing: 3px; margin-bottom: 20px; font-size: 24px; text-align: center; font-family: var(--font-head, serif); }
.dossier-top-stats { display: flex; justify-content: space-around; margin-bottom: 30px; }
.stat-box { text-align: center; background: rgba(255, 255, 255, 0.05); padding: 15px; border-radius: 8px; min-width: 100px; }
.stat-box .label { font-size: 10px; opacity: 0.6; letter-spacing: 1px; margin-bottom: 5px; }
.stat-box .value { font-size: 36px; font-weight: bold; color: var(--theme-color); text-shadow: 0 0 15px rgba(212, 175, 55, 0.2); }
.dossier-body { max-width: 600px; margin: 0 auto; width: 100%; }
.dossier-history { padding: 0 20px; margin-bottom: 20px; }

.history-item {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.history-item.expanded {
    background: rgba(255, 255, 255, 0.08);
}

.history-item:last-child {
    border-bottom: none;
}

.history-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.history-details {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    color: #aaa;
    flex-direction: column;
}

.history-item.expanded .history-details {
    display: flex;
}

/* About Me Tab Specifics */
#aboutme-content { font-size: 18px; }
#aboutme-content .history-item { font-size: 16px; padding: 15px 10px; }
#aboutme-content .history-details { font-size: 14px; }

.tab-header { font-family: var(--font-head); font-size: 22px; color: var(--theme-color); margin-bottom: 25px; text-align: center; border-bottom: 1px solid rgba(212, 175, 55, 0.3); padding-bottom: 15px; text-transform: uppercase; }

.reveal-container { display: inline-flex; align-items: baseline; justify-content: center; width: 100%; margin-bottom: 3vh; border-bottom: 1px solid rgba(212, 175, 55, 0.3); padding-bottom: 2vh; }
.reveal-main { font-family: var(--font-head); font-size: 24px; color: var(--theme-color); display: inline-block; white-space: nowrap; }
.reveal-hidden { display: inline-block; white-space: nowrap; overflow: hidden; max-width: 0; opacity: 0; transition: max-width 2.5s ease-in-out, opacity 2.5s ease-in-out; vertical-align: bottom; }
.reveal-container.active .reveal-hidden { max-width: 800px; opacity: 1; }

.anim-box-wrapper { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255,255,255,0.1); padding: 15px; margin: 20px 0; border-radius: 4px; text-align: center; }
.anim-container { font-family: var(--font-head); font-size: 26px; color: #fff; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; letter-spacing: 1px; line-height: 1.5; }
.word { display: inline-flex; }
.char { display: inline-block; transition: all 1.6s cubic-bezier(0.25, 1, 0.5, 1); }
.consonant { color: #fff; }
.vowel { width: 0; opacity: 0; color: #f1c40f; overflow: hidden; margin: 0; transform: scaleX(0); transform-origin: left; text-align: center; transition: width 1.6s ease, opacity 1.6s ease, color 1.6s ease, margin 1.6s ease, transform 1.6s ease; }
.space { width: 0; overflow: hidden; display: inline-block; transition: width 1.6s cubic-bezier(0.25, 1, 0.5, 1); flex-shrink: 0; }
.anim-container.stage-1 .space { width: 0.8em; }
.anim-container.stage-2 .vowel { width: 0.7em; transform: scaleX(1); opacity: 1; color: transparent; margin: 0 0.05em; }
.anim-container.stage-2 .vowel.narrow { width: 0.35em; }
.anim-container.stage-2 .vowel.wide { width: 0.85em; }
.anim-container.stage-3 .vowel { color: #f1c40f; }
.anim-container.stage-4 .vowel { color: #fff; }

.anim-container .char.vowel {
    text-decoration: underline;
    text-decoration-color: rgba(255,255,255,0.5);
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    text-decoration-skip-ink: auto;
}
.anim-container.stage-3 .char.vowel { text-decoration: none; }

.cta-container { display: flex; gap: 10px; margin-top: 20px; justify-content: center; }
.btn-cta { padding: 12px 20px; font-family: var(--font-head); font-size: 12px; background: transparent; border: 1px solid var(--theme-color); color: var(--theme-color); cursor: pointer; text-decoration: none; text-transform: uppercase; transition: 0.3s; text-align: center; flex: initial; width: 100%; max-width: 240px; }
.btn-cta:hover { background: var(--theme-color); color: #000; }
.nav-btn:active, .btn-cta:active { transform: scale(0.95); }
.inline-link { color: var(--theme-color); text-decoration: none; border-bottom: 1px solid transparent; transition: 0.3s; }
.inline-link:hover { border-bottom-color: var(--theme-color); }

.shake { animation: shake 0.4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25%, 75% { transform: translateX(-5px); } 50% { transform: translateX(5px); } }

/* HUD & Session Styles */
.round-display { position: absolute; top: calc(5px + env(safe-area-inset-top, 0px)); left: 15px; z-index: 1000; font-weight: bold; font-size: 1.1rem; color: var(--theme-color); text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
.score-display { 
    position: absolute; top: calc(5px + env(safe-area-inset-top, 0px)); right: 15px; z-index: 1000; 
    font-weight: bold; font-size: 1.1rem; color: var(--theme-color); 
    text-shadow: 0 1px 2px rgba(0,0,0,0.8); 
    display: flex; align-items: center; gap: 8px; 
    transform-origin: right center; /* To scale from the right */
}
.score-display.score-updating {
    animation: pulse-score 1s ease-in-out;
}
@keyframes pulse-score { 0% { transform: scale(1); } 20% { transform: scale(1.2); } 100% { transform: scale(1); } }
#score-val { min-width: 60px; text-align: right; display: inline-block; }

.bonus-timer { width: 13px; height: 13px; margin-top: 1px; transition: transform 0.2s ease-in-out, opacity 0.5s ease-in-out; }
.bonus-timer.timer-pulse {
    animation: pulse-timer 0.5s ease-in-out;
}
@keyframes pulse-timer { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }
.bonus-timer svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
#timer-base { fill: none; stroke-width: 32; transition: stroke 0.3s; }
#timer-overlay { fill: none; stroke: #666; stroke-width: 32; stroke-dasharray: 0 100; }

.score-breakdown-table { width: 100%; margin: 20px 0; border-collapse: collapse; background: rgba(0, 0, 0, 0.3); border-radius: 8px; color: #fff; font-family: var(--font-body); }
.score-breakdown-table td { padding: 14px; border-bottom: 1px solid rgba(255,255,255,0.1); text-align: left; font-size: 18px; }
.score-breakdown-table tr:last-child td { border-bottom: none; }

.breakdown-row {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
.breakdown-row.visible {
    opacity: 1;
    transform: translateY(0);
}

.new-session-btn { display: block; width: 100%; padding: 12px; background-color: var(--theme-color); color: #000; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; margin-top: 15px; font-family: var(--font-head); font-weight: bold; }
.new-session-btn:hover { opacity: 0.9; }
.new-session-btn:active { transform: scale(0.95); }

/* Animations & Particles */
@keyframes slideOutLeft { to { transform: translateX(-30px); opacity: 0; } }
@keyframes slideInRight { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.slide-out { animation: slideOutLeft 0.2s ease-in forwards; }
.slide-in { animation: slideInRight 0.3s ease-out forwards; }
.particle { position: absolute; width: 6px; height: 6px; border-radius: 50%; pointer-events: none; z-index: 2000; }

/* Settings UI */
.settings-btn { position: fixed; bottom: 20px; left: 20px; width: 40px; height: 40px; background: transparent; border: none; display: flex; align-items: center; justify-content: center; color: var(--theme-color); cursor: pointer; z-index: 100; transition: transform 0.2s; }
.settings-btn:active { transform: scale(0.95); }
.about-btn { position: fixed; bottom: 20px; right: 20px; background: rgba(0,0,0,0.6); border: 1px solid var(--theme-color); border-radius: 6px; color: var(--theme-color); padding: 8px 15px; font-family: var(--font-head); font-size: 12px; cursor: pointer; z-index: 100; transition: transform 0.2s; }
.about-btn:active { transform: scale(0.95); }

.settings-modal { position: fixed; bottom: 70px; left: 20px; width: 300px; background: rgba(10, 10, 10, 0.95); border: 1px solid var(--theme-color); border-radius: 8px; padding: 25px; display: none; flex-direction: column; gap: 15px; z-index: 101; box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
.settings-modal.active { display: flex; animation: fadeInText 0.3s ease; }
.setting-row { display: flex; flex-direction: column; gap: 5px; }
.setting-label { font-family: var(--font-head); font-size: 14px; color: var(--theme-color); }
.setting-slider { width: 100%; -webkit-appearance: none; height: 4px; background: #333; border-radius: 2px; outline: none; }
.setting-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--theme-color); border-radius: 50%; cursor: pointer; }

.menu-logo { height: 150px; width: auto; margin-bottom: 20px; display: block; margin-left: auto; margin-right: auto; }

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 50px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--theme-color); }
input:checked + .slider:before { transform: translateX(26px); }