/* ============================================================
   NICEPLAY · 視覺系統
   ------------------------------------------------------------
   沿用《臺東卡牌大賽 · 寶可夢道館賽》現場實戰的主視覺：
     · 純黑底 + 純白大字（投影在暗場最清楚）
     · 電光藍 = 主要動作 · 萊姆綠 = 進行中／勝
     · 紅 = 對手側／警示 · 橄欖金 = 眉標與次要資訊
     · 桌號用襯線體、數字用等寬體、中文用黑體
   色值取樣自實際主視覺，非目測。

   現場不接外網，一律走系統字型，不載任何 webfont。
   ============================================================ */

:root {
  --black:      #000000;
  --ink:        #0B0B0D;   /* 卡片底，比純黑亮一階好分層 */
  --ink-2:      #14141A;
  --white:      #FAFAFA;
  --blue:       #1824E4;   /* 電光藍 */
  --blue-soft:  #7C86FF;
  --lime:       #B0D000;   /* 進行中 · 勝 · 晉級 */
  --red:        #D8285F;   /* 對手側 · 警示 */
  --pink:       #FFB4C6;
  --gold:       #A89330;   /* 眉標 */
  --gold-dim:   #4A4218;

  --line:       rgba(250,250,250,.14);
  --line-hard:  rgba(250,250,250,.30);
  --dim:        rgba(250,250,250,.60);
  --faint:      rgba(250,250,250,.34);

  --f-cn:    "PingFang TC","Noto Sans TC","Microsoft JhengHei","Heiti TC",sans-serif;
  --f-serif: "Songti TC","Times New Roman","PMingLiU",serif;
  --f-mono:  "SF Mono",Menlo,Consolas,"JetBrains Mono",monospace;

  --r: 10px;
  --tap: 48px;             /* 觸控目標下限 */
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--black);
  color: var(--white);
  font-family: var(--f-cn);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ── 頂列 ───────────────────────────────────────────── */
.top {
  flex: 0 0 auto; background: var(--ink);
  border-bottom: 2px solid var(--line-hard);
  padding: 10px 14px; display: flex; align-items: center; gap: 12px;
}
.brand {
  font-family: var(--f-mono); font-size: 12px; font-weight: 700;
  letter-spacing: .22em; color: var(--lime); white-space: nowrap;
}
.brand span { color: var(--faint); letter-spacing: .12em; }
.evt { flex: 1; min-width: 0; font-size: 14px; color: var(--dim);
       white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .clock { font-family: var(--f-mono); font-size: 15px; color: var(--dim); }

/* ── 分頁 ───────────────────────────────────────────── */
.tabs { flex: 0 0 auto; display: flex; gap: 2px; background: var(--black);
        border-bottom: 2px solid var(--line-hard); }
.tabs button {
  flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--dim);
  min-height: 52px; font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; letter-spacing: .04em;
}
.tabs button.on { background: var(--ink); color: var(--lime);
                  box-shadow: inset 0 -3px 0 var(--lime); }
.tabs button:disabled { opacity: .3; cursor: default; }

/* ── 內容區 ─────────────────────────────────────────── */
.pane { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: none;
        -webkit-overflow-scrolling: touch; }
.pane.on { display: block; }
.wrap { max-width: 820px; margin: 0 auto; }

h2.sec {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-size: 11px; font-weight: 400;
  letter-spacing: .2em; text-transform: uppercase; color: var(--gold);
  margin: 0 0 12px;
}
h2.sec::after { content: ''; flex: 1; height: 1px; background: var(--gold-dim); }
h2.sec em { font-style: normal; font-family: var(--f-cn); font-size: 14px;
            font-weight: 700; letter-spacing: 0; color: var(--white); }
h2.sec + .row, h2.sec + .grid { margin-top: 0; }
.sec-gap { margin-top: 26px; }

/* ── 表單 ───────────────────────────────────────────── */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.row > .grow { flex: 1 1 160px; min-width: 0; }
label.fld { display: flex; flex-direction: column; gap: 5px; flex: 1 1 150px; min-width: 0; }
label.fld > span { font-family: var(--f-mono); font-size: 10px; letter-spacing: .16em;
                   text-transform: uppercase; color: var(--faint); }

