/* [claude code] 2026-08-29 Phase 0:籃球總經理 client 樣式
 *
 * 🔴 字級全部走這六個變數 —— 手機上只要改 :root 那一處。
 * (baseball_life 的教訓:字級散在四十幾個地方,手機實測完要改得到處都是)
 */
:root {
  --f-xs: 11px;
  --f-sm: 12px;
  --f-md: 14px;
  --f-lg: 17px;
  --f-xl: 22px;
  --f-xxl: 30px;

  --bg: #0d1220;
  --bg2: #141b2d;
  --bg3: #1c2540;
  --line: #26314f;
  --tx: #e8edf7;
  --tx2: #94a3c4;
  --tx3: #64708f;
  --acc: #ff8b3d;
  --acc2: #4d94ff;
  --ok: #35c46a;
  --bad: #ef4d5e;
  --warn: #f5b73d;
  --team: #ff8b3d;

  --r: 10px;
  --pad: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--tx);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  font-size: var(--f-md);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

.screen { min-height: 100vh; }
[hidden] { display: none !important; }

/* ── 開局 ───────────────────────────────────────── */
#setup {
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 14px 40px;
}
.setup-box { width: 100%; max-width: 720px; }
.setup-box h1 { font-size: var(--f-xxl); letter-spacing: 1px; }
.tagline { color: var(--tx2); font-size: var(--f-md); margin: 6px 0 22px; }
.tagline b { color: var(--acc); }

.field { margin-bottom: 18px; }
.field > label {
  display: block; font-size: var(--f-sm); color: var(--tx2);
  margin-bottom: 7px; font-weight: 600;
}
.hint { color: var(--tx3); font-weight: 400; }

input[type=text], input[type=number], select {
  width: 100%; background: var(--bg2); color: var(--tx);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; font-size: var(--f-md); font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--acc2); }

.segs { display: flex; gap: 8px; flex-wrap: wrap; }
.seg {
  flex: 1; min-width: 130px; background: var(--bg2); color: var(--tx2);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; font-size: var(--f-sm); font-family: inherit;
  cursor: pointer; text-align: left;
}
.seg.on { background: var(--bg3); color: var(--tx); border-color: var(--acc); }

.team-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 7px; max-height: 340px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px;
}
.team-card {
  background: var(--bg3); border: 1px solid transparent; border-radius: 8px;
  padding: 8px 6px; cursor: pointer; text-align: center;
  border-left: 3px solid var(--c, var(--line));
}
.team-card.on { border-color: var(--acc); background: #2a2013; }
.team-card .ab { font-weight: 700; font-size: var(--f-md); letter-spacing: .5px; }
.team-card .nm { font-size: var(--f-xs); color: var(--tx2); margin-top: 2px; }

button.primary {
  background: var(--acc); color: #1a1005; border: none; border-radius: var(--r);
  padding: 12px 18px; font-size: var(--f-md); font-weight: 700;
  font-family: inherit; cursor: pointer;
}
button.primary:disabled { background: var(--bg3); color: var(--tx3); cursor: default; }
button.primary.big { width: 100%; padding: 15px; font-size: var(--f-lg); }
button.ghost {
  background: var(--bg3); color: var(--tx); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 14px; font-size: var(--f-sm);
  font-family: inherit; cursor: pointer;
}
button.ghost.sm { padding: 6px 10px; }
button.ghost:disabled { color: var(--tx3); cursor: default; }
button.danger { background: #3a1620; color: #ffb3bc; border-color: #5c2230; }

.setup-foot { text-align: center; color: var(--tx3); font-size: var(--f-xs); margin-top: 16px; }
.setup-saves { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: var(--pad); margin-bottom: 20px; }
.setup-saves h3 { font-size: var(--f-md); margin-bottom: 8px; }
.or { text-align: center; color: var(--tx3); font-size: var(--f-sm); margin-top: 10px; }
.save-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg3); border-radius: 8px; padding: 9px 11px; margin-bottom: 6px;
  cursor: pointer;
}
.save-row:hover { background: #222c4a; }
.save-row .s-main { font-size: var(--f-sm); }
.save-row .s-sub { font-size: var(--f-xs); color: var(--tx2); }

/* ── 主畫面骨架 ─────────────────────────────────── */
#game { display: flex; flex-direction: column; height: 100vh; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px var(--pad); background: var(--bg2);
  border-bottom: 1px solid var(--line); flex: none;
}
.top-team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team-dot { width: 10px; height: 34px; border-radius: 3px; background: var(--team); flex: none; }
.team-name { font-size: var(--f-lg); font-weight: 700; line-height: 1.15; }
.team-sub { font-size: var(--f-xs); color: var(--tx2); }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.phase-pill {
  background: var(--bg3); border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px; font-size: var(--f-xs); color: var(--tx2); white-space: nowrap;
}

