:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --table-bg: #101915;
  --table-text: #f7f2e5;
  --table-muted: #c6cbbb;
  --table-gold: #eed293;
  --table-line: #415648;
  --table-button: #19251e;
  --canvas: var(--table-bg);
  --panel: #1a2821;
  --text: var(--table-text);
  --muted: var(--table-muted);
  --gold: var(--table-gold);
  --line: var(--table-line);
  --field: #111c16;
  --secondary: var(--table-button);
  --wash: #233c30;
  --focus: #f8dc9b;
  --action: var(--gold);
  --action-text: #241c0c;
}
:root[data-theme="light"] {
  color-scheme: light;
  --canvas: #eef3ec;
  --panel: #fafcf8;
  --text: #273a2e;
  --muted: #465d4e;
  --gold: #715020;
  --line: #b4c6b8;
  --field: #f3f7ef;
  --secondary: #e7efe6;
  --wash: #d1e3d6;
  --focus: #216440;
  --action: #234933;
  --action-text: #f5f7ef;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--text); background: var(--canvas); }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
input, select {
  width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--field);
}
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.on { display: flex; }
.gbtn, .dbtn2 {
  min-height: 44px; padding: 8px 14px; border: 1px solid transparent; border-radius: 9px;
  font-weight: 750; text-align: center;
}
.gbtn { background: var(--action); color: var(--action-text); }
.dbtn2 { background: var(--secondary); border-color: var(--line); color: var(--text); }
.gbtn:active:not(:disabled), .dbtn2:active:not(:disabled) { transform: translateY(1px); }
.open-padup { text-decoration: none; }

