/* ==========================================================
   PEP Policy Simulation — Design System
   PEP Blue palette, simulation game UI
   ========================================================== */

/* ===== カスタムプロパティ ===== */
:root {
    --pep-blue: #303f9f;
    --pep-blue-dark: #1a237e;
    --pep-blue-light: #E8EAF6;
    --pep-blue-second: #7986CB;
    --pep-blue-hover: #283593;

    --text-primary: #23221e;
    --text-secondary: #4a4a4a;
    --text-muted: #7a7a7a;
    --text-on-dark: #ffffff;

    --bg-page: #fafafa;
    --bg-white: #ffffff;
    --bg-subtle: #f5f5f8;

    --border-main: #ddd;
    --border-light: #eee;
    --border-focus: var(--pep-blue-second);

    --radius: 6px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);

    --layout-max-width: 1100px;
    --layout-gutter: clamp(1rem, 2vw, 1.5rem);

    --success: #2e7d32;
    --warning: #f57f17;
    --danger: #c62828;
    --info: var(--pep-blue);
}

/* ===== グローバルリセット ===== */
body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
                 "Noto Sans JP", sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    letter-spacing: -0.01em;
    font-weight: 700;
}

a { color: var(--pep-blue); }
a:hover { color: var(--pep-blue-hover); }

/* ===== ナビゲーション ===== */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-main);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container,
main.container,
.site-footer .container {
    width: 100%;
    max-width: calc(var(--layout-max-width) + (var(--layout-gutter) * 2));
    margin-inline: auto;
    padding-left: var(--layout-gutter);
    padding-right: var(--layout-gutter);
    box-sizing: border-box;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0;
    padding-bottom: 0;
    min-height: 56px;
}

.site-logo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pep-blue);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.site-logo:hover { color: var(--pep-blue-dark); }

.site-nav {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.site-nav li a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}
.site-nav li a:hover {
    background: var(--bg-subtle);
    color: var(--pep-blue);
}

/* ===== フッター ===== */
.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-light);
}
.site-footer .container {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
}

/* ===== ヒーローセクション ===== */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}
.hero h1 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: var(--pep-blue-dark);
}
.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ===== 特徴グリッド ===== */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin: 2rem 0;
}
.feature-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.feature-card h3 {
    font-size: 1rem;
    color: var(--pep-blue);
    margin-bottom: 0.5rem;
}
.feature-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* ===== CTA ===== */
.cta-section {
    text-align: center;
    padding: 2rem 0;
}

/* ===== ゲームフロー（ステップ表示） ===== */
.how-it-works {
    margin: 2rem 0;
}
.how-it-works h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}
.steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 700px;
    margin: 0 auto;
}
.step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.step-number {
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pep-blue);
    color: var(--text-on-dark);
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 50%;
}
.step-content h4 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}
.step-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== ボタン ===== */
.btn-primary {
    display: inline-block;
    background: var(--pep-blue);
    color: var(--text-on-dark);
    padding: 0.4rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--pep-blue-hover); color: var(--text-on-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    display: inline-block;
    background: var(--bg-white);
    color: var(--pep-blue);
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;
}
.btn-secondary:hover { background: var(--bg-subtle); color: var(--pep-blue); }

.btn-large { padding: 0.625rem 2rem; font-size: 0.95rem; }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

.btn-remove {
    background: none;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
}

/* ===== フォーム ===== */
.create-form {
    max-width: 700px;
    margin: 0 auto;
}
.form-section {
    margin-bottom: 2rem;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.form-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}
.form-help {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-actions {
    text-align: center;
    margin: 2rem 0;
}

/* モード選択 */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.mode-option {
    cursor: pointer;
}
.mode-option input { display: none; }
.mode-card {
    border: 2px solid var(--border-main);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    transition: border-color 0.15s;
}
.mode-option input:checked + .mode-card {
    border-color: var(--pep-blue);
    background: var(--pep-blue-light);
}
.mode-card strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}
.mode-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

