/* =========================================================
   市町村 地図パズル — フラットデザイン
   ・すりガラス / グラデーション文字 / 強い光彩は使わない
   ・面は不透明な単色、区切りは 1px ボーダーで表現
   ・角丸は 4〜8px に統一
   ========================================================= */
:root {
    --bg-primary: #0f172a;      /* 画面全体 */
    --surface: #1e293b;         /* HUD・モーダル・ピース棚 */
    --surface-2: #273449;       /* モーダル内のカード */
    --surface-3: #2f3e57;       /* ホバー */
    --map-bg: #172033;          /* 地図の盤面 */
    --border: #334155;
    --border-strong: #475569;

    --accent: #38bdf8;
    --accent-strong: #0284c7;
    --accent-strong-hover: #0369a1;
    --green: #10b981;
    --green-text: #34d399;
    --orange: #f97316;
    --orange-text: #fb923c;
    --red: #ef4444;
    --gold: #facc15;

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --radius-s: 4px;
    --radius-m: 6px;
    --radius-l: 8px;

    --shadow-float: 0 4px 12px rgba(0, 0, 0, 0.35); /* 浮遊要素（ドラッグ中・ポップアップ）専用 */
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'M PLUS Rounded 1c', 'Outfit', -apple-system, sans-serif;
    margin: 0;
    padding: 14px 20px 18px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    color: var(--text-main);
    overflow: hidden;
}

/* 数字は等幅の欧文書体で読みやすく */
.stat-value,
.progress-text,
.clear-stat-val,
.ranking-time,
.ranking-date {
    font-family: 'Outfit', 'M PLUS Rounded 1c', sans-serif;
    font-variant-numeric: tabular-nums;
}

/* --- ヘッダー / ゲームHUD --- */
#game-hud {
    width: 100%;
    max-width: 920px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 10px 16px;
    margin-bottom: 10px;
    z-index: 10;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-logo {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--text-main);
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.game-logo-sub {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
}

.mode-badge {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: var(--radius-s);
}
.mode-badge.easy {
    color: var(--green-text);
    border: 1px solid var(--green);
}
.mode-badge.hard {
    color: var(--orange-text);
    border: 1px solid var(--orange);
}

.hud-center {
    display: flex;
    align-items: center;
    gap: 28px;
}

.hud-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-info {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.stat-label {
    font-size: 0.66rem;
    color: var(--text-muted);
    font-weight: 700;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

/* 進行度バー */
.progress-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 160px;
}

.progress-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.progress-text {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--accent);
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon-sub {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    border-radius: var(--radius-m);
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-icon-sub:hover {
    background: var(--surface-2);
    border-color: var(--text-faint);
    color: var(--text-main);
}

/* --- サブメッセージトースト --- */
#message-area {
    height: 22px;
    font-size: 0.86rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
}

/* --- マップエリア --- */
#map-area {
    width: 100%;
    max-width: 920px;
    flex-grow: 1;
    background: var(--map-bg);
    border-radius: var(--radius-l);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 8px;
    position: relative;
    cursor: grab;
    touch-action: none;
}

#map-area:active { cursor: grabbing; }

#map-area svg {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* マップパーツ（不透明で色漏れゼロ） */
#map-area path {
    pointer-events: auto;
    fill: #ffffff;
    stroke: #38bdf8;
    stroke-width: 1.2px;
    vector-effect: non-scaling-stroke;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

#map-area path.drag-over {
    fill: #fef08a;
    stroke: #f97316;
    stroke-width: 2.4px;
}

#map-area path.solved {
    fill: #10b981;
    stroke: #047857;
    stroke-width: 1.2px;
}

/* ミス時のマップ振動エフェクト */
#map-area.wrong-shake {
    animation: mapWrongShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
    border-color: var(--red);
}

@keyframes mapWrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* ズームヘルプヒント */
.map-hint {
    position: absolute;
    bottom: 10px;
    right: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--radius-s);
    font-size: 0.72rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* =========================================================
   ★ ポップアップ演出 (正解時・不正解時共通アニメーション)
   ========================================================= */
