:root {
  --bg: #f3f0e8;
  --panel: #fffdf8;
  --ink: #2a2e35;
  --muted: #6c727c;
  --line: #e2ddd0;
  --brand: #2f4a66;
  --accent: #d9822b;
  --ok: #2e9d5b;
  --bad: #d6453d;
  --miss: #9a8f7d;
  --you: #f2b705;
  --target: #e5484d;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  background: var(--brand); color: #fff; flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { font-size: 28px; }
.brand b { font-size: 18px; letter-spacing: 1px; display: block; }
.brand small { opacity: .7; font-size: 12px; }
.clockbox { display: flex; align-items: center; gap: 10px; margin-left: auto; }
#clock {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 26px; font-weight: 700;
  background: #13263a; color: #7dffa8; padding: 2px 12px; border-radius: 8px; letter-spacing: 2px;
  text-shadow: 0 0 6px rgba(125,255,168,.5);
}
#dayLabel { font-size: 13px; opacity: .85; }
.daybar { width: 90px; height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.daybar i { display: block; height: 100%; width: 0; background: var(--accent); }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: rgba(255,255,255,.12); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; color: #fff; padding: 6px 10px; min-width: 34px; }
.seg button:hover { background: rgba(255,255,255,.15); }
.seg button.on { background: var(--accent); }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px;
  transition: transform .08s, background .15s;
}
.btn:hover:not(:disabled) { background: #f6f2e8; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #c4721f; }
.btn.danger { background: #fff1f0; border-color: #f2b8b5; color: var(--bad); font-weight: 700; }
.btn.danger.on { background: var(--bad); color: #fff; }
.btn.ghost { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.card .btn.ghost { background: #f4f1ea; color: var(--ink); }
.btn.small { padding: 4px 8px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 8px; }
.mini { border: 0; background: none; padding: 0 2px; font-size: 13px; }

/* ---------- layout ---------- */
main { flex: 1; display: flex; min-height: 0; }
#mapArea { flex: 1; position: relative; min-width: 0; display: flex; }
#mapWrap {
  flex: 1; overflow: auto; background: #5d6670; cursor: grab;
  overscroll-behavior: contain;
}
#mapWrap.dragging { cursor: grabbing; }
#map { padding: 12px; width: max-content; }
#map svg { display: block; border-radius: 6px; box-shadow: 0 6px 30px rgba(0,0,0,.35); user-select: none; }

#panel {
  width: 360px; flex: none; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px;
  border-left: 1px solid var(--line);
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.card .row { display: flex; gap: 8px; }
.card .row .btn { flex: 1; }
.hint { color: var(--muted); font-size: 12.5px !important; margin-top: 8px !important; }

#setupCard { border: 2px solid var(--accent); }

.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; position: relative; flex: none; box-shadow: 0 0 0 3px var(--target); }
.avatar i { position: absolute; inset: 9px; border-radius: 50%; }
.tname { font-weight: 700; font-size: 17px; }
.tmeta { color: var(--muted); font-size: 13px; }
.who .btn { margin-left: auto; }
.score { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 6px; margin-top: 12px; text-align: center; }
.score div { background: #f6f3ec; border-radius: 8px; padding: 6px 0; }
.score b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.score span { font-size: 11px; color: var(--muted); }
.score .ok b { color: var(--ok); } .score .bad b { color: var(--bad); } .score .miss b { color: var(--miss); }

.actgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.actgrid button {
  display: flex; align-items: center; gap: 6px; text-align: left; font-size: 13.5px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 8px;
}
.actgrid button:hover:not(:disabled) { border-color: var(--accent); background: #fff8ee; }
.actgrid button .e { font-size: 18px; width: 22px; text-align: center; }
.actgrid button.hic .e { font-size: 13px; font-weight: 900; color: var(--bad); }
.actgrid button.flash-ok { animation: flashOk .5s; }
.actgrid button.flash-bad { animation: flashBad .5s; }
@keyframes flashOk { 0% { background: #c8f2d6; } 100% { background: #fff; } }
@keyframes flashBad { 0% { background: #ffd2cf; } 100% { background: #fff; } }

.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 13px; }
.log.small { max-height: 160px; }
.log li { padding: 4px 6px; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.log li time { font-family: ui-monospace, Menlo, monospace; color: var(--muted); flex: none; }
.log li.ok { color: var(--ok); }
.log li.wrong { color: var(--bad); }
.log li.miss { color: var(--miss); }
.log li.info { color: var(--brand); }
.log li.empty { color: var(--muted); justify-content: center; }
.radar .log li.near { font-weight: 700; }

/* ---------- map overlays ---------- */
#banner {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); width: max-content; max-width: 90%;
  background: rgba(20,30,45,.92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 15px; box-shadow: 0 4px 20px rgba(0,0,0,.3); pointer-events: none;
}
#tooltip {
  position: fixed; z-index: 20; pointer-events: none; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.15); white-space: nowrap;
}
#tooltip b { font-size: 14px; }

/* ---------- SVG ---------- */
.roomlabel { font-size: 14px; font-weight: 700; fill: #4a525d; }
.roomlabel.small { font-size: 11px; font-weight: 600; }
.grouplabel { font-size: 20px; font-weight: 800; fill: #fff; }

#screens .scr { fill: #8fd0ff; }
#screens .glow { fill: #8fd0ff; opacity: .22; }
#screens g[data-scr="lock"] .scr, #screens g[data-scr="lock"] .glow { fill: #2a3d6e; }
#screens g[data-scr="off"] .scr { fill: #111; } #screens g[data-scr="off"] .glow { opacity: 0; }
#screens g[data-scr="saver"] .scr, #screens g[data-scr="saver"] .glow { fill: #b48cff; }
#screens g[data-scr="stock"] .scr, #screens g[data-scr="stock"] .glow { fill: #ff4040; }
#screens g[data-scr="shop"] .scr, #screens g[data-scr="shop"] .glow { fill: #ff9a2e; }
#screens g[data-scr="video"] .scr, #screens g[data-scr="video"] .glow { fill: #ff3b6b; }
#screens g[data-scr="code"] .scr, #screens g[data-scr="code"] .glow { fill: #39ff7a; animation: flicker .25s steps(2) infinite; }
@keyframes flicker { 50% { opacity: .4; } }

.agent { transition: opacity .5s; }
.agent.gone { opacity: 0; }
.agent .body { transform-box: fill-box; transform-origin: center; }
.agent.anim-shake .body { animation: shake .18s infinite; }
.agent.anim-nod .body { animation: nod 1.6s ease-in-out infinite; }
.agent.anim-grow .body { animation: grow 1s ease-in-out infinite; }
.agent.anim-comb .body { animation: comb .5s ease-in-out infinite; }
.agent.walking .body { animation: bob .35s ease-in-out infinite; }
@keyframes shake { 0%,100% { transform: translateX(-1.5px); } 50% { transform: translateX(1.5px); } }
@keyframes nod { 0%,100% { transform: scale(1); } 50% { transform: scale(.88); } }
@keyframes comb { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes grow { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@keyframes bob { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.ring { fill: none; stroke-width: 3; }
.ring.you { stroke: var(--you); }
.ring.target { stroke: var(--target); stroke-dasharray: 5 3; animation: spin 4s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.seatmark { stroke-width: 3; }
.seatmark.you { fill: rgba(242,183,5,.18); stroke: var(--you); }
.seatmark.target { fill: rgba(229,72,77,.14); stroke: var(--target); stroke-dasharray: 8 5; }
.tag { font-size: 11px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.tag.you { fill: #9a7300; } .tag.target { fill: var(--target); }

.bubble { transition: opacity .2s; }
.bubble .b { opacity: 0; transition: opacity .2s; }
.bubble.show .b { opacity: 1; }
.bubble rect.bg { fill: #fff; stroke: #c9ced6; }
.bubble text.em { font-size: 15px; text-anchor: middle; dominant-baseline: central; }
.bubble .hic { opacity: 0; }
.bubble .hic text { font-size: 14px; font-weight: 900; fill: #d6453d; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.bubble .hic circle { fill: none; stroke: #d6453d; stroke-width: 2; }
.bubble.hicOn .hic { animation: hicPop 1.2s ease-out forwards; }
.bubble.hicOn .hic circle { animation: wave 1.2s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes hicPop { 0% { opacity: 0; transform: translateY(6px); } 10% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
@keyframes wave { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(3.2); opacity: 0; } }
.poof { font-size: 22px; text-anchor: middle; dominant-baseline: central; animation: poof 1s forwards; pointer-events: none; }
@keyframes poof { 0% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

#hits rect { fill: transparent; cursor: pointer; }
#hits rect:hover { fill: rgba(255,255,255,.18); stroke: #fff; stroke-width: 2; }
body.picking #hits rect:hover { fill: rgba(242,183,5,.35); stroke: var(--you); stroke-width: 3; }
body.picking-target #hits rect:hover { fill: rgba(229,72,77,.3); stroke: var(--target); }
body.accusing #hits rect:hover { fill: rgba(214,69,61,.35); stroke: var(--bad); stroke-width: 3; }
body.accusing #mapWrap { cursor: crosshair; }
#marks .accused { font-size: 22px; text-anchor: middle; dominant-baseline: central; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #222b36; color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); animation: toastIn .25s, toastOut .4s 2.2s forwards; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); } .toast.gold { background: linear-gradient(90deg,#d9822b,#f2b705); font-weight: 700; font-size: 16px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,22,32,.55); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.sheet { background: var(--panel); border-radius: 16px; max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px 24px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.sheet .close { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 18px; color: var(--muted); }
.sheet h2 { margin: 0 0 4px; }
.sheet h4 { margin: 16px 0 6px; }
.sheet p, .sheet li { line-height: 1.6; font-size: 14.5px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sheet th, .sheet td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.sheet td.num, .sheet th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet .rank { font-size: 22px; font-weight: 800; color: var(--accent); margin: 8px 0; }
.sheet .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.sheet .actions .btn { flex: 1; }
.stamp { display: inline-block; border: 3px solid var(--bad); color: var(--bad); padding: 2px 10px; border-radius: 6px; font-weight: 800; transform: rotate(-4deg); }

/* ---------- share ---------- */
.share-preview { display: block; width: 100%; max-width: 320px; margin: 12px auto; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.sheet.has-head { padding-top: 0; max-width: 560px; }
.sheet.has-head > .close { display: none; }
.sheethead {
  display: flex; align-items: center; justify-content: space-between; margin: 0 -24px 14px; padding: 14px 24px;
  border-bottom: 1px solid var(--line); font-size: 14px; color: var(--accent); font-weight: 700;
}
.sheethead button { border: 0; background: none; color: var(--ink); font-size: 14px; padding: 6px 0 6px 12px; }
.sharelead { margin: 0 0 12px !important; font-size: 15px !important; }
.sharecard { border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.12); }
.sharecard .pic { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; background: #5d6670; border-bottom: 3px solid var(--accent); }
.sharecard .txt { padding: 12px 16px 12px; }
.sharecard .kicker { font-size: 11.5px; font-weight: 700; color: var(--ok); }
.sharecard .ttl { font-size: 24px; font-weight: 800; line-height: 1.25; margin: 2px 0 4px; }
.sharecard .meta { font-size: 13px; color: var(--ink); }
.sharecard .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.sharecard .foot b { font-family: ui-monospace, Menlo, monospace; font-weight: 600; color: var(--ink); white-space: nowrap; }
.sharebar { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.sharebar button { border: 1px solid #cfc8b8; border-radius: 4px; background: #fff; color: var(--ink); padding: 12px 8px; font-size: 15px; }
.sharebar button:hover { background: #fff8ee; border-color: var(--accent); }
.sharebar button b { font-weight: 500; }
.sharebar button.main { background: var(--accent); border-color: var(--accent); color: #fff; padding: 12px 8px 10px; }
.sharebar button.main:hover { background: #c4721f; }
.sharebar button.main b { display: block; font-size: 17px; font-weight: 800; }
.sharebar button.main small { display: block; font-size: 12px; opacity: .85; margin-top: 3px; }
.sharegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-note { font-size: 12.5px !important; color: var(--muted); margin-top: 10px !important; }

/* ---------- 外型升級 ---------- */
.lookline { margin-top: 8px; font-size: 13px; color: var(--accent); font-weight: 700; }
.miniscore em { font-style: normal; font-size: 15px; margin-left: 3px; }
.aura { animation: aura 0.9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes aura { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.15); opacity: 1; } }
.spikes { stroke: #e0a100; stroke-width: .8; }
.shades { fill: #111; stroke: #111; stroke-width: .8; }
.sparks path { fill: none; stroke: #1e8fff; stroke-width: 2.2; stroke-linejoin: round; animation: spark .3s steps(2) infinite; }
.sparks path:nth-child(2) { animation-delay: .15s; }
@keyframes spark { 50% { opacity: 0; } }

.mobile-only { display: none !important; }
button { touch-action: manipulation; }
#mapWrap { touch-action: pan-x pan-y; display: flex; }
#map { margin: auto; }
#followBtn.on { background: var(--target); }
.stack { display: contents; }
.actgrid button .s { display: none; }
#clock.ff::after { content: '⏩'; font-size: .55em; margin-left: 4px; vertical-align: middle; }

/* 手機版精簡辦公室：縮小顯示，字要大一點 */
.roomlabel.big { font-size: 19px; font-weight: 800; }
body.compact .tag { font-size: 14px; }
body.compact .grouplabel { font-size: 22px; }

@media (max-width: 900px) {
  .mobile-only { display: revert !important; }
  .desktop-only, #speedSeg, #followBtn, #toMe { display: none !important; }
  html, body { height: 100%; }
  body { height: 100dvh; overflow: hidden; -webkit-tap-highlight-color: transparent; }
  main { flex-direction: column; min-height: 0; flex: 1; }
  #mapArea { flex: 1; min-height: 0; }
  #map { padding: 6px; }

  /* 上方：只放狀態（時鐘、分數）與不常用的按鈕 */
  .topbar { gap: 8px; padding: 5px 10px; padding-top: max(5px, env(safe-area-inset-top)); flex-wrap: nowrap; }
  .brand { display: none; }
  .clockbox { margin-left: 0; gap: 7px; }
  #dayLabel { font-size: 12px; white-space: nowrap; }
  .daybar { display: none; }
  #clock { font-size: 21px; padding: 3px 8px; letter-spacing: 1px; white-space: nowrap; }
  .miniscore { display: flex !important; align-items: baseline; gap: 2px; background: rgba(255,255,255,.14); padding: 4px 9px; border-radius: 999px; }
  .miniscore b { font-size: 17px; font-variant-numeric: tabular-nums; }
  .miniscore span { font-size: 11px; opacity: .8; }
  .controls { margin-left: auto; gap: 4px; flex-wrap: nowrap; }
  .controls .btn.ghost { width: 40px; height: 40px; padding: 0; font-size: 18px; border-radius: 11px; }
  .controls .lbl { display: none; }

  /* 放大後回到全覽 */
  #fitBtn {
    position: absolute; right: 10px; bottom: 10px; z-index: 6; display: block !important;
    width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92);
    box-shadow: 0 3px 12px rgba(0,0,0,.3); font-size: 22px; font-weight: 800; color: var(--ink);
  }

  /* 下方：操作面板（高度跟著內容，地圖吃掉剩下的空間） */
  #panel {
    width: 100%; flex: none; max-height: 62dvh; border-left: 0; border-top: 1px solid var(--line);
    padding: 7px 7px calc(7px + env(safe-area-inset-bottom)); gap: 7px; overflow-y: auto; background: var(--bg);
    overscroll-behavior: contain;
  }
  body.setup .stack, body.setup #targetCard { display: none !important; }
  /* 上面是日誌／雷達的小視窗，下面永遠是記錄按鈕，兩邊都不用切換就按得到 */
  .stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .stack > .feedtabs { grid-row: 1; display: flex !important; gap: 5px; }
  .stack > .card[data-tab="log"], .stack > .card[data-tab="radar"] {
    grid-row: 2; grid-column: 1; height: 76px; overflow-y: auto; padding: 2px 8px; overscroll-behavior: contain;
  }
  .stack > #actCard { grid-row: 3; }
  #panel[data-tab="log"] .stack > .card[data-tab="radar"],
  #panel[data-tab="radar"] .stack > .card[data-tab="log"] { visibility: hidden; }
  .stack > .card[data-tab="log"] h3, .stack > .card[data-tab="radar"] h3, .radar .hint, #accuseBtn { display: none; }
  .stack .log { font-size: 13px; }
  .stack .log li { padding: 4px 2px; }
  .feedtabs button {
    position: relative; height: 30px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line);
    background: #fff; font-size: 13px; font-weight: 700; color: var(--muted);
  }
  .feedtabs button.on { color: var(--accent); border-color: var(--accent); background: #fff4e6; }
  .feedtabs i { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }

  .card { padding: 10px; }
  .card h3 { font-size: 15px; margin-bottom: 6px; }
  .card .row .btn, #startBtn, #accuseBtn { min-height: 50px; font-size: 16px; }

  /* 目標＋操作列：一行 */
  #targetCard { display: flex !important; align-items: center; gap: 6px; padding: 5px 5px 5px 8px; }
  #targetCard[hidden] { display: none !important; }
  .who { flex: 1; min-width: 0; gap: 7px; cursor: pointer; }
  .whotext { min-width: 0; flex: 1; }
  .avatar { width: 30px; height: 30px; box-shadow: 0 0 0 2.5px var(--target); }
  .avatar i { inset: 6px; }
  .tname { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tmeta { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #renameBtn, #switchBtn, .score, .lookline { display: none; }
  .strip { display: flex !important; gap: 5px; flex: none; }
  .strip button {
    width: 44px; height: 44px; padding: 0; border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
    font-size: 20px; font-weight: 800; position: relative;
  }
  .strip button.on { background: #fff4e6; border-color: var(--accent); }
  .strip button.main { background: var(--accent); border-color: var(--accent); color: #fff; }
  .strip button.danger { border-color: #f2b8b5; background: #fff1f0; }
  .strip button.danger.on { background: var(--bad); }
  .strip #speedCycle { font-size: 15px; white-space: nowrap; }
  .strip button:active:not(:disabled) { transform: scale(.92); }
  .strip i { position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
  .strip i.cnt {
    width: auto; height: auto; top: -6px; right: -5px; min-width: 17px; padding: 0 4px; border-radius: 999px;
    font-size: 11px; font-style: normal; line-height: 17px; color: #fff;
  }

  /* 記錄按鈕：全部一次看完，不用捲 */
  #actCard { padding: 5px; }
  #actCard h3, #actCard .hint { display: none; }
  .actgrid { grid-template-columns: repeat(7, 1fr); gap: 5px; }
  .actgrid button {
    flex-direction: column; justify-content: center; text-align: center; gap: 3px; min-width: 0;
    padding: 5px 0 4px; min-height: 54px; font-size: min(10.5px, 2.8vw); line-height: 1.15; border-radius: 10px;
    border-width: 1.5px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
  }
  .actgrid button .n { display: none; }
  .actgrid button .s { display: block; white-space: nowrap; }
  .actgrid button .e { font-size: 22px; width: auto; line-height: 1; }
  .actgrid button.hic .e { font-size: 15px; line-height: 22px; }
  .actgrid button:active:not(:disabled) { transform: scale(.93); background: #fff1de; border-color: var(--accent); }
  .log.small { max-height: none; }

  #toasts { top: auto; bottom: calc(var(--panel-h, 40dvh) + 10px); }
  .toast { font-size: 14px; padding: 8px 14px; }
  #banner { top: 10px; bottom: auto; font-size: 14px; padding: 9px 16px; max-width: calc(100% - 24px); white-space: normal; text-align: center; }

  .modal { padding: 0; align-items: flex-end; }
  .sheet { border-radius: 18px 18px 0 0; max-height: 92dvh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .sheet .close { width: 44px; height: 44px; right: 6px; top: 6px; font-size: 20px; }
  .sheet .actions .btn { flex: 1 1 100%; min-height: 50px; font-size: 16px; }
  .sheethead { margin: 0 -16px 12px; padding: 12px 16px; }
  .sheethead button { min-height: 32px; }
  .sharebar button { min-height: 48px; }
  .sharecard .ttl { font-size: 21px; }
}

@media (max-width: 370px) {
  #dayLabel { display: none; }
  .actgrid { grid-template-columns: repeat(6, 1fr); }
  .strip { gap: 4px; }
  .strip button { width: 40px; }
}

/* 矮的手機（iPhone SE 之類）：日誌只留兩行、按鈕矮一點，全部記錄按鈕不用捲就按得到 */
@media (max-width: 900px) and (max-height: 720px) {
  .stack > .card[data-tab="log"], .stack > .card[data-tab="radar"] { height: 52px; }
  .feedtabs button { height: 26px; font-size: 12px; }
  .actgrid button { min-height: 46px; gap: 2px; padding: 3px 0; }
  .actgrid button .e { font-size: 19px; }
  .actgrid button.hic .e { font-size: 13px; line-height: 19px; }
}
