/* === VARIABLES === */
:root {
    --bg-primary: #0a0a0c;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-card: #16161f;
    
    --text-primary: #e8e6e3;
    --text-secondary: #9d9a95;
    --text-muted: #5a5856;
    --text-accent: #c9a87c;
    
    --accent-gold: #c9a87c;
    --accent-gold-dim: #8a7355;
    --accent-red: #8b3a3a;
    --accent-red-bright: #c45050;
    --accent-green: #3a6b4a;
    --accent-green-bright: #4a9960;
    --accent-blue: #3a4a6b;
    --accent-purple: #5a3a6b;
    
    --stat-intelligence: #6b8cc9;
    --stat-selfrespect: #c9a87c;
    --stat-social: #9b7cc9;
    --stat-mental: #7cc9a8;
    --stat-energy: #c9c97c;
    
    --border-color: #2a2a35;
    --border-light: #3a3a45;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Crimson Pro', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === OVERLAYS === */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
}

/* === GAME CONTAINER === */
#game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* === SCREENS === */
.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

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

/* === TITLE SCREEN === */
#title-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.title-content {
    animation: titleReveal 1.5s ease;
}

@keyframes titleReveal {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.title-decoration {
    font-size: 2rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.main-title {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-family: var(--font-body);
    font-size: 1.25rem;
    font-weight: 300;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.tagline {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    letter-spacing: 0.02em;
}

.warning-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2rem;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* === BUTTONS === */
.primary-btn {
    font-family: var(--font-body);
    font-size: 1.1rem;
    padding: 14px 40px;
    background: linear-gradient(135deg, var(--accent-gold-dim), var(--accent-gold));
    color: var(--bg-primary);
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

.primary-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.primary-btn:hover::before {
    left: 100%;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(201, 168, 124, 0.3);
}

.primary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.primary-btn:disabled:hover::before {
    left: -100%;
}

.secondary-btn {
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 12px 30px;
    background: transparent;
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold-dim);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.secondary-btn:hover {
    background: rgba(201, 168, 124, 0.1);
    border-color: var(--accent-gold);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-gold-dim);
}

/* === CHARACTER SCREEN === */
#character-screen {
    padding-top: 60px;
}

.screen-content {
    max-width: 600px;
    margin: 0 auto;
}

.screen-content h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 400;
    text-align: center;
    margin-bottom: 0.5rem;
}

.instruction-text {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.character-form {
    background: var(--bg-card);
    padding: 30px;
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-gold);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.form-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 1.1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.form-group input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* Background Options */
.background-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.background-option {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
}

.background-option:hover {
    border-color: var(--accent-gold-dim);
    transform: translateY(-2px);
}

.background-option.selected {
    border-color: var(--accent-gold);
    background: rgba(201, 168, 124, 0.05);
}

.background-option.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--accent-gold);
    font-size: 1.2rem;
}

.bg-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.bg-name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.bg-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
}

.bg-stats {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

#confirm-character-btn {
    width: 100%;
    margin-top: 10px;
}

/* === GAME SCREEN === */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.player-name-display {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--accent-gold);
}

.chapter-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.day-display {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* === STATS PANEL === */
.stats-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.stats-panel.collapsed {
    max-height: 0;
    border: none;
    margin-bottom: 0;
}

.stats-panel:not(.collapsed) {
    max-height: 500px;
    padding: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
}

.stat-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.stat-icon {
    font-size: 1.3rem;
}

.stat-name {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-bar-container {
    height: 6px;
    background: var(--bg-secondary);
    margin-bottom: 5px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    transition: width var(--transition-normal), background-color var(--transition-normal);
}

.stat-item[data-stat="intelligence"] .stat-bar { background: var(--stat-intelligence); }
.stat-item[data-stat="selfRespect"] .stat-bar { background: var(--stat-selfrespect); }
.stat-item[data-stat="social"] .stat-bar { background: var(--stat-social); }
.stat-item[data-stat="mentalHealth"] .stat-bar { background: var(--stat-mental); }
.stat-item[data-stat="energy"] .stat-bar { background: var(--stat-energy); }

.stat-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Stat warnings */
.stat-item.critical .stat-bar {
    animation: statPulse 1s ease-in-out infinite;
}

@keyframes statPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Traits Section */
.traits-section {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.traits-header {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.traits-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.trait-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 4px 10px;
    border: 1px solid;
}

.trait-tag.positive {
    border-color: var(--accent-green);
    color: var(--accent-green-bright);
    background: rgba(58, 107, 74, 0.1);
}

.trait-tag.negative {
    border-color: var(--accent-red);
    color: var(--accent-red-bright);
    background: rgba(139, 58, 58, 0.1);
}

.trait-tag.neutral {
    border-color: var(--border-light);
    color: var(--text-secondary);
    background: rgba(58, 58, 58, 0.1);
}

/* === STORY CONTAINER === */
.story-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 30px;
}

.story-text {
    font-size: 1.15rem;
    line-height: 1.85;
    margin-bottom: 30px;
}

.story-text p {
    margin-bottom: 1rem;
}

.story-text p:last-child {
    margin-bottom: 0;
}

.story-text .emphasis {
    color: var(--accent-gold);
    font-style: italic;
}

.story-text .whisper {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.story-text .thought {
    color: var(--text-secondary);
    font-style: italic;
}

/* === CHOICES === */
.choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
}

.choice-btn {
    text-align: left;
    padding: 18px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.05rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.choice-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--accent-gold);
    transform: scaleY(0);
    transition: transform var(--transition-normal);
}

.choice-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-gold-dim);
    transform: translateX(5px);
}