#celebration-overlay {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    transition: none;
}

#celebration-overlay.animate-pop {
    animation: celebrationPop 1.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes celebrationPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -42%) scale(0.85);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.06);
    }
    25% {
        transform: translate(-50%, -50%) scale(1);
    }
    75% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -58%) scale(0.96);
    }
}

.celeb-badge {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 3px 14px;
    border-radius: var(--radius-s);
    margin-bottom: 6px;
}

/* 正解時のバッジ */
#celebration-overlay.is-correct .celeb-badge {
    background: var(--green);
}

/* 不正解時のバッジ */
#celebration-overlay.is-wrong .celeb-badge {
    background: var(--red);
}

.celeb-title-box {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 12px 28px;
    text-align: center;
    display: flex;
    align-items: baseline;
    gap: 12px;
    box-shadow: var(--shadow-float);
}

/* 正解時のタイトルボックス */
#celebration-overlay.is-correct .celeb-title-box {
    border: 2px solid var(--green);
}

/* 不正解時のタイトルボックス */
#celebration-overlay.is-wrong .celeb-title-box {
    border: 2px solid var(--red);
}

.celeb-town-name {
    font-size: 2.1rem;
    font-weight: 900;
    color: #ffffff;
}

.celeb-status {
    font-size: 1.2rem;
    font-weight: 800;
}

#celebration-overlay.is-correct .celeb-status {
    color: var(--green-text);
}

#celebration-overlay.is-wrong .celeb-status {
    color: #fca5a5;
}

.celeb-combo {
    font-size: 0.92rem;
    font-weight: 800;
    margin-top: 8px;
    padding: 2px 10px;
    border-radius: var(--radius-s);
    background: var(--surface);
}

.celeb-combo:empty {
    display: none;
}

#celebration-overlay.is-correct .celeb-combo {
    color: var(--gold);
}

#celebration-overlay.is-wrong .celeb-combo {
    color: var(--text-main);
}

/* --- ピース並び替えコントロール --- */
#choices-controls {
    width: 100%;
    max-width: 920px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 6px;
    padding: 0 4px;
}

.sort-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
}

.sort-btn-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.btn-sort {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    border-radius: var(--radius-m);
    padding: 4px 10px;
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-sort:hover {
    background: var(--surface-2);
    border-color: var(--text-faint);
    color: var(--text-main);
}

.btn-sort.active {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--accent);
}

/* --- ピース選択エリア --- */
#choices-area {
    width: 100%;
    max-width: 920px;
    height: 118px;
    display: flex;
    align-items: center;
    overflow-x: auto;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    touch-action: pan-x;
}

#choices-area::-webkit-scrollbar {
    height: 6px;
}
#choices-area::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.choice-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: white;
    border-radius: var(--radius-m);
    cursor: grab;
    user-select: none;
    min-width: 88px;
    height: 98px;
    touch-action: pan-x;
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    position: relative;
    flex-shrink: 0;
}

.choice-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    background: var(--surface-3);
}

.choice-item.dragging {
    opacity: 0.35;
    transform: none;
}

.choice-thumb {
    width: 52px;
    height: 52px;
    margin-bottom: 6px;
    background: var(--map-bg);
    border-radius: var(--radius-s);
    pointer-events: none;
}

.choice-thumb path {
    fill: #f8fafc;
    stroke: #38bdf8;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.town-name {
    font-size: 0.72rem;
    line-height: 1.15;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    white-space: normal;
    word-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 80px;
    color: var(--text-main);
}

/* =========================================================
   全画面オーバーレイ共通（タイトル / 市町村 / 難易度 / クリア）
   ========================================================= */
#game-start-screen,
#city-select-screen,
#start-screen,
#clear-screen {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(15, 23, 42, 0.94);
    justify-content: center;
    align-items: center;
    padding: 24px;
}

#game-start-screen { display: flex; z-index: 10005; }
#city-select-screen { display: none; z-index: 10002; }
#start-screen { display: none; z-index: 10000; }
#clear-screen { display: none; z-index: 10001; }

