:root {
  --bg: #1c0709;
  --bg2: #2b0c10;
  --panel: #3a1116;
  --panel2: #4a161c;
  --line: #6b2a2f;
  --text: #fbefe2;
  --muted: #c9a99a;
  --red: #c62828;
  --maroon: #7a1020;
  --orange: #f08a24;
  --yellow: #ffd23f;
  --ok: #7bd389;
  font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
a { color: var(--yellow); }
input, select, button { font: inherit; color: inherit; }
input, select {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--orange); outline-offset: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.pad { padding: 12px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #5c1d24; border-color: var(--orange); }
.btn.primary { background: linear-gradient(180deg, var(--orange), #c9560f); border-color: #ffb066; color: #1c0709; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: var(--red); color: #ff9a9a; }
.btn.ghost { background: transparent; }
.btn.big { padding: 10px 18px; font-size: 1.05rem; }
.btn.on { background: var(--yellow); color: #2b0c10; border-color: var(--yellow); font-weight: 700; }
.btn.small { padding: 3px 8px; font-size: .85rem; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; margin-left: auto; padding: 0 4px; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: .85rem; }
.pill.bad, .bad-text { color: #ff9a7a; border-color: var(--red); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--yellow); color: #2b0c10; padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 100;
  transition: .2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- หน้าแรก ---------- */
.lobby {
  height: 100vh; overflow: auto; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 0%, #5a1520 0%, var(--bg) 60%);
}
.lobby-card {
  width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px #0008;
}
.lobby-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.logo { font-size: 1.7rem; font-weight: 800; color: var(--yellow); letter-spacing: .02em; }
.lobby-card p { margin: 0; }
.or { text-align: center; color: var(--muted); font-size: .9rem; }
.bot-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px dashed var(--line, #ffffff22); border-radius: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .3em; width: 9em; text-align: center; flex: 1; }
.join-box { background: var(--bg2); border: 1px solid var(--orange); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.code { color: var(--yellow); letter-spacing: .15em; }
.link { font-size: .92rem; }
.tips { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; line-height: 1.6; }

/* ---------- แถบบน ---------- */
.bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--bg2); border-bottom: 1px solid var(--line);
  min-height: 48px; flex-wrap: nowrap;
}
.brand { font-weight: 800; color: var(--yellow); text-decoration: none; font-size: 1.1rem; }
.room-code { background: var(--panel2); border: 1px solid var(--orange); border-radius: 8px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.room-code b { color: var(--yellow); letter-spacing: .12em; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.conn.ok { background: var(--ok); }
.conn.bad { background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.turn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.my-turn { color: var(--yellow); }
.tools { display: flex; gap: 6px; }
.panel-toggle { display: none; }

/* ---------- โต๊ะ ---------- */
.table { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.table-body { flex: 1; display: flex; min-height: 0; }
.board {
  flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 6px 8px; overflow-x: hidden; overflow-y: auto; user-select: none;
  background: radial-gradient(ellipse at 50% 50%, #4a1219 0%, #2a0a0e 55%, #170507 100%);
  --ch: 100px; --cw: 69px; --gap: 6px;
}
.midline { width: 70%; height: 2px; background: linear-gradient(90deg, transparent, var(--orange), transparent); opacity: .5; flex: none; }

/* ---------- โหมดกติกา ---------- */
.guide {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; width: min(100%, 860px);
  min-height: 40px; padding: 6px 12px; margin: 2px 0; border-radius: 12px; text-align: center;
  background: linear-gradient(90deg, #00000000, #3a1116ee 15%, #3a1116ee 85%, #00000000); border-top: 1px solid #f08a2455; border-bottom: 1px solid #f08a2455;
  font-size: .92rem; line-height: 1.35;
}
.guide b { color: var(--yellow); }
.guide small { color: var(--muted); }
.guide .g-skill { margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--yellow); background: #ffffff0a; font-size: .9em; }
.guide.hot { border-color: var(--yellow); box-shadow: 0 0 18px #ffd23f33; }
.guide.finished { font-size: 1.15rem; border-color: var(--yellow); }
.guide.manual { opacity: .8; }
.g-btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.g-btns .btn { padding: 5px 12px; }
.g-check { display: flex; align-items: center; gap: 4px; font-size: .85rem; cursor: pointer; }
.phases { display: flex; align-items: center; gap: 4px; margin-right: 6px; }
.phases i { color: var(--muted); font-style: normal; }
.ph { padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); font-size: .85rem; font-weight: 700; }
.ph.on { background: var(--orange); border-color: var(--yellow); color: #1c0709; }
.card.pick { cursor: pointer; animation: pick 1s ease-in-out infinite; z-index: 6; }
@keyframes pick { 50% { box-shadow: 0 0 0 3px var(--yellow), 0 0 18px var(--orange); } }
.atk-slot { border: 2px solid var(--red) !important; box-shadow: 0 0 16px #c62828aa; }
.tgt-slot { border: 2px solid var(--yellow) !important; box-shadow: 0 0 16px #ffd23faa; }
.boost-slot { border: 2px solid var(--orange) !important; }
/* สกิลการ์ด */
.guide.ab-offer { flex-direction: column; align-items: stretch; text-align: left; max-height: 34vh; overflow: auto; }
.ab-list { display: flex; flex-direction: column; gap: 6px; }
.ab-row { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; line-height: 1.4; }
.ab-row .btn { flex: none; padding: 3px 10px; }
.ab-row b { color: var(--yellow); }
.pick-opt { position: relative; cursor: pointer; border-radius: 8px; outline: 3px solid transparent; transition: outline-color .1s; }
.pick-opt.on { outline-color: var(--yellow); box-shadow: 0 0 16px var(--orange); }
.pick-opt.off { opacity: .55; cursor: not-allowed; }
.pick-opt .card { cursor: pointer; }
.modal-foot .btn[disabled] { opacity: .45; cursor: not-allowed; }
.skills { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.skill { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.skill-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.skill-head .btn { margin-left: auto; }
.sk-kind { font-size: .72rem; font-weight: 800; background: var(--maroon); border-radius: 5px; padding: 0 6px; color: var(--yellow); }
.sk-tag { font-size: .72rem; color: #ffb3a1; }
.sk-tag.ok { color: var(--ok); }
.skill-text { font-size: .8rem; line-height: 1.45; color: var(--text); }
.side-grid {
  display: grid; gap: 6px; justify-content: center; flex: none;
  grid-template-columns: var(--ch) repeat(3, var(--ch)) var(--ch) var(--ch);
}
.side-grid.me {
  grid-template-rows: calc(var(--cw) + 18px) var(--ch) var(--ch);
  grid-template-areas: "dmg trig gc gc gc bind" "dmg fl vc fr deck acc" "dmg bl bc br drop acc";
}
.side-grid.opp {
  grid-template-rows: var(--ch) var(--ch) calc(var(--cw) + 18px);
  grid-template-areas: "acc drop br bc bl dmg" "acc deck fr vc fl dmg" "bind gc gc gc trig dmg";
}
/* จอกว้าง: ฝั่งละ 2 แถว ให้การ์ดใหญ่ขึ้น · Trigger/GC อยู่คอลัมน์ข้างแถวหน้า-หลัง */
.board.wide .side-grid { grid-template-columns: repeat(7, var(--ch)); grid-template-rows: var(--ch) var(--ch); }
.board.wide .side-grid.me { grid-template-areas: "dmg trig fl vc fr deck acc" "dmg gc bl bc br drop bind"; }
.board.wide .side-grid.opp { grid-template-areas: "bind drop br bc bl gc dmg" "acc deck fr vc fl trig dmg"; }
.board.wide .z-gc .rowcards { flex-direction: column; padding-top: 14px; }
.board.wide .z-gc .rowcards .hold + .hold { margin-left: 0; margin-top: calc(var(--cw) * -.62); }
.board.wide .z-trigger .rowcards { padding-top: 14px; }
.a-dmg { grid-area: dmg; } .a-trig { grid-area: trig; } .a-gc { grid-area: gc; } .a-bind { grid-area: bind; }
.a-fl { grid-area: fl; } .a-vc { grid-area: vc; } .a-fr { grid-area: fr; } .a-bl { grid-area: bl; } .a-bc { grid-area: bc; } .a-br { grid-area: br; }
.a-deck { grid-area: deck; } .a-drop { grid-area: drop; } .a-acc { grid-area: acc; }
.empty-side {
  flex: 1; display: grid; place-items: center; gap: 10px; color: var(--muted); border: 2px dashed var(--line); border-radius: 16px;
  width: min(100%, 640px); margin: 8px 0; text-align: center; padding: 12px;
}

.slot, .pile, .rowzone, .damage {
  position: relative; border: 1.5px dashed #ffffff26; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: #00000024;
}
.slot { border-radius: 50%; }
.slot.vc { border-color: #f08a2499; background: radial-gradient(circle, #f08a2422, #00000024 70%); }
.slot.sel-slot { border: 2px solid var(--yellow); }
.slot-label {
  position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%); font-size: calc(var(--ch) * .1); color: #ffffff55;
  pointer-events: none; white-space: nowrap; font-weight: 700; letter-spacing: .05em;
}
.rowzone .slot-label, .damage .slot-label { top: 2px; bottom: auto; }
.pile .slot-label { bottom: auto; top: -2px; }
.count {
  position: absolute; right: 2px; top: 2px; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--maroon);
  border: 1px solid var(--orange); font-size: 12px; font-weight: 700; display: grid; place-items: center; z-index: 3; pointer-events: none;
}
.pile .count { top: auto; bottom: 4px; right: 4px; }
.damage { flex-direction: column; justify-content: flex-start; overflow: hidden; }
.damage .slot-label b { color: var(--yellow); font-size: 1.2em; }
.damage .hold { position: absolute; left: 50%; margin-left: calc(var(--ch) / -2); }
.rowzone { overflow: hidden; }
.rowcards { display: flex; align-items: center; justify-content: center; gap: 4px; padding-top: 12px; }
.z-gc .rowcards .hold + .hold { margin-left: calc(var(--ch) * -.45); }
.hold { position: relative; width: var(--ch); height: var(--cw); flex: none; }
.hold > .card { position: absolute; left: calc((var(--ch) - var(--cw)) / 2); top: calc((var(--cw) - var(--ch)) / 2); transform: rotate(90deg); }
.hold > .card.sel { box-shadow: 0 0 0 3px var(--yellow); }
.gz { border-color: #ffd23f66; }
.gz-up {
  position: absolute; left: 4px; bottom: 4px; z-index: 3; background: var(--yellow); color: #2b0c10; font-size: 11px; font-weight: 800;
  padding: 1px 6px; border-radius: 8px; pointer-events: none;
}
.heart { position: absolute; transform: translate(-18%, -10%) scale(.82); opacity: .75; }
.heart + .card { position: relative; transform: translate(10%, 6%); }
.legion { display: flex; }
.legion > .card + .card { margin-left: calc(var(--cw) * -.45); }
.vc-tag {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%); z-index: 4; background: var(--yellow); color: #2b0c10;
  font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 6px; pointer-events: none;
}
.soul {
  position: absolute; right: -10px; bottom: -6px; z-index: 5; background: var(--maroon); border: 1px solid var(--yellow); color: var(--yellow);
  border-radius: 10px; font-size: 11px; font-weight: 700; padding: 2px 7px; cursor: pointer;
}
.drop-hover { outline: 3px solid var(--yellow) !important; outline-offset: 2px; background: #ffd23f22 !important; }

/* ---------- การ์ด ---------- */
.card {
  position: relative; width: var(--cw); height: var(--ch); border-radius: calc(var(--ch) * .05); overflow: hidden; flex: none;
  transition: transform .15s; box-shadow: 0 2px 6px #0009; cursor: grab; touch-action: none; background: #222;
}
.card.rest { transform: rotate(90deg); }
.card.sel { box-shadow: 0 0 0 3px var(--yellow), 0 0 16px var(--orange); }
.card.mull { outline: 3px solid var(--red); opacity: .6; }
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.card .txt {
  position: absolute; inset: 0; padding: 4px; display: flex; flex-direction: column; gap: 2px; font-size: calc(var(--ch) * .085); line-height: 1.15;
  background: linear-gradient(160deg, #6b1a24, #2a0a0e); border: 2px solid #b8860b; border-radius: inherit; overflow: hidden;
}
.card .txt b { font-size: 1.05em; word-break: break-word; }
.card .txt.token { background: linear-gradient(160deg, #a35a00, #4a2a00); }
.t-grade { color: var(--yellow); font-weight: 800; }
.t-trig { align-self: flex-start; padding: 0 4px; border-radius: 4px; background: var(--red); font-weight: 700; }
.t-heal { background: #2e8b57; } .t-draw { background: #1e6fb8; } .t-front { background: #a86800; }
.t-pow { margin-top: auto; font-weight: 800; }
.card.back, .mini-back {
  background:
    radial-gradient(circle at 50% 45%, #ffd23f 0 9%, transparent 10%),
    radial-gradient(circle at 50% 45%, transparent 0 22%, #f08a2455 23% 25%, transparent 26%),
    repeating-linear-gradient(45deg, #5a0f16 0 6px, #4a0c12 6px 12px);
  border: 2px solid #c9961a;
}
.card.fd::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, #0007 0 6px, #0003 6px 12px); }
.fd-label { position: absolute; top: 40%; left: 0; right: 0; text-align: center; z-index: 2; font-weight: 800; font-size: calc(var(--ch) * .12); text-shadow: 0 1px 3px #000; }
.pw {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; text-align: center; background: #000c; font-weight: 800;
  font-size: calc(var(--ch) * .11); padding: 1px 0;
}
.pw.mod { color: var(--yellow); }
.card.small { width: calc(var(--cw) * .72); height: calc(var(--ch) * .72); }
.card.small .txt { font-size: calc(var(--ch) * .065); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; opacity: .92; box-shadow: 0 12px 30px #000c; transition: none; }


/* ---------- มือ ---------- */
.hand { display: flex; align-items: flex-end; justify-content: center; flex: none; width: 100%; min-height: calc(var(--ch) * .4); }
.hand.me { min-height: calc(var(--ch) + 8px); padding: 4px 8px 0; border-radius: 12px; }
.hand.me .card + .card { margin-left: var(--gap); }
.hand.me .card:hover { transform: translateY(-10px); z-index: 5; }
.hand.other { flex-direction: column; align-items: center; gap: 2px; }
.hand-name { font-size: .85rem; color: var(--muted); }
.minis { display: flex; justify-content: center; }
.mini-back { width: calc(var(--cw) * .38); height: calc(var(--ch) * .38); border-radius: 4px; border-width: 1px; }
.mini-back + .mini-back { margin-left: calc(var(--cw) * -.12); }

/* ---------- แผงข้าง ---------- */
.side { width: 300px; flex: none; display: flex; flex-direction: column; background: var(--bg2); border-left: 1px solid var(--line); min-height: 0; }
.detail { padding: 10px; border-bottom: 1px solid var(--line); max-height: 48%; overflow: auto; }
.detail-img { position: relative; width: 150px; aspect-ratio: .686; float: left; margin: 0 10px 6px 0; border-radius: 8px; overflow: hidden; }
.detail-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; }
.detail-fallback { position: absolute; inset: 0; --ch: 218px; }
.detail-fallback .txt { position: absolute; inset: 0; padding: 6px; display: flex; flex-direction: column; gap: 4px; background: linear-gradient(160deg, #6b1a24, #2a0a0e); border: 2px solid #b8860b; border-radius: 8px; font-size: 14px; }
.detail-text h3 { margin: 0 0 2px; font-size: 1rem; color: var(--yellow); }
.detail-meta { color: var(--muted); font-size: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chips span { background: var(--panel2); border-radius: 6px; padding: 1px 6px; font-size: .78rem; }
.detail-text p { font-size: .84rem; line-height: 1.5; margin: 6px 0 0; clear: both; white-space: pre-wrap; }
.log { flex: 1; overflow: auto; padding: 8px 10px; font-size: .84rem; line-height: 1.45; min-height: 80px; }
.l { padding: 2px 0; border-bottom: 1px dashed #ffffff10; }
.l time { color: #ffffff55; font-size: .75rem; }
.l-turn { color: var(--orange); font-weight: 700; }
.l-chat { color: #ffe9a8; }
.l-check { color: var(--yellow); }
.l-dice, .l-reveal { color: #ffb3a1; }
.chat { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat input { flex: 1; }
.actions { display: none; padding: 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.actions.show { display: block; }
.act-title { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 6px; color: var(--yellow); }
.act-title small { color: var(--muted); font-weight: 400; }
.act-btns { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; align-items: center; }
.act-btns .btn { padding: 4px 8px; font-size: .85rem; }
.act-sub { font-size: .78rem; color: var(--muted); margin-right: 2px; }

/* ---------- เมนู / หน้าต่าง ---------- */
.menu {
  position: fixed; z-index: 80; background: var(--panel); border: 1px solid var(--orange); border-radius: 10px; padding: 4px;
  min-width: 240px; box-shadow: 0 10px 30px #000a; max-height: 80vh; overflow: auto;
}
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--panel2); }
.menu button.danger { color: #ff9a9a; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; }
.modal {
  position: fixed; z-index: 70; left: 50%; top: 56px; transform: translateX(-50%); width: min(760px, calc(100vw - 24px)); max-height: 58vh;
  display: flex; flex-direction: column; background: #2b0c10f2; border: 1px solid var(--orange); border-radius: 14px; box-shadow: 0 16px 50px #000c;
  --ch: 130px; --cw: 89px;
}
body.dragging .modal { opacity: .25; pointer-events: none; }
.modal-head { display: flex; align-items: center; padding: 10px 14px; font-weight: 700; color: var(--yellow); border-bottom: 1px solid var(--line); }
.modal-cards { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; overflow: auto; }
.modal-cards .card { touch-action: pan-y; }
.modal .hint, .builder .hint { font-size: .8rem; color: var(--muted); padding: 0 14px 8px; }
.modal-foot { display: flex; gap: 8px; padding: 0 14px 12px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; padding: 12px; overflow: auto; }
.pick-list .btn { text-align: left; white-space: normal; }
.pick-list small { color: var(--muted); }
.reveal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: #000a; }
.reveal-card { display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 700; color: var(--yellow); }
.reveal .card.big { --ch: min(60vh, 440px); --cw: calc(var(--ch) * .686); }

/* ---------- หน้าจัดเด็ค ---------- */
.builder { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.builder-body { flex: 1; display: grid; grid-template-columns: 360px 1fr 300px; min-height: 0; }
.deck-pane { padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow: auto; border-right: 1px solid var(--line); background: var(--bg2); }
.deck-pane select, .deck-pane input { width: 100%; }
.deck-pane .row select { flex: 1; }
#deck-list { flex: 1; }
#deck-list h4 { margin: 10px 0 4px; color: var(--orange); font-size: .9rem; }
#deck-list h4 small { color: var(--muted); }
.deck-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 6px; font-size: .88rem; }
.deck-row:hover { background: var(--panel); }
.deck-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; width: 24px; height: 24px; padding: 0; cursor: pointer; line-height: 1; }
.mini.star.on { background: var(--yellow); color: #2b0c10; }
.stat-row { display: flex; flex-wrap: wrap; gap: 4px; font-size: .85rem; }
.stat-row.small { color: var(--muted); }
.search-pane { display: flex; flex-direction: column; min-height: 0; padding: 12px 12px 0; }
.filters input { flex: 1 1 220px; }
.results { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; padding: 4px 2px 16px; align-content: start; }
.res { position: relative; cursor: pointer; --ch: 160px; --cw: 110px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.res .card { cursor: pointer; }
.res:hover .card { box-shadow: 0 0 0 2px var(--orange); }
.res-name { font-size: .75rem; text-align: center; color: var(--muted); line-height: 1.2; max-width: 110px; }
.have { position: absolute; top: 4px; right: 8px; background: var(--yellow); color: #2b0c10; font-weight: 800; border-radius: 10px; padding: 0 7px; z-index: 3; }
.more { grid-column: 1 / -1; justify-self: center; }
.detail-pane { padding: 12px; overflow: auto; border-left: 1px solid var(--line); background: var(--bg2); }
.detail-pane .detail-img { float: none; width: 100%; margin: 0 0 10px; }
.detail-pane .detail-fallback { --ch: 400px; }

/* ---------- ประวัติเกมฝั่งซ้าย (จอกว้าง) ---------- */
.log-pane { display: none; }
@media (min-width: 1280px) {
  .log-pane { display: flex; flex-direction: column; flex: none; width: 260px; min-height: 0; background: var(--bg2); border-right: 1px solid var(--line); }
  .side .detail { flex: 1; min-height: 0; max-height: none; border-bottom: 0; }
}

/* ---------- จอแคบ / มือถือ ---------- */
@media (max-width: 900px) {
  /* ซ่อนด้วย right ไม่ใช่ transform: transform จะทำให้แผงปุ่ม (.actions แบบ fixed) ข้างในหลุดออกนอกจอไปกับแผงข้าง */
  .side { position: fixed; right: calc(-1 * min(340px, 92vw)); top: 48px; bottom: 0; z-index: 60; width: min(340px, 92vw); visibility: hidden; transition: right .2s, visibility .2s; }
  .side.open { right: 0; visibility: visible; box-shadow: -10px 0 30px #000a; }
  .side .actions.show { visibility: visible; }
  .panel-toggle { display: inline-block; }
  .tools .btn { padding: 5px 8px; font-size: .82rem; }
  .tools [data-cmd="drive"], .tools [data-cmd="damage"], .tools [data-cmd="standAll"] { display: none; }
  .actions.show {
    position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 65; border: 1px solid var(--orange); border-radius: 12px;
    max-height: 45vh; overflow: auto; box-shadow: 0 -8px 30px #000a;
  }
  .side .actions.show { position: fixed; }
  .turn { font-size: .82rem; }
  .builder-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .detail-pane { display: none; }
  .deck-pane { max-height: 45vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .room-code { padding: 3px 6px; font-size: .85rem; }
  .bar { gap: 6px; padding: 6px 8px; }
  .turn { display: none; }
}
