/* 競技場 arena — 跟呱呱村謎題同一套夜色（#15171c＋銅色）。手機優先。
   狀態一律「符號＋文字」，不靠顏色分辨（柏逸色盲）。 */
:root {
  --bg: #15171c;
  --panel: #1f2229;
  --panel2: #272b34;
  --line: #3a3f4b;
  --text: #e8e6df;
  --muted: #a3a5af;
  --accent: #e3b341;
  --accent2: #7fb3d5;
  --focus: #9ecbff;
  --tabbar-h: 60px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif; line-height: 1.6; }
a { color: var(--accent2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top h1 { margin: 0; font-size: 18px; letter-spacing: 1px; white-space: nowrap; }
.hright { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sitebtn { flex: none; display: inline-flex; align-items: center; height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel2); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
/* 名字太長就縮成「…」，但「後台／登出」一定留著（320 寬的手機也按得到） */
.user { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; white-space: nowrap; }
.user .uname { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user a { flex: none; }
@media (max-width: 420px) {
  header.top { padding: 10px; gap: 6px; }
  header.top h1 { font-size: 16px; letter-spacing: 0; }
  .hright { gap: 5px; }
  .sitebtn { padding: 0 8px; font-size: 12px; }
}

main { max-width: 760px; margin: 0 auto; padding: 14px 12px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
h2 { font-size: 18px; margin: 4px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); font-weight: normal; }
.notice { font-size: 13px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; margin: 10px 0; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }

/* 下方分頁列 */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { position: relative; height: var(--tabbar-h); background: none; border: 0; border-top: 3px solid transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
nav.tabs button .ico { font-size: 19px; line-height: 1.1; }
nav.tabs button[aria-current="page"] { color: var(--text); border-top-color: var(--accent); font-weight: bold; }
.badge { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #1a1a1a; font-size: 11px; font-weight: bold; line-height: 18px; }

/* 按鈕 */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border: 0; border-radius: 9px; background: var(--accent); color: #1a1a1a; font: inherit; font-size: 15px; font-weight: bold; cursor: pointer; text-decoration: none; transition: transform .12s cubic-bezier(.23, 1, .32, 1); }
.btn.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: normal; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* 切換鈕（排行榜的遊戲分頁） */
.seg { display: flex; gap: 6px; margin: 4px 0 10px; }
.seg button { flex: 1; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); font-weight: bold; }
.seg button[aria-pressed="true"]::before { content: "● "; color: var(--accent); }

/* 排行榜 */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: normal; font-size: 12px; }
td.rank { width: 56px; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { word-break: break-word; }
tr.me td { background: var(--panel2); font-weight: bold; }
.sub { display: block; font-size: 11px; color: var(--muted); font-weight: normal; }

/* 我的戰力值 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex: 1 1 140px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.chip b { font-size: 20px; font-variant-numeric: tabular-nums; }
.chip span { display: block; font-size: 12px; color: var(--muted); }

/* 宣戰卡 */
.ch .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ch .vs { font-weight: bold; word-break: break-word; }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 5px; padding: 0 7px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ch .format { white-space: pre-line; background: #111318; border-left: 3px solid var(--accent); border-radius: 6px; padding: 7px 10px; margin: 8px 0; font-size: 14px; word-break: break-word; }
.ch .st { font-size: 14px; margin-top: 6px; }
.ch .meta { font-size: 12px; color: var(--muted); }
.ch .box { background: var(--panel2); border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: 13px; word-break: break-word; }
.ch .box a { word-break: break-all; }

/* 表單 */
label.f { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=url], input[type=search], textarea, select { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #111318; color: var(--text); font: inherit; font-size: 16px; }
textarea { min-height: 84px; resize: vertical; }
.pick { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; }
.pick button { display: flex; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 8px 12px; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.pick button:last-child { border-bottom: 0; }
.pick button[aria-pressed="true"] { background: var(--panel2); font-weight: bold; }
.pick button[aria-pressed="true"]::before { content: "✔ "; }
.pick button small { color: var(--muted); white-space: nowrap; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts label { flex: 1 1 120px; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); cursor: pointer; font-size: 15px; }
.opts input { width: 18px; height: 18px; accent-color: var(--accent); }
.msg { margin: 10px 0; padding: 9px 12px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); font-size: 14px; }
.msg.bad { border-color: #d9a066; }
.msg.ok { border-color: var(--accent); }

/* 彈窗 */
dialog { width: min(92vw, 480px); max-height: 88vh; overflow-y: auto; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin-top: 0; }
dialog[open] { animation: pop .2s cubic-bezier(.23, 1, .32, 1); }
dialog[open]::backdrop { animation: fade .2s cubic-bezier(.23, 1, .32, 1); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.eventbody { white-space: pre-line; }

/* ── v1.1：賽季／比賽大會／對戰表（沒有加任何動效） ── */
.seg { flex-wrap: wrap; }
.seg button { flex: 1 1 88px; }
.season b { font-size: 15px; }
.sub.title { color: var(--accent); }
input[type=number], input[type=datetime-local] { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #111318; color: var(--text); font: inherit; font-size: 16px; color-scheme: dark; }
.tour .st { margin-top: 4px; font-weight: bold; }
.podium { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.podium:last-child { border-bottom: 0; }
.podium span { flex: none; min-width: 76px; }
.podium b { word-break: break-word; }
.names { display: flex; flex-wrap: wrap; gap: 6px; }
.names .tag { white-space: normal; word-break: break-word; color: var(--text); padding: 2px 8px; }
/* 對戰表：手機上一輪一段、一場一塊，由上往下看（不做橫向的樹狀圖，320 寬也不用左右滑） */
.bracket .match { padding: 9px 0; border-bottom: 1px solid var(--line); }
.bracket .match:first-child { padding-top: 0; }
.bracket .match:last-child { border-bottom: 0; padding-bottom: 0; }
.side { display: flex; align-items: baseline; gap: 8px; padding: 3px 8px; border-left: 3px solid transparent; }
.side .seed { flex: none; min-width: 28px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side .pname { flex: 1; min-width: 0; word-break: break-word; }
.side .res { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.side.won { border-left-color: var(--accent); font-weight: bold; }
.side.won .res { color: var(--text); }
.side.mine { background: var(--panel2); border-radius: 0 6px 6px 0; }
.side.tbd { color: var(--muted); font-size: 13px; }
.mstate { font-size: 13px; color: var(--muted); padding: 3px 8px 0; }
.meta.code { word-break: break-all; font-family: Consolas, monospace; }
/* 後台：一列兩欄的小表單、清單列 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line > span { min-width: 0; word-break: break-word; }
.line .btn { min-height: 38px; padding: 5px 12px; font-size: 14px; }
/* ── v1.2：約時間／討論（沒有加任何動效） ── */
input[type=date], input[type=time] { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #111318; color: var(--text); font: inherit; font-size: 16px; color-scheme: dark; }
.ch .when { font-size: 14px; margin-top: 6px; word-break: break-word; }
.ch .when.ok { font-weight: bold; }
.talk { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.talk .talkbtn { min-height: 40px; padding: 5px 12px; font-size: 14px; }
.talkpanel { margin-top: 8px; }
.tmsg { background: var(--panel2); border-left: 3px solid var(--line); border-radius: 0 8px 8px 0; padding: 6px 10px; margin: 6px 0; }
.tmsg.mine { border-left-color: var(--accent); }
.tmsg .twho { font-size: 12px; color: var(--muted); word-break: break-word; }
.tmsg .tbody { font-size: 14px; white-space: pre-line; word-break: break-word; overflow-wrap: anywhere; }
.talkpanel textarea { min-height: 64px; margin-top: 6px; }
footer { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 12px 0; }

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:active:not(:disabled) { transform: none; }
  dialog[open] { animation: fade .2s ease; }   /* 減少動態：不縮放，只留淡入 */
}
@media (min-width: 700px) {
  main { padding-top: 20px; }
}
