/* 设计规范
   颜色：暖色深底 + 唯一强调色「青碧」#48c0a3（中国传统色）；灰色一律偏暖
   字号：13 / 15 / 20 / 28 四档；间距 4 的倍数；按钮圆角 10，弹窗圆角 26 = 内圆角 10 + 内边距 16
   默认平面：不发光、不加毛玻璃，只有真正浮起来的弹窗有阴影 */
:root {
  --bg: #1b1714;
  --surface: #26201c;
  --fill: #342c26;
  --fill-hover: #3e352e;
  --line: #3a322c;
  --text: #f3ede4;
  --text-2: #b3a89b;
  --accent: #48c0a3;
  --on-accent: #10201b;
  --warn: #e4808c;
  --fs-s: 13px;
  --fs-m: 15px;
  --fs-l: 20px;
  --fs-xl: 28px;
  --r-btn: 10px;
  --r-dialog: 26px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 400 var(--fs-m)/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); font-size: var(--fs-s); }

/* 顶部信息 */
#hud {
  position: fixed; top: 0; left: 0; right: 0; text-align: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 0; pointer-events: none;
}
#score { font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; }
#score small { font-size: var(--fs-m); font-weight: 400; color: var(--text-2); margin-left: 4px; }
.stats { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; color: var(--text-2); }
.stats b { color: var(--text); font-weight: 600; }
.stats .warn, .stats .warn b { color: var(--warn); }
#hearts { display: inline-flex; gap: 3px; align-items: center; }
#hearts svg { width: 15px; height: 15px; display: block; }

/* 底部操作 */
#bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex; justify-content: center; gap: 12px;
}
button {
  font: inherit; color: var(--text); cursor: pointer;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: var(--r-btn);
  background: var(--fill);
}
button:hover:not(:disabled) { background: var(--fill-hover); }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--on-accent); font-weight: 600; padding: 0 32px; }
button.primary:hover { background: #55cdb0; }

/* 提示条：引导与临时消息共用一个样式 */
#coach, #toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 8px 16px; border-radius: var(--r-btn);
  background: var(--surface); text-align: center; pointer-events: none;
}
#coach { top: calc(env(safe-area-inset-top) + 16px); animation: rise .3s ease-out; }
#toast { top: var(--toast-top, 96px); opacity: 0; transition: opacity .2s; }
#toast.show { opacity: 1; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, -6px); } }

.pop {
  position: fixed; transform: translate(-50%, -50%); pointer-events: none;
  font-size: var(--fs-l); font-weight: 600; color: var(--accent);
  animation: pop .8s ease-out forwards;
}
@keyframes pop { to { transform: translate(-50%, -150%); opacity: 0; } }

/* 开始页：不用卡片，直接放在背景上 */
#start { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; }
#start h1 { margin: 0; font-size: var(--fs-xl); line-height: 1.3; font-weight: 600; }
#start p { margin: 0; }
#start .primary { margin: 24px 0 8px; }

/* 弹窗 */
.panel {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(12, 10, 8, .6); padding: 16px;
}
.dialog {
  width: min(400px, 100%); max-height: 100%; overflow: auto; touch-action: pan-y;
  padding: 24px 16px 16px; border-radius: var(--r-dialog);
  background: var(--surface); box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
  animation: rise-in .25s ease-out;
}
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }
.dialog h2 { margin: 0 0 12px; font-size: var(--fs-l); line-height: 1.3; font-weight: 600; text-align: center; }
.dialog h3 { margin: 20px 0 8px; font-size: var(--fs-m); font-weight: 600; padding: 0 4px; }
.rows { margin: 0; padding: 0 4px; }
.rows div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.rows dt { color: var(--text-2); }
.rows dd { margin: 0; font-weight: 600; }
.rows .accent { color: var(--accent); }
.choices { display: grid; gap: 8px; }
.choices button { display: block; text-align: left; padding: 12px 16px; line-height: 1.5; }
.choices strong { font-weight: 600; }
.choices small { display: block; font-size: var(--fs-s); color: var(--text-2); }
.choices em { font-style: normal; font-size: var(--fs-s); color: var(--text-2); margin-left: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.actions button { flex: 1 1 auto; }
.actions .muted { width: 100%; text-align: center; margin: 4px 0 0; }
.dialog > .primary { display: block; width: 100%; margin-top: 20px; }
#loading p { margin: 0; padding: 8px 16px; border-radius: var(--r-btn); background: var(--surface); }
.actions button { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.actions button:hover:not(:disabled) { background: var(--fill); }

/* 计数泡：唯一允许用全圆角的地方之一 */
#bar button { position: relative; padding: 0 14px; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--fill-hover); color: var(--text);
  font-size: var(--fs-s); line-height: 20px; font-weight: 600; text-align: center;
}
button:disabled .badge { opacity: 1; }
#bar { gap: 10px; }
#bar button.on { box-shadow: inset 0 0 0 2px var(--accent); }
#bar button.primary { padding: 0 14px; }

.center { text-align: center; }
.lead { margin: 0 4px 16px; text-align: center; }
.choices .line { display: flex; align-items: baseline; gap: 8px; }
.choices .line em { margin-left: auto; }
.tag { font-style: normal; font-size: var(--fs-s); color: var(--accent); }
.choices button:disabled { opacity: .45; }

/* 路线图 */
#map-svg { display: block; width: 100%; margin-top: 8px; }
#map-svg line { stroke: var(--line); stroke-width: 2; }
#map-svg line.walked { stroke: var(--text-2); }
#map-svg .node rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
#map-svg .node text { fill: var(--text-2); font-size: 13px; text-anchor: middle; }
#map-svg .node.done rect { fill: var(--fill); stroke: var(--fill); }
#map-svg .node.ok { cursor: pointer; }
#map-svg .node.ok rect { stroke: var(--accent); stroke-width: 2; }
#map-svg .node.ok text { fill: var(--text); font-weight: 600; }
#map-svg .node.ok:hover rect, #map-svg .node.ok:focus rect { fill: var(--fill); }
#map-svg .node:focus { outline: none; }
#map-svg .node.here rect { fill: var(--accent); stroke: var(--accent); }
#map-svg .node.here text { fill: var(--on-accent); font-weight: 600; }