.choice-btn:hover::before {
    transform: scaleY(1);
}

.choice-btn .choice-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-gold);
    margin-right: 12px;
}

.choice-btn .choice-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
}

/* Locked choices */
.choice-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.choice-btn.locked:hover {
    transform: none;
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.choice-btn.locked::before {
    background: var(--accent-red);
}

/* Recommended choices (trick!) */
.choice-btn.recommended {
    border-color: var(--accent-green);
}

.choice-btn.recommended .choice-hint {
    color: var(--accent-green-bright);
}

/* === NOTIFICATIONS === */
.notification-area {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.notification {
    padding: 15px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    animation: notificationSlide 0.3s ease, notificationFade 0.3s ease 3.7s forwards;
    box-shadow: var(--shadow-lg);
}

@keyframes notificationSlide {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes notificationFade {
    to { opacity: 0; transform: translateX(50px); }
}

.notification.stat-change {
    border-left: 3px solid var(--accent-gold);
}

.notification.stat-up {
    border-left-color: var(--accent-green-bright);
}

.notification.stat-down {
    border-left-color: var(--accent-red-bright);
}

.notification.event {
    border-left-color: var(--accent-purple);
}

.notification-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.notification-text {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.notification-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-top: 5px;
}

.notification-stat.positive { color: var(--accent-green-bright); }
.notification-stat.negative { color: var(--accent-red-bright); }

/* === MODALS === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: modalFade 0.3s ease;
}

.modal.active {
    display: flex;
}

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

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: modalSlide 0.3s ease;
}

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

.event-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.modal-content h3 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 15px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.7;
}

.event-effects {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

.effect-tag {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 5px 12px;
}

.effect-tag.positive {
    background: rgba(58, 107, 74, 0.2);
    color: var(--accent-green-bright);
}

.effect-tag.negative {
    background: rgba(139, 58, 58, 0.2);
    color: var(--accent-red-bright);
}

/* === ENDING SCREEN === */
#ending-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.ending-content {
    max-width: 600px;
    padding: 40px;
}

.ending-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.ending-content h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: 20px;
}

.ending-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 30px;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.final-stat {
    text-align: center;
}

.final-stat-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.final-stat-value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--text-primary);
}

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

.ending-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Analysis Modal */
.analysis-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.analysis-text {
    margin-bottom: 20px;
}

.analysis-text p {
    margin-bottom: 15px;
}

.choices-made {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.choice-record {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.choice-record:last-child {
    border-bottom: none;
}

.choice-record-scene {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.choice-record-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.choice-record-outcome {
    font-size: 0.85rem;
    margin-top: 4px;
    font-style: italic;
}

.choice-record-outcome.good { color: var(--accent-green-bright); }
.choice-record-outcome.bad { color: var(--accent-red-bright); }
.choice-record-outcome.neutral { color: var(--text-muted); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .main-title {
        font-size: 2.5rem;
    }
    
    .background-options {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .final-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .game-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .notification-area {
        left: 10px;
        right: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    #game-container {
        padding: 10px;
    }
    
    .story-container {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .final-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ending-buttons {
        flex-direction: column;
    }
}

/* === SPECIAL EFFECTS === */
.screen-shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.stat-flash {
    animation: statFlash 0.5s ease;
}

@keyframes statFlash {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(2); }
}

/* Ending type styles */
.ending-content.good-ending h2 { color: var(--accent-green-bright); }
.ending-content.neutral-ending h2 { color: var(--text-secondary); }
.ending-content.bad-ending h2 { color: var(--accent-red-bright); }
.ending-content.secret-ending h2 { color: var(--accent-gold); }