:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-secondary: #10b981;
    --accent-yellow: #fbbf24;
    --accent-red: #ef4444;
    --accent-pink: #ec4899;
    --font-outfit: 'Outfit', 'Noto Sans JP', sans-serif;
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    overscroll-behavior-y: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-outfit);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

/* Background Animations */
.background-decor {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.15;
    pointer-events: none;
}

.blob-1 {
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    top: -200px;
    left: -200px;
    animation: floatBlob 20s infinite alternate;
}

.blob-2 {
    background: radial-gradient(circle, var(--accent-pink) 0%, transparent 70%);
    bottom: -200px;
    right: -200px;
    animation: floatBlob 25s infinite alternate-reverse;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 80px) scale(1.2); }
}

.app-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Screens */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.active {
    display: block;
    opacity: 1;
}

/* Start Screen Styling */
.game-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.game-header h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    margin-bottom: 10px;
}

.game-header h1 span {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-sub);
    font-size: 1.1rem;
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 25px;
}

details.intro-card {
    transition: all 0.3s ease;
}

details.intro-card summary {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-secondary);
    cursor: pointer;
    outline: none;
    padding: 2px 0;
    user-select: none;
    transition: color 0.2s ease;
}

details.intro-card summary:hover {
    color: var(--accent-primary);
}

details.intro-card ul {
    margin-top: 15px;
    list-style: none;
    padding-left: 0;
}

.intro-card li {
    margin-bottom: 12px;
    position: relative;
    padding-left: 25px;
    color: var(--text-sub);
    line-height: 1.6;
}

.intro-card li::before {
    content: "🎈";
    position: absolute;
    left: 0;
    top: 2px;
}

.intro-card strong {
    color: var(--text-main);
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .setup-grid {
        grid-template-columns: 1fr;
    }
}

.setup-card h3 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
}

/* Category Options Grid UI */
.category-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.cat-option {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.cat-option:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cat-option.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.25));
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.cat-option input[type="checkbox"] {
    display: none; /* Hide default checkboxes completely */
}

.cat-option span {
    font-weight: 600;
    font-size: 0.9rem;
}

.cat-basic-container {
    grid-column: 1 / -1; /* Make the required basic category take full width */
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    overflow: hidden;
}

.cat-basic-container .cat-option {
    padding: 0;
    background: transparent;
    border: none;
}

.cat-basic-container .cat-option:hover {
    background: transparent;
    border-color: transparent;
    transform: none;
    box-shadow: none;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.toggle-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Region Selection Buttons */
.region-select-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.region-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.region-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.region-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: transparent;
    box-shadow: var(--shadow-glow);
}

/* Buttons */
.start-btn-container {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 40px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    font-family: var(--font-outfit);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 30px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.8rem;
}

.btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.btn-text strong {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-text span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.back-home-container {
    text-align: center;
    margin-top: 30px;
}

.back-link {
    color: var(--text-sub);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--text-main);
}

/* Game HUD */
.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.hud-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 30px;
    font-family: var(--font-outfit);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.hud-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.hud-stats {
    display: flex;
    gap: 15px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    padding: 6px 16px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-sub);
    text-transform: uppercase;
}

.stat-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent-yellow);
}

/* Map Instruction Overlay (SVGキャンバス内重ね合わせ) */
.map-instruction-overlay {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    text-align: center;
    background: rgba(15, 23, 42, 0.85); /* ダークな背景で文字を引き立たせる */
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 8px 18px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none; /* 下のSVGへのドラッグ＆ドロップを邪魔しない */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 480px;
    transition: all 0.3s ease;
}

.overlay-pref-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.overlay-instruction {
    font-size: 0.85rem;
    color: var(--accent-yellow);
    font-weight: 700;
}

/* Balloon Area */
.balloon-area {
    min-height: 110px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--card-border);
    border-radius: 20px;
    padding: 15px;
    position: relative;
}

/* Balloon Element */
.balloon {
    background: radial-gradient(circle at 30% 30%, #4f46e5, #312e81);
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 700;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none; /* Safari / iOS */
    -webkit-touch-callout: none; /* iOS 長押しメニューの抑止 */
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.3);
    position: relative;
    transition: transform 0.1s, box-shadow 0.2s;
    touch-action: none; /* Prevents scroll when dragging on mobile */
    font-size: 0.95rem;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    animation: floatBalloon 3s infinite ease-in-out alternate;
}

.balloon:active {
    cursor: grabbing;
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

/* Balloon Balloon String Effect */
.balloon::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 10px;
    background: rgba(255, 255, 255, 0.4);
}

