/* 藥衝對戰場 —— 漫畫風：粗黑框、硬陰影、網點底。 */
:root {
  --ink: #17130e;
  --ink-soft: #4a423a;
  --paper: #fdf3df;
  --paper-deep: #f2e6cd;
  --white: #fffdf6;
  --acid: #d8f34a;
  --acid-dark: #b4d024;
  --amber: #ffca43;
  --red: #f2604c;
  --green: #35b37e;
  --sky: #74c0fc;
  --line: var(--ink);
  --muted: #7d7264;
  --radius: 20px;
  --pop: 4px 4px 0 var(--ink);
  --pop-sm: 3px 3px 0 var(--ink);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  /* 網點底：漫畫感的來源之一，很淡，不搶字 */
  background-color: var(--paper);
  background-image: radial-gradient(var(--ink) 1.1px, transparent 1.2px);
  background-size: 14px 14px;
  background-position: -3px -3px;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", ui-sans-serif, system-ui, -apple-system,
               "PingFang TC", "Noto Sans TC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
body::before {  /* 網點只留淡淡一層 */
  content: ""; position: fixed; inset: 0; background: var(--paper); opacity: .93; z-index: -1;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--ink); }

.shell { max-width: 860px; margin: 0 auto; padding: 14px 14px 56px; }

/* ---- 頂欄 ---- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 0 16px; }
.brand {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 0; padding: 0; font-weight: 900; font-size: 17px; letter-spacing: .02em;
}
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--acid); color: var(--ink); border: 3px solid var(--ink);
  border-radius: 11px; font-size: 16px; font-weight: 900; box-shadow: var(--pop-sm);
  transform: rotate(-6deg);
}
.topbar .spacer { flex: 1; }
.pill {
  border: 2.5px solid var(--ink); background: var(--white); border-radius: 999px;
  padding: 3px 11px; font-size: 12.5px; font-weight: 800; color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px; box-shadow: 2px 2px 0 var(--ink);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); border: 1.5px solid var(--ink); }
.pill.live .dot { background: var(--green); }
.pill.down .dot { background: var(--red); }

/* ---- 卡片 ---- */
.card {
  background: var(--white); border: 3px solid var(--ink); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--pop); margin-bottom: 16px;
}
.card h2 { font-size: 19px; font-weight: 900; margin-bottom: 4px; }
.kicker {
  display: block; width: fit-content;   /* 自成一行，但只包住文字才有貼紙感 */
  font-size: 11.5px; font-weight: 900; letter-spacing: .1em;
  color: var(--ink); background: var(--acid); border: 2.5px solid var(--ink);
  border-radius: 999px; padding: 1px 10px; margin: 0 0 9px; transform: rotate(-1.5deg);
}
.muted { color: var(--muted); font-size: 13.5px; }

/* ---- 表單 ---- */
label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: 13px; font-weight: 900; color: var(--ink); margin-bottom: 5px; }
input[type=text], select {
  width: 100%; padding: 11px 13px; border: 3px solid var(--ink); border-radius: 13px;
  background: var(--white); outline: none; font-weight: 700;
}
input[type=text]:focus, select:focus { box-shadow: var(--pop-sm); }
input.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 900; font-size: 24px; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; border: 3px solid var(--ink);
  background: var(--white); color: var(--ink); font-weight: 900;
  box-shadow: var(--pop); transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: 2px 2px 0 var(--ink); }
.btn.ghost { background: var(--white); }
.btn.acid { background: var(--acid); }
.btn.wide { width: 100%; }
.btn.sm { padding: 7px 14px; font-size: 13.5px; box-shadow: var(--pop-sm); }
.row { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---- 模式選擇 ---- */
.modes { display: grid; gap: 11px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .modes { grid-template-columns: 1fr; } }
.mode {
  text-align: left; border: 3px solid var(--ink); background: var(--white); border-radius: 16px;
  padding: 13px 15px; display: grid; gap: 3px; box-shadow: var(--pop-sm);
  transition: transform .06s, box-shadow .06s;
}
.mode:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.mode strong { font-size: 16.5px; font-weight: 900; }
.mode small { color: var(--ink-soft); font-size: 12.5px; line-height: 1.45; }
.mode[aria-pressed=true] { background: var(--acid); }

/* ---- 房號 ---- */
.roomcode { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.roomcode b {
  font-size: 46px; letter-spacing: .14em; font-weight: 900; font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 1px var(--ink);
}

/* ---- 角色 ---- */
.char { display: block; flex: none; }
.prow .char { animation: bob 2.6s ease-in-out infinite; }
.prow.turn .char { animation: bob 1s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-2.5px) } }
@media (prefers-reduced-motion: reduce) { .prow .char { animation: none; } }