input[type=text], input[type=number], select, textarea {
  background: var(--ink); color: var(--white);
  border: 2px solid var(--line-hard); border-radius: var(--r);
  padding: 0 12px; min-height: var(--tap);
  font-family: inherit; font-size: 16px; width: 100%;
}
textarea { padding: 10px 12px; min-height: 132px; line-height: 1.7; resize: vertical;
           font-size: 15px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--lime); outline-offset: 2px;
}
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--dim) 50%),
  linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 12px) 21px;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 34px; }

button {
  font-family: inherit; font-size: 15px; font-weight: 700; letter-spacing: .02em;
  color: var(--white); background: var(--ink);
  border: 2px solid var(--line-hard); border-radius: var(--r);
  padding: 0 16px; min-height: var(--tap); cursor: pointer;
  transition: transform .06s, filter .12s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .35; cursor: default; }
button.go   { background: var(--lime); border-color: var(--lime); color: var(--black); font-weight: 900; }
button.main { background: var(--blue); border-color: var(--blue); color: var(--white); font-weight: 900; }
button.warn { background: var(--gold); border-color: var(--gold); color: var(--black); font-weight: 900; }
button.danger { border-color: var(--red); color: var(--pink); }
button.sm { min-height: 40px; font-size: 13px; padding: 0 12px; font-weight: 500; }
button.big { min-height: 60px; font-size: 18px; }

.hint { font-size: 13px; color: var(--dim); line-height: 1.7; margin-top: 8px; }
.hint b { color: var(--white); }
.ok  { color: var(--lime); font-weight: 700; }
.bad { color: var(--pink); font-weight: 700; }

/* ── 名單 ───────────────────────────────────────────── */
.roster { display: flex; flex-wrap: wrap; gap: 7px; }
.nm {
  display: flex; align-items: center; gap: 7px;
  background: var(--ink); border: 2px solid var(--line-hard); border-radius: 999px;
  padding: 8px 14px; font-size: 15px; font-weight: 700; min-height: 42px; cursor: pointer;
}
.nm i { font-style: normal; font-family: var(--f-mono); font-size: 11px; font-weight: 700;
        background: var(--line-hard); padding: 2px 6px; border-radius: 3px; min-width: 22px;
        text-align: center; }
.nm.out { opacity: .5; border-style: dashed; border-color: var(--red); color: var(--pink); }
.nm.out span { text-decoration: line-through; text-decoration-thickness: 2px; }
.nm.out i { background: var(--red); }

/* ── 對戰卡 ─────────────────────────────────────────── */
.mt { display: flex; align-items: stretch; gap: 8px; margin-bottom: 9px; }
.mt .tb {
  flex: 0 0 46px; height: 46px; align-self: center;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-serif); font-size: 20px; font-weight: 700;
  border: 2px solid var(--line-hard); border-radius: 50%;
}
.mt.done .tb { border-color: var(--lime); color: var(--lime); }
.mt.islive .tb { box-shadow: 0 0 0 3px rgba(176,208,0,.25); }
.mt .sd {
  flex: 1 1 0; min-width: 0; background: var(--ink);
  border: 2px solid var(--line-hard); border-radius: var(--r);
  padding: 9px 12px; min-height: 56px; display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mt .sd i { font-style: normal; font-family: var(--f-mono); font-size: 11px; font-weight: 700;
            background: var(--line-hard); padding: 2px 6px; border-radius: 3px;
            min-width: 22px; text-align: center; flex: 0 0 auto; }
.mt .sd .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mt .sd.win { background: var(--lime); border-color: var(--lime); color: var(--black); }
.mt .sd.win i { background: rgba(0,0,0,.35); color: var(--white); }
.mt .sd.win::after { content: '勝'; margin-left: auto; font-size: 13px; font-weight: 900; }
.mt .sd.lose { color: rgba(250,250,250,.42); }
.mt .sd.lose i { opacity: .55; }
.mt .sd.bye { opacity: .55; cursor: default; justify-content: center; font-weight: 400; }
.mt .dw {
  flex: 0 0 54px; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--line-hard); border-radius: var(--r);
  font-size: 13px; color: var(--dim); cursor: pointer; min-height: 56px;
}
.mt .dw.on { background: var(--gold); border-style: solid; border-color: var(--gold);
             color: var(--black); font-weight: 900; }

.prog { display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
        font-family: var(--f-mono); font-size: 12px; letter-spacing: .12em; color: var(--dim); }
.prog b { color: var(--lime); font-size: 22px; font-weight: 700; }
.prog .bar { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--lime); transition: width .3s; }