/* --- モーダル共通 --- */
.start-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 40px 40px 32px;
    border-radius: var(--radius-l);
    text-align: center;
    max-width: 540px;
    width: 100%;
    animation: modalIn 0.25s ease-out;
}

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

/* 見出し → 説明文は近く、説明文 → 中身は大きく離す */
.start-modal h1 {
    font-size: 1.9rem;
    font-weight: 900;
    margin: 0 0 6px;
    color: var(--text-main);
    line-height: 1.3;
}

.start-modal p {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin: 0 0 32px;
    line-height: 1.6;
}

/* --- ゲーム開始画面 (タイトル) --- */
.game-start-modal {
    max-width: 520px;
    padding: 56px 44px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-start-title {
    font-size: 2.3rem;
    font-weight: 900;
    margin: 0 0 12px;
    color: var(--text-main);
    line-height: 1.25;
}

.game-start-modal .game-start-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 0 40px;
    line-height: 1.75;
}

.btn-game-start-play {
    width: 100%;
    max-width: 300px;
    flex: none;
    padding: 15px 28px;
    font-size: 1.15rem;
}

.game-start-note {
    font-size: 0.76rem;
    color: var(--text-faint);
    margin-top: 16px;
}

/* --- 市町村選択画面 --- */
.city-modal {
    max-width: 680px;
    text-align: left;
}

.city-main-title {
    font-size: 1.9rem;
}

.city-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.city-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 18px 20px 14px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background-color 0.15s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.city-card:hover,
.city-card:focus-visible {
    background: var(--surface-3);
    border-color: var(--accent);
    outline: none;
}

.city-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.city-card-romaji {
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-faint);
    letter-spacing: 1.5px;
}

.city-card-name {
    font-size: 1.45rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 4px;
}

.city-card-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
    flex-grow: 1;
}

.city-card-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent);
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.city-card-action .arrow {
    font-size: 0.7rem;
    transition: transform 0.15s;
}

.city-card:hover .city-card-action .arrow {
    transform: translateX(3px);
}

.city-return-actions {
    margin-top: 28px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- モード選択画面 --- */
.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-radius: var(--radius-l);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left-width: 4px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s, border-color 0.15s;
    position: relative;
}

.mode-card:hover {
    background: var(--surface-3);
}

.mode-card.easy-card { border-left-color: var(--green); }
.mode-card.easy-card:hover { border-color: var(--green); }

.mode-card.hard-card { border-left-color: var(--orange); }
.mode-card.hard-card:hover { border-color: var(--orange); }

.mode-details {
    flex-grow: 1;
}

.mode-topline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.mode-tag {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: var(--radius-s);
}
.easy-tag { background: var(--green); color: #fff; }
.hard-tag { background: var(--orange); color: #fff; }

.mode-saved-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: var(--radius-s);
    color: var(--accent);
    border: 1px solid var(--accent);
    margin-left: auto;
}

.mode-title {
    font-size: 1.12rem;
    font-weight: 900;
    color: #fff;
}

.mode-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.mode-play-arrow {
    font-size: 0.85rem;
    color: var(--text-faint);
    transition: transform 0.15s, color 0.15s;
}

.mode-card:hover .mode-play-arrow {
    transform: translateX(3px);
    color: var(--text-main);
}

.mode-modal-actions {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-modal-actions .btn-game-secondary {
    width: 100%;
    padding: 10px 20px;
    font-size: 0.88rem;
}

/* --- クリア画面 --- */
.clear-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--gold);
    padding: 36px 32px 28px;
    border-radius: var(--radius-l);
    text-align: center;
    max-width: 500px;
    width: 100%;
    max-height: 94vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease-out;
}

.clear-title {
    font-size: 2rem;
    font-weight: 900;
    margin: 0 0 4px;
    color: var(--text-main);
}

.clear-subtitle {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* 新記録達成バナー */
.clear-banner-wrap {
    margin-bottom: 12px;
}

.clear-new-record-banner {
    display: inline-block;
    background: var(--gold);
    color: #422006;
    font-size: 0.86rem;
    font-weight: 900;
    padding: 4px 14px;
    border-radius: var(--radius-s);
}

.clear-rank-badge {
    display: inline-block;
    color: var(--gold);
    border: 1px solid var(--gold);
    font-size: 0.86rem;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: var(--radius-s);
    margin-bottom: 20px;
}

.clear-stats-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 14px 18px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 14px;
}

