@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700&display=swap');

:root {
    --primary-color: #6a0dad; 
    --primary-light: #9b59b6;
    --primary-dark: #4a0080;
    --text-color: #f3e5f5; 
    --bg-overlay: rgba(20, 0, 30, 0.85);
    --card-bg: rgba(40, 10, 60, 0.9);
    --font-main: "华文中宋", "STZhongsong", "Songti SC", "Noto Serif SC", serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    overflow: hidden;
    background: #050010 url('../taipei101.jpg') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-color);
}

canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* Ensure canvas is transparent to see body background */
    background: transparent; 
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-overlay);
    /* backdrop-filter: blur(8px); REMOVED per user request */
    transition: opacity 0.5s;
}

.hidden {
    display: none !important;
}

/* Cover */
#cover-screen {
    background: linear-gradient(to bottom, rgba(74, 0, 128, 0.3), rgba(0, 0, 0, 0.9)), url('../taipei101.jpg') no-repeat center bottom;
    background-size: cover;
}

.cover-content {
    text-align: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 50px rgba(106, 13, 173, 0.4);
}

.cover-title {
    font-size: 3.5rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px var(--primary-light);
    margin-bottom: 10px;
    letter-spacing: 5px;
}

.cover-subtitle {
    font-size: 1.2rem;
    color: #d1c4e9;
    margin-bottom: 40px;
    font-style: italic;
}

button {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    border: 1px solid rgba(255,255,255,0.2);
    padding: 15px 40px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 50px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(106, 13, 173, 0.4);
}

button:disabled, button.disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading */
#loading-screen .loader-text {
    font-size: 1.2rem;
    color: #d1c4e9;
    margin-top: 30px;
    height: 100px; /* Fixed height for scrolling */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
}

.loading-log-item {
    margin: 5px 0;
    opacity: 0;
    animation: fadeInLog 0.5s forwards;
}

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

/* History Toast - Artistic Popup */
.history-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    pointer-events: none;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
}

.toast-msg {
    width: auto;
    max-width: 80vw;
}

.artistic-popup {
    background: rgba(0, 0, 0, 0.4); /* Transparent dark */
    /* backdrop-filter: blur(4px); REMOVED per user request */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 40px 60px; /* Larger padding */
    text-align: center;
    color: #fff;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    animation: fadeScaleIn 0.8s ease-out;
    min-width: 400px; /* Ensure larger size */
}

.artistic-popup .popup-content {
    font-family: "华文中宋", "STZhongsong", serif;
    font-size: 1.2rem; /* Smaller font */
    line-height: 1.8;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.artistic-popup .popup-footer {
    font-family: "Cinzel", serif;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 10px;
    display: inline-block;
    padding-left: 20px;
    padding-right: 20px;
}

@keyframes fadeScaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
#shop-screen {
    background: var(--bg-overlay);
    padding: 20px;
    overflow-y: auto;
    display: block; 
}

.shop-header {
    text-align: center;
    margin: 40px 0 20px;
    padding: 20px;
}

.shop-header h2 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: #e1bee7;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto 40px;
}

.shop-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(155, 89, 182, 0.3);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.shop-item:hover {
    border-color: var(--primary-light);
    transform: translateY(-5px);
}

.shop-item.selected {
    background: rgba(106, 13, 173, 0.4);
    border-color: #fff;
    box-shadow: 0 0 20px rgba(155, 89, 182, 0.6);
}

.shop-item h4 { color: #fff; margin-bottom: 8px; font-size: 1.1rem; }
.shop-item p { font-size: 0.9rem; color: #b39ddb; margin-bottom: 12px; }
.shop-item .price { font-weight: bold; color: #ffeb3b; font-size: 1.1rem; }

#confirm-purchase-btn {
    display: block;
    margin: 20px auto 60px;
    min-width: 300px;
}

/* HUD */
#game-ui {
    pointer-events: none;
    background: transparent;
    justify-content: flex-start;
}

.hud-top {
    width: 100%;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    background: linear-gradient(to bottom, rgba(20,0,30,0.9), transparent);
}

.bars { width: 250px; }
.bar-container {
    background: rgba(255,255,255,0.1);
    height: 18px; /* Increased height for text */
    margin-bottom: 8px;
    border-radius: 9px;
    overflow: hidden;
    position: relative; /* For absolute text */
}
.bar { 
    height: 100%; 
    transition: width 0.3s; 
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Text on right of bar? Or center? */
}
.bar-text {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
    text-shadow: 0 0 2px #000;
    font-weight: bold;
    z-index: 2;
}
#hud-stamina { background: linear-gradient(90deg, #2ecc71, #27ae60); }
#hud-sanity { background: linear-gradient(90deg, #9b59b6, #8e44ad); }

.stat-change {
    display: block;
    margin-top: 5px;
    font-size: 0.9em;
    color: #ffeb3b;
}

#control-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 5;
    animation: fadePulse 3s infinite;
}