@keyframes floatBalloon {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-5px) rotate(1deg); }
    100% { transform: translateY(3px) rotate(-1deg); }
}

/* Floating animation delays for dynamic feel */
.balloon:nth-child(2n) { animation-delay: 0.5s; animation-duration: 3.5s; }
.balloon:nth-child(3n) { animation-delay: 0.8s; animation-duration: 4s; }
.balloon:nth-child(4n) { animation-delay: 1.2s; animation-duration: 3.2s; }

/* Different balloon colors depending on category */
.balloon.cat-name { background: radial-gradient(circle at 30% 30%, #ec4899, #9d174d); }
.balloon.cat-capital { background: radial-gradient(circle at 30% 30%, #3b82f6, #1e3a8a); }
.balloon.cat-city { background: radial-gradient(circle at 30% 30%, #a855f7, #581c87); }
.balloon.cat-landform { background: radial-gradient(circle at 30% 30%, #10b981, #064e3b); }
.balloon.cat-industry { background: radial-gradient(circle at 30% 30%, #f97316, #7c2d12); }
.balloon.cat-industryType { background: radial-gradient(circle at 30% 30%, #facc15, #854d0e); }
.balloon.cat-transport { background: radial-gradient(circle at 30% 30%, #06b6d4, #083344); }
.balloon.cat-environment { background: radial-gradient(circle at 30% 30%, #14b8a6, #115e59); }
.balloon.cat-culture { background: radial-gradient(circle at 30% 30%, #6366f1, #312e81); }

/* Map Area */
.map-container {
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--card-bg);
    overflow: hidden;
    position: relative;
    height: 540px; /* 縦幅を固定 */
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#japan-map {
    max-width: 100%;
    height: 100%; /* 高さを固定化 */
    max-height: 500px;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
}

/* Map Path Styling */
.pref-path {
    fill: #1e293b;
    stroke: #334155;
    stroke-width: 1.5px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.pref-path:hover {
    fill: #475569;
    stroke: #64748b;
    filter: brightness(1.2);
}

/* Highlight Target Pref */
.pref-path.target-active {
    fill: #1e293b !important; /* シルエット表示のため暗くする */
    stroke: #475569;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.15));
}

/* --- 海岸線 (実線) & 陸上境界線 (点線) のデザイン --- */
.pref-border-sea {
    stroke: #60a5fa; /* 明るい青 */
    stroke-width: 1.0px;
    vector-effect: non-scaling-stroke;
    fill: none;
    transition: stroke 0.3s, stroke-width 0.3s;
}

.pref-border-land {
    stroke: #64748b; /* グレー */
    stroke-width: 0.8px;
    stroke-dasharray: 3, 3;
    vector-effect: non-scaling-stroke;
    fill: none;
    transition: stroke 0.3s, stroke-width 0.3s;
}

/* 名前特定後の境界線変化 */
.pref-named .pref-border-sea {
    stroke: var(--accent-primary) !important;
    stroke-width: 1.2px !important;
    filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.4));
}

.pref-named .pref-border-land {
    stroke: #94a3b8 !important;
    stroke-width: 0.8px !important;
}

/* 完成後の境界線変化 */
.pref-completed .pref-border-sea {
    stroke: #34d399 !important; /* エメラルドグリーン */
    stroke-width: 1.5px !important;
    filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.5)) !important;
}

.pref-completed .pref-border-land {
    stroke: #86efac !important; /* 明るい緑の点線 */
    stroke-width: 1.0px !important;
    stroke-dasharray: 4, 3 !important;
}

/* Name/Drag states */
.pref-path.pref-named {
    fill: rgba(59, 130, 246, 0.35) !important;
    stroke: var(--accent-primary) !important;
    stroke-width: 1.5px !important;
    filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.3)) !important;
}

.pref-path.drag-over {
    fill: rgba(16, 185, 129, 0.35) !important;
    stroke: var(--accent-secondary) !important;
    stroke-width: 2px !important;
}

.pref-path.pref-completed {
    fill: rgba(16, 185, 129, 0.5) !important;
    stroke: var(--accent-secondary) !important;
    stroke-width: 2px !important;
    filter: drop-shadow(0 0 15px rgba(16, 185, 129, 0.4)) !important;
}

/* Under Map Cards Section */
.cards-section {
    margin-top: 30px;
}

.cards-section h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    min-height: 100px;
}

.no-cards-placeholder {
    width: 100%;
    text-align: center;
    color: var(--text-sub);
    padding: 30px;
    border: 1.5px dashed var(--card-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.01);
}

/* Prefecture Information Card */
.pref-card {
    background: var(--card-bg);
    border: 1.5px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    width: calc(33.333% - 10px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    animation: slideInCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

@media (max-width: 900px) {
    .pref-card { width: calc(50% - 7.5px); }
}

@media (max-width: 600px) {
    .pref-card { width: 100%; }
}

.pref-card.completed-glow {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

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

.pref-card-name {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
}

.pref-card-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
}

.pref-card.completed-glow .pref-card-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #a7f3d0;
}

.pref-info-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pref-info-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    line-height: 1.4;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    padding-bottom: 4px;
}

.pref-info-label {
    color: var(--text-sub);
    font-weight: 600;
}

.pref-info-value {
    color: var(--text-main);
    font-weight: 700;
    text-align: right;
    max-width: 65%;
}

/* Results Screen Styling */
.result-card {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 30px;
}

.result-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
}

.result-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-stat-item .stat-label {
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.result-stat-item .stat-value {
    font-size: 2.2rem;
}

.result-evaluation {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.6;
    color: #e2e8f0;
    border-top: 1px solid var(--card-border);
    padding-top: 20px;
}

/* --- 2列構成横並びレイアウト --- */
.game-board-layout {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 100%;
    align-items: stretch;
    margin-top: 15px;
}

.map-column {
    flex: 1.0;
    min-width: 0;
}

.cards-column {
    flex: 1.0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* --- 左右ナビゲーション矢印 --- */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 12;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.nav-arrow:hover {
    background: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.prev-arrow {
    left: 20px;
}

.next-arrow {
    right: 20px;
}

/* --- アクティブな都道府県詳細カード --- */
.active-pref-detail {
    padding: 12px;
    height: 100%;
    max-height: 580px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.active-pref-detail h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.15rem;
    color: var(--accent-secondary);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 6px;
}

#active-card-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 0; /* 高さ制限を有効にする */
}

.pref-detail-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
    box-sizing: border-box;
    min-height: 0; /* 子の高さ制限用 */
}

.pref-detail-card.completed-glow {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.3);
    background: rgba(6, 78, 59, 0.15);
}

.pref-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 8px;
    flex-shrink: 0;
}

.pref-detail-badge {
    font-size: 0.85rem;
    color: var(--text-sub);
    font-weight: 600;
}

.pref-detail-status-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 700;
}

.pref-detail-status-badge.solving-tag {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.pref-detail-status-badge.complete-tag {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-secondary);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.pref-detail-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: flex-start;
    overflow-y: auto;
    padding-right: 4px;
}

/* カード内スクロールバーのカスタマイズ */
.pref-detail-body::-webkit-scrollbar {
    width: 5px;
}
.pref-detail-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 3px;
}
.pref-detail-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.pref-detail-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.detail-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.detail-item.name-row {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-sub);
    font-weight: 700;
}

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

.detail-value.text-highlight {
    font-size: 1.45rem;
    color: var(--accent-primary);
}

.lock-placeholder {
    color: var(--text-sub);
    font-size: 1.0rem;
    font-weight: 500;
    opacity: 0.7;
}

/* スマホなど縦長画面でのレスポンシブ対応 */
@media (max-width: 950px) {
    .game-board-layout {
        flex-direction: column;
    }
    
    .map-column, .cards-column {
        flex: none;
        width: 100%;
    }
    
    .nav-arrow {
        width: 40px;
        height: 40px;
    }
    .prev-arrow { left: 10px; }
    .next-arrow { right: 10px; }
}

/* スマホ専用: カード内部を自動高さにしてはみ出しを防ぐ */
@media (max-width: 768px) {
    .active-pref-detail {
        max-height: none;
        height: auto;
        padding: 10px;
    }

    #active-card-container {
        align-items: flex-start;
        height: auto;
        min-height: unset;
    }

    .pref-detail-card {
        height: auto;
        min-height: unset;
        overflow: visible;
    }

    .pref-detail-body {
        overflow-y: visible; /* スマホはページ自体でスクロールするため内部スクロール不要 */
        max-height: none;
    }
}

/* マップキャンバス上の正誤判定ツールチップ */
.map-tooltip {
    position: absolute;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 6px;
    animation: floatUpFade 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.map-tooltip.correct {
    background: rgba(16, 185, 129, 0.9); /* エメラルドグリーン */
    color: #ffffff;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.map-tooltip.wrong {
    background: rgba(239, 68, 68, 0.9); /* レッド */
    color: #ffffff;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

@keyframes floatUpFade {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.8);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -20px) scale(1.05);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -30px) scale(1.0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -45px) scale(0.9);
    }
}

/* --- 解説ポップアップ・ツールチップデザイン --- */
.info-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.info-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.info-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.info-help-trigger {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    line-height: 1;
}

.info-help-trigger:hover {
    background: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}

/* 用語解説ダイアログ */
.explanation-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 420px;
    background: rgba(15, 23, 42, 0.96);
    border: 1.5px solid var(--accent-primary);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 25px rgba(59, 130, 246, 0.35);
    border-radius: 18px;
    padding: 22px;
    z-index: 2000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.explanation-popup.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1.0);
}

.explanation-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.explanation-popup-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.explanation-popup-close {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s, transform 0.2s;
    line-height: 1;
}

.explanation-popup-close:hover {
    color: #ffffff;
    transform: scale(1.1);
}

.explanation-popup-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
    word-break: break-all;
}