/* ── 排名表 ─────────────────────────────────────────── */
table.rank { width: 100%; border-collapse: collapse; font-size: 15px; }
table.rank th {
  font-family: var(--f-mono); font-size: 10px; font-weight: 400; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold); text-align: right;
  padding: 7px 6px; border-bottom: 1px solid var(--gold-dim); white-space: nowrap;
}
table.rank th.l { text-align: left; }
table.rank td { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: right;
                font-variant-numeric: tabular-nums; white-space: nowrap; }
table.rank td.l { text-align: left; width: 99%; }
table.rank td.rk { font-weight: 900; text-align: center; width: 34px; }
table.rank td.pt { color: var(--lime); font-weight: 900; font-size: 17px; }
table.rank tr.cut td { background: rgba(176,208,0,.09); }
table.rank tr.cutline td { border-bottom: 2px solid var(--lime); }
table.rank tr.out td { opacity: .4; }
table.rank tr.out td.l { text-decoration: line-through; }
.nmcell { display: flex; align-items: center; gap: 7px; }
.nmcell i { font-style: normal; font-family: var(--f-mono); font-size: 11px; font-weight: 700;
            background: var(--line-hard); padding: 2px 5px; border-radius: 3px;
            min-width: 22px; text-align: center; }
.dropb { border: 2px solid var(--line-hard); border-radius: 7px; padding: 3px 9px;
         font-size: 12px; color: var(--dim); background: transparent; min-height: 30px; }
.dropb.on { border-color: var(--red); color: var(--pink); }

/* ── 危險區 ─────────────────────────────────────────── */
.danger-zone { margin-top: 26px; padding: 14px; border: 2px dashed var(--red);
               border-radius: var(--r); }

/* ── 投影模式 ───────────────────────────────────────── */
body.present .top, body.present .tabs { display: none; }
body.present .pane { padding: 0; }
#present { display: none; position: fixed; inset: 0; background: var(--black); z-index: 50;
           flex-direction: column; }
body.present #present { display: flex; }

.pv-hd { flex: 0 0 auto; display: flex; align-items: stretch; gap: 1.5vw;
         padding: 1.3vw 2.1vw 1.1vw; border-bottom: 1px solid var(--line-hard); }
