YaLight commited on
Commit
a60fe5f
·
0 Parent(s):

Implement playable high school simulator

Browse files
Files changed (5) hide show
  1. README.md +20 -0
  2. app.js +1357 -0
  3. assets/campus.svg +14 -0
  4. index.html +85 -0
  5. styles.css +485 -0
README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: HighSchoolSimulator
3
+ sdk: static
4
+ app_file: index.html
5
+ pinned: false
6
+ ---
7
+
8
+ # HighSchoolSimulator
9
+
10
+ 一個可直接在 Hugging Face Static Space 遊玩的高中生活模擬器。
11
+
12
+ 目前版本實作:
13
+
14
+ - 三年制月份流程
15
+ - 平日與假期行動
16
+ - 月末審核
17
+ - 期中/期末考
18
+ - 隨機事件
19
+ - 突發結局與終末結局
20
+
app.js ADDED
@@ -0,0 +1,1357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const MONTH_ORDER = [9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8];
2
+ const HOLIDAY_MONTHS = new Set([1, 2, 7, 8]);
3
+ const WEEKDAY_PHASES = ["早上", "下午", "晚上"];
4
+ const HOLIDAY_PHASES = ["早上", "中午", "晚上"];
5
+ const STORAGE_KEY = "high-school-simulator-state-v1";
6
+
7
+ const STAT_LABELS = {
8
+ learning: "學習",
9
+ language: "語文",
10
+ logic: "邏輯",
11
+ social: "社交",
12
+ stamina: "體力",
13
+ staminaMax: "體力上限",
14
+ health: "生理健康",
15
+ stress: "壓力",
16
+ warnings: "警告",
17
+ awards: "嘉獎",
18
+ };
19
+
20
+ const STAT_TONES = {
21
+ learning: "blue",
22
+ language: "purple",
23
+ logic: "purple",
24
+ social: "green",
25
+ stamina: "green",
26
+ health: "orange",
27
+ stress: "red",
28
+ };
29
+
30
+ const SCORE_BANDS = [
31
+ { max: 20, text: "一竅不通" },
32
+ { max: 40, text: "有所認識" },
33
+ { max: 60, text: "普通/一般" },
34
+ { max: 80, text: "認識深刻" },
35
+ { max: 90, text: "熟練掌握" },
36
+ { max: 1000, text: "非常專業" },
37
+ ];
38
+
39
+ const els = {};
40
+ let state = loadState();
41
+ let modalContinue = null;
42
+
43
+ document.addEventListener("DOMContentLoaded", () => {
44
+ bindElements();
45
+ bindStaticActions();
46
+ render();
47
+
48
+ if (state.history.length === 0) {
49
+ addLog("高中生活開始了。");
50
+ saveState();
51
+ render();
52
+ }
53
+ });
54
+
55
+ function bindElements() {
56
+ Object.assign(els, {
57
+ calendarText: document.querySelector("#calendarText"),
58
+ phaseBadge: document.querySelector("#phaseBadge"),
59
+ statsGrid: document.querySelector("#statsGrid"),
60
+ warningText: document.querySelector("#warningText"),
61
+ awardText: document.querySelector("#awardText"),
62
+ examAverageText: document.querySelector("#examAverageText"),
63
+ modeText: document.querySelector("#modeText"),
64
+ roundText: document.querySelector("#roundText"),
65
+ slotText: document.querySelector("#slotText"),
66
+ choiceGrid: document.querySelector("#choiceGrid"),
67
+ logList: document.querySelector("#logList"),
68
+ saveButton: document.querySelector("#saveButton"),
69
+ newGameButton: document.querySelector("#newGameButton"),
70
+ clearLogButton: document.querySelector("#clearLogButton"),
71
+ modalOverlay: document.querySelector("#modalOverlay"),
72
+ modalKicker: document.querySelector("#modalKicker"),
73
+ modalTitle: document.querySelector("#modalTitle"),
74
+ modalBody: document.querySelector("#modalBody"),
75
+ modalResult: document.querySelector("#modalResult"),
76
+ modalChoices: document.querySelector("#modalChoices"),
77
+ });
78
+ }
79
+
80
+ function bindStaticActions() {
81
+ els.saveButton.addEventListener("click", () => {
82
+ saveState();
83
+ addLog("進度已保存。");
84
+ render();
85
+ });
86
+
87
+ els.newGameButton.addEventListener("click", () => {
88
+ showModal({
89
+ kicker: "重新開始",
90
+ title: "要開始新的高中生活嗎?",
91
+ body: "目前進度會被覆蓋。",
92
+ choices: [
93
+ {
94
+ label: "重新開始",
95
+ action: () => {
96
+ state = createInitialState();
97
+ addLog("新的高中生活開始了。");
98
+ saveState();
99
+ closeModal();
100
+ render();
101
+ },
102
+ },
103
+ { label: "取消", action: closeModal },
104
+ ],
105
+ });
106
+ });
107
+
108
+ els.clearLogButton.addEventListener("click", () => {
109
+ state.history = [];
110
+ addLog("紀錄已清空。");
111
+ saveState();
112
+ render();
113
+ });
114
+ }
115
+
116
+ function createInitialState() {
117
+ return {
118
+ year: 1,
119
+ monthPointer: 0,
120
+ round: 1,
121
+ phase: 0,
122
+ contestUsed: false,
123
+ ended: false,
124
+ ending: null,
125
+ stats: {
126
+ learning: 30,
127
+ language: 25,
128
+ logic: 25,
129
+ social: 30,
130
+ stamina: 80,
131
+ staminaMax: 80,
132
+ health: 70,
133
+ stress: 40,
134
+ warnings: 0,
135
+ awards: 0,
136
+ },
137
+ examScores: [],
138
+ flags: {
139
+ backgroundUnlocked: false,
140
+ },
141
+ history: [],
142
+ };
143
+ }
144
+
145
+ function loadState() {
146
+ try {
147
+ const raw = localStorage.getItem(STORAGE_KEY);
148
+ if (!raw) return createInitialState();
149
+ const parsed = JSON.parse(raw);
150
+ return {
151
+ ...createInitialState(),
152
+ ...parsed,
153
+ stats: { ...createInitialState().stats, ...parsed.stats },
154
+ flags: { ...createInitialState().flags, ...parsed.flags },
155
+ history: Array.isArray(parsed.history) ? parsed.history : [],
156
+ examScores: Array.isArray(parsed.examScores) ? parsed.examScores : [],
157
+ };
158
+ } catch {
159
+ return createInitialState();
160
+ }
161
+ }
162
+
163
+ function saveState() {
164
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
165
+ }
166
+
167
+ function render() {
168
+ const month = getCurrentMonth();
169
+ const holiday = isHolidayMonth(month);
170
+ const phases = holiday ? HOLIDAY_PHASES : WEEKDAY_PHASES;
171
+ const phaseName = phases[state.phase] || phases[0];
172
+ const schoolYearLabel = `第 ${state.year} 年`;
173
+
174
+ els.calendarText.textContent = `${schoolYearLabel} ${month} 月`;
175
+ els.phaseBadge.textContent = phaseName;
176
+ els.modeText.textContent = holiday ? "假期" : "平日";
177
+ els.roundText.textContent = `第 ${state.round} 輪`;
178
+ els.slotText.textContent = phaseName;
179
+ els.warningText.textContent = state.stats.warnings;
180
+ els.awardText.textContent = state.stats.awards;
181
+ els.examAverageText.textContent = getExamAverageText();
182
+
183
+ renderStats();
184
+ renderChoices();
185
+ renderLog();
186
+ }
187
+
188
+ function renderStats() {
189
+ const statItems = [
190
+ ["learning", state.stats.learning, 100],
191
+ ["language", state.stats.language, 100],
192
+ ["logic", state.stats.logic, 100],
193
+ ["social", state.stats.social, 100],
194
+ ["stamina", state.stats.stamina, state.stats.staminaMax],
195
+ ["health", state.stats.health, 120],
196
+ ["stress", state.stats.stress, 100],
197
+ ];
198
+
199
+ els.statsGrid.innerHTML = "";
200
+
201
+ statItems.forEach(([key, value, max]) => {
202
+ const card = document.createElement("article");
203
+ card.className = "stat-card";
204
+ card.dataset.tone = STAT_TONES[key] || "blue";
205
+
206
+ const percent = max > 0 ? clamp((value / max) * 100, 0, 100) : 0;
207
+ const desc = key === "stamina" ? `${value}/${state.stats.staminaMax}` : describeScore(value);
208
+
209
+ card.innerHTML = `
210
+ <div class="stat-line">
211
+ <span class="stat-name">${STAT_LABELS[key]}</span>
212
+ <span class="stat-value">${Math.round(value)}${key === "stamina" ? `/${state.stats.staminaMax}` : ""}</span>
213
+ </div>
214
+ <div class="bar-track"><div class="bar-fill" style="width: ${percent}%"></div></div>
215
+ <span class="stat-desc">${desc}</span>
216
+ `;
217
+
218
+ els.statsGrid.appendChild(card);
219
+ });
220
+ }
221
+
222
+ function renderChoices() {
223
+ els.choiceGrid.innerHTML = "";
224
+
225
+ if (state.ended) {
226
+ const button = createChoiceButton({
227
+ label: "重新開始",
228
+ hint: "開始新的三年",
229
+ tone: "red",
230
+ onClick: () => {
231
+ state = createInitialState();
232
+ addLog("新的高中生活開始了。");
233
+ saveState();
234
+ render();
235
+ },
236
+ });
237
+ els.choiceGrid.appendChild(button);
238
+ return;
239
+ }
240
+
241
+ getAvailableActions().forEach((action) => {
242
+ els.choiceGrid.appendChild(
243
+ createChoiceButton({
244
+ label: action.label,
245
+ hint: action.hint,
246
+ tone: action.tone,
247
+ onClick: () => takeAction(action.id),
248
+ }),
249
+ );
250
+ });
251
+ }
252
+
253
+ function createChoiceButton({ label, hint, tone, onClick }) {
254
+ const button = document.createElement("button");
255
+ button.className = "choice-button";
256
+ button.type = "button";
257
+ button.dataset.tone = tone || "blue";
258
+ button.innerHTML = `<strong>${label}</strong><span>${hint || ""}</span>`;
259
+ button.addEventListener("click", onClick);
260
+ return button;
261
+ }
262
+
263
+ function renderLog() {
264
+ els.logList.innerHTML = "";
265
+
266
+ state.history
267
+ .slice()
268
+ .reverse()
269
+ .forEach((entry) => {
270
+ const item = document.createElement("li");
271
+ item.innerHTML = `<time>${entry.time}</time>${entry.text}`;
272
+ els.logList.appendChild(item);
273
+ });
274
+ }
275
+
276
+ function getAvailableActions() {
277
+ const month = getCurrentMonth();
278
+
279
+ if (isHolidayMonth(month)) {
280
+ const base = [
281
+ { id: "holidayPlay", label: "玩樂", hint: "調整壓力與社交", tone: "green" },
282
+ { id: "holidayStudyLogic", label: "讀書(理)", hint: "學習與邏輯", tone: "blue" },
283
+ { id: "holidayStudyLanguage", label: "讀書(文)", hint: "學習與語文", tone: "purple" },
284
+ { id: "holidaySport", label: "運動", hint: "體力消耗,健康波動", tone: "orange" },
285
+ { id: "holidayNap", label: "zzZ", hint: "恢復體力,降低壓力", tone: "green" },
286
+ ];
287
+
288
+ if (state.phase === 0 && !state.contestUsed) {
289
+ base.unshift(
290
+ { id: "languageContest", label: "語文比賽", hint: "本輪直接結束", tone: "purple" },
291
+ { id: "logicContest", label: "邏輯競賽", hint: "本輪直接結束", tone: "blue" },
292
+ );
293
+ }
294
+
295
+ return base;
296
+ }
297
+
298
+ if (state.phase === 0) {
299
+ return [
300
+ { id: "sport", label: "運動", hint: "體力 -20,壓力下降", tone: "orange" },
301
+ { id: "studyLanguage", label: "學習(文科)", hint: "語文與學習", tone: "purple" },
302
+ { id: "studyLogic", label: "學習(理科)", hint: "邏輯與學習", tone: "blue" },
303
+ { id: "nap", label: "zzZ", hint: "可能被記警告", tone: "green" },
304
+ { id: "skipClass", label: "逃課", hint: "裝病請假", tone: "red" },
305
+ { id: "makeFriends", label: "交友", hint: "社交機會", tone: "green" },
306
+ ];
307
+ }
308
+
309
+ if (state.phase === 1) {
310
+ return [
311
+ { id: "sport", label: "運動", hint: "體力 -20,壓力下降", tone: "orange" },
312
+ { id: "studyLanguage", label: "學習(文科)", hint: "語文與學習", tone: "purple" },
313
+ { id: "studyLogic", label: "學習(理科)", hint: "邏輯與學習", tone: "blue" },
314
+ { id: "nap", label: "zzZ", hint: "可能被記警告", tone: "green" },
315
+ { id: "makeFriends", label: "交友", hint: "社交機會", tone: "green" },
316
+ ];
317
+ }
318
+
319
+ return [
320
+ { id: "sport", label: "運動", hint: "體力 -20,壓力下降", tone: "orange" },
321
+ { id: "studyLanguage", label: "讀書(文)", hint: "語文與學習", tone: "purple" },
322
+ { id: "studyLogic", label: "讀書(理)", hint: "邏輯與學習", tone: "blue" },
323
+ { id: "onlineFriends", label: "和朋友連機", hint: "社交與壓力波動", tone: "green" },
324
+ { id: "sleep", label: "睡覺", hint: "體力與健康恢復", tone: "green" },
325
+ ];
326
+ }
327
+
328
+ function takeAction(actionId) {
329
+ if (state.ended) return;
330
+
331
+ const actionMap = {
332
+ sport: () => weekdaySport(),
333
+ studyLanguage: () => weekdayStudyLanguage(),
334
+ studyLogic: () => weekdayStudyLogic(),
335
+ nap: () => weekdayNap(),
336
+ skipClass: () => skipClass(),
337
+ makeFriends: () => makeFriends(),
338
+ onlineFriends: () => onlineFriends(),
339
+ sleep: () => sleep(),
340
+ holidayPlay: () => holidayPlay(),
341
+ holidayStudyLogic: () => holidayStudyLogic(),
342
+ holidayStudyLanguage: () => holidayStudyLanguage(),
343
+ holidaySport: () => holidaySport(),
344
+ holidayNap: () => holidayNap(),
345
+ languageContest: () => contest("language"),
346
+ logicContest: () => contest("logic"),
347
+ };
348
+
349
+ const handler = actionMap[actionId];
350
+ if (!handler) return;
351
+
352
+ handler();
353
+
354
+ if (checkSuddenEnding()) return;
355
+
356
+ if (actionId === "languageContest" || actionId === "logicContest") {
357
+ advanceHolidayRound();
358
+ } else {
359
+ advancePhase();
360
+ }
361
+
362
+ saveState();
363
+ render();
364
+ }
365
+
366
+ function weekdaySport() {
367
+ const outcome = rollWeighted([
368
+ { chance: 30, text: "運動時有些勉強。", delta: { health: -10, stamina: -20, stress: -3 } },
369
+ { chance: 20, text: "訓練讓體能上限提升。", delta: { health: 5, staminaMax: 1, stamina: -20, stress: -3 } },
370
+ { chance: 50, text: "活動筋骨後身體狀態更好。", delta: { health: 5, stamina: -20, stress: -3 } },
371
+ ]);
372
+ applyOutcome("運動", outcome);
373
+ }
374
+
375
+ function weekdayStudyLanguage() {
376
+ const outcome = rollWeighted([
377
+ { chance: 50, text: "文科學習穩定進展。", delta: { language: 2, learning: 2, stamina: -10, stress: 3 } },
378
+ { chance: 35, text: "今天特別讀得進去。", delta: { language: 3, learning: 3, stamina: -10, stress: 3 } },
379
+ { chance: 15, text: "只留下了一點印象。", delta: { language: 1, stamina: -10, stress: 3 } },
380
+ ]);
381
+ applyOutcome("學習(文科)", outcome);
382
+ }
383
+
384
+ function weekdayStudyLogic() {
385
+ const outcome = rollWeighted([
386
+ { chance: 60, text: "理科學習穩定進展。", delta: { learning: 2, logic: 2, stamina: -10, stress: 4 } },
387
+ { chance: 20, text: "解題手感不錯。", delta: { learning: 3, logic: 3, stamina: -10, stress: 4 } },
388
+ { chance: 5, text: "思路完全打通。", delta: { learning: 3, logic: 4, stamina: -10, stress: 4 } },
389
+ { chance: 15, text: "讀了半天卻沒有吸收。", delta: { stamina: -10, stress: 4 } },
390
+ ]);
391
+ applyOutcome("學習(理科)", outcome);
392
+ }
393
+
394
+ function weekdayNap() {
395
+ const caughtChance = Math.min(95, 35 + state.stats.warnings * 5);
396
+ const outcome = rollWeighted([
397
+ { chance: caughtChance, text: "睡過頭被抓到。", delta: { stress: 10, learning: -1, warnings: 1 } },
398
+ { chance: 100 - caughtChance, text: "休息後恢復了一點體力。", delta: { learning: -1, stamina: 10 } },
399
+ ]);
400
+ applyOutcome("zzZ", outcome);
401
+ }
402
+
403
+ function skipClass() {
404
+ const outcome = rollWeighted([
405
+ { chance: 60, text: "裝病成功,暫時逃離壓力。", delta: { stress: -20, learning: -5 } },
406
+ { chance: 40, text: "裝病讓狀況變得更糟。", delta: { stress: 10, health: -10 } },
407
+ ]);
408
+ applyOutcome("逃課", outcome);
409
+ }
410
+
411
+ function makeFriends() {
412
+ const outcome = rollWeighted([
413
+ { chance: 70, text: "和同學聊得很順利。", delta: { social: 3 } },
414
+ { chance: 30, text: "互動不太順利。", delta: { social: -1, stress: 5 } },
415
+ ]);
416
+ applyOutcome("交友", outcome);
417
+ }
418
+
419
+ function onlineFriends() {
420
+ const outcome = rollWeighted([
421
+ { chance: 65, text: "連機過程很放鬆。", delta: { social: 2, stamina: -10, stress: -5 } },
422
+ { chance: 35, text: "遊戲過程反而吵了起來。", delta: { social: -2, stamina: -10, stress: 3 } },
423
+ ]);
424
+ applyOutcome("和朋友連機", outcome);
425
+ }
426
+
427
+ function sleep() {
428
+ applyOutcome("睡覺", { text: "好好休息了一晚。", delta: { stamina: 10, health: 5 } });
429
+ }
430
+
431
+ function holidayPlay() {
432
+ const outcome = rollWeighted([
433
+ { chance: 60, text: "玩得很盡興。", delta: { social: 1, stress: -15 } },
434
+ { chance: 30, text: "普通地放鬆了一下。", delta: { stress: -5 } },
435
+ { chance: 10, text: "玩樂安排不順。", delta: { stress: 10, social: -1 } },
436
+ ]);
437
+ applyOutcome("玩樂", outcome);
438
+ }
439
+
440
+ function holidayStudyLogic() {
441
+ const outcome = rollWeighted([
442
+ { chance: 70, text: "假期讀書有所收穫。", delta: { learning: 2, logic: 2, stamina: -10, stress: 4 } },
443
+ { chance: 20, text: "今天效率很高。", delta: { learning: 3, logic: 3, stamina: -10, stress: 4 } },
444
+ { chance: 10, text: "越讀越混亂。", delta: { learning: -2, logic: -2, stamina: -10, stress: 4 } },
445
+ ]);
446
+ applyOutcome("讀書(理)", outcome);
447
+ }
448
+
449
+ function holidayStudyLanguage() {
450
+ const outcome = rollWeighted([
451
+ { chance: 70, text: "文科讀書有所收穫。", delta: { learning: 2, language: 2, stamina: -10, stress: 3 } },
452
+ { chance: 20, text: "今天讀得還可以。", delta: { learning: 1, language: 1, stamina: -10, stress: 3 } },
453
+ { chance: 10, text: "內容吸收得不太好。", delta: { learning: -2, language: -2, stamina: -10, stress: 3 } },
454
+ ]);
455
+ applyOutcome("讀書(文)", outcome);
456
+ }
457
+
458
+ function holidaySport() {
459
+ const outcome = rollWeighted([
460
+ { chance: 30, text: "假期運動過量。", delta: { health: -15, stamina: -20, stress: -5 } },
461
+ { chance: 20, text: "體能訓練有效果。", delta: { health: 5, staminaMax: 1, stamina: -20, stress: -5 } },
462
+ { chance: 50, text: "運動讓身體狀態更好。", delta: { health: 5, stamina: -20, stress: -5 } },
463
+ ]);
464
+ applyOutcome("運動", outcome);
465
+ }
466
+
467
+ function holidayNap() {
468
+ applyOutcome("zzZ", { text: "假期補眠讓你舒服不少。", delta: { stress: -5, stamina: 10 } });
469
+ }
470
+
471
+ function contest(type) {
472
+ const threshold = [50, 65, 80][state.year - 1];
473
+ const statKey = type === "language" ? "language" : "logic";
474
+ const title = type === "language" ? "語文比賽" : "邏輯競賽";
475
+ const passed = state.stats[statKey] > threshold;
476
+
477
+ state.contestUsed = true;
478
+
479
+ if (passed) {
480
+ applyOutcome(title, {
481
+ text: `達到第 ${state.year} 年門檻 ${threshold},比賽表現出色。`,
482
+ delta: { [statKey]: 6, learning: 6, stamina: -20, stress: -10, awards: 1 },
483
+ });
484
+ } else {
485
+ applyOutcome(title, {
486
+ text: `未達第 ${state.year} 年門檻 ${threshold},仍累積了經驗。`,
487
+ delta: { [statKey]: 4, learning: 4, stamina: -20 },
488
+ });
489
+ }
490
+ }
491
+
492
+ function applyOutcome(title, outcome) {
493
+ const actual = applyDelta(outcome.delta || {});
494
+ const deltaText = formatDelta(actual);
495
+ addLog(`${title}:${outcome.text}${deltaText ? `(${deltaText})` : ""}`);
496
+ }
497
+
498
+ function advancePhase() {
499
+ const month = getCurrentMonth();
500
+ const holiday = isHolidayMonth(month);
501
+ const maxPhases = holiday ? HOLIDAY_PHASES.length : WEEKDAY_PHASES.length;
502
+
503
+ state.phase += 1;
504
+
505
+ if (state.phase < maxPhases) return;
506
+
507
+ state.phase = 0;
508
+
509
+ if (holiday) {
510
+ advanceHolidayRound();
511
+ return;
512
+ }
513
+
514
+ maybeRunExam(() => {
515
+ state.round += 1;
516
+ if (state.round > 2) {
517
+ finishMonth();
518
+ } else {
519
+ saveState();
520
+ render();
521
+ }
522
+ });
523
+ }
524
+
525
+ function advanceHolidayRound() {
526
+ state.phase = 0;
527
+ state.round += 1;
528
+
529
+ if (state.round > 3) {
530
+ finishMonth();
531
+ }
532
+ }
533
+
534
+ function maybeRunExam(afterExam) {
535
+ const month = getCurrentMonth();
536
+ const examMap = {
537
+ "10-1": "logic",
538
+ "12-2": "language",
539
+ "4-1": "logic",
540
+ "6-2": "language",
541
+ };
542
+ const subject = examMap[`${month}-${state.round}`];
543
+
544
+ if (!subject) {
545
+ afterExam();
546
+ return;
547
+ }
548
+
549
+ const score = calculateExamScore(subject);
550
+ state.examScores.push({
551
+ year: state.year,
552
+ month,
553
+ subject,
554
+ score,
555
+ });
556
+
557
+ const subjectLabel = subject === "logic" ? "邏輯" : "語文";
558
+ addLog(`${month} 月考試:學習 + ${subjectLabel},得到 ${score} 分。`);
559
+ saveState();
560
+
561
+ showModal({
562
+ kicker: "考試",
563
+ title: `${month} 月考試`,
564
+ body: `本次考試科目為學習 + ${subjectLabel}。`,
565
+ result: `成績:${score} 分`,
566
+ choices: [{ label: "繼續", action: () => closeModal(afterExam) }],
567
+ });
568
+ }
569
+
570
+ function calculateExamScore(subject) {
571
+ const learning = state.stats.learning;
572
+ const subjectValue = state.stats[subject];
573
+ const firstIsLearning = Math.random() < 0.5;
574
+ const weighted = firstIsLearning
575
+ ? (learning * 3 + subjectValue) / 4
576
+ : (subjectValue * 3 + learning) / 4;
577
+ const low = [-15, -30, -40][state.year - 1];
578
+ const high = [10, 5, 0][state.year - 1];
579
+ return Math.round(clamp(randomBetween(weighted + low, weighted + high), 0, 100));
580
+ }
581
+
582
+ function finishMonth() {
583
+ const review = getMonthlyReview();
584
+
585
+ if (review) {
586
+ const actual = applyDelta(review.delta || {});
587
+ addLog(`${getCurrentMonth()} 月審核:${review.title}。${review.text}${formatDelta(actual) ? `(${formatDelta(actual)})` : ""}`);
588
+ saveState();
589
+
590
+ showModal({
591
+ kicker: `${getCurrentMonth()} 月審核`,
592
+ title: review.title,
593
+ body: review.text,
594
+ result: formatDelta(actual),
595
+ choices: [
596
+ {
597
+ label: "繼續",
598
+ action: () => closeModal(() => afterMonthReview()),
599
+ },
600
+ ],
601
+ });
602
+ return;
603
+ }
604
+
605
+ afterMonthReview();
606
+ }
607
+
608
+ function afterMonthReview() {
609
+ if (checkSuddenEnding()) return;
610
+ triggerSemesterEvent(() => advanceMonth());
611
+ }
612
+
613
+ function triggerSemesterEvent(done) {
614
+ const month = getCurrentMonth();
615
+ if (!isWeekdayMonth(month)) {
616
+ done();
617
+ return;
618
+ }
619
+
620
+ const positionMap = {
621
+ 9: 1,
622
+ 10: 2,
623
+ 11: 3,
624
+ 12: 4,
625
+ 3: 1,
626
+ 4: 2,
627
+ 5: 3,
628
+ 6: 4,
629
+ };
630
+ const position = positionMap[month];
631
+ const guaranteed = position === 3;
632
+ const possible = position === 1 || position === 2;
633
+
634
+ if (!guaranteed && !possible) {
635
+ done();
636
+ return;
637
+ }
638
+
639
+ if (possible && Math.random() < 0.1) {
640
+ addLog("這個月沒有發生特殊事件。");
641
+ done();
642
+ return;
643
+ }
644
+
645
+ const event = pickRandomEvent();
646
+ if (!event) {
647
+ addLog("沒有符合條件的特殊事件。");
648
+ done();
649
+ return;
650
+ }
651
+
652
+ showGameEvent(event, done);
653
+ }
654
+
655
+ function advanceMonth() {
656
+ state.monthPointer += 1;
657
+
658
+ if (state.monthPointer >= MONTH_ORDER.length * 3) {
659
+ showFinalEnding();
660
+ return;
661
+ }
662
+
663
+ state.year = Math.floor(state.monthPointer / MONTH_ORDER.length) + 1;
664
+ state.round = 1;
665
+ state.phase = 0;
666
+ state.contestUsed = false;
667
+ saveState();
668
+ render();
669
+ }
670
+
671
+ function getMonthlyReview() {
672
+ const month = getCurrentMonth();
673
+ const year = state.year;
674
+ const s = state.stats;
675
+
676
+ if (month === 9) {
677
+ if (s.language > 35) return { title: "自我介紹大成功!", text: "語文組織能力讓同學留下好印象。", delta: { social: 3, stress: 1 } };
678
+ if (s.language >= 15) return { title: "中規中矩的自我介紹", text: "你順利完成了自我介紹。", delta: { social: 2, stress: 1 } };
679
+ return { title: "令人困惑的自我介紹", text: "同學對你的表達有些困惑。", delta: { social: 1, stress: 3 } };
680
+ }
681
+
682
+ if (month === 10) {
683
+ const high = [40, 55, 70][year - 1];
684
+ const low = [25, 30, 35][year - 1];
685
+ if (s.social > high) return { title: "報告合作順利", text: "分組報告進行得很流暢。", delta: { social: 2, learning: 3 } };
686
+ if (s.social < low) return { title: "分組報告失控", text: "組員之間爆發爭吵,報告未如期完成。", delta: { social: -2, stress: 1 } };
687
+ return { title: "報告正常完成", text: "分組報告平穩收尾。", delta: { social: 1, learning: 2 } };
688
+ }
689
+
690
+ if (month === 12) {
691
+ const high = [80, 90, 105][year - 1];
692
+ if (s.health > high) return { title: "絲毫不受天氣影響", text: "天氣劇烈轉變也沒有影響你。", delta: { stamina: 10 } };
693
+ if (s.health < 65) return { title: "身體變得虛弱", text: "天氣變化讓你有些不舒服。", delta: { stamina: -10, stress: 2 } };
694
+ return { title: "身體些微受影響", text: "你感受到天氣變化帶來的負擔。", delta: { stamina: -5, stress: 1 } };
695
+ }
696
+
697
+ if (month === 1) {
698
+ const high = [55, 65, 75][year - 1];
699
+ const low = [30, 25, 20][year - 1];
700
+ if (s.stress > high) return { title: "壓力過大", text: "你決定稍微放鬆一下。", delta: { stress: -3 } };
701
+ if (s.stress < low) return { title: "開始鬆懈", text: "你提不起對學習的興趣。", delta: { stress: -2, learning: -3 } };
702
+ return { title: "完成個人規劃", text: "你按自身情況做好了規劃。", delta: { stress: 1, learning: 2 } };
703
+ }
704
+
705
+ if (month === 3) {
706
+ const high = [85, 88, 91][year - 1];
707
+ if (s.staminaMax > high) return { title: "運動健將", text: "你在運動會得到了眾人的掌聲。", delta: { social: 3, stress: -3 } };
708
+ if (s.staminaMax <= 80) return { title: "沒被選上", text: "你沒有被選上運動會選手。", delta: { stress: 1 } };
709
+ return { title: "運動能手", text: "你在運動會有不錯的表現。", delta: { social: 2 } };
710
+ }
711
+
712
+ if (month === 4) {
713
+ if (s.stress > 80) return { title: "心理諮商", text: "老師認為你的壓力太大,安排了諮商。", delta: { stress: -10, stamina: -10 } };
714
+ if (s.stress < 20) return { title: "督促學習", text: "老師認為你太鬆懈,督促你學習。", delta: { stress: 10, stamina: -10, learning: 5 } };
715
+ return { title: "正常扛壓", text: "你不需要特殊輔導。", delta: { stress: -5, stamina: 5 } };
716
+ }
717
+
718
+ if (month === 6) {
719
+ const high = [50, 60, 70][year - 1];
720
+ const low = [25, 30, 35][year - 1];
721
+ if (s.logic > high) return { title: "思緒清晰", text: "你整理好了自己的想法。", delta: { learning: 5, stress: -5 } };
722
+ if (s.logic < low) return { title: "腦袋一片混亂", text: "整理思緒的過程讓你更焦慮。", delta: { stress: 5 } };
723
+ return { title: "整理好想法", text: "你逐漸理清目前的學習狀態。", delta: { learning: 2, stress: -3 } };
724
+ }
725
+
726
+ if (month === 7) {
727
+ const high = [55, 70, 85][year - 1];
728
+ if (s.social > high) return { title: "社交大成功", text: "娛樂活動讓你受到歡迎。", delta: { stress: -10, social: 3 } };
729
+ if (s.social < 30) return { title: "找不到隊友", text: "你在活動中感到有些孤立。", delta: { stress: 5 } };
730
+ return { title: "默默參與", text: "你低調地參加了活動。", delta: { stress: -3, social: 1 } };
731
+ }
732
+
733
+ return null;
734
+ }
735
+
736
+ function showGameEvent(event, done) {
737
+ if (event.auto) {
738
+ const result = event.auto();
739
+ const actual = applyDelta(result.delta || {});
740
+ addLog(`事件:${event.title}。${result.text}${formatDelta(actual) ? `(${formatDelta(actual)})` : ""}`);
741
+ saveState();
742
+
743
+ showModal({
744
+ kicker: "事件",
745
+ title: event.title,
746
+ body: event.body,
747
+ result: `${result.text}${formatDelta(actual) ? `\n${formatDelta(actual)}` : ""}`,
748
+ choices: [{ label: "繼續", action: () => closeModal(() => finishEvent(done)) }],
749
+ });
750
+ return;
751
+ }
752
+
753
+ showModal({
754
+ kicker: "事件",
755
+ title: event.title,
756
+ body: event.body,
757
+ choices: event.choices.map((choice) => ({
758
+ label: choice.label,
759
+ action: () => {
760
+ const result = choice.apply();
761
+ if (result && result.ending) {
762
+ closeModal(() => {
763
+ triggerSpecialEnding(result.ending.title, result.ending.body);
764
+ });
765
+ return;
766
+ }
767
+
768
+ const actual = applyDelta((result && result.delta) || {});
769
+ addLog(`事件:${event.title}/${choice.label}。${result.text}${formatDelta(actual) ? `(${formatDelta(actual)})` : ""}`);
770
+ saveState();
771
+
772
+ showModal({
773
+ kicker: "事件結果",
774
+ title: event.title,
775
+ body: result.text,
776
+ result: formatDelta(actual),
777
+ choices: [{ label: "繼續", action: () => closeModal(() => finishEvent(done)) }],
778
+ });
779
+ },
780
+ })),
781
+ });
782
+ }
783
+
784
+ function finishEvent(done) {
785
+ if (checkSuddenEnding()) return;
786
+ done();
787
+ }
788
+
789
+ function getEvents() {
790
+ const s = state.stats;
791
+ return [
792
+ {
793
+ title: "目擊證人",
794
+ body: "你看見了一起霸凌事件,你正站在一個沒人發現的位置。",
795
+ condition: () => true,
796
+ choices: [
797
+ { label: "默默離去", apply: () => ({ text: "你選擇不介入。", delta: { stress: 5 } }) },
798
+ {
799
+ label: "上前制止",
800
+ apply: () => {
801
+ if (state.stats.staminaMax >= 85) {
802
+ state.flags.backgroundUnlocked = true;
803
+ return { text: "你成功制止了事件。", delta: { stress: -5, social: 3 } };
804
+ }
805
+ return { text: "你沒能壓住局面。", delta: { stress: 10, social: -10 } };
806
+ },
807
+ },
808
+ { label: "通報老師", apply: () => ({ text: "你把事情交給老師處理。", delta: { social: -3, stress: 1 } }) },
809
+ ],
810
+ },
811
+ {
812
+ title: "背景勢力",
813
+ body: "你成功擊退他們後,有一群人似乎想投靠你。",
814
+ condition: () => state.flags.backgroundUnlocked,
815
+ choices: [
816
+ {
817
+ label: "拒絕",
818
+ apply: () =>
819
+ state.stats.language >= 30
820
+ ? { text: "你明確拒絕,場面還算平穩。", delta: { social: -1 } }
821
+ : { text: "你的拒絕方式引來誤會。", delta: { social: -3, stress: 3 } },
822
+ },
823
+ {
824
+ label: "同意",
825
+ apply: () =>
826
+ rollWeighted([
827
+ { chance: 70, text: "他們成為你的人脈。", delta: { social: 5 } },
828
+ { chance: 30, text: "事情變得有些張揚。", delta: { social: 5, warnings: 1 } },
829
+ ]),
830
+ },
831
+ ],
832
+ },
833
+ {
834
+ title: "網路吃瓜",
835
+ body: "你在網路上看見一則消息,似乎是某藝人又再度失言。",
836
+ condition: () => true,
837
+ choices: [
838
+ { label: "強力譴責", apply: () => ({ text: "你把情緒宣洩了出去。", delta: { stress: -5 } }) },
839
+ { label: "分析事件", apply: () => ({ text: "你嘗試拆解事件脈絡。", delta: { logic: 2 } }) },
840
+ ],
841
+ },
842
+ {
843
+ title: "分組",
844
+ body: "又來到分組活動的時刻,你想以什麼分組策略行動呢?",
845
+ condition: () => true,
846
+ choices: [
847
+ { label: "默默等有人來找你", apply: () => ({ text: "等待讓你有些焦慮。", delta: { stress: 3 } }) },
848
+ {
849
+ label: "主動找尋組員",
850
+ apply: () =>
851
+ state.stats.social >= 50
852
+ ? { text: "你順利找到了合適組員。", delta: { stress: -3, social: 3 } }
853
+ : { text: "主動出擊並不順利。", delta: { stress: 5, social: 1 } },
854
+ },
855
+ ],
856
+ },
857
+ {
858
+ title: "來自朋友的關心",
859
+ body: "朋友注意到你的狀態不太好,主動來關心你。",
860
+ condition: () => s.social > 40 && s.stress > 70,
861
+ choices: [
862
+ {
863
+ label: "和朋友分擔想法",
864
+ apply: () =>
865
+ rollWeighted([
866
+ { chance: 90, text: "朋友理解了你。", delta: { stress: -5, social: 2 } },
867
+ { chance: 10, text: "溝通沒有完全順利。", delta: { stress: 2, social: -2 } },
868
+ ]),
869
+ },
870
+ { label: "說自己沒事", apply: () => ({ text: "你把話吞了回去。", delta: { stress: 1 } }) },
871
+ ],
872
+ },
873
+ {
874
+ title: "意外受傷",
875
+ body: "你的身體狀況不佳,發生了小意外。",
876
+ condition: () => s.health < 60,
877
+ auto: () =>
878
+ state.stats.social > 50
879
+ ? { text: "朋友照顧了你。", delta: { social: 2, stress: -1 } }
880
+ : { text: "你只能獨自承受。", delta: { stress: 3 } },
881
+ },
882
+ {
883
+ title: "自主學習",
884
+ body: "你感覺自己可以安排一段自主學習時間。",
885
+ condition: () => s.learning > 50,
886
+ choices: [
887
+ { label: "奮發學習", apply: () => ({ text: "你推進了自己的學習進度。", delta: { stress: 5, learning: 3 } }) },
888
+ { label: "暫時休息", apply: () => ({ text: "你選擇調整狀態。", delta: { stress: -3 } }) },
889
+ ],
890
+ },
891
+ {
892
+ title: "校園霸凌",
893
+ body: "你因為社交狀態低落而被盯上。",
894
+ condition: () => s.social < 20,
895
+ choices: [
896
+ { label: "默默承受", apply: () => ({ text: "你把事情壓在心裡。", delta: { stress: 5, health: -2 } }) },
897
+ {
898
+ label: "反抗",
899
+ apply: () =>
900
+ state.stats.health > 80
901
+ ? { text: "你成功反抗,但消耗了體力。", delta: { stamina: -10 } }
902
+ : { text: "反抗失敗,狀況更糟。", delta: { stress: 5, health: -5, stamina: -10 } },
903
+ },
904
+ ],
905
+ },
906
+ {
907
+ title: "吵架",
908
+ body: "你和同學起了衝突。",
909
+ condition: () => true,
910
+ choices: [
911
+ {
912
+ label: "據理力爭",
913
+ apply: () =>
914
+ state.stats.logic > 40
915
+ ? { text: "你的論點站得住腳。", delta: { stress: -5, social: -1 } }
916
+ : { text: "爭論失敗讓你更煩躁。", delta: { stress: 10 } },
917
+ },
918
+ { label: "無視", apply: () => ({ text: "你不想再理會這件事。", delta: { stress: 5 } }) },
919
+ ],
920
+ },
921
+ {
922
+ title: "學習困境",
923
+ body: "你卡在不上不下的學習瓶頸。",
924
+ condition: () => s.learning > 40 && s.learning < 60,
925
+ choices: [
926
+ {
927
+ label: "求助同學朋友",
928
+ apply: () =>
929
+ rollWeighted([
930
+ { chance: 80, text: "同學幫你解開疑惑。", delta: { learning: 3, stress: -2 } },
931
+ { chance: 20, text: "求助過程有些尷尬。", delta: { social: -2, stress: 2 } },
932
+ ]),
933
+ },
934
+ {
935
+ label: "自己領悟",
936
+ apply: () =>
937
+ rollWeighted([
938
+ { chance: 60, text: "你靠自己理解了一點。", delta: { learning: 1, stress: 3 } },
939
+ { chance: 40, text: "你越想越焦慮。", delta: { stress: 5 } },
940
+ ]),
941
+ },
942
+ ],
943
+ },
944
+ {
945
+ title: "家庭革命",
946
+ body: "家人對你的讀書狀況非常不滿。",
947
+ condition: () => s.learning < 60,
948
+ choices: [
949
+ {
950
+ label: "認真學習",
951
+ apply: () =>
952
+ rollWeighted([
953
+ { chance: 60, text: "你試著回應期待。", delta: { learning: 3, stress: 5 } },
954
+ { chance: 40, text: "你勉強自己讀了一些。", delta: { learning: 1, stress: 8 } },
955
+ ]),
956
+ },
957
+ { label: "無視", apply: () => ({ text: "你不想回應家人的壓力。", delta: { stress: 5 } }) },
958
+ ],
959
+ },
960
+ {
961
+ title: "抄襲功課",
962
+ body: "同學希望你把功課借給他抄。",
963
+ condition: () => s.learning > 50 && s.social > 50,
964
+ choices: [
965
+ {
966
+ label: "同意",
967
+ apply: () =>
968
+ rollWeighted([
969
+ { chance: 60, text: "同學很感謝你。", delta: { social: 3, stress: 1 } },
970
+ { chance: 40, text: "你開始擔心被發現。", delta: { stress: 5 } },
971
+ ]),
972
+ },
973
+ { label: "不同意", apply: () => ({ text: "同學有些不滿。", delta: { social: -3, stress: 2 } }) },
974
+ ],
975
+ },
976
+ {
977
+ title: "留校查看",
978
+ body: "你的警告累積到需要留校查看。",
979
+ condition: () => s.warnings >= 3,
980
+ choices: [
981
+ { label: "逃跑", apply: () => ({ text: "你選擇逃避處分。", delta: { warnings: 1 } }) },
982
+ { label: "乖乖反省", apply: () => ({ text: "你接受處分並反省。", delta: { warnings: -1, stress: 5 } }) },
983
+ ],
984
+ },
985
+ {
986
+ title: "頒獎典禮",
987
+ body: "你被通知要上台領獎。",
988
+ condition: () => s.awards > 1,
989
+ choices: [
990
+ { label: "大肆宣揚", apply: () => ({ text: "你到處宣傳這件事。", delta: { social: -3, stress: -5 } }) },
991
+ { label: "默默領獎", apply: () => ({ text: "你低調領完獎。", delta: { stress: -1 } }) },
992
+ ],
993
+ },
994
+ {
995
+ title: "遲到",
996
+ body: "體力不足讓你沒能準時到校。",
997
+ condition: () => s.stamina < 20,
998
+ auto: () => ({ text: "你被記了一次警告。", delta: { stress: 3, warnings: 1 } }),
999
+ },
1000
+ {
1001
+ title: "即將遲到",
1002
+ body: "你發現自己快要遲到了。",
1003
+ condition: () => true,
1004
+ choices: [
1005
+ {
1006
+ label: "竭力衝刺",
1007
+ apply: () =>
1008
+ rollWeighted([
1009
+ { chance: 70, text: "你趕上了。", delta: { stamina: -5 } },
1010
+ { chance: 30, text: "你還是遲到了。", delta: { stamina: -5, stress: 3, warnings: 1 } },
1011
+ ]),
1012
+ },
1013
+ { label: "無所謂", apply: () => ({ text: "你選擇慢慢走。", delta: { stress: 3, warnings: 1 } }) },
1014
+ ],
1015
+ },
1016
+ {
1017
+ title: "讀書會",
1018
+ body: "學校推薦一個課後讀書會,會一起討論課外書籍並上台發表。",
1019
+ condition: () => true,
1020
+ choices: [
1021
+ {
1022
+ label: "參加讀書會",
1023
+ apply: () =>
1024
+ state.stats.language >= 40
1025
+ ? { text: "你在讀書會表現得不錯。", delta: { language: 3, social: 3, stress: 3 } }
1026
+ : { text: "你努力參與,但有些吃力。", delta: { language: 2, social: 1, stress: 5 } },
1027
+ },
1028
+ { label: "不參加讀書會", apply: () => ({ text: "你省下了一些心力。", delta: { stress: -1 } }) },
1029
+ ],
1030
+ },
1031
+ {
1032
+ title: "諮商",
1033
+ body: "你的壓力讓你整天睡不好,正在考慮是否該尋求協助。",
1034
+ condition: () => s.stress > 70,
1035
+ choices: [
1036
+ {
1037
+ label: "去看",
1038
+ apply: () =>
1039
+ rollWeighted([
1040
+ { chance: 70, text: "諮商讓你舒緩不少。", delta: { stress: -10 } },
1041
+ { chance: 30, text: "你有些擔心他人的眼光。", delta: { social: -5 } },
1042
+ ]),
1043
+ },
1044
+ { label: "不去看", apply: () => ({ text: "你暫時把問題放著。", delta: { stress: 1 } }) },
1045
+ ],
1046
+ },
1047
+ {
1048
+ title: "被老師冤枉",
1049
+ body: "你按時交了功課,但老師把你和沒交功課的同學認錯了。",
1050
+ condition: () => true,
1051
+ choices: [
1052
+ {
1053
+ label: "據理力爭",
1054
+ apply: () =>
1055
+ state.stats.logic >= 40
1056
+ ? { text: "老師發現誤會並向你道歉。", delta: { stress: -2 } }
1057
+ : { text: "老師不聽你的解釋。", delta: { stress: 5 } },
1058
+ },
1059
+ { label: "默不作聲", apply: () => ({ text: "你忍了下來。", delta: { stress: 2 } }) },
1060
+ {
1061
+ label: "情緒爆發",
1062
+ apply: () =>
1063
+ state.stats.stamina < 85
1064
+ ? { text: "你的行動完全失敗,事情更嚴重了。", delta: { stress: 5, warnings: 3 } }
1065
+ : {
1066
+ text: "事情失控到無法挽回。",
1067
+ ending: {
1068
+ title: "勒令退學(Bad End 3)",
1069
+ body: "一份功課導致的悲劇。",
1070
+ },
1071
+ },
1072
+ },
1073
+ ],
1074
+ },
1075
+ {
1076
+ title: "被遺忘的它",
1077
+ body: "你回到家後發現今天的功課留在了學校。",
1078
+ condition: () => true,
1079
+ choices: [
1080
+ {
1081
+ label: "重回學校",
1082
+ apply: () =>
1083
+ rollWeighted([
1084
+ { chance: 80, text: "你成功拿回功課。", delta: { stress: -1, stamina: -10 } },
1085
+ { chance: 20, text: "學校已經關門。", delta: { stress: 3, stamina: -10, warnings: 1 } },
1086
+ ]),
1087
+ },
1088
+ { label: "放棄", apply: () => ({ text: "你準備承受後果。", delta: { stress: 5, warnings: 1 } }) },
1089
+ ],
1090
+ },
1091
+ {
1092
+ title: "催眠的數學課",
1093
+ body: "缺乏體力讓你在數學課上被睡意包圍。",
1094
+ condition: () => s.stamina < 20,
1095
+ choices: [
1096
+ {
1097
+ label: "順應睡意",
1098
+ apply: () =>
1099
+ rollWeighted([
1100
+ { chance: 70, text: "你睡了一下恢復體力。", delta: { learning: -1, stamina: 10 } },
1101
+ { chance: 30, text: "你睡得不安穩。", delta: { learning: -1, stress: 5 } },
1102
+ ]),
1103
+ },
1104
+ { label: "強撐學習", apply: () => ({ text: "你硬是把課聽完。", delta: { stress: 2, learning: 1 } }) },
1105
+ ],
1106
+ },
1107
+ {
1108
+ title: "突擊測驗",
1109
+ body: "老師宣布今天要考上個月的教學內容。",
1110
+ condition: () => true,
1111
+ auto: () =>
1112
+ state.stats.learning >= 55
1113
+ ? { text: "你拿到了不錯的分數。", delta: { stress: -2 } }
1114
+ : { text: "分數不理想,壓力開始增加。", delta: { stress: 5 } },
1115
+ },
1116
+ ];
1117
+ }
1118
+
1119
+ function pickRandomEvent() {
1120
+ const eligible = getEvents().filter((event) => event.condition());
1121
+ if (eligible.length === 0) return null;
1122
+ return eligible[Math.floor(Math.random() * eligible.length)];
1123
+ }
1124
+
1125
+ function checkSuddenEnding() {
1126
+ if (state.ended) return true;
1127
+
1128
+ if (state.stats.stress >= 100) {
1129
+ triggerSpecialEnding("壓力崩潰(Bad End 1)", "壓力已經超過你能承受的範圍。");
1130
+ return true;
1131
+ }
1132
+
1133
+ if (state.stats.warnings >= 9) {
1134
+ triggerSpecialEnding("被趕出學校(Bad End 2)", "警告累積到 9 次,學校決定將你退學。");
1135
+ return true;
1136
+ }
1137
+
1138
+ if (state.stats.health <= 0) {
1139
+ triggerSpecialEnding("過勞倒下(Bad End 4)", "生理健康歸零,這段高中生活被迫中止。");
1140
+ return true;
1141
+ }
1142
+
1143
+ return false;
1144
+ }
1145
+
1146
+ function triggerSpecialEnding(title, body) {
1147
+ state.ended = true;
1148
+ state.ending = { title, body };
1149
+ addLog(`結局:${title}`);
1150
+ saveState();
1151
+ render();
1152
+
1153
+ showModal({
1154
+ kicker: "結局",
1155
+ title,
1156
+ body,
1157
+ result: getFinalStatsText(),
1158
+ choices: [
1159
+ {
1160
+ label: "重新開始",
1161
+ action: () => {
1162
+ state = createInitialState();
1163
+ addLog("新的高中生活開始了。");
1164
+ saveState();
1165
+ closeModal();
1166
+ render();
1167
+ },
1168
+ },
1169
+ ],
1170
+ });
1171
+ }
1172
+
1173
+ function showFinalEnding() {
1174
+ const average = getExamAverage();
1175
+ const excellent = average >= 85;
1176
+ const title = excellent ? "優等生" : "成功畢業";
1177
+ const body = excellent
1178
+ ? "三年考試平均達到 85 分以上,你以優等生姿態畢業。"
1179
+ : "你完成了三年的高中生活,順利畢業。";
1180
+
1181
+ state.ended = true;
1182
+ state.ending = { title, body };
1183
+ addLog(`終末結局:${title}`);
1184
+ saveState();
1185
+ render();
1186
+
1187
+ showModal({
1188
+ kicker: "終末結局",
1189
+ title,
1190
+ body,
1191
+ result: `考試平均:${Number.isFinite(average) ? average.toFixed(1) : "--"}\n${getFinalStatsText()}`,
1192
+ choices: [
1193
+ {
1194
+ label: "重新開始",
1195
+ action: () => {
1196
+ state = createInitialState();
1197
+ addLog("新的高中生活開始了。");
1198
+ saveState();
1199
+ closeModal();
1200
+ render();
1201
+ },
1202
+ },
1203
+ ],
1204
+ });
1205
+ }
1206
+
1207
+ function applyDelta(delta) {
1208
+ const before = { ...state.stats };
1209
+
1210
+ Object.entries(delta).forEach(([key, value]) => {
1211
+ if (typeof value !== "number") return;
1212
+
1213
+ if (key === "staminaMax") {
1214
+ state.stats.staminaMax = Math.round(clamp(state.stats.staminaMax + value, 1, 120));
1215
+ state.stats.stamina = clamp(state.stats.stamina, 0, state.stats.staminaMax);
1216
+ return;
1217
+ }
1218
+
1219
+ if (!(key in state.stats)) return;
1220
+ state.stats[key] += value;
1221
+ });
1222
+
1223
+ state.stats.learning = Math.round(clamp(state.stats.learning, 0, 100));
1224
+ state.stats.language = Math.round(clamp(state.stats.language, 0, 100));
1225
+ state.stats.logic = Math.round(clamp(state.stats.logic, 0, 100));
1226
+ state.stats.social = Math.round(clamp(state.stats.social, 0, 100));
1227
+ state.stats.health = Math.round(clamp(state.stats.health, 0, 120));
1228
+ state.stats.stress = Math.round(clamp(state.stats.stress, 0, 100));
1229
+ state.stats.warnings = Math.max(0, Math.round(state.stats.warnings));
1230
+ state.stats.awards = Math.max(0, Math.round(state.stats.awards));
1231
+ state.stats.stamina = Math.round(clamp(state.stats.stamina, 0, state.stats.staminaMax));
1232
+
1233
+ const actual = {};
1234
+ Object.keys(state.stats).forEach((key) => {
1235
+ const diff = state.stats[key] - before[key];
1236
+ if (diff !== 0) actual[key] = diff;
1237
+ });
1238
+ return actual;
1239
+ }
1240
+
1241
+ function formatDelta(delta) {
1242
+ const entries = Object.entries(delta || {}).filter(([, value]) => value !== 0);
1243
+ if (entries.length === 0) return "";
1244
+ return entries
1245
+ .map(([key, value]) => `${STAT_LABELS[key] || key}${value > 0 ? "+" : ""}${value}`)
1246
+ .join("、");
1247
+ }
1248
+
1249
+ function describeScore(value) {
1250
+ const band = SCORE_BANDS.find((item) => value <= item.max);
1251
+ return band ? band.text : SCORE_BANDS[SCORE_BANDS.length - 1].text;
1252
+ }
1253
+
1254
+ function rollWeighted(outcomes) {
1255
+ const total = outcomes.reduce((sum, item) => sum + item.chance, 0);
1256
+ let roll = Math.random() * total;
1257
+ for (const outcome of outcomes) {
1258
+ roll -= outcome.chance;
1259
+ if (roll <= 0) return outcome;
1260
+ }
1261
+ return outcomes[outcomes.length - 1];
1262
+ }
1263
+
1264
+ function addLog(text) {
1265
+ state.history.push({
1266
+ time: `${state.year} 年 ${getCurrentMonth()} 月 ${getPhaseName()}`,
1267
+ text,
1268
+ });
1269
+
1270
+ if (state.history.length > 90) {
1271
+ state.history = state.history.slice(-90);
1272
+ }
1273
+ }
1274
+
1275
+ function getCurrentMonth() {
1276
+ return MONTH_ORDER[state.monthPointer % MONTH_ORDER.length];
1277
+ }
1278
+
1279
+ function getPhaseName() {
1280
+ const month = getCurrentMonth();
1281
+ const phases = isHolidayMonth(month) ? HOLIDAY_PHASES : WEEKDAY_PHASES;
1282
+ return phases[state.phase] || phases[0];
1283
+ }
1284
+
1285
+ function isHolidayMonth(month) {
1286
+ return HOLIDAY_MONTHS.has(month);
1287
+ }
1288
+
1289
+ function isWeekdayMonth(month) {
1290
+ return WEEKDAY_MONTHS.has(month);
1291
+ }
1292
+
1293
+ function getExamAverage() {
1294
+ if (state.examScores.length === 0) return Number.NaN;
1295
+ const total = state.examScores.reduce((sum, item) => sum + item.score, 0);
1296
+ return total / state.examScores.length;
1297
+ }
1298
+
1299
+ function getExamAverageText() {
1300
+ const average = getExamAverage();
1301
+ return Number.isFinite(average) ? average.toFixed(1) : "--";
1302
+ }
1303
+
1304
+ function getFinalStatsText() {
1305
+ return [
1306
+ `學習:${state.stats.learning}`,
1307
+ `語文:${state.stats.language}`,
1308
+ `邏輯:${state.stats.logic}`,
1309
+ `社交:${state.stats.social}`,
1310
+ `體力:${state.stats.stamina}/${state.stats.staminaMax}`,
1311
+ `生理健康:${state.stats.health}`,
1312
+ `壓力:${state.stats.stress}`,
1313
+ `警告:${state.stats.warnings}`,
1314
+ `嘉獎:${state.stats.awards}`,
1315
+ ].join("\n");
1316
+ }
1317
+
1318
+ function randomBetween(min, max) {
1319
+ return min + Math.random() * (max - min);
1320
+ }
1321
+
1322
+ function clamp(value, min, max) {
1323
+ return Math.min(max, Math.max(min, value));
1324
+ }
1325
+
1326
+ function showModal({ kicker, title, body, result, choices }) {
1327
+ modalContinue = null;
1328
+ els.modalKicker.textContent = kicker || "";
1329
+ els.modalTitle.textContent = title || "";
1330
+ els.modalBody.textContent = body || "";
1331
+ els.modalResult.textContent = result || "";
1332
+ els.modalChoices.innerHTML = "";
1333
+
1334
+ (choices || [{ label: "繼續", action: closeModal }]).forEach((choice) => {
1335
+ const button = document.createElement("button");
1336
+ button.className = "modal-choice";
1337
+ button.type = "button";
1338
+ button.textContent = choice.label;
1339
+ button.addEventListener("click", choice.action);
1340
+ els.modalChoices.appendChild(button);
1341
+ });
1342
+
1343
+ els.modalOverlay.hidden = false;
1344
+ }
1345
+
1346
+ function closeModal(afterClose) {
1347
+ els.modalOverlay.hidden = true;
1348
+ modalContinue = null;
1349
+
1350
+ if (typeof afterClose === "function") {
1351
+ afterClose();
1352
+ }
1353
+
1354
+ saveState();
1355
+ render();
1356
+ }
1357
+
assets/campus.svg ADDED
index.html ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="zh-Hant">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>高中模擬器</title>
7
+ <link rel="stylesheet" href="styles.css" />
8
+ <script src="app.js" defer></script>
9
+ </head>
10
+ <body>
11
+ <div id="app" class="app-shell">
12
+ <header class="topbar">
13
+ <div class="title-block">
14
+ <img class="school-mark" src="assets/campus.svg" alt="" aria-hidden="true" />
15
+ <div>
16
+ <h1>高中模擬器</h1>
17
+ <p id="calendarText">第 1 年 9 月</p>
18
+ </div>
19
+ </div>
20
+ <div class="top-actions">
21
+ <button id="saveButton" class="ghost-button" type="button">保存</button>
22
+ <button id="newGameButton" class="danger-button" type="button">重新開始</button>
23
+ </div>
24
+ </header>
25
+
26
+ <main class="game-layout">
27
+ <section class="panel stats-panel" aria-labelledby="statsHeading">
28
+ <div class="panel-heading">
29
+ <h2 id="statsHeading">狀態</h2>
30
+ <span id="phaseBadge" class="phase-badge">早上</span>
31
+ </div>
32
+ <div id="statsGrid" class="stats-grid"></div>
33
+ <div class="meta-grid">
34
+ <div>
35
+ <span>警告</span>
36
+ <strong id="warningText">0</strong>
37
+ </div>
38
+ <div>
39
+ <span>嘉獎</span>
40
+ <strong id="awardText">0</strong>
41
+ </div>
42
+ <div>
43
+ <span>考試平均</span>
44
+ <strong id="examAverageText">--</strong>
45
+ </div>
46
+ </div>
47
+ </section>
48
+
49
+ <section class="panel play-panel" aria-labelledby="choiceHeading">
50
+ <div class="scene-strip">
51
+ <img src="assets/campus.svg" alt="" aria-hidden="true" />
52
+ <div>
53
+ <span id="modeText">平日</span>
54
+ <strong id="roundText">第 1 輪</strong>
55
+ </div>
56
+ </div>
57
+ <div class="panel-heading">
58
+ <h2 id="choiceHeading">行動</h2>
59
+ <span id="slotText">早上</span>
60
+ </div>
61
+ <div id="choiceGrid" class="choice-grid"></div>
62
+ </section>
63
+
64
+ <section class="panel log-panel" aria-labelledby="logHeading">
65
+ <div class="panel-heading">
66
+ <h2 id="logHeading">紀錄</h2>
67
+ <button id="clearLogButton" class="ghost-button compact" type="button">清空</button>
68
+ </div>
69
+ <ol id="logList" class="log-list"></ol>
70
+ </section>
71
+ </main>
72
+ </div>
73
+
74
+ <div id="modalOverlay" class="modal-overlay" hidden>
75
+ <section class="modal-box" role="dialog" aria-modal="true" aria-labelledby="modalTitle">
76
+ <p id="modalKicker" class="modal-kicker"></p>
77
+ <h2 id="modalTitle"></h2>
78
+ <p id="modalBody"></p>
79
+ <div id="modalResult" class="modal-result"></div>
80
+ <div id="modalChoices" class="modal-choices"></div>
81
+ </section>
82
+ </div>
83
+ </body>
84
+ </html>
85
+
styles.css ADDED
@@ -0,0 +1,485 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ color-scheme: light;
3
+ --bg: #f5f6f2;
4
+ --ink: #1f2933;
5
+ --muted: #64707d;
6
+ --line: #d9ddd3;
7
+ --panel: #ffffff;
8
+ --panel-strong: #eef4f7;
9
+ --green: #28795a;
10
+ --blue: #315f99;
11
+ --orange: #b05c21;
12
+ --red: #b23a48;
13
+ --purple: #6b4fa3;
14
+ --shadow: 0 12px 30px rgba(32, 42, 54, 0.11);
15
+ }
16
+
17
+ * {
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ body {
22
+ margin: 0;
23
+ min-height: 100vh;
24
+ font-family:
25
+ "Microsoft JhengHei",
26
+ "PingFang TC",
27
+ "Noto Sans TC",
28
+ system-ui,
29
+ sans-serif;
30
+ letter-spacing: 0;
31
+ color: var(--ink);
32
+ background:
33
+ linear-gradient(180deg, rgba(49, 95, 153, 0.09), transparent 260px),
34
+ var(--bg);
35
+ }
36
+
37
+ button {
38
+ font: inherit;
39
+ }
40
+
41
+ .app-shell {
42
+ width: min(1180px, calc(100% - 28px));
43
+ margin: 0 auto;
44
+ padding: 18px 0 28px;
45
+ }
46
+
47
+ .topbar {
48
+ display: flex;
49
+ justify-content: space-between;
50
+ align-items: center;
51
+ gap: 16px;
52
+ padding: 14px 0 18px;
53
+ }
54
+
55
+ .title-block {
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 12px;
59
+ }
60
+
61
+ .school-mark {
62
+ width: 58px;
63
+ height: 58px;
64
+ border: 1px solid var(--line);
65
+ border-radius: 8px;
66
+ background: #fff;
67
+ }
68
+
69
+ h1,
70
+ h2,
71
+ p {
72
+ margin: 0;
73
+ }
74
+
75
+ h1 {
76
+ font-size: clamp(1.45rem, 2.4vw, 2rem);
77
+ line-height: 1.1;
78
+ }
79
+
80
+ .title-block p {
81
+ margin-top: 5px;
82
+ color: var(--muted);
83
+ font-size: 0.95rem;
84
+ }
85
+
86
+ .top-actions,
87
+ .modal-choices {
88
+ display: flex;
89
+ gap: 8px;
90
+ flex-wrap: wrap;
91
+ }
92
+
93
+ .game-layout {
94
+ display: grid;
95
+ grid-template-columns: 300px minmax(0, 1fr) 310px;
96
+ gap: 14px;
97
+ align-items: start;
98
+ }
99
+
100
+ .panel {
101
+ background: var(--panel);
102
+ border: 1px solid var(--line);
103
+ border-radius: 8px;
104
+ box-shadow: var(--shadow);
105
+ }
106
+
107
+ .stats-panel,
108
+ .play-panel,
109
+ .log-panel {
110
+ padding: 14px;
111
+ }
112
+
113
+ .panel-heading {
114
+ display: flex;
115
+ justify-content: space-between;
116
+ align-items: center;
117
+ gap: 10px;
118
+ margin-bottom: 12px;
119
+ }
120
+
121
+ .panel-heading h2 {
122
+ font-size: 1.05rem;
123
+ }
124
+
125
+ .phase-badge,
126
+ #slotText,
127
+ #modeText {
128
+ display: inline-flex;
129
+ align-items: center;
130
+ min-height: 28px;
131
+ padding: 4px 10px;
132
+ border-radius: 8px;
133
+ background: var(--panel-strong);
134
+ color: var(--blue);
135
+ font-weight: 700;
136
+ font-size: 0.88rem;
137
+ }
138
+
139
+ .stats-grid {
140
+ display: grid;
141
+ gap: 9px;
142
+ }
143
+
144
+ .stat-card {
145
+ border: 1px solid var(--line);
146
+ border-radius: 8px;
147
+ padding: 10px;
148
+ background: #fcfcfa;
149
+ }
150
+
151
+ .stat-line {
152
+ display: flex;
153
+ justify-content: space-between;
154
+ align-items: baseline;
155
+ gap: 10px;
156
+ margin-bottom: 7px;
157
+ }
158
+
159
+ .stat-name {
160
+ font-weight: 700;
161
+ }
162
+
163
+ .stat-value {
164
+ color: var(--muted);
165
+ font-variant-numeric: tabular-nums;
166
+ }
167
+
168
+ .bar-track {
169
+ height: 9px;
170
+ overflow: hidden;
171
+ border-radius: 8px;
172
+ background: #e8e9e0;
173
+ }
174
+
175
+ .bar-fill {
176
+ height: 100%;
177
+ width: 0%;
178
+ background: var(--green);
179
+ transition: width 160ms ease;
180
+ }
181
+
182
+ .stat-card[data-tone="blue"] .bar-fill {
183
+ background: var(--blue);
184
+ }
185
+
186
+ .stat-card[data-tone="orange"] .bar-fill {
187
+ background: var(--orange);
188
+ }
189
+
190
+ .stat-card[data-tone="red"] .bar-fill {
191
+ background: var(--red);
192
+ }
193
+
194
+ .stat-card[data-tone="purple"] .bar-fill {
195
+ background: var(--purple);
196
+ }
197
+
198
+ .stat-desc {
199
+ display: block;
200
+ margin-top: 6px;
201
+ color: var(--muted);
202
+ font-size: 0.82rem;
203
+ }
204
+
205
+ .meta-grid {
206
+ display: grid;
207
+ grid-template-columns: repeat(3, 1fr);
208
+ gap: 8px;
209
+ margin-top: 12px;
210
+ }
211
+
212
+ .meta-grid div {
213
+ border: 1px solid var(--line);
214
+ border-radius: 8px;
215
+ padding: 9px 8px;
216
+ background: #f8faf8;
217
+ }
218
+
219
+ .meta-grid span {
220
+ display: block;
221
+ color: var(--muted);
222
+ font-size: 0.78rem;
223
+ }
224
+
225
+ .meta-grid strong {
226
+ display: block;
227
+ margin-top: 2px;
228
+ font-size: 1.05rem;
229
+ }
230
+
231
+ .scene-strip {
232
+ min-height: 94px;
233
+ display: flex;
234
+ align-items: center;
235
+ gap: 14px;
236
+ margin-bottom: 14px;
237
+ padding: 12px;
238
+ border: 1px solid var(--line);
239
+ border-radius: 8px;
240
+ background: #f6f2e9;
241
+ }
242
+
243
+ .scene-strip img {
244
+ width: 130px;
245
+ max-width: 42%;
246
+ height: 70px;
247
+ object-fit: contain;
248
+ }
249
+
250
+ .scene-strip div {
251
+ display: grid;
252
+ gap: 7px;
253
+ }
254
+
255
+ .scene-strip strong {
256
+ font-size: 1.25rem;
257
+ }
258
+
259
+ .choice-grid {
260
+ display: grid;
261
+ grid-template-columns: repeat(2, minmax(0, 1fr));
262
+ gap: 10px;
263
+ }
264
+
265
+ .choice-button,
266
+ .ghost-button,
267
+ .danger-button {
268
+ border: 1px solid transparent;
269
+ border-radius: 8px;
270
+ cursor: pointer;
271
+ transition:
272
+ transform 120ms ease,
273
+ border-color 120ms ease,
274
+ background 120ms ease;
275
+ }
276
+
277
+ .choice-button {
278
+ min-height: 76px;
279
+ padding: 12px;
280
+ color: #fff;
281
+ background: var(--blue);
282
+ text-align: left;
283
+ }
284
+
285
+ .choice-button strong {
286
+ display: block;
287
+ font-size: 1rem;
288
+ line-height: 1.25;
289
+ }
290
+
291
+ .choice-button span {
292
+ display: block;
293
+ margin-top: 6px;
294
+ font-size: 0.8rem;
295
+ line-height: 1.35;
296
+ color: rgba(255, 255, 255, 0.84);
297
+ }
298
+
299
+ .choice-button[data-tone="green"] {
300
+ background: var(--green);
301
+ }
302
+
303
+ .choice-button[data-tone="orange"] {
304
+ background: var(--orange);
305
+ }
306
+
307
+ .choice-button[data-tone="red"] {
308
+ background: var(--red);
309
+ }
310
+
311
+ .choice-button[data-tone="purple"] {
312
+ background: var(--purple);
313
+ }
314
+
315
+ .choice-button:hover,
316
+ .ghost-button:hover,
317
+ .danger-button:hover {
318
+ transform: translateY(-1px);
319
+ }
320
+
321
+ .choice-button:disabled {
322
+ cursor: not-allowed;
323
+ opacity: 0.5;
324
+ transform: none;
325
+ }
326
+
327
+ .ghost-button,
328
+ .danger-button {
329
+ min-height: 36px;
330
+ padding: 7px 12px;
331
+ color: var(--ink);
332
+ background: #fff;
333
+ border-color: var(--line);
334
+ }
335
+
336
+ .danger-button {
337
+ color: #fff;
338
+ background: var(--red);
339
+ border-color: var(--red);
340
+ }
341
+
342
+ .compact {
343
+ min-height: 30px;
344
+ padding: 4px 9px;
345
+ font-size: 0.85rem;
346
+ }
347
+
348
+ .log-panel {
349
+ max-height: calc(100vh - 112px);
350
+ position: sticky;
351
+ top: 12px;
352
+ overflow: hidden;
353
+ }
354
+
355
+ .log-list {
356
+ display: grid;
357
+ gap: 8px;
358
+ max-height: calc(100vh - 178px);
359
+ margin: 0;
360
+ padding: 0 2px 0 22px;
361
+ overflow: auto;
362
+ }
363
+
364
+ .log-list li {
365
+ padding: 8px 9px;
366
+ border: 1px solid var(--line);
367
+ border-radius: 8px;
368
+ background: #fbfbf8;
369
+ font-size: 0.88rem;
370
+ line-height: 1.45;
371
+ }
372
+
373
+ .log-list time {
374
+ display: block;
375
+ margin-bottom: 2px;
376
+ color: var(--muted);
377
+ font-size: 0.76rem;
378
+ }
379
+
380
+ .modal-overlay {
381
+ position: fixed;
382
+ inset: 0;
383
+ display: grid;
384
+ place-items: center;
385
+ padding: 18px;
386
+ background: rgba(18, 24, 31, 0.55);
387
+ z-index: 20;
388
+ }
389
+
390
+ .modal-overlay[hidden] {
391
+ display: none;
392
+ }
393
+
394
+ .modal-box {
395
+ width: min(560px, 100%);
396
+ max-height: calc(100vh - 36px);
397
+ overflow: auto;
398
+ padding: 20px;
399
+ border-radius: 8px;
400
+ border: 1px solid var(--line);
401
+ background: #fff;
402
+ box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
403
+ }
404
+
405
+ .modal-kicker {
406
+ color: var(--blue);
407
+ font-weight: 700;
408
+ font-size: 0.9rem;
409
+ }
410
+
411
+ .modal-box h2 {
412
+ margin-top: 4px;
413
+ font-size: 1.38rem;
414
+ }
415
+
416
+ .modal-box p {
417
+ margin-top: 12px;
418
+ line-height: 1.65;
419
+ color: #303942;
420
+ }
421
+
422
+ .modal-result {
423
+ margin-top: 12px;
424
+ color: var(--muted);
425
+ line-height: 1.5;
426
+ white-space: pre-wrap;
427
+ }
428
+
429
+ .modal-choices {
430
+ margin-top: 16px;
431
+ }
432
+
433
+ .modal-choice {
434
+ min-height: 42px;
435
+ padding: 9px 13px;
436
+ border: 1px solid var(--blue);
437
+ border-radius: 8px;
438
+ color: #fff;
439
+ background: var(--blue);
440
+ cursor: pointer;
441
+ }
442
+
443
+ @media (max-width: 980px) {
444
+ .game-layout {
445
+ grid-template-columns: 1fr;
446
+ }
447
+
448
+ .log-panel {
449
+ max-height: none;
450
+ position: static;
451
+ }
452
+
453
+ .log-list {
454
+ max-height: 320px;
455
+ }
456
+ }
457
+
458
+ @media (max-width: 620px) {
459
+ .app-shell {
460
+ width: min(100% - 18px, 1180px);
461
+ padding-top: 10px;
462
+ }
463
+
464
+ .topbar {
465
+ align-items: stretch;
466
+ flex-direction: column;
467
+ }
468
+
469
+ .top-actions {
470
+ width: 100%;
471
+ }
472
+
473
+ .top-actions button {
474
+ flex: 1;
475
+ }
476
+
477
+ .choice-grid {
478
+ grid-template-columns: 1fr;
479
+ }
480
+
481
+ .meta-grid {
482
+ grid-template-columns: 1fr 1fr;
483
+ }
484
+ }
485
+