/* ポップアップ用背景フェード */
.explanation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.explanation-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* アクティブなステップの行ハイライトとフォーカス */
.detail-item[data-step] {
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.detail-item.active-step-row {
    background: rgba(52, 152, 219, 0.15) !important;
    border-left: 4px solid #3498db !important;
    box-shadow: inset 0 0 8px rgba(52, 152, 219, 0.1);
    animation: stepPulse 2s infinite ease-in-out;
}

/* 選択中バルーンのインジケータ（モバイル補助UI用） */
.balloon.selected-pulse {
    outline: 3px solid var(--accent-primary) !important;
    outline-offset: 2px;
    box-shadow: 0 0 15px var(--accent-primary) !important;
    animation: selectedPulse 1.2s infinite ease-in-out !important;
}

@keyframes selectedPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.96); opacity: 0.9; }
    100% { transform: scale(1); }
}

@keyframes stepPulse {
    0% { background: rgba(52, 152, 219, 0.1); }
    50% { background: rgba(52, 152, 219, 0.22); }
    100% { background: rgba(52, 152, 219, 0.1); }
}

/* ドラッグ中の元のバルーンを半透明にする */
.balloon.dragging {
    opacity: 0.25 !important;
}

/* ゲームエリア全体でダブルクリック・ダブルタップ・長押しによる文字選択を完全に防ぐ */
#game-screen,
.balloon-area,
.balloon-container,
.detail-card,
#japan-map,
#japan-map * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* クイズ完了時などの汎用フェードイン表示用 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* アドバンスモード用スタイル */
.start-advance-btn {
    background: linear-gradient(135deg, #f59e0b, #ef4444) !important;
    color: white !important;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.3) !important;
    border: none !important;
}

