:root {
    --bg-color: #1a1a2e;
    --text-color: #e0e0e0;
    --primary-color: #16213e;
    --secondary-color: #0f3460;
    --accent-color: #e94560;
    --next-btn-color: #f96d00;
    --font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
}

body {
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    overflow: hidden;
    height: 100vh; /* fallback for browsers that don't support dvh */
    height: 100dvh; /* dynamic viewport height */
}

.screen { display: none; }
.screen.active { display: flex; }

/* --- タイトル画面 --- */
#title-screen.active {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
}
#game-title-display {
    font-size: 3rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    margin-bottom: 50px;
}
.title-menu button, .title-menu-link {
    display: block;
    width: 280px;
    margin: 15px auto;
    padding: 15px;
    font-size: 1.2rem;
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid var(--primary-color);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    text-decoration: none;
    box-sizing: border-box;
}
.title-menu button:hover, .title-menu-link:hover {
    background-color: var(--accent-color);
    transform: scale(1.05);
}
.title-menu button:disabled {
    background-color: #555;
    color: #888;
    cursor: not-allowed;
    transform: none;
}

/* --- 章・END演出画面 --- */
#interlude-screen.active {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}
#interlude-text {
    font-size: 4rem;
    color: white;
    text-shadow: 0 0 15px white;
    animation: fadeIn 2s ease-in-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
#interlude-next-button {
    margin-top: 50px;
    animation: fadeIn 2s 1s ease-in-out backwards;
}


/* --- ゲーム画面 --- */
#game-screen.active {
    flex-direction: column;
    height: 100%;
}
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px;
    background-color: var(--primary-color);
    flex-shrink: 0;
}
#scene-info, #char-count { font-size: 0.9rem; color: #ccc; }
.game-menu { display: flex; gap: 5px; }
.game-header-btn {
    background: none;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}
.game-header-btn:hover { background-color: var(--secondary-color); }

#game-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
}

.text-container {
    display: grid;
    flex-grow: 1;
    grid-template-rows: 1fr 1fr;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
}

.text-area-wrapper {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}
.lang-label-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.lang-label { font-size: 0.8rem; color: #aaa; }
.speak-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.speak-btn:hover {
    opacity: 1;
}
.text-box { flex-grow: 1; font-size: 1.1rem; line-height: 1.6; outline: none; white-space: pre-wrap; }

.choice-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 15px;
    cursor: default;
}
.choice-container button {
    width: 80%; max-width: 500px; padding: 20px; font-size: 1.1rem;
    line-height: 1.5; background-color: var(--secondary-color); color: var(--text-color);
    border: 1px solid var(--primary-color); border-radius: 5px;
    cursor: pointer; transition: background-color 0.3s; text-align: left;
}
.choice-container button:hover { background-color: var(--accent-color); }
.choice-container button span { display: block; padding: 2px 0; font-size: 0.8em; opacity: 0.8; }

.game-footer {
    display: flex; justify-content: center; align-items: center;
    padding: 10px; gap: 20px; background-color: var(--primary-color);
    flex-shrink: 0;
}
.game-footer-btn {
    padding: 10px 20px; min-width: 100px; font-size: 1rem;
    border-radius: 5px; cursor: pointer; border: none;
    background-color: var(--secondary-color); color: var(--text-color);
}
#next-button {
    background-color: var(--next-btn-color); color: white;
    font-weight: bold; transform: scale(1.1); border: 2px solid #ff8c00;
    animation: pulse 1.5s infinite;
}
#next-button:disabled { background-color: #555; animation: none; cursor: not-allowed; }
#auto-button.active { background-color: var(--accent-color); color: white; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(249, 109, 0, 0.7); }
  70% { box-shadow: 0 0 10px 15px rgba(249, 109, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(249, 109, 0, 0); }
}

/* --- モーダル --- */
#modal-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); display: none;
    justify-content: center; align-items: center; z-index: 100;
}
#modal-container.active { display: flex; }
.modal-content {
    background-color: var(--primary-color); padding: 20px; border-radius: 10px;
    width: 80%; max-width: 600px; max-height: 80vh;
    display: flex; flex-direction: column;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
#modal-title { margin-top: 0; color: var(--accent-color); }
#modal-progress { font-size: 0.9rem; color: #ccc; }
#modal-body { overflow-y: auto; flex-grow: 1; margin-top: 15px; }
#modal-body button.back-to-chapters { margin-bottom: 20px; background-color: var(--accent-color); color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; }

#modal-close-button { margin-top: 20px; padding: 10px; align-self: flex-end; background-color: var(--secondary-color); color: var(--text-color); border: none; border-radius: 5px; cursor: pointer; }

.slot-list, .scene-list, .chapter-list, .ending-list { list-style: none; padding: 0; }
.slot-list li, .scene-list li, .chapter-list li, .ending-list li {
    background-color: var(--secondary-color); margin-bottom: 10px; padding: 15px;
    border-radius: 5px; display: flex; justify-content: space-between; align-items: center;
    transition: background-color 0.2s;
}
.chapter-list li { cursor: pointer; }
.chapter-list li:hover { background-color: var(--accent-color); }
.scene-list button, .slot-list button { margin-left: 10px; background-color: var(--accent-color); border: none; color: white; padding: 5px 10px; border-radius: 3px; cursor: pointer; }
.scene-list button:disabled { background-color: #555; cursor: not-allowed; }
.settings-item { display: flex; align-items: center; margin-bottom: 15px; }
.settings-item label { margin-right: 15px; }
