:root {
  --theme: #20c997; --bg: #f8f9fa; --border: #ced4da;
  --primary: #4dabf7; --orange: #ff922b; --danger: #fa5252; --success: #40c057; --warning: #fcc419;
  --line-color: #343a40;
}

* { box-sizing: border-box; }
body { font-family: 'Hiragino Maru Gothic ProN', 'Rounded M+ 1c', sans-serif; background-color: var(--bg); margin: 0; padding: 10px; display: flex; justify-content: center; color: #343a40; }
.app-container { background: white; max-width: 900px; width: 100%; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.1); overflow: hidden; }

/* Header & Mission */
header { background: #e6fcf5; padding: 15px; text-align: center; border-bottom: 3px solid var(--theme); }
h1 { margin: 0 0 10px; color: var(--theme); font-size: 1.5rem; }
.notebook-prompt { display: inline-block; background: white; border: 2px solid #63e6be; color: var(--theme); padding: 5px 15px; border-radius: 20px; font-weight: bold; }
.mission-bar { background: #f8f9fa; padding: 10px 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-bottom: 2px solid var(--border); }
.mission-label { font-weight: bold; color: #495057; }
.problem-display { margin-left: auto; font-size: 1.2rem; font-weight: bold; background: white; padding: 6px 15px; border: 2px solid var(--theme); border-radius: 8px; color: #495057; }
.target-num { color: var(--danger); font-size: 1.4rem; }

/* Buttons */
.btn { padding: 6px 12px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 0.95rem; transition: transform 0.1s; }
.btn:active { transform: translateY(2px); }
.btn-outline { background: white; border: 2px solid var(--theme); color: var(--theme); }
.btn-outline:hover { background: #e6fcf5; }
.btn-blue { background: var(--primary); color: white; }
.btn-lightblue { background: #74c0fc; color: white; }
.btn-red { background: var(--danger); color: white; }
.btn-orange { background: var(--orange); color: white; }
.btn-gray { background: #dee2e6; color: #495057; }
.btn-gray.outline { background: white; border: 2px solid #adb5bd; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #343a40; }
.btn-yellow { background: #ffd43b; color: #343a40; }
.small-btn { padding: 4px 8px; font-size: 0.85rem; }
.hidden { display: none !important; }

/* Workspace & Tabs */
.workspace { border-bottom: 2px dashed var(--border); }
.tool-tabs { display: flex; background: #e9ecef; }
.tool-tab { flex: 1; padding: 12px; border: none; background: transparent; font-size: 1.1rem; font-weight: bold; color: #495057; cursor: pointer; border-bottom: 3px solid transparent; }
.tool-tab.active { background: white; color: var(--theme); border-bottom: 3px solid var(--theme); }
.visual-content { display: none; padding: 20px; min-height: 400px; animation: fadeIn 0.3s; background: white; }
.visual-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Controls */
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; background: #f8f9fa; padding: 10px; border-radius: 8px; border: 1px solid var(--border); }
.val-badge { font-size: 1.1rem; font-weight: bold; margin-left: 10px; background: white; padding: 4px 15px; border: 2px solid var(--border); border-radius: 20px; }
.val-badge span { color: var(--danger); font-size: 1.4rem; }
.hint-btn { margin-left: auto; border-radius: 20px; }

/* 1. Number Line */
.line-stage { padding: 120px 20px 40px; position: relative; }
.number-line { position: relative; height: 4px; background: var(--line-color); width: 100%; }
.nl-tick { position: absolute; bottom: 0; width: 2px; background: var(--line-color); transform: translateX(-50%); }
.nl-tick.major { height: 20px; } .nl-tick.minor { height: 10px; }
.nl-label { position: absolute; top: 15px; transform: translateX(-50%); font-weight: bold; font-size: 1.1rem; }
.goal-flag { position: absolute; bottom: 25px; transform: translateX(-50%); font-size: 2rem; color: var(--danger); animation: bounce 1s infinite; }
.current-arrow { position: absolute; top: -35px; transform: translateX(-50%); color: var(--primary); font-size: 2rem; transition: left 0.3s ease; }
/* ジャンプ軌跡の矢印 */
.jump-path { position: absolute; border: 3px solid; border-bottom: none; border-radius: 12px 12px 0 0; opacity: 0.8; transition: all 0.3s ease; }
.jump-path.plus { border-color: var(--primary); background: rgba(77,171,247,0.1); }
.jump-path.minus { border-color: var(--danger); background: rgba(250,82,82,0.1); }
.jump-val { position: absolute; top: -25px; left: 50%; transform: translateX(-50%); font-weight: bold; font-size: 1rem; background: white; padding: 0 4px; border-radius: 4px; }
@keyframes bounce { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }

/* 2. Blocks */
.block-stage { display: flex; justify-content: center; }
.block-area { width: 100%; max-width: 600px; min-height: 250px; background: #f1f3f5; border-radius: 12px; padding: 20px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; border: 2px dashed var(--border); }
.placeholder { color: #adb5bd; width: 100%; text-align: center; margin-top: 80px; font-weight: bold; }
.b-1 { width: 60px; height: 60px; background: var(--success); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 1.5rem; animation: popIn 0.2s; border: 2px solid #2b8a3e; }
.b-01 { width: 22px; height: 50px; background: var(--primary); border-radius: 4px; border: 1px solid #1864ab; animation: popIn 0.2s; }
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* 3. Words (見方メーカー) */
.vis-header { font-weight: bold; margin-bottom: 15px; color: #495057; display: flex; justify-content: space-between; align-items: center; }
.view-maker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.view-card { background: white; border: 2px solid var(--border); border-radius: 8px; padding: 15px; font-size: 1.1rem; font-weight: bold; line-height: 1.8; }
.kouta { border-color: #74c0fc; background: #e7f5ff; }
.misaki { border-color: #ffa8a8; background: #fff5f5; }
.haruto { border-color: #8ce99a; background: #ebfbee; }
.ami { border-color: #ffd8a8; background: #fff9db; }
.avatar { font-size: 1.1rem; margin-bottom: 10px; border-bottom: 1px dashed rgba(0,0,0,0.1); padding-bottom: 5px; }
.num-in { width: 50px; padding: 4px; border: 2px solid var(--border); border-radius: 6px; text-align: center; font-size: 1.1rem; font-weight: bold; color: #343a40; }
.num-in:focus { outline: none; border-color: var(--primary); }
.target-span { color: var(--danger); font-size: 1.3rem; }

/* Notebook Guide */
.notebook-guide { background: #fff9db; padding: 20px; text-align: center; }
.notebook-guide h3 { margin: 0 0 10px; color: #d4a017; font-size: 1.1rem; }
.notebook-guide p { margin: 0; font-weight: bold; color: #495057; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; padding: 30px; border-radius: 12px; max-width: 400px; width: 90%; text-align: center; border-top: 8px solid var(--warning); }
.mt-3 { margin-top: 15px; }