.start-advance-btn:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 15px 30px rgba(239, 68, 68, 0.5) !important;
}

.start-btn-container.flex-row {
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: center;
    width: 100%;
}

@media (max-width: 600px) {
    .start-btn-container.flex-row {
        gap: 8px;
    }
    .start-btn-container.flex-row .btn {
        padding: 10px 15px !important;
        gap: 8px !important;
        border-radius: 30px !important;
    }
    .start-btn-container.flex-row .btn-icon {
        font-size: 1.2rem !important;
    }
    .start-btn-container.flex-row .btn-text strong {
        font-size: 0.9rem !important;
    }
    .start-btn-container.flex-row .btn-text span {
        font-size: 0.65rem !important;
    }
}

/* 穴埋め表示用のスタイル */
span.blank {
    color: #e07b00;
    font-weight: bold;
}

span.blank.hidden-blank {

    background: rgba(255, 255, 255, 0.15);
    border-bottom: 2px dashed #f59e0b;
    padding: 2px 8px;
    margin: 0 4px;
    border-radius: 4px;
    font-weight: bold;
    color: #f59e0b;
    cursor: default;
    transition: all 0.3s ease;
}

span.blank.correct-blank {
    background: rgba(16, 185, 129, 0.2);
    border-bottom: 2px solid #10b981;
    color: #10b981;
    padding: 2px 8px;
    margin: 0 4px;
    border-radius: 4px;
    font-weight: bold;
}

.explanation-quiz-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.explanation-quiz-instruction {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: bold;
    text-align: center;
}

.explanation-quiz-choices {
    display: flex;
    flex-direction: row;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.quiz-choice-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
    transition: all 0.2s ease;
}

.quiz-choice-btn:hover:not(.wrong) {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-primary);
}

.quiz-choice-btn.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
    cursor: not-allowed;
    opacity: 0.6;
}

.quiz-choice-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    color: #10b981;
}

.explanation-quiz-feedback {
    text-align: center;
    font-weight: bold;
    font-size: 0.95rem;
    min-height: 20px;
}