.tabs {
  display: flex; background: var(--bg2); border-bottom: 1px solid var(--line);
  overflow-x: auto; flex: none; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; min-width: 62px; background: none; border: none; color: var(--tx3);
  padding: 11px 6px; font-size: var(--f-sm); font-family: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.on { color: var(--acc); border-bottom-color: var(--acc); font-weight: 600; }

#main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pane { display: none; padding: var(--pad); padding-bottom: 20px; }
.pane.on { display: block; }

.actionbar {
  display: flex; gap: 8px; padding: 10px var(--pad);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--bg2); border-top: 1px solid var(--line); flex: none;
}
.actionbar button { flex: 1; }

/* ── 卡片與表格 ─────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--r); padding: var(--pad); margin-bottom: 11px;
}
.card > h3 {
  font-size: var(--f-sm); color: var(--tx2); font-weight: 600;
  margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center;
}
.card > h3 .r { color: var(--tx3); font-weight: 400; }

.stat-row { display: flex; gap: 8px; }
.stat {
  flex: 1; background: var(--bg3); border-radius: 8px; padding: 9px 7px; text-align: center;
}
.stat .v { font-size: var(--f-lg); font-weight: 700; line-height: 1.2; }
.stat .k { font-size: var(--f-xs); color: var(--tx2); margin-top: 1px; }
.stat .v.good { color: var(--ok); }
.stat .v.bad { color: var(--bad); }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--f-sm); }
th {
  text-align: right; color: var(--tx3); font-weight: 600; font-size: var(--f-xs);
  padding: 6px 5px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: var(--bg2);
}
th.l, td.l { text-align: left; }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--tx); }
th.sorted { color: var(--acc); }
td {
  text-align: right; padding: 7px 5px; border-bottom: 1px solid #1c2338;
  white-space: nowrap;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #1a2338; }
tr.mine td { background: #1d2233; }
tr.mine td:first-child { box-shadow: inset 3px 0 0 var(--acc); }

.pname { font-weight: 600; }
.ptag { font-size: var(--f-xs); color: var(--tx3); }
.ovr { font-weight: 700; }
.pos-chip {
  display: inline-block; background: var(--bg3); border-radius: 4px;
  padding: 1px 5px; font-size: var(--f-xs); color: var(--tx2); min-width: 26px; text-align: center;
}

/* 能力條 */
.rt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px 14px; }
.rt { display: flex; align-items: center; gap: 7px; font-size: var(--f-xs); }
.rt .n { color: var(--tx2); width: 28px; flex: none; }
.rt .bar { flex: 1; height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.rt .bar i { display: block; height: 100%; background: var(--acc2); }
.rt .v { width: 20px; text-align: right; color: var(--tx); flex: none; }

/* log */
.log { font-size: var(--f-sm); max-height: 260px; overflow-y: auto; }
.log div { padding: 4px 0; border-bottom: 1px solid #1a2135; color: var(--tx2); }
.log div:last-child { border: none; color: var(--tx); }

/* 比賽結果 */
.g-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 9px; background: var(--bg3); border-radius: 7px; margin-bottom: 5px;
  font-size: var(--f-sm);
}
.g-row.win { border-left: 3px solid var(--ok); }
.g-row.loss { border-left: 3px solid var(--bad); }
.g-row.next { border-left: 3px solid var(--tx3); color: var(--tx2); }

.msg {
  background: #1b2740; border-left: 3px solid var(--acc2); border-radius: 7px;
  padding: 10px 12px; font-size: var(--f-sm); margin-bottom: 11px;
}
.msg.warn { background: #2b2412; border-left-color: var(--warn); }
.msg.bad { background: #2b1620; border-left-color: var(--bad); }
.msg.good { background: #14291d; border-left-color: var(--ok); }

.empty { color: var(--tx3); text-align: center; padding: 26px 10px; font-size: var(--f-sm); }

/* 交易機 */
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.trade-side { background: var(--bg3); border-radius: 8px; padding: 9px; min-height: 90px; }
.trade-side h4 { font-size: var(--f-xs); color: var(--tx2); margin-bottom: 7px; }
.chip {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg2); border-radius: 6px; padding: 6px 8px;
  margin-bottom: 4px; font-size: var(--f-xs); cursor: pointer;
}
.chip:hover { background: #222c48; }
.chip .x { color: var(--bad); font-weight: 700; }
.pick-chip { border-left: 2px solid var(--acc2); }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.pill {
  background: var(--bg3); border: 1px solid var(--line); border-radius: 16px;
  padding: 5px 11px; font-size: var(--f-xs); color: var(--tx2);
  cursor: pointer; font-family: inherit;
}
.pill.on { background: var(--acc); color: #1a1005; border-color: var(--acc); font-weight: 600; }

/* 彈窗 */
.modal {
  position: fixed; inset: 0; background: rgba(4,7,14,.78);
  display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 50;
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto;
  position: relative;
}
.modal-x {
  position: absolute; top: 10px; right: 10px; background: none; border: none;
  color: var(--tx3); font-size: var(--f-lg); cursor: pointer; padding: 4px 8px;
}
.modal-box h2 { font-size: var(--f-lg); margin-bottom: 3px; padding-right: 30px; }
.modal-sub { color: var(--tx2); font-size: var(--f-sm); margin-bottom: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--line); border-radius: 22px;
  padding: 10px 18px; font-size: var(--f-sm); z-index: 60; max-width: 88vw;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.toast.bad { background: #3a1620; border-color: #5c2230; color: #ffb3bc; }
.toast.good { background: #14291d; border-color: #245e39; color: #a8f0c0; }

/* 桌機 */
@media (min-width: 760px) {
  :root { --f-xs: 12px; --f-sm: 13px; --f-md: 15px; --f-lg: 19px; --f-xl: 25px; --f-xxl: 34px; --pad: 16px; }
  .pane { max-width: 1100px; margin: 0 auto; }
  .tabs { justify-content: center; }
  .tab { flex: none; min-width: 96px; }
  .actionbar { max-width: 1100px; margin: 0 auto; width: 100%; }
  .rt-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── 調度分頁(Phase 1)────────────────────────────── */

.min-bar {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  background: var(--bg3); border-radius: 8px; padding: 9px 12px; margin-bottom: 10px;
}
.min-total { font-size: var(--f-xl); font-weight: 700; line-height: 1; }
.min-total span { font-size: var(--f-sm); font-weight: 400; color: var(--tx2); }
.min-total.ok { color: var(--ok); }
.min-total.off { color: var(--warn); }
.min-hint { font-size: var(--f-xs); color: var(--tx2); }

.rot-list { display: flex; flex-direction: column; gap: 4px; }
.rot-row {
  display: grid;
  grid-template-columns: 34px 1fr 42px auto auto;
  align-items: center; gap: 6px;
  background: var(--bg3); border-radius: 7px; padding: 6px 8px;
  border-left: 3px solid transparent;
}
.rot-row.starter { border-left-color: var(--acc); background: #232c46; }
.rot-row.bench { cursor: pointer; grid-template-columns: 34px 1fr 42px auto; }
.rot-row.bench:hover { background: #2a3352; }
.rot-num {
  font-size: var(--f-xs); color: var(--tx3); text-align: center;
}
.rot-row.starter .rot-num { color: var(--acc); font-weight: 700; }
.rot-name { min-width: 0; font-size: var(--f-sm); overflow: hidden; }
.rot-name b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rot-ovr { text-align: right; font-size: var(--f-sm); }
.rot-min { display: flex; align-items: center; gap: 2px; }
.rot-move { display: flex; gap: 2px; }
.rot-add { color: var(--acc); font-size: var(--f-lg); text-align: center; }

.mbtn {
  background: var(--bg2); color: var(--tx2); border: 1px solid var(--line);
  border-radius: 5px; width: 26px; height: 28px; font-size: var(--f-sm);
  font-family: inherit; cursor: pointer; padding: 0;
}
.mbtn:hover:not(:disabled) { background: var(--line); color: var(--tx); }
.mbtn:disabled { opacity: .3; cursor: default; }
.mbtn.del { color: var(--bad); }
.min-in {
  width: 42px; text-align: center; padding: 5px 2px;
  font-size: var(--f-sm); background: var(--bg2); color: var(--tx);
  border: 1px solid var(--line); border-radius: 5px;
  -moz-appearance: textfield;
}
.min-in::-webkit-outer-spin-button, .min-in::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}

.tac-row { margin-bottom: 13px; }
.tac-row:last-child { margin-bottom: 0; }
.tac-label { font-size: var(--f-sm); color: var(--tx2); font-weight: 600; margin-bottom: 5px; }
.tac-desc {
  font-size: var(--f-xs); color: var(--tx2); margin-top: 6px;
  padding-left: 9px; border-left: 2px solid var(--line); line-height: 1.5;
}

@media (max-width: 420px) {
  .rot-row { grid-template-columns: 28px 1fr 36px auto; }
  /* 手機上把上下移按鈕收起來 —— 五欄擠不下,而排序在手機上本來就難點 */
  .rot-move [data-up], .rot-move [data-down] { display: none; }
}

/* ── Phase 2:圖表與 box score ─────────────────────── */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-axis {
  display: flex; justify-content: space-between;
  font-size: var(--f-xs); color: var(--tx3); margin-top: 3px;
}
.chart-label { font-size: var(--f-xs); color: var(--tx2); margin-bottom: 2px; }
.chart-label b { color: var(--tx); font-size: var(--f-sm); }

.g-list { max-height: 320px; overflow-y: auto; }
.g-row.clickable { cursor: pointer; }
.g-row.clickable:hover { background: #232c48; }

.box-team { margin-bottom: 14px; }
.box-team-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 9px; background: var(--bg3); border-radius: 7px 7px 0 0;
  font-size: var(--f-sm);
}
.box-score { font-size: var(--f-xl); font-weight: 700; }
.box-tbl { font-size: var(--f-xs); }
.box-tbl th { font-size: 10px; padding: 5px 3px; }
.box-tbl td { padding: 5px 3px; }
.box-tbl tr.best td { background: #2a2416; }
.box-tbl tr.best td:first-child { box-shadow: inset 3px 0 0 var(--acc); }
.box-tbl tfoot td {
  border-top: 1px solid var(--line); border-bottom: none;
  color: var(--tx2); font-size: var(--f-xs);
}

/* ── Phase 3:更衣室與個性 ─────────────────────────── */

.chem-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 9px;
}
.chem-score { font-size: var(--f-xxl); font-weight: 700; line-height: 1; }
.chem-level { font-size: var(--f-sm); font-weight: 600; margin-left: 7px; }
.chem-mood { font-size: var(--f-xs); color: var(--tx2); }
.chem-mood b { color: var(--tx); font-size: var(--f-sm); }

.chem-notes { display: flex; flex-direction: column; gap: 4px; }
.chem-note {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--bg3); border-radius: 6px; padding: 7px 9px;
  font-size: var(--f-sm); border-left: 3px solid var(--line);
}
/* 台灣紅賺綠賠 —— 但這裡是「好 / 壞」不是「漲 / 跌」,用中性的暖冷色 */
.chem-note.good { border-left-color: var(--ok); }
.chem-note.bad { border-left-color: var(--bad); }
.chem-delta { font-size: var(--f-xs); color: var(--tx3); flex: none; }
.chem-note.good .chem-delta { color: var(--ok); }
.chem-note.bad .chem-delta { color: var(--bad); }

.pers-tag-only {
  background: var(--bg3); border-radius: 7px; padding: 10px;
  text-align: center; font-size: var(--f-md); color: var(--tx2);
}
.mood-why {
  margin-top: 9px; padding: 8px 10px; background: var(--bg3);
  border-radius: 7px; font-size: var(--f-sm); color: var(--tx2);
}
.mood-why b { color: var(--tx); }
