:root {
  --bg: #062016; --felt: #0e5233; --felt2: #08331f; --ink: #f4f1e8; --muted: #9fc0ad;
  --gold: #f5c542; --fold: #c2413a; --call: #2b8a3e; --raise: #e8890c; --line: rgba(255,255,255,.14);
  --panel: rgba(0,0,0,.30);
  --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; display: none; }
.screen.on { display: flex; }
.page { overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at 50% 0%, #135c3a 0%, var(--bg) 70%); }
.page .wrap { width: 100%; max-width: 460px; margin: 0 auto; padding: calc(20px + var(--sa-t)) 16px calc(28px + var(--sa-b)); }
.logo { text-align: center; font-size: 34px; letter-spacing: 6px; margin-top: 4px; }
h1 { text-align: center; margin: 4px 0 2px; font-size: 30px; letter-spacing: -0.5px; }
h2 { font-size: 16px; margin: 18px 0 8px; color: var(--gold); }
h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.sub { text-align: center; color: var(--muted); margin: 4px 0 10px; }
.nomoney { text-align: center; font-weight: 700; background: rgba(245,197,66,.14); border: 1px solid rgba(245,197,66,.45);
  color: var(--gold); border-radius: 999px; padding: 7px 12px; margin: 10px auto 16px; width: fit-content; max-width: 100%; }
.nomoney.small { font-size: 13px; margin-top: 18px; }
.lbl { display: block; font-size: 14px; color: var(--muted); margin: 6px 0; }
input, select { width: 100%; font-size: 17px; padding: 12px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0,0,0,.35); outline: none; }
input:focus, select:focus { border-color: var(--gold); }
select { padding: 10px 8px; font-size: 16px; appearance: none; -webkit-appearance: none; text-align: center; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 4px 14px 14px; margin-top: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.grid3 label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.row > .btn { flex: 1; }
.btn { border: 0; border-radius: 14px; padding: 13px 16px; font-size: 17px; font-weight: 700; cursor: pointer;
  background: rgba(255,255,255,.12); min-height: 50px; }
.btn:active { transform: scale(.98); filter: brightness(1.1); }
.btn:disabled { opacity: .4; }
.btn.primary { background: linear-gradient(180deg, #ffd65c, #e9ae1b); color: #2a1d00; }
.btn.big { width: 100%; font-size: 19px; min-height: 56px; margin-top: 4px; }
.btn.ghost { background: transparent; color: var(--muted); width: 100%; margin-top: 10px; }
.foot, .note { color: var(--muted); font-size: 13px; text-align: center; line-height: 1.6; margin-top: 18px; }
.warn { color: #ffb4a8; text-align: center; font-weight: 700; }
.recent { margin-top: 12px; }
.bigcode { text-align: center; font-size: 46px; font-weight: 800; letter-spacing: 10px; color: var(--gold); margin: 0 0 12px; }
.seats { list-style: none; padding: 0; margin: 0; }
.seats li { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin-bottom: 8px; min-height: 52px; }
.seats li .nm { flex: 1; font-weight: 700; }
.seats li.empty { color: var(--muted); border-style: dashed; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #3ddc84; flex: none; }
.dot.off { background: #777; }
.mini { border: 0; background: rgba(255,255,255,.12); border-radius: 8px; padding: 6px 10px; font-size: 13px; }

/* ---------- 테이블 ---------- */
#table { flex-direction: column; background: radial-gradient(ellipse at 50% 42%, #187548 0%, var(--felt) 38%, var(--felt2) 100%);
  padding: var(--sa-t) 0 var(--sa-b); user-select: none; -webkit-user-select: none;
  display: none; }
#table.on { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top" "opps" "board" "me" "act"; height: 100%; }
.top { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 4px 8px; min-height: 42px; }
.ico { border: 0; background: rgba(0,0,0,.25); border-radius: 10px; width: 40px; height: 36px; font-size: 18px; cursor: pointer; flex: none; }
.ico.txt { width: auto; padding: 0 12px; font-size: 14px; font-weight: 700; }
.tinfo { flex: 1; text-align: center; font-size: 13px; color: var(--muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tinfo b { color: var(--ink); }

.opps { grid-area: opps; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 0 8px; }
.seat { position: relative; background: var(--panel); border: 2px solid transparent; border-radius: 14px; padding: 7px 8px 9px;
  min-height: 0; overflow: hidden; }
.seat.turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(245,197,66,.45); }
.seat.out { opacity: .5; }
.seat .nm { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.seat .stk { font-size: 14px; color: var(--gold); font-weight: 700; }
.seat .st { font-size: 12.5px; color: var(--muted); min-height: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .hc { display: flex; gap: 3px; margin-top: 4px; --cw: min(10.5vw, 6.2dvh, 44px); min-height: calc(var(--cw) * 1.4); }
.seat .empty { color: var(--muted); font-weight: 700; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 800; border-radius: 6px; padding: 1px 5px; background: rgba(255,255,255,.18); flex: none; }
.badge.d { background: #fff; color: #111; border-radius: 50%; width: 18px; height: 18px; padding: 0; text-align: center; line-height: 18px; }
.bet { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.45); border: 1px solid rgba(245,197,66,.6);
  color: var(--gold); font-weight: 800; font-size: 13px; border-radius: 999px; padding: 2px 8px; }
.won { position: absolute; right: 8px; top: 7px; color: #9cff9c; font-weight: 900; font-size: 15px; }
.tbar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--gold); width: 100%; transition: width .2s linear; }
.tbar.low { background: #ff6b5e; }

.board { grid-area: board; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 0; padding: 4px 8px; }
.pot { font-weight: 800; font-size: 16px; background: rgba(0,0,0,.3); border-radius: 999px; padding: 4px 14px; color: var(--gold); min-height: 1.5em; }
.cards { display: flex; gap: 5px; --cw: min(15.5vw, 10.5dvh, 70px); min-height: calc(var(--cw) * 1.4); }
.status { font-size: 14.5px; text-align: center; min-height: 2.6em; line-height: 1.3; padding: 0 6px; }
.status b { color: var(--gold); }

.me { grid-area: me; display: flex; align-items: center; gap: 10px; margin: 0 8px; padding: 8px 10px 10px; position: relative;
  background: var(--panel); border-radius: 16px; border: 2px solid transparent; }
.me.turn { border-color: var(--gold); box-shadow: 0 0 16px rgba(245,197,66,.4); }
.me .hc { display: flex; gap: 5px; --cw: min(17vw, 11dvh, 78px); min-height: calc(var(--cw) * 1.4); flex: none; }
.me .info { flex: 1; min-width: 0; }
.me .nm { font-weight: 800; font-size: 16px; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.me .stk { color: var(--gold); font-weight: 800; font-size: 20px; }
.me .made { font-size: 13px; color: #cfe8da; margin-top: 2px; }
.me .bet { bottom: 10px; }

.actions { grid-area: act; padding: 8px 8px calc(8px); display: flex; flex-direction: column; gap: 7px; min-height: 0; }
.abtn { border: 0; border-radius: 14px; font-weight: 800; font-size: 17px; min-height: 56px; color: #fff; cursor: pointer; padding: 4px 6px; line-height: 1.15; }
.abtn small { display: block; font-size: 12.5px; font-weight: 700; opacity: .9; }
.abtn:active { transform: scale(.97); filter: brightness(1.15); }
.abtn:disabled { opacity: .35; }
.abtn.fold { background: var(--fold); }
.abtn.call { background: var(--call); }
.abtn.raise { background: var(--raise); }
.abtn.allin { background: linear-gradient(180deg, #ff5f6d, #c81d4e); }
.abtn.gold { background: linear-gradient(180deg, #ffd65c, #e9ae1b); color: #2a1d00; }
.mainrow { display: grid; grid-template-columns: 1fr 1.25fr 1.25fr; gap: 7px; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.presets button { border: 0; border-radius: 10px; background: rgba(0,0,0,.35); font-weight: 700; font-size: 14px; min-height: 38px; cursor: pointer; }
.presets button.sel { background: rgba(232,137,12,.55); }
.slrow { display: flex; align-items: center; gap: 8px; }
.slrow button { border: 0; border-radius: 10px; width: 44px; height: 38px; background: rgba(0,0,0,.35); font-size: 20px; font-weight: 800; flex: none; cursor: pointer; }
input[type=range] { flex: 1; padding: 0; border: 0; background: transparent; height: 38px; accent-color: var(--raise); }
.waitrow { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; min-height: 56px; }
.waitrow .emo { border: 0; background: rgba(0,0,0,.28); border-radius: 12px; font-size: 22px; width: 46px; height: 46px; cursor: pointer; }
.waittxt { width: 100%; text-align: center; color: var(--muted); font-size: 14px; }
.conn { position: fixed; top: calc(8px + var(--sa-t)); left: 50%; transform: translateX(-50%); background: #b3261e; color: #fff;
  padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 13px; z-index: 30; }

/* ---------- 카드 ---------- */
.card { width: var(--cw, 48px); height: calc(var(--cw, 48px) * 1.4); border-radius: calc(var(--cw, 48px) * .12); background: #fbfbf7;
  color: #111; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 2px 5px rgba(0,0,0,.35); flex: none; position: relative; }
.card b { font-size: calc(var(--cw, 48px) * .48); font-weight: 900; letter-spacing: -1px; }
.card i { font-style: normal; font-size: calc(var(--cw, 48px) * .44); margin-top: 1px; }
.card.s-s { color: #151515; } .card.s-h { color: #d3262e; } .card.s-d { color: #1c63c9; } .card.s-c { color: #188a3b; }
.card.back { background: repeating-linear-gradient(45deg, #b22a2a 0 5px, #8f1f1f 5px 10px); border: 3px solid #fbfbf7; }
.card.slot { background: rgba(0,0,0,.18); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); }
.card.dim { opacity: .35; }
.card.hi { box-shadow: 0 0 0 3px var(--gold), 0 0 12px rgba(245,197,66,.8); }
.card.flip { animation: flip .35s ease-out; }
@keyframes flip { from { transform: rotateY(90deg) scale(.9); } to { transform: none; } }
.s-s { color: #e8e8e8; } .s-h { color: #ff5a5f; } .s-d { color: #5aa2ff; } .s-c { color: #4fd17a; }

/* ---------- 창·알림 ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86%; background: #0d2d1f; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; padding-bottom: var(--sa-b); max-width: 560px; margin: 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 17px; }
.sheet-content { overflow-y: auto; padding: 12px 14px 18px; -webkit-overflow-scrolling: touch; }
.sheet-content .btn { width: 100%; margin-top: 8px; }
.score { width: 100%; border-collapse: collapse; font-size: 15px; }
.score td, .score th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.score td:first-child, .score th:first-child { text-align: left; }
.plus { color: #8dff9c; } .minus { color: #ff9b8f; }
.hist { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: rgba(0,0,0,.2); font-size: 14px; }
.hist .hrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; --cw: 28px; }
.hist .hrow .card b { font-size: 13px; } .hist .hrow .card i { font-size: 12px; }
.hist .lbl2 { color: var(--muted); width: 54px; flex: none; }
.hist .acts { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sa-b)); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px;
  border-radius: 12px; z-index: 50; font-weight: 700; max-width: 90vw; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.floatemo { position: fixed; font-size: 40px; z-index: 35; pointer-events: none; animation: up 1.6s ease-out forwards; }
@keyframes up { from { transform: translate(-50%, 0) scale(.6); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); } to { transform: translate(-50%, -70px) scale(1); opacity: 0; } }

/* 작은 폰(320×568) */
@media (max-height: 600px) and (orientation: portrait) {
  .abtn { min-height: 50px; font-size: 16px; }
  .presets button, .slrow button { min-height: 32px; height: 32px; }
  input[type=range] { height: 32px; }
  .status { min-height: 2.4em; font-size: 13.5px; }
  .seat { padding: 5px 7px 7px; }
}
/* 큰 화면: 너무 작아 보이지 않게 가운데 기둥 */
@media (min-width: 700px) and (orientation: portrait), (min-width: 900px) {
  #table.on { max-width: 560px; margin: 0 auto; left: 0; right: 0; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .seat .hc { --cw: min(9vw, 6.5dvh, 54px); }
  .cards { --cw: min(13vw, 10dvh, 84px); }
  .me .hc { --cw: min(15vw, 11dvh, 92px); }
}
/* 가로 폰(740×360 등): 오른쪽에 단추 */
@media (orientation: landscape) and (max-height: 520px) {
  #table.on { grid-template-columns: minmax(0, 1fr) min(44vw, 330px); grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top act" "opps act" "board act" "me act"; max-width: none; }
  .top { min-height: 34px; padding: 2px 8px; }
  .ico { height: 30px; }
  .opps { gap: 6px; }
  .seat { padding: 3px 7px 5px; }
  .seat .hc { --cw: min(5vw, 9dvh, 34px); margin-top: 2px; }
  .seat .st { display: none; }
  .cards { --cw: min(7vw, 15dvh, 56px); }
  .board { gap: 3px; padding: 2px 8px; }
  .status { min-height: 1.3em; font-size: 13px; }
  .pot { font-size: 14px; padding: 2px 12px; }
  .me { padding: 4px 10px 6px; margin-bottom: 4px; }
  .me .hc { --cw: min(8vw, 16dvh, 60px); }
  .me .stk { font-size: 17px; }
  .actions { justify-content: flex-end; padding: 6px 8px 8px 0; }
  .mainrow { grid-template-columns: 1fr 1fr 1fr; }
  .abtn { min-height: 52px; font-size: 15px; }
}

/* 리바인·족보·게임 끝 */
.rb { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.seat .stk .rb { margin-left: 2px; }
.me .rb { margin-top: 1px; }
.card.mh { box-shadow: 0 0 0 2px rgba(140,220,255,.85), 0 0 9px rgba(140,220,255,.55); }
.why { color: #cfe8da; font-size: 12.5px; }
.mainrow.two { grid-template-columns: 1.6fr 1fr; }
.rank { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; background: rgba(0,0,0,.18); }
.rank.cur { border-color: var(--gold); background: rgba(245,197,66,.14); }
.rank .rk-n { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px; }
.rank .rk-n small { width: 100%; color: var(--muted); font-size: 12.5px; }
.rank .hrow { display: flex; gap: 4px; margin-top: 6px; --cw: 30px; }
.rank .hrow .card b { font-size: 14px; } .rank .hrow .card i { font-size: 12px; }
.over { position: absolute; inset: 0; z-index: 25; background: rgba(4,20,13,.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.over-box { width: 100%; max-width: 420px; }
.over-box h1 { color: var(--gold); }
.over-box .score td, .over-box .score th { text-align: center; }
.tinfo { min-width: 0; }
@media (max-width: 360px) { .ico.txt { padding: 0 9px; font-size: 13px; } .top { gap: 4px; padding: 4px 6px; } .tinfo { font-size: 12px; } }

/* 4~6인: 작은 자리 칸 */
#table.many .opps { gap: 5px; padding: 0 6px; }
#table.many .seat { padding: 4px 6px 5px; border-radius: 11px; }
#table.many .seat .nm { font-size: 13px; gap: 3px; }
#table.many .seat .stk { font-size: 12.5px; }
#table.many .seat .st { font-size: 11.5px; }
#table.many .seat .hc { --cw: min(7.4vw, 4.6dvh, 32px); min-height: 0; margin-top: 2px; }
#table.many .seat .hc:empty { display: none; }
#table.many .seat .bet { font-size: 11px; padding: 1px 6px; right: 5px; bottom: 5px; }
#table.many .seat .won { font-size: 12px; top: 4px; right: 5px; }
#table.many .badge { font-size: 9.5px; padding: 0 4px; }
#table.many .badge.d { width: 15px; height: 15px; line-height: 15px; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-align: center; min-width: 0; }
.center .pot { font-size: 13.5px; padding: 3px 10px; }
.center .status { font-size: 11.5px; min-height: 0; padding: 0; }
#table.rows2 .board { padding: 2px 8px; }
@media (orientation: landscape) and (max-height: 520px) {
  #table.many .seat { padding: 2px 6px 3px; }
  #table.many .seat .hc { --cw: min(3.6vw, 7.5dvh, 28px); }
  #table.rows2 .cards { --cw: min(6.5vw, 14dvh, 52px); }
}
