:root {
    --bg-color: #0f172a;
    --container-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --bot-msg-bg: #334155;
    --user-msg-bg: #0369a1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 500px;
    height: 90vh;
    background-color: var(--container-bg);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    /* 子要素のはみ出しを防ぐ */
}

#chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

h1 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-align: center;
    background: linear-gradient(90deg, var(--accent-color), #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#status-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-item span {
    font-size: 0.8rem;
    min-width: 80px;
    color: var(--text-secondary);
}

.bar-container {
    flex-grow: 1;
    height: 8px;
    background-color: #0f172a;
    border-radius: 4px;
    overflow: hidden;
}

.bar {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease-out, background-color 0.3s;
}

#anger-bar {
    background-color: var(--danger-color);
}

#contradiction-bar {
    background-color: var(--warning-color);
}

#chat-window {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--bot-msg-bg) var(--container-bg);
    scroll-behavior: smooth;
    padding-bottom: 40px;
    /* 下部に余白を追加 */
}

#chat-window::-webkit-scrollbar {
    width: 6px;
}

#chat-window::-webkit-scrollbar-thumb {
    background-color: var(--bot-msg-bg);
    border-radius: 3px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 15px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out;
}

/* 選択画面 */
.selection-screen {
    padding: 30px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* centerから調整 */
    align-items: center;
    gap: 30px;
    animation: fadeIn 0.5s ease-out;
    overflow-y: auto;
    /* 選択肢が多い場合にスクロール */
}

.selection-screen h2 {
    font-size: 1.8rem;
    background: linear-gradient(90deg, var(--accent-color), #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.character-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    width: 100%;
}

.char-card {
    background-color: var(--bot-msg-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.char-card:hover {
    border-color: var(--accent-color);
    background-color: rgba(56, 189, 248, 0.1);
    transform: translateY(-5px);
}

.char-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.char-card h3 {
    margin-bottom: 5px;
}

.char-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* キャラクター別テーマ */
.theme-mom {
    --accent-color: #f472b6;
    --user-msg-bg: #db2777;
}

.theme-partner {
    --accent-color: #fb7185;
    --user-msg-bg: #e11d48;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background-color: var(--bot-msg-bg);
    border-bottom-left-radius: 2px;
}

.message.user {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    border-bottom-right-radius: 2px;
}

footer {
    padding: 20px;
    background-color: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#choices-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 40vh;
    /* 長すぎる場合に制限 */
    overflow-y: auto;
    padding-right: 5px;
}

#choices-container::-webkit-scrollbar {
    width: 4px;
}

#choices-container::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 2px;
}

.choice-btn {
    background-color: var(--container-bg);
    border: 1px solid var(--accent-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.choice-btn:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
    transform: scale(1.02);
}

.choice-btn:active {
    transform: scale(0.98);
}

/* モーダル */
#modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

#result-modal {
    background-color: var(--container-bg);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 80%;
    border: 1px solid var(--accent-color);
}

#result-title {
    margin-bottom: 15px;
    font-size: 1.5rem;
}

#result-message {
    margin-bottom: 25px;
    color: var(--text-secondary);
}

#restart-btn {
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
}

.hidden {
    display: none !important;
}