/* 素材入力 */
.material-input {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.material-input select {
    width: 100px;
    flex-shrink: 0;
}
.material-input textarea {
    flex: 1;
    min-width: 200px;
}

/* ===== バッジ ===== */
.badge {
    display: inline-block;
    background: var(--pep-blue-light);
    color: var(--pep-blue);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff8e1; color: var(--warning); }
.badge-danger { background: #ffebee; color: var(--danger); }

/* ===== ゲーム画面 ===== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 0.5rem;
}
.game-header h2 { margin: 0; font-size: 1.1rem; }
.game-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.timer {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--pep-blue);
    padding: 0.25rem 0.75rem;
    background: var(--pep-blue-light);
    border-radius: var(--radius);
}
.timer.urgent {
    color: var(--danger);
    background: #ffebee;
    animation: pulse 1s infinite;
}
@keyframes pulse {
    50% { opacity: 0.6; }
}

/* ゲームレイアウト */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 0.75rem;
    height: calc(100vh - 140px);
    min-height: 400px;
}
@media (max-width: 768px) {
    .game-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* チャットエリア */
.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}
.chat-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    padding: 0;
    overflow-x: auto;
}
.chat-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.chat-tab.active {
    color: var(--pep-blue);
    border-bottom-color: var(--pep-blue);
    font-weight: 600;
}
.chat-tab.unread::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--danger);
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    min-height: 0;
}
.chat-msg {
    margin-bottom: 0.5rem;
    line-height: 1.45;
}
.chat-msg .msg-sender {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--pep-blue);
}
.chat-msg .msg-sender.npc { color: var(--success); }
.chat-msg .msg-sender.system { color: var(--warning); }
.chat-msg .msg-content {
    font-size: 0.85rem;
    color: var(--text-primary);
}
.chat-msg .msg-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}
.chat-msg.briefing {
    background: var(--pep-blue-light);
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius);
    border-left: 3px solid var(--pep-blue);
}
.chat-msg.event {
    background: #fff8e1;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius);
    border-left: 3px solid var(--warning);
}
.chat-msg.system-msg {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border-light);
}
.chat-form input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    font-size: 0.95rem;
    min-width: 0;
}
.chat-form button {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* サイドパネル */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    min-height: 0;
}
.panel-section {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
}
.panel-section h4 {
    font-size: 0.8rem;
    margin: 0 0 0.5rem;
    color: var(--pep-blue);
}

/* 指標表示 */
.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
}
.metric-item:last-child { border-bottom: none; }
.metric-name { color: var(--text-secondary); }
.metric-value { font-weight: 600; font-family: monospace; }
.metric-value.up { color: var(--success); }
.metric-value.down { color: var(--danger); }

/* キャラクター情報 */
.char-info .char-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}
.char-info .char-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.char-info .char-detail {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}
.char-info .secret-info {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
}
.char-info .victory-conditions {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}
.char-info .victory-conditions li {
    margin-bottom: 0.25rem;
}

/* 決断フォーム */
#decision-form {
    margin: 0;
}
#decision-options {
    margin-bottom: 0.75rem;
}
.decision-option {
    display: block;
    margin-bottom: 0.5rem;
}
.decision-option label {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1.4;
    transition: border-color 0.15s;
}
.decision-option label:hover {
    border-color: var(--pep-blue-second);
}
.decision-option input:checked + span {
    color: var(--pep-blue);
    font-weight: 600;
}
#decision-reasoning {
    width: 100%;
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    padding: 0.35rem 0.5rem;
}

/* ===== ロビー ===== */
#lobby-players ul {
    list-style: none;
    padding: 0;
}
#lobby-players li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
#lobby-players li .host-badge {
    background: var(--pep-blue);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-size: 0.7rem;
    margin-left: 0.25rem;
}

#character-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.character-card {
    border: 2px solid var(--border-main);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.character-card:hover { border-color: var(--pep-blue-second); }
.character-card.selected {
    border-color: var(--pep-blue);
    background: var(--pep-blue-light);
}
.character-card.taken {
    opacity: 0.5;
    cursor: not-allowed;
}
.character-card .char-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}
.character-card .char-card-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.character-card .char-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== 振り返り ===== */
.review-page {
    max-width: 800px;
    margin: 0 auto;
}
.review-section {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.review-section h3 {
    font-size: 1rem;
    color: var(--pep-blue);
    margin-bottom: 1rem;
}

/* スコアボード */
.scoreboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.scoreboard th, .scoreboard td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.scoreboard th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
}
.scoreboard .score {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--pep-blue);
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .features-grid { grid-template-columns: 1fr; }
    .mode-selector { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.5rem; }
    .game-header { flex-direction: column; align-items: flex-start; }
}