#menu, #lobby { align-items: center; overflow: auto; padding: 20px max(16px, env(safe-area-inset-left)); }
#menu { background: radial-gradient(ellipse at 50% 22%, var(--wash), var(--canvas) 72%); }
.wrap { width: min(100%, 620px); display: grid; gap: 16px; margin: auto 0; }
#menu .wrap { width: min(100%, 490px); }
#menu h1 { text-align: center; font-size: clamp(20px, 4vw, 27px); }
#menuNote:empty { display: none; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(6px, 2.6vw, 16px); }
.mode {
  position: relative; min-width: 0; aspect-ratio: 5 / 7; padding: 8px 3px; border-radius: 12px;
  background: linear-gradient(160deg, #fffbf0, #e7e4d2); color: #202a24; border: 3px solid transparent;
  box-shadow: 0 7px 20px #0005; display: grid; place-content: center; gap: 6px;
}
.mode .big { font-size: clamp(32px, 10vw, 60px); line-height: 1; }
.mode .corner { position: absolute; top: 7px; left: 8px; font-size: 13px; font-weight: 850; line-height: 1; text-align: left; }
.mode .r, .card.red { color: #aa2d3a; }
.mode b { font-size: clamp(11px, 3.5vw, 16px); }
.mode.sel { border-color: var(--gold); box-shadow: 0 0 0 2px #eed29367, 0 8px 22px #0007; }
.note { font-size: 13px; line-height: 1.5; color: var(--muted); }
#menu .note { text-align: center; }
.lobby-head, .section-head, .lobby-nav, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lobby-head { flex-wrap: wrap; }
.lobby-head h1 { font-size: clamp(20px, 4vw, 26px); }
.xp { color: var(--gold); font-weight: 800; font-size: 14px; }
.box { display: grid; gap: 12px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.box h2 { font-size: 16px; }
.form-fields { display: grid; gap: 8px; }
.field { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
#rooms { display: grid; gap: 8px; }
.room { display: flex; gap: 8px; align-items: center; padding: 10px; background: var(--field); border-radius: 8px; }
.room .grow { flex: 1; min-width: 0; display: grid; gap: 3px; }
.room b { overflow-wrap: anywhere; font-size: 14px; }
.room small { color: var(--muted); font-size: 12px; }
.room button { flex: none; }
#chipsDialog {
  width: min(92%, 380px); padding: 0; border: 0; border-radius: 14px; color: var(--text);
  background: var(--canvas); box-shadow: 0 18px 36px #0008;
}
#chipsDialog::backdrop { background: #07150ec7; }
#chipsNote { font-size: 13px; line-height: 1.5; color: var(--muted); }
.dialog-actions { justify-content: flex-end; }

#table {
  --text: var(--table-text); --muted: var(--table-muted); --gold: var(--table-gold);
  --line: var(--table-line); --secondary: var(--table-button); --focus: var(--table-gold);
  width: min(100%, 1100px); min-height: 480px; margin-inline: auto; background: var(--table-bg);
}
#topbar { flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 10px; z-index: 4; }
#topbar .grow {
  flex: 1; color: var(--gold); text-align: center; font-size: clamp(12px, 2.5vw, 16px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#topbar button { padding-inline: 9px; white-space: nowrap; font-size: 12px; }
#arena { position: relative; flex: 1; min-height: 315px; }
#rim {
  position: absolute; inset: 8% 6% 12%; border-radius: 47% / 45%; padding: 10px;
  background: linear-gradient(150deg, #94734b, #4b3a27 60%);
  box-shadow: 0 14px 32px #0008, inset 0 0 0 1px #a98c6144;
}
#felt {
  width: 100%; height: 100%; border-radius: inherit;
  background: radial-gradient(ellipse at 50% 42%, #27674e, #16442f 85%);
  box-shadow: inset 0 0 0 1px #d4c49180, inset 0 0 0 6px #101e1744, inset 0 0 35px #09211988;
}
#center {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 72%; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none;
}
#street { font-size: 11px; padding: 2px 8px; border-radius: 8px; background: #e1cf9d; color: #22321e; font-weight: 800; }
#street:empty, #board:empty { display: none; }
#pot, .bet {
  display: flex; align-items: center; gap: 5px; background: #0a2118e6; border: 1px solid #bddcb34d;
  border-radius: 16px; padding: 4px 9px; font-size: 13px; font-weight: 850; color: var(--gold);
}
#pot small { color: var(--muted); font-size: 11px; }
#board { display: flex; gap: 4px; --cw: clamp(24px, 7vw, 48px); }
#banner {
  display: none; text-align: center; padding: 5px 10px; border-radius: 8px; background: #e9d49a;
  color: #261e13; font-size: clamp(11px, 3vw, 14px); font-weight: 800; line-height: 1.35;
  max-width: 100%; overflow-wrap: anywhere;
}
#banner small { display: block; font-weight: 650; }

.seat {
  position: absolute; transform: translate(-50%, -50%); z-index: 2; --cw: clamp(22px, 5vw, 38px);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.seat.me { --cw: clamp(32px, 9vw, 52px); }
.seat .cards { display: flex; justify-content: center; }
.seat .cards .card + .card { margin-left: calc(var(--cw) * -.52); }
.seat.me .cards .card + .card { margin-left: calc(var(--cw) * -.12); }
.who { display: flex; align-items: center; position: relative; }
.ava {
  width: clamp(29px, 6vw, 42px); aspect-ratio: 1; border-radius: 50%; padding: 3px; flex: none;
  position: relative; z-index: 1; background: conic-gradient(var(--ring, transparent) calc(var(--p, 0) * 1%), #14281a 0);
}
.ava i {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  border: 1px solid #f5e1a4a0; font-size: 14px; font-style: normal; font-weight: 850;
}
.plate {
  margin-left: -8px; padding: 2px 6px 2px 10px; min-width: 49px; background: #14251deF;
  border: 1px solid #a4ba9a78; border-radius: 0 8px 8px 0;
}
.plate .nm { font-size: 11px; font-weight: 750; overflow: hidden; max-width: clamp(50px, 12vw, 95px); white-space: nowrap; text-overflow: ellipsis; }
.plate .ch { font-size: 11px; font-weight: 850; color: var(--gold); display: flex; align-items: center; gap: 3px; }
.coin { width: 8px; height: 8px; border-radius: 50%; background: #cfb171; border: 1px solid #fae8a2; }
.seat.turn .ava { --ring: #8cffb3; --p: 100; }
.seat.win .ava { --ring: var(--gold); --p: 100; }
.seat.win .plate { border-color: var(--gold); }
.seat.fold .cards, .seat.fold .who, .seat.offline .who { opacity: .55; }
.dmark {
  position: absolute; left: -4px; top: -3px; width: 16px; height: 16px; z-index: 2;
  display: grid; place-items: center; background: #f7f1de; color: #19241b; font-size: 10px; font-weight: 900; border-radius: 50%;
}
.badge, .hn { font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 750; white-space: nowrap; background: #10291d; }
.b-fold, .b-leave { background: #384941; }
.b-allin, .b-ddadang { background: #8e3743; }
.hn { color: #2d2412; background: var(--gold); }
.gain {
  position: absolute; z-index: 2; left: 50%; top: -6px; pointer-events: none; white-space: nowrap;
  font-weight: 850; color: var(--gold); text-shadow: 0 2px 3px #000; animation: rise 1.6s ease-out forwards;
}
@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -32px); }
}
.bet { position: absolute; z-index: 1; transform: translate(-50%, -50%); font-size: 11px; padding: 2px 6px; }
.stack { position: relative; width: 13px; height: 13px; flex: none; }
.stack b { position: absolute; left: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--c); border: 1px dashed #f6eed7; }
.stack b:nth-child(1) { top: 2px; --c: #ab4951; }
.stack b:nth-child(2) { top: 0; --c: #48769e; }
.stack b:nth-child(3) { top: -2px; --c: #4e8a69; }

.card {
  position: relative; flex: none; overflow: hidden; padding: 0; border: 0;
  width: var(--cw); height: calc(var(--cw) * 1.37); border-radius: calc(var(--cw) * .12);
  background: linear-gradient(155deg, #fffdf6, #e9e5d4); color: #141e18; box-shadow: -1px 2px 4px #0008;
}
.card .r { position: absolute; top: 5%; left: 8%; font-size: calc(var(--cw) * .39); font-weight: 900; line-height: 1; }
.card .s1 { position: absolute; left: 9%; top: 35%; font-size: calc(var(--cw) * .29); line-height: 1; }
.card .s2 { position: absolute; right: 8%; bottom: 5%; font-size: calc(var(--cw) * .55); line-height: 1; }
.card.back { background: repeating-linear-gradient(45deg, #234939 0 4px, #306148 4px 8px); box-shadow: inset 0 0 0 2px #f2e9c7, -1px 2px 4px #0008; }
.card.ind { display: grid; place-items: center; font-weight: 900; font-size: calc(var(--cw) * .65); }
.card.ind.q { color: var(--gold); background: #204947; box-shadow: inset 0 0 0 2px #f2e9c7, -1px 2px 4px #0008; }
.card.hid::after { content: ""; position: absolute; inset: 0; background: #183c6928; }
.card.upmark { box-shadow: 0 0 0 1px var(--gold), -1px 2px 4px #0008; }
.card.dim { filter: brightness(.55); }
.card.deal { animation: deal .24s ease-out backwards; }
@keyframes deal {
  0% { opacity: 0; transform: translateY(-15px) scale(.8); }
  100% { opacity: 1; transform: none; }
}
.card.pick { transition: transform .12s; }
.card.pick:focus-visible { z-index: 3; }
.card.disc { opacity: .56; transform: translateY(5px); }
.card.open { transform: translateY(-7px); box-shadow: 0 0 0 2px var(--gold); }
.card .tag {
  position: absolute; inset: auto 0 0; text-align: center; line-height: 1.5; font-size: 9px; font-weight: 900;
  background: #305a40; color: #fff;
}

#bar {
  flex: none; z-index: 4; display: grid; gap: 6px;
  background: #111d17; border-top: 1px solid var(--line);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
}
.turn-info { display: grid; grid-template-columns: minmax(0, 1fr) 30px; align-items: center; }
#info { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 21px; font-size: 13px; color: var(--muted); }
#info .mh { background: #2b4435; color: var(--gold); padding: 2px 8px; border-radius: 8px; font-weight: 800; white-space: nowrap; }
#info b, #clock { color: var(--gold); }
#clock { font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.acts, .acts2 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.acts2 { grid-template-columns: 1fr 1.5fr; }
.ab {
  width: 100%; min-height: 44px; padding: 4px 2px; border: 1px solid #668d73; border-radius: 8px;
  background: #304938; color: var(--text); font-weight: 750; font-size: 14px; line-height: 1.2;
  display: grid; align-content: center; justify-items: center;
}
.ab small { font-size: 10px; min-height: 12px; }
.ab:disabled { background: #1c2d22; border-color: #486151; }
.a-fold { background: #394945; }
.a-call, .a-check { background: #2c6252; }
.a-ok, .a-half, .a-quarter { background: var(--gold); color: #241c0c; border-color: #e8c777; }
#toast {
  position: fixed; left: 50%; top: 12px; z-index: 9; transform: translateX(-50%);
  padding: 9px 12px; width: max-content; max-width: 90vw; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); font-size: 13px; text-align: center; display: none; box-shadow: 0 4px 18px #0006;
}
#logbox {
  position: absolute; z-index: 5; top: 0; right: 6px; width: min(230px, 88%); max-height: 56%; overflow: auto;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #142119f2; color: #ebe3d1; font-size: 12px; line-height: 1.6;
}
@media (max-width: 540px) {
  #rim { inset-inline: 2%; padding: 7px; }
  .acts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  #topbar { padding-inline: 5px; gap: 4px; }
  #topbar button { padding-inline: 5px; }
  .seat .cards .card + .card { margin-left: calc(var(--cw) * -.63); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