/* ---- 玩家列 ---- */
.players { display: grid; gap: 8px; }
.prow {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; border: 3px solid var(--ink); border-radius: 14px; background: var(--white);
  box-shadow: var(--pop-sm);
}
.prow .nm { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .sc { font-weight: 900; font-variant-numeric: tabular-nums; font-size: 17px; }
.prow.off { opacity: .42; }
.prow.turn { background: var(--acid); box-shadow: 5px 5px 0 var(--ink); }
.prow.me .nm::after { content: "（你）"; color: var(--muted); font-weight: 700; font-size: 12px; }
.tag {
  font-size: 11px; font-weight: 900; padding: 1px 8px; border-radius: 999px;
  background: var(--ink); color: var(--acid); border: 2px solid var(--ink); white-space: nowrap;
}
.tag.ok { background: var(--green); color: #fff; }
.tag.no { background: var(--red); color: #fff; }
.tag.wait { background: var(--white); color: var(--muted); }
.tag.bot { background: var(--white); color: var(--ink); }
.prow.bot { border-style: dashed; }
.xbtn {
  flex: none; width: 26px; height: 26px; border-radius: 9px; border: 2.5px solid var(--ink);
  background: var(--white); color: var(--ink); font-size: 12px; font-weight: 900; line-height: 1; padding: 0;
}
.xbtn:hover { background: var(--red); color: #fff; }

/* ---- 題目：對話框 ---- */
.qcard { position: relative; }
.qcard::before, .qcard::after {  /* 對話框的小尾巴 */
  content: ""; position: absolute; top: -14px; left: 34px;
  border-left: 13px solid transparent; border-right: 13px solid transparent;
  border-bottom: 14px solid var(--ink);
}
.qcard::after { top: -9px; border-bottom-color: var(--white); }
.qmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 9px; font-weight: 700; }
.qprompt { font-size: 18.5px; font-weight: 800; line-height: 1.5; margin-bottom: 14px; }
.opts { display: grid; gap: 9px; }
.opt {
  display: flex; gap: 11px; align-items: flex-start; text-align: left;
  padding: 12px 14px; border: 3px solid var(--ink); border-radius: 15px; background: var(--white);
  width: 100%; box-shadow: var(--pop-sm); font-weight: 600;
  transition: transform .06s, box-shadow .06s;
}
.opt:not(:disabled):active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.opt .k {
  flex: none; width: 27px; height: 27px; border-radius: 9px; display: grid; place-items: center;
  background: var(--paper-deep); border: 2.5px solid var(--ink); font-weight: 900; font-size: 13px;
}
.opt[aria-pressed=true] { background: var(--sky); }
.opt[aria-pressed=true] .k { background: var(--ink); color: #fff; }
.opt.correct { background: var(--green); color: #fff; }
.opt.correct .k { background: var(--white); color: var(--ink); }
.opt.mine-wrong { background: var(--red); color: #fff; }
.opt.mine-wrong .k { background: var(--white); color: var(--ink); }
.opt:disabled { cursor: default; }
.opt .ot { flex: 1; min-width: 0; }
/* 正解與自己選的都用文字標出來，不要只靠顏色分辨 */
.otag {
  flex: none; align-self: center; font-size: 11.5px; font-weight: 900; white-space: nowrap;
  background: var(--white); color: var(--ink); border: 2.5px solid var(--ink);
  border-radius: 999px; padding: 2px 9px; box-shadow: 2px 2px 0 var(--ink);
}



.timer {
  height: 13px; border-radius: 999px; background: var(--white); overflow: hidden;
  margin-bottom: 13px; border: 2.5px solid var(--ink);
}
.timer > i { display: block; height: 100%; background: var(--acid); transition: width .12s linear; }
.timer.warn > i { background: var(--red); }

.explain {
  margin-top: 13px; padding: 12px 14px; border-radius: 15px;
  background: var(--paper); border: 3px dashed var(--ink); font-size: 14.5px;
}
.explain b { display: block; margin-bottom: 3px; font-weight: 900; }
.explain .trap { margin-top: 7px; color: var(--ink-soft); }
.explain .src { margin-top: 9px; font-size: 12.5px; }

/* 漫畫爆炸字：答對／答錯的即時回饋 */
.burst {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 18px; font-weight: 900; font-size: 17px; letter-spacing: .04em;
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: var(--pop-sm);
  transform: rotate(-3deg); animation: pop .28s cubic-bezier(.2, 1.6, .4, 1);
}
.burst.ok { background: var(--acid); }
.burst.no { background: var(--red); color: #fff; }
@keyframes pop { 0% { transform: rotate(-3deg) scale(.4) } 100% { transform: rotate(-3deg) scale(1) } }

/* ---- 棋盤 ---- */
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(6, 1fr);
  gap: 5px; aspect-ratio: 8 / 6; margin-bottom: 16px;
}
.tile {
  position: relative;                 /* 棋子用絕對定位站在格子邊緣 */
  border: 2.5px solid var(--ink); border-radius: 10px; background: var(--white);
  padding: 2px 1px; box-shadow: 2px 2px 0 var(--ink);
  display: grid; grid-template-rows: auto auto; justify-items: center; align-content: center;
  min-width: 0; min-height: 0;
}
.tile .ico { display: block; line-height: 0; }
.tile .ticon { display: block; width: 17px; height: 17px; }
.tile .lb {
  font-weight: 900; color: var(--ink); font-size: 9px; line-height: 1.35;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.tile.t-start { background: var(--acid); }
.tile.t-bonus { background: var(--amber); }
.tile.t-chance { background: #cfe8ff; }
.tile.t-rest { background: var(--paper-deep); }
/* 每格稍微歪一點點，看起來像手排上去的，不是印表機印的 */
.board .tile:nth-child(odd) { transform: rotate(-1.4deg); }
.board .tile:nth-child(even) { transform: rotate(1.4deg); }
.board .tile.here { transform: rotate(0deg) scale(1.06); }
.tile.here { box-shadow: 0 0 0 3px var(--red), 2px 2px 0 var(--ink); z-index: 3; }
/* 格子只有 34px 左右，棋子放在格子裡會被壓掉，所以讓它站在下緣、人多時互相重疊 */
.tile .pawns {
  position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
  display: flex; z-index: 2; pointer-events: none;
}
.tile .pawns .char { margin: 0 -3px; filter: drop-shadow(0 1.5px 0 rgba(23, 19, 14, .35)); }
.board .center {
  grid-column: 2 / 8; grid-row: 2 / 6;
  border: 3px dashed var(--ink); border-radius: 18px;
  background-color: var(--paper);
  background-image: radial-gradient(var(--paper-deep) 2px, transparent 2.2px);
  background-size: 13px 13px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 8px; text-align: center;
}
.dice {
  font-size: 40px; line-height: 1; width: 54px; height: 54px; display: grid; place-items: center;
  background: var(--white); border: 3px solid var(--ink); border-radius: 15px; box-shadow: var(--pop-sm);
  transform: rotate(-6deg);
}
.dice.rolling { animation: shake .5s ease-in-out infinite; }
@keyframes shake { 0%, 100% { transform: rotate(-9deg) } 50% { transform: rotate(9deg) } }
.turnname { font-weight: 900; display: flex; align-items: center; gap: 6px; }
.log { margin-top: 10px; font-size: 13px; color: var(--ink-soft); display: grid; gap: 3px; font-weight: 600; }
.log div { padding: 4px 0; border-bottom: 2px dotted var(--paper-deep); }

/* ---- 結算 ---- */
.rank { display: grid; gap: 9px; }
.rank .prow { padding: 9px 12px; }
.rank .prow .no { font-weight: 900; width: 22px; flex: none; font-size: 17px; }
/* 名字一行、戰績一行，不然長的戰績文字會把名字擠掉 */
.rank .who { flex: 1; min-width: 0; display: grid; gap: 0; line-height: 1.35; }
.rank .who .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .who .muted { font-size: 12px; }
.rank .prow .sc { font-size: 20px; flex: none; }
.rank .prow:first-child { background: var(--acid); box-shadow: 5px 5px 0 var(--ink); }

.updbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 11px; white-space: nowrap;
  background: var(--white); color: var(--ink); padding: 8px 10px 8px 16px;
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: var(--pop);
  font-weight: 900; font-size: 14px; z-index: 30;
}

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--acid); color: var(--ink); padding: 9px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 900; border: 3px solid var(--ink); box-shadow: var(--pop-sm); z-index: 20;
}
footer.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 4px 0; line-height: 1.6; }
