:root {
    --bg-color: #f4f7fc;
    --primary-color: #0d47a1;
    --accent-color: #ff8f00;
    --text-color: #263238;
    --light-text-color: #ffffff;
    --border-color: #e0e0e0;
    --card-bg: #ffffff;
    --shadow: 0 6px 20px rgba(0, 30, 80, 0.08);
    --success-color: #4caf50;
    --error-color: #f44336;
    --levelup-color: #ffd600;
    --stamina-color: #29b6f6;
    --kizuna-color: #f06292;
    --tutorial-color: #673ab7;
}

/* --- 全体・基本UI --- */
html { scroll-behavior: smooth; }
body { font-family: 'M PLUS Rounded 1c', sans-serif; background-color: var(--bg-color); color: var(--text-color); margin: 0; display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; }
#game-container { width: 100%; max-width: 450px; background-color: var(--card-bg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); overflow: hidden; margin: 16px 0; display: flex; flex-direction: column; transition: background 0.8s ease; position: relative; }
.screen { padding: 20px 24px 32px; box-sizing: border-box; width: 100%; }
h1, h2, h3 { color: var(--primary-color); text-align: center; }
h2 { font-size: 1.5rem; font-weight: 700; margin: 0 0 24px; padding-bottom: 12px; border-bottom: 3px solid var(--accent-color); }
h3 { font-size: 1.3rem; font-weight: 700; margin: 28px 0 16px; display: flex; align-items: center; gap: 8px; }
.btn { display: inline-block; width: 100%; padding: 16px; border: none; border-radius: 12px; background: linear-gradient(45deg, var(--accent-color), #ffb300); color: var(--light-text-color); font-size: 1.2rem; font-weight: 700; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(255, 143, 0, 0.3); text-align: center; text-decoration: none; }
.btn:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(255, 143, 0, 0.4); }
.btn:disabled { background: #bdbdbd; box-shadow: none; cursor: not-allowed; opacity: 0.7; }

/* --- スタート画面 --- */
#start-screen .form-group { margin-bottom: 18px; }
#start-screen label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--primary-color); }
#start-screen input, #start-screen select { width: 100%; padding: 14px; border: 1px solid var(--border-color); border-radius: 12px; box-sizing: border-box; font-size: 1rem; font-family: inherit; background-color: #f9fafb; }

/* --- メイン画面UI --- */
#header-info { padding: 16px; border-radius: 16px; margin-bottom: 24px; background: rgba(255,255,255,0.7); backdrop-filter: blur(5px); border: 1px solid rgba(255,255,255,0.8); }
.status-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.bar-container { flex-grow: 1; height: 12px; background-color: #e0e0e0; border-radius: 6px; overflow: hidden; margin: 0 10px; }
#exp-bar { height: 100%; background: linear-gradient(90deg, #ffd600, #ffab00); transition: width 0.5s ease; }
#stamina-bar { height: 100%; background: linear-gradient(90deg, var(--stamina-color), #81d4fa); transition: width 0.3s ease; }
.status-label { font-size: 0.9rem; font-weight: bold; }
#stamina-timer { font-size: 0.8rem; color: #546e7a; }

#car-display-area { text-align: center; margin-bottom: 12px; }
#car-visual img { width: 100%; max-width: 320px; height: auto; filter: drop-shadow(0 10px 15px rgba(0,0,0,0.15)); }
#car-message-box { background-color: #e3f2fd; border-radius: 12px; padding: 12px 16px; margin: 16px auto 12px; max-width: 90%; position: relative; border: 2px solid #90caf9; }
#car-message-box::before { content: ''; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); border-width: 10px 10px 0; border-style: solid; border-color: #90caf9 transparent transparent; }
#car-message { font-size: 1rem; color: var(--primary-color); font-weight: bold; }

#kizuna-info { display: flex; justify-content: center; align-items: center; gap: 8px; margin-bottom: 20px; }
#kizuna-level { font-size: 1.1rem; font-weight: 800; color: var(--kizuna-color); }

/* ミッションUI */
.mission-item { background-color: var(--card-bg); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); transition: transform 0.2s; }
.mission-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mission-title { font-weight: 700; font-size: 1.15rem; }
.mission-desc { font-size: 0.95rem; color: #546e7a; margin-bottom: 12px; }
.mission-footer { display: flex; justify-content: space-between; align-items: center; }
.mission-reward { font-size: 1rem; font-weight: bold; }
.mission-reward.exp { color: var(--accent-color); }
.mission-reward.stamina { color: var(--stamina-color); }
.mission-btn { width: auto; padding: 10px 20px; font-size: 0.9rem; background: var(--primary-color); box-shadow: 0 2px 8px rgba(13, 71, 161, 0.2); }
.difficulty-badge { padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 700; color: white; }
.difficulty-easy { background-color: #66bb6a; } .difficulty-normal { background-color: #ffa726; } .difficulty-hard { background-color: #ef5350; } .difficulty-special { background: linear-gradient(45deg, #ab47bc, #7e57c2); } .difficulty-tutorial { background-color: var(--tutorial-color); }

/* ログエリア */
#log-area ul { list-style: none; padding: 8px; margin: 0; height: 180px; overflow-y: auto; background-color: #f9f9f9; border-radius: 12px; }
#log-area li { padding: 8px 10px; border-bottom: 1px solid #eee; }
.log-kizuna { color: var(--kizuna-color); font-weight: bold; background: #fce4ec; border-left: 4px solid var(--kizuna-color); }
.log-levelup { color: #8d6e63; font-weight: 800; background: var(--levelup-color); }
.log-success { color: var(--success-color); } .log-error { color: var(--error-color); } .log-info { color: #546e7a; }

/* --- モーダル --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); z-index: 1000; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: opacity 0.3s; }
.modal-overlay.visible { opacity: 1; visibility: visible; }
.modal-content { background: white; padding: 24px 32px; border-radius: 20px; width: 90%; max-width: 400px; text-align: center; transform: scale(0.9); transition: transform 0.3s; }
.modal-overlay.visible .modal-content { transform: scale(1); }
.modal-content h3 { margin-top: 0; }

/* 特殊ミッションUI */
#drag-area { display: flex; justify-content: space-around; align-items: center; padding: 20px 0; }
.draggable { cursor: grab; font-size: 3rem; }
.drop-target { width: 80px; height: 80px; border: 2px dashed #ccc; border-radius: 12px; display: flex; justify-content: center; align-items: center; font-size: 3rem; }
.drop-target.hover { border-color: var(--accent-color); background: #fffde7; }
#sequence-area .seq-item, #find-area .find-item { width: 70px; height: 70px; border: 2px solid #ccc; border-radius: 12px; display: flex; justify-content: center; align-items: center; font-size: 2rem; cursor: pointer; transition: background-color 0.2s; }
#find-area { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; justify-items: center; }
#sequence-area { display: flex; justify-content: center; gap: 10px; }
.seq-item.tapped { background: var(--accent-color); color: white; }
#tap-target { width: 120px; height: 120px; margin: 20px auto; background-color: var(--accent-color); border-radius: 50%; display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; font-size: 1.5rem; font-weight: bold; cursor: pointer; user-select: none; transition: transform 0.1s; }
#tap-target:active { transform: scale(0.95); }

/* 結果モーダル */
#result-modal-content .result-icon { font-size: 4rem; margin-bottom: 16px; }
.result-icon.success { color: var(--success-color); }
.result-icon.fail { color: var(--error-color); }
#result-reward { font-size: 1.2rem; font-weight: bold; margin: 16px 0; }
#result-correct-answer { background: #f1f8e9; border: 1px solid #c5e1a5; padding: 10px; border-radius: 8px; margin-top: 16px; text-align: left; }
#result-modal-close-btn { margin-top: 24px; }