:root {
  --main-blue: #3498db;
  --dark-blue: #2980b9;
  --main-green: #2ecc71;
  --accent-red: #e74c3c;
  --accent-orange: #e67e22;
  --text-dark: #333;
  --bg-color: #f4f7f6;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Meiryo", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  margin: 0;
  padding: 20px;
}

.app-container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

header {
  border-bottom: 4px solid var(--main-green);
  padding-bottom: 10px;
  margin-bottom: 25px;
}

.page-title-group { display: flex; align-items: center; }
.page-num {
  background: var(--main-green); color: white; font-size: 24px; font-weight: bold;
  padding: 5px 15px; border-radius: 8px 8px 0 8px; margin-right: 15px;
}
h1 { margin: 0; font-size: 24px; color: #2c3e50; }
.subtitle { margin: 10px 0 0 0; font-size: 16px; color: #7f8c8d; font-weight: bold; }

.mission-card {
  background: white; border: 2px solid #ecf0f1; border-radius: 10px;
  padding: 25px; margin-bottom: 30px; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.section-title {
  color: var(--dark-blue); font-size: 20px; border-bottom: 2px solid var(--main-blue);
  padding-bottom: 8px; margin-top: 0; line-height: 1.4;
}

.interactive-workspace {
  background: #f8f9fa; border-radius: 10px; padding: 20px; text-align: center;
  border: 2px dashed var(--main-blue); margin-bottom: 20px;
}
.instruction { font-weight: bold; color: var(--accent-orange); margin-top: 0; font-size: 18px;}

/* タブボタン */
.tab-buttons { display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;}
.tab-btn {
  background: #fff; border: 2px solid var(--main-blue); color: var(--main-blue);
  padding: 10px 20px; font-size: 16px; font-weight: bold; border-radius: 25px;
  cursor: pointer; transition: all 0.2s;
}
.tab-btn.active { background: var(--main-blue); color: #fff; }

/* ツール1: 線分図 */
.diagram-area { padding: 20px 0; }
.diagram-track {
  width: 100%; height: 60px; background: #ecf0f1; border-radius: 10px;
  position: relative; overflow: hidden; display: flex;
}
.diagram-bar {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-weight: bold; color: white; font-size: 14px; position: absolute;
  transition: left 0.5s ease-in-out;
}
.box-bar { background: #e67e22; width: 25%; left: 0; z-index: 2;}
.item-bar { background: #3498db; width: 75%; left: 100%; z-index: 1;} /* 初期は右外 */

.action-btn {
  background: var(--main-green); color: white; border: none; padding: 10px 20px;
  font-size: 16px; font-weight: bold; border-radius: 8px; cursor: pointer;
  box-shadow: 0 4px 0 #27ae60; transition: transform 0.1s, box-shadow 0.1s; margin: 5px;
}
.action-btn:active { transform: translateY(4px); box-shadow: none; }
.reset-btn { background: #95a5a6; box-shadow: 0 4px 0 #7f8c8d; }
.box-btn { background: #e67e22; box-shadow: 0 4px 0 #d35400; }
.item-btn { background: #3498db; box-shadow: 0 4px 0 #2980b9; }

/* ツール2: たんいの部屋 */
.unit-room-area { display: flex; flex-direction: column; align-items: center;}
.unit-table { border-collapse: collapse; font-size: 22px; font-weight: bold; background: #fff; }
.unit-table th { padding: 10px 20px; background: #dff9fb; border: 2px solid #bdc3c7;}
.unit-table td { padding: 15px 20px; text-align: right; border-left: 2px solid #bdc3c7; border-right: 2px solid #bdc3c7;}
.border-bottom { border-bottom: 3px solid #2c3e50; }
.math-sign { float: left; color: #e74c3c; }
.kg-col { background: #fdf2e9; }
.g-col { background: #eafaf1; }

/* ツール3: はかり */
.scale-container { display: flex; justify-content: center; margin-bottom: 15px; }
#main-circular-scale { filter: drop-shadow(0px 5px 5px rgba(0,0,0,0.2)); transition: all 0.3s;}
.current-weight-display { font-size: 20px; font-weight: bold; color: var(--text-dark); margin-bottom: 10px; }

/* ひき算エリア */
.subtraction-visual { width: 100%; margin: 20px 0; }
.total-bar { background: #f1c40f; padding: 10px; font-weight: bold; border-radius: 10px 10px 0 0; border: 2px solid #f39c12; border-bottom: none;}
.split-bars { display: flex; height: 60px; }
.mao-bar { background: #e74c3c; width: 85%; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; border-radius: 0 0 0 10px; border: 2px solid #c0392b; opacity: 1; transition: opacity 0.3s, transform 0.5s; transform-origin: left;}
.dog-bar { background: #9b59b6; width: 15%; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; border-radius: 0 0 10px 0; border: 2px solid #8e44ad;}

input[type=range] { width: 100%; margin: 20px 0; cursor: pointer; }

/* 共通パーツ */
.question-box { background: #eafaf1; padding: 15px 20px; border-radius: 10px; text-align: center; }
.input-row-multi { font-size: 18px; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 5px; flex-wrap: wrap;}
input[type="text"] { font-family: inherit; font-size: 18px; text-align: center; border: 2px solid #bdc3c7; border-radius: 5px; padding: 8px; transition: all 0.3s; }
input[type="text"]:focus { border-color: var(--main-blue); outline: none; background: #eef7ff; }
.correct-input { background-color: #d4edda !important; border-color: #28a745 !important; color: #155724; font-weight: bold;}
.table-input { width: 60px; }
.large-input { width: 90px; }

.hint-btn { background: #fff; border: 2px solid #f1c40f; padding: 5px 15px; border-radius: 20px; font-weight: bold; cursor: pointer; color: #d35400;}
.hint-box { display: none; background: #fff9c4; border-radius: 5px; padding: 10px; margin-top: 10px; font-size: 15px; font-weight: bold; color: #333;}
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.character-insight { background: #fff3cd; border: 2px solid #ffc107; padding: 15px; border-radius: 20px; display: inline-block; font-weight: bold; text-align: left; }

/* ノートまとめエリア */
.notebook-section { background: #fdfefe; border: 3px dashed var(--accent-red); padding: 25px; border-radius: 15px; margin-top: 30px; }
.notebook-section h2 { margin-top: 0; color: var(--accent-red); }
.notebook-section ul { font-weight: bold; color: #2c3e50; line-height: 1.8;}