@keyframes fadePulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

.hud-info { text-align: right; }
#hud-height { font-size: 2.5rem; font-weight: bold; color: #fff; text-shadow: 0 0 10px var(--primary-color); }
#hud-time { font-size: 1.2rem; color: #d1c4e9; }

#game-message {
    position: absolute;
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 0, 30, 0.8);
    padding: 20px 40px;
    border-radius: 30px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s;
    max-width: 80%;
    border: 1px solid var(--primary-light);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    font-size: 1.1rem;
}
#game-message.show { opacity: 1; }

/* Event Modal */
#event-modal {
    background: rgba(10, 0, 20, 0.9);
    z-index: 100;
}

.event-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    border: 2px solid var(--primary-light);
    box-shadow: 0 0 50px rgba(106, 13, 173, 0.5);
}

.event-card h2 { color: #ffeb3b; margin-bottom: 20px; font-size: 2rem; }
.event-card p { margin-bottom: 30px; line-height: 1.8; font-size: 1.1rem; color: #e1bee7; }

#event-choices button {
    display: block;
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}
#event-choices button:hover { background: var(--primary-light); border-color: white; }

/* Ending Poster */
#ending-screen {
    background: #050010;
    padding: 20px;
    overflow-y: auto;
}

#ending-poster-card {
    background: white;
    color: #111;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    border-radius: 10px;
    margin: 20px auto;
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

/* Paper texture effect */
#ending-poster-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIi8+CjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNlZWUiLz4KPC9zdmc+');
    opacity: 0.5;
    pointer-events: none;
}

.poster-header {
    border-bottom: 2px solid #111;
    padding-bottom: 20px;
}

.poster-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: #111;
    margin-bottom: 5px;
    font-family: "Impact", sans-serif;
    text-transform: uppercase;
}

.poster-subtitle {
    font-size: 1.2rem;
    color: #444;
    letter-spacing: 2px;
}

.poster-body {
    flex: 1;
}

.poster-quote {
    font-size: 1.1rem;
    line-height: 1.8;
    font-style: italic;
    margin-bottom: 30px;
    font-weight: bold;
}

.poster-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-item .label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
}

.stat-item .value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #111;
}

.poster-footer {
    border-top: 1px solid #ddd;
    padding-top: 20px;
    font-size: 0.8rem;
    color: #666;
}

.game-tag {
    margin-top: 10px;
    font-weight: bold;
    color: #111;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    /* backdrop-filter: blur(5px); REMOVED per user request */
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    border: 1px solid var(--primary-light);
    box-shadow: 0 0 40px rgba(106, 13, 173, 0.5);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.event-result-card h2 {
    color: #e1bee7;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 10px;
}

.result-body {
    font-size: 1.1rem;
    margin-bottom: 25px;
    line-height: 1.6;
}

.result-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 20px;
    font-style: italic;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* History Toast */
.history-container {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse; /* Newest at bottom visually, but we append so actually top? Flex col reverse puts first child at bottom. */
    align-items: center;
    pointer-events: none;
    z-index: 20;
    width: 300px;
}
.toast-msg {
    margin-top: 10px;
    width: 100%;
    transition: opacity 1s;
    animation: slideUp 0.5s ease-out;
}
.tombstone-style {
    background: linear-gradient(to bottom, #4a4a4a, #2a2a2a);
    border: 1px solid #777;
    border-top-left-radius: 100px; /* Round top like tombstone */
    border-top-right-radius: 100px;
    color: #ddd;
    position: relative;
    padding: 20px 15px 15px 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.6);
    text-align: center;
}
.tombstone-header {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 8px;
    letter-spacing: 2px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}
.tombstone-body {
    font-size: 0.95rem;
    margin: 10px 0;
    line-height: 1.4;
    color: #fff;
}
.tombstone-footer {
    font-size: 0.7rem;
    color: #888;
    font-style: italic;
    margin-top: 10px;
    text-align: right;
}
.tombstone-height {
    position: absolute;
    bottom: 10px;
    left: 20px;
    font-size: 0.7rem;
    color: #aaa;
}

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

/* Stats Overlay */
.stats-overlay {
    position: absolute;
    top: 60px; /* Below HUD top */
    right: 20px;
    text-align: right;
    font-size: 0.9rem;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
    line-height: 1.6;
    z-index: 15;
    color: rgba(255,255,255,0.8);
    pointer-events: none;
}