.pv-tag {
  position: relative; flex: 0 0 auto; width: 7.4vw; height: 7.4vw;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-serif); font-size: 2.6vw; font-weight: 700;
  border: .22vw solid var(--white); border-radius: 50%; text-align: center; line-height: 1.1;
}
.pv-name { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.pv-name b { font-size: 3.4vw; font-weight: 900; line-height: 1.06; }
.pv-name span { font-size: 1.3vw; color: var(--dim); margin-top: .4vw; }
.pv-count { flex: 0 0 auto; display: flex; flex-direction: column;
            align-items: flex-end; justify-content: center; min-width: 12vw; }
.pv-count b { font-family: var(--f-mono); font-size: 8.4vw; font-weight: 700;
              line-height: .86; letter-spacing: -.035em; }
.pv-count i { font-style: normal; margin-top: .4vw; font-family: var(--f-mono);
              font-size: 1vw; letter-spacing: .18em; color: var(--gold); }
.pv-count.warn b { color: var(--gold); }
.pv-count.urgent b { color: var(--red); }
.pv-body { flex: 1 1 auto; padding: 1.4vw 2.1vw; overflow: hidden; }
.pv-ft { flex: 0 0 auto; display: flex; align-items: center; gap: 1.5vw;
         padding: .85vw 2.1vw; border-top: 1px solid var(--gold-dim);
         font-size: 1.4vw; background: var(--black); }
.pv-ft .k { font-family: var(--f-mono); font-size: .9vw; letter-spacing: .2em;
            text-transform: uppercase; color: var(--gold); }
.pv-ft .grow { flex: 1; }
.pv-ft .exit { font-size: .95vw; color: var(--faint); }

.pv-grid { display: grid; gap: .6vw; height: 100%; }
.pv-seat { position: relative; overflow: hidden; background: var(--ink);
           border: 1px solid var(--line); border-radius: 8px;
           padding: .45vw .9vw; display: flex; align-items: center; gap: .8vw; min-width: 0; }
.pv-seat.live { border: .16vw solid var(--lime); }
.pv-no { position: relative; flex: 0 0 auto; border-radius: 50%;
         display: flex; align-items: center; justify-content: center;
         font-family: var(--f-serif); font-weight: 700; line-height: 1;
         border: 2px solid var(--line-hard); }
.pv-seat.live .pv-no { border-color: var(--lime); color: var(--lime); }
.pv-who { flex: 1 1 auto; min-width: 0; }
.pv-p { font-weight: 700; line-height: 1.16; white-space: nowrap;
        overflow: hidden; text-overflow: ellipsis; display: flex;
        align-items: baseline; gap: .4vw; }
.pv-p i { font-style: normal; font-family: var(--f-mono); font-weight: 700;
          border-radius: 3px; padding: 0 .3vw; line-height: 1.16; flex: 0 0 auto;
          text-align: center; }
.pv-p.a i { background: var(--blue); }
.pv-p.b i { background: var(--red); }
.pv-p .nm2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pv-p .rec { margin-left: auto; font-family: var(--f-mono); font-weight: 700;
             color: rgba(250,250,250,.8); flex: 0 0 auto; }
.pv-p.win { color: var(--lime); }
.pv-p.lose { color: rgba(250,250,250,.5); }
.pv-p.lose i { opacity: .6; }
.pv-p.lose .rec { color: rgba(250,250,250,.8); }
.pv-p .adv { background: var(--lime); color: var(--black); font-weight: 900;
             border-radius: 3px; padding: 0 .3vw; line-height: 1.16; }
.pv-vs { display: flex; align-items: center; gap: .4vw; font-family: var(--f-serif);
         letter-spacing: .12em; color: var(--dim); margin: .08vw 0; }
.pv-vs::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.pv-empty { color: var(--dim); font-weight: 400; }

/* 投影：即時名次（兩欄） */
.pv-rank { display: grid; grid-template-columns: repeat(2, 1fr);
           grid-auto-flow: column; gap: .5vw; height: 100%; }
.pv-rk { display: flex; align-items: center; gap: 1vw; background: var(--ink);
         border: 1px solid var(--line); border-radius: 8px; padding: .3vw 1.2vw; min-width: 0; }
.pv-rk b { flex: 0 0 3.2vw; font-family: var(--f-serif); font-weight: 700;
           text-align: right; color: var(--dim); }
.pv-rk i { flex: 0 0 auto; font-style: normal; font-family: var(--f-mono); font-weight: 700;
           background: var(--line-hard); padding: .1vw .4vw; border-radius: 3px;
           min-width: 2.4vw; text-align: center; }
.pv-rk span { flex: 1 1 auto; font-weight: 700; min-width: 0;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-rk em { flex: 0 0 auto; font-style: normal; font-family: var(--f-mono); color: var(--dim); }
.pv-rk u { flex: 0 0 3.4vw; text-decoration: none; text-align: right;
           font-family: var(--f-mono); font-weight: 700; }
.pv-rk.in { border-color: var(--lime); background: rgba(176,208,0,.08); }
.pv-rk.in b, .pv-rk.in u { color: var(--lime); }
.pv-rk.out { opacity: .35; }
.pv-rk.out span { text-decoration: line-through; }

/* ── 提示條 ─────────────────────────────────────────── */
#toast { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; display: none;
         background: var(--gold); color: var(--black); font-weight: 900; font-size: 15px;
         padding: 13px 16px; text-align: center; }
#toast.bad { background: var(--red); color: var(--white); }
#toast.on { display: block; }

@media (max-width: 560px) {
  .tabs button { font-size: 13px; min-height: 48px; }
  .pane { padding: 12px; }
  .mt .sd { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── 列印：名次表直接印或存 PDF ───────────────────────── */
@media print {
  html, body { background: #fff; color: #111; overflow: visible; height: auto; }
  .top, .tabs, .danger-zone, #toast, #present, button { display: none !important; }
  .pane { display: none !important; }
  .pane.print-me { display: block !important; overflow: visible; padding: 0; }
  table.rank th { color: #555; border-bottom: 1.5pt solid #111; }
  table.rank td { border-bottom: .4pt solid #ddd; }
  table.rank td.pt { color: #0a6b2e; }
  table.rank tr.cut td { background: #eef7e6; }
  table.rank tr.cutline td { border-bottom: 1.5pt solid #0a6b2e; }
  .nmcell i { background: #eee; color: #333; }
  h2.sec { color: #555; }
  h2.sec em { color: #111; }
}