.clear-stat-divider {
    width: 1px;
    height: 38px;
    background: var(--border);
}

.clear-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.clear-stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 2px;
}

.clear-stat-val {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-main);
}

.clear-stat-val.time {
    color: var(--gold);
}

.clear-stat-val.combo {
    color: var(--accent);
}

/* --- ランキングエリア --- */
.ranking-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 12px 14px;
    margin-bottom: 28px;
    text-align: left;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.ranking-title {
    font-size: 0.84rem;
    font-weight: 800;
    color: var(--text-main);
}

.ranking-mode-tag {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: var(--radius-s);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ranking-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    font-size: 0.82rem;
}

.ranking-row + .ranking-row {
    border-top-color: var(--border);
    border-radius: 0;
}

.ranking-row-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ranking-rank {
    font-weight: 800;
    font-size: 0.82rem;
    width: 36px;
    color: var(--text-muted);
}

.ranking-rank.gold { color: var(--gold); }
.ranking-rank.silver { color: #e2e8f0; }
.ranking-rank.bronze { color: var(--orange-text); }

.ranking-time {
    font-weight: 800;
    font-size: 0.96rem;
    color: #fff;
    min-width: 50px;
}

.ranking-grade {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0 6px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}

.ranking-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ranking-date {
    font-size: 0.72rem;
    color: var(--text-faint);
}

.ranking-badge-new {
    font-size: 0.66rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: var(--radius-s);
    background: var(--gold);
    color: #422006;
}

.ranking-row.is-new-record {
    background: rgba(250, 204, 21, 0.1);
    border: 1px solid rgba(250, 204, 21, 0.45);
    border-radius: var(--radius-s);
}

.ranking-empty {
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.clear-actions {
    display: flex;
    gap: 8px;
}

/* --- ボタン --- */
.btn-game-primary {
    flex: 1.4;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    border-radius: var(--radius-m);
    border: 1px solid var(--accent-strong);
    background: var(--accent-strong);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn-game-primary:hover {
    background: var(--accent-strong-hover);
    border-color: var(--accent-strong-hover);
}

.btn-game-primary:active {
    transform: translateY(1px);
}

.btn-game-secondary {
    flex: 1;
    padding: 12px 18px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    border-radius: var(--radius-m);
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn-game-secondary:hover {
    background: var(--surface-2);
    border-color: var(--text-faint);
}

.btn-game-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.city-return-actions .btn-game-secondary {
    flex: none;
    padding: 10px 18px;
    font-size: 0.88rem;
}

/* --- スマートフォン対応 --- */
@media (max-width: 700px) {
    body {
        padding: 8px 10px 10px;
        min-width: 0;
        height: 100vh;
        height: 100dvh;
        overflow-x: hidden;
    }

    #game-hud {
        min-width: 0;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "left right"
            "center center";
        gap: 8px;
        padding: 9px 10px;
        margin-bottom: 6px;
        border-radius: var(--radius-m);
        align-items: center;
    }

    .hud-left {
        grid-area: left;
        min-width: 0;
        gap: 6px;
    }

    .game-logo {
        min-width: 0;
        max-width: 100%;
        font-size: clamp(0.82rem, 3.8vw, 1rem);
        gap: 4px;
        white-space: nowrap;
    }

    .game-logo-sub {
        display: none;
    }

    .mode-badge {
        flex-shrink: 0;
        font-size: 0.64rem;
        padding: 2px 6px;
    }

    .hud-center {
        grid-area: center;
        min-width: 0;
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .hud-stat {
        min-width: 0;
        gap: 5px;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    .progress-container {
        width: clamp(110px, 38vw, 160px);
        min-width: 0;
    }

    .hud-right {
        grid-area: right;
        justify-content: flex-end;
        gap: 4px;
    }

    .btn-icon-sub {
        min-height: 28px;
        padding: 4px 6px;
        font-size: 0.6rem;
        line-height: 1.15;
        white-space: nowrap;
    }

    #message-area {
        width: 100%;
        min-width: 0;
        height: 24px;
        margin-bottom: 5px;
        font-size: clamp(0.68rem, 3.2vw, 0.82rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #map-area {
        width: 100%;
        min-width: 0;
        min-height: 250px;
        margin-bottom: 8px;
        border-radius: var(--radius-m);
    }

    .map-hint {
        right: 8px;
        bottom: 8px;
        max-width: calc(100% - 16px);
        padding: 3px 8px;
        font-size: 0.64rem;
        white-space: nowrap;
    }

    #celebration-overlay {
        width: min(84%, 330px);
        max-width: calc(100% - 24px);
    }

    .celeb-badge {
        max-width: 100%;
        padding: 3px 12px;
        font-size: 0.74rem;
        white-space: nowrap;
    }

    .celeb-title-box {
        width: 100%;
        max-width: 100%;
        padding: 9px 12px;
        gap: 7px;
        justify-content: center;
        white-space: nowrap;
    }

    .celeb-town-name {
        min-width: 0;
        flex-shrink: 0;
        font-size: clamp(1.3rem, 7vw, 1.8rem);
        line-height: 1.15;
        white-space: nowrap;
    }

    .celeb-status {
        flex-shrink: 0;
        font-size: clamp(0.9rem, 4.5vw, 1.1rem);
        line-height: 1.15;
        white-space: nowrap;
    }

    .celeb-combo {
        max-width: 100%;
        margin-top: 6px;
        font-size: 0.78rem;
        line-height: 1.25;
        text-align: center;
    }

    #choices-controls {
        gap: 4px;
        margin-bottom: 4px;
        justify-content: space-between;
    }

    .sort-label {
        font-size: 0.68rem;
    }

    .sort-btn-group {
        gap: 3px;
    }

    .btn-sort {
        padding: 3px 6px;
        font-size: 0.65rem;
    }

    #choices-area {
        width: 100%;
        min-width: 0;
        height: 110px;
        padding: 8px 9px;
        gap: 8px;
        border-radius: var(--radius-m);
    }

    .choice-item {
        min-width: 78px;
        width: 78px;
        height: 90px;
        padding: 6px 7px;
    }

    .choice-thumb {
        width: 45px;
        height: 45px;
        margin-bottom: 4px;
    }

    .town-name {
        max-width: 72px;
        font-size: 0.65rem;
    }

    #game-start-screen,
    #city-select-screen,
    #start-screen,
    #clear-screen {
        padding: 12px;
    }

    .city-modal,
    .start-modal,
    .clear-modal {
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        padding: 28px 20px 22px;
    }

    .clear-stats-card {
        padding: 12px 10px;
    }

    .clear-stat-val {
        font-size: 1.28rem;
    }

    .clear-stat-label {
        font-size: 0.68rem;
    }

    .game-start-modal {
        padding: 40px 22px 28px;
    }

    .game-start-title {
        font-size: clamp(1.7rem, 8vw, 2.3rem);
    }

    .game-start-modal .game-start-subtitle {
        margin-bottom: 32px;
    }

    .city-main-title,
    .start-modal h1 {
        font-size: clamp(1.5rem, 7vw, 1.9rem);
    }

    .start-modal p {
        margin-bottom: 24px;
    }

    .city-cards-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .city-card {
        padding: 14px 16px 12px;
    }

    .mode-card {
        padding: 14px 16px;
    }

    .clear-actions {
        flex-direction: column;
        gap: 8px;
    }

    .ranking-card {
        padding: 10px 10px;
        margin-bottom: 20px;
    }

    @media (max-width: 440px) {
        .ranking-date {
            display: none;
        }
    }
}

@media (max-width: 380px) {
    .progress-container {
        width: 31vw;
    }

    #celebration-overlay {
        width: min(88%, 290px);
    }

    .celeb-title-box {
        padding-left: 8px;
        padding-right: 8px;
        gap: 5px;
    }
}