@media (max-width: 620px) { body { overflow-x: hidden; }.status-strip .status-message { white-space: normal; }.hand-seat-2 { position: relative; left: 0; width: 64px; } }
@media (max-width: 620px) { body { height: 100vh; overflow: hidden; } body .app-shell { height: 100vh; overflow: hidden; padding: 4px; } body .status-strip { min-height: 48px; padding: 6px 8px; gap: 5px; font-size: 11px; } body .board { margin: 4px 0; gap: 4px; } body .table-panel { min-height: 220px; } body .inline-log { min-height: 64px; max-height: 72px; } body .seat-hand { min-height: 64px; padding: 5px; } body .seat-hand-heading { margin-bottom: 2px; font-size: 9px; } body .seat-hand-cards .card { height: 36px; width: 20px; flex-basis: 20px; padding: 2px; font-size: 9px; } body .hand-panel { min-height: 170px; padding: 6px; } body .hand { margin-top: 20px; gap: 3px; } body .hand .card { width: 29px; height: 43px; flex-basis: 29px; padding: 3px; font-size: 10px; } body .seat-action-hint { font-size: 9px; } body .seat-action-buttons button { min-height: 24px; padding: 0 5px; font-size: 9px; } }
:root { --player-card-size: 110px; color-scheme: light; font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", "Malgun Gothic", sans-serif; background: #e9eee9; color: #15221c; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; }
.app-shell { width: min(100%, 1200px); margin: 0 auto; padding: 18px 16px 32px; }
h1, h2, p { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
.eyebrow, .panel-kicker { color: #557066; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.start-button { min-height: 40px; border: 1px solid #156a51; background: #156a51; color: #fff; border-radius: 5px; padding: 0 14px; font-size: 14px; font-weight: 700; }
.status-strip { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: center; background: #113a31; color: #fff; padding: 12px 14px; border-radius: 6px; font-size: 14px; }
.status-strip strong { background: #d2a52d; color: #172219; padding: 4px 8px; border-radius: 4px; text-align: center; }
.status-strip .status-message { color: #dce8df; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.reaction-label { color: #f7e7a5; font-weight: 700; white-space: nowrap; }
.board { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.5fr) minmax(220px, 1.5fr) minmax(160px, 1fr); grid-template-rows: auto auto auto; grid-template-areas: ". p3 h3 h3" "p2 center center p4" "h2 h2 h4 h4"; gap: 10px 12px; margin: 12px 0; align-items: center; }.players { display: contents; }
.player { width: var(--player-card-size); height: var(--player-card-size); min-width: 0; border: 1px solid #c5d0c8; background: #f9fbf8; padding: 10px; border-radius: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; }
.player.seat-1 { grid-area: p2; justify-self: center; }.player.seat-2 { grid-area: p3; justify-self: center; }.player.seat-3 { grid-area: p4; justify-self: center; }
.player.active { border-color: #d2a52d; box-shadow: inset 0 0 0 1px #d2a52d; background: #fffdf2; }
.current-turn-tag {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  justify-content: center;
  border: 1px solid #fff0a2;
  border-radius: 4px;
  padding: 2px 6px;
  background: #d79a1d;
  color: #1e2519;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0,0,0,.3);
}
.current-turn-tag:empty { display: none; }
.player-status-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; min-height: 14px; }.player span { color: #577166; font-size: 11px; font-weight: 700; }.player strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.player small { color: #718177; font-size: 12px; }.declaration-tag, .red-ten-tag, .ting-tag { align-self: center; padding: 2px 4px; border-radius: 3px; font-size: 10px; font-style: normal; font-weight: 700; }.declaration-tag { background: #f2d77b; color: #624800; }.red-ten-tag { background: #fde5e1; color: #b63030; }.ting-tag { background: #dceff1; color: #12616b; }
.game-grid { grid-area: center; min-width: 0; }
.seat-hand { min-width: 0; min-height: 112px; border: 1px solid #c5d0c8; border-radius: 6px; background: #fff; padding: 10px; }.hand-seat-1 { grid-area: h2; margin-right: 22px; }.hand-seat-2 { grid-area: h3; position: relative; left: -120px; width: calc(100% + 120px); }.hand-seat-3 { grid-area: h4; margin-left: 22px; }.seat-hand.turn-hand { border-color: #d2a52d; box-shadow: inset 0 0 0 1px #d2a52d; }.seat-hand.selectable-hand { background: #fffdf2; }.seat-hand-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 12px; }.seat-hand-heading strong { white-space: nowrap; }.seat-hand-heading span { color: #6b7c73; font-size: 11px; white-space: nowrap; }.seat-hand-cards { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; overflow: visible; padding: 3px 1px 5px; }.seat-hand-cards .card { flex: 0 0 44px; width: 44px; height: 62px; padding: 6px; font-size: 13px; }
.bot-hand { background: #f8fbf9; }.bot-hand .seat-hand-cards { flex-wrap: nowrap; justify-content: center; gap: 0; overflow: hidden; }.bot-hand .seat-hand-cards .card { flex: 0 0 28px; width: 28px; height: 58px; margin-left: -8px; border: 1px solid #9aada4; border-radius: 5px; background: #dfe9e4; color: transparent; box-shadow: -1px 0 0 rgba(36, 75, 62, .2); }.bot-hand .seat-hand-cards .card:first-child { margin-left: 0; }.bot-hand .seat-hand-cards .card span, .bot-hand .seat-hand-cards .card small { visibility: hidden; }
.seat-actions { margin-top: 8px; padding-top: 8px; border-top: 1px solid #e1e8e3; }.seat-action-hint { margin: 0 0 7px; color: #4d6257; font-size: 11px; text-align: center; }.seat-action-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }.seat-action-buttons button { min-height: 32px; padding: 0 9px; border: 1px solid #8ea59a; border-radius: 4px; background: #fff; color: #254438; font-size: 12px; font-weight: 700; }.seat-action-buttons button.primary { background: #156a51; color: #fff; border-color: #156a51; }
.table-panel, .hand-panel, .actions { background: #fff; border: 1px solid #c5d0c8; border-radius: 6px; padding: 14px; }
.table-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(180px, .75fr); gap: 12px; min-height: 130px; }.table-state { display: flex; min-width: 0; flex-direction: column; }.table-meta { min-height: 28px; display: flex; align-items: center; justify-content: center; gap: 10px; color: #557066; font-size: 12px; text-align: center; }.table-meta strong { background: #d2a52d; color: #172219; padding: 4px 10px; border-radius: 4px; }.table-state > .panel-kicker, .inline-log > .panel-kicker { height: 20px; display: flex; align-items: center; justify-content: center; text-align: center; }.table-cards { flex: 1; min-height: 75px; display: flex; align-items: center; justify-content: center; gap: 14px; color: #23483b; font-size: 18px; font-weight: 700; text-align: center; }.table-cards .start-button { flex: 0 0 auto; }.turn-label { color: #557066; font-size: 13px; }.inline-log { min-width: 0; border-left: 1px solid #c5d0c8; }.inline-log ol { margin: 10px 0 0 12px; padding-left: 20px; max-height: 120px; overflow: auto; color: #42544a; font-size: 12px; }.inline-log li + li { margin-top: 5px; }
.lower-layout { margin-top: 12px; }.play-area { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; align-items: center; }.hand-panel { position: relative; min-height: 112px; }.hand-heading { display: flex; justify-content: center; align-items: center; gap: 12px; text-align: center; }.hand-heading > div:first-child { text-align: center; }.hand-status { position: absolute; right: 14px; top: 14px; display: flex; align-items: center; gap: 8px; color: #557066; font-size: 13px; }.hand-status .error { color: #bb2929; font-weight: 700; }
.player-one-hand-title { display: flex; align-items: center; gap: 7px; color: #15221c; font-size: 12px; font-weight: 700; text-align: left; }.player-one-hand-title span { color: #557066; font-size: 11px; }.player-one-hand-title em { padding: 2px 5px; border-radius: 3px; background: #dceff1; color: #12616b; font-size: 10px; font-style: normal; }
.hand { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; min-height: 82px; }
.card { width: 54px; height: 74px; border: 1px solid #b9c4bc; border-radius: 5px; background: #fff; padding: 7px; display: flex; flex-direction: column; justify-content: space-between; align-items: start; font-weight: 800; }.card small { font-size: 10px; opacity: .7; }.card.red { color: #b63030; }.card.black { color: #17231d; }.card.selected { transform: translateY(-8px); border-color: #d2a52d; box-shadow: 0 3px 0 #d2a52d; background: #fffbed; }
.actions { margin-top: 12px; }.actions > p { color: #4d6257; font-size: 13px; margin-bottom: 10px; text-align: center; }.action-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }.action-buttons button { min-height: 42px; border: 1px solid #8ea59a; padding: 0 15px; border-radius: 5px; font-weight: 700; }.secondary { background: #fff; color: #254438; }.primary { background: #156a51; color: #fff; border-color: #156a51 !important; }
.player-one-slot { display: flex; justify-content: center; align-items: center; margin: 0; }.player-one-slot .player { width: 110px; height: 110px; }
.result-dialog { width: min(92vw, 520px); border: 1px solid #98aaa1; border-radius: 6px; padding: 22px; color: #15221c; background: #fff; box-shadow: 0 18px 60px rgba(15, 33, 26, .28); }.result-dialog::backdrop { background: rgba(11, 31, 24, .48); }.result-header { display: flex; justify-content: space-between; align-items: start; }.result-message { margin-top: 12px; color: #2e4f41; font-weight: 700; }.result-section { border-top: 1px solid #d7e0da; margin-top: 16px; padding-top: 12px; }.result-teams { display: grid; gap: 7px; margin-top: 8px; font-size: 14px; }.result-declarations { margin-top: 8px; color: #42594d; font-size: 14px; }.result-scores { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 7px; }.result-scores li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; font-size: 14px; }.result-scores strong { font-variant-numeric: tabular-nums; }.result-scores small { color: #698076; }.gain { color: #157450; }.loss { color: #bb2929; }.result-actions { display: flex; justify-content: end; margin-top: 20px; }.result-actions button { min-width: 82px; min-height: 40px; border: 0; border-radius: 5px; font-weight: 700; }
@media (max-width: 620px) { .app-shell { width: 100%; padding: 8px 6px 20px; }.status-strip { grid-template-columns: auto auto; }.status-strip .status-message { grid-column: 1 / -1; }.board { grid-template-columns: 64px minmax(0, 1fr) 64px; grid-template-rows: auto auto auto; grid-template-areas: "h2 h2 h2" "p3 center p4" "h3 . h4"; gap: 8px 6px; margin: 8px 0; }.player.seat-1 { display: none; }.player.seat-2, .player.seat-3 { width: 64px; height: 88px; padding: 6px 3px; }.player.seat-2 { grid-area: p3; }.player.seat-3 { grid-area: p4; }.player strong { font-size: 11px; }.player small { font-size: 10px; }.player-status-tags { min-height: 13px; }.red-ten-tag, .ting-tag, .declaration-tag { max-width: 60px; overflow: hidden; font-size: 9px; }.game-grid { grid-area: center; min-width: 0; }.table-panel { min-height: 270px; padding: 8px; }.table-layout { grid-template-columns: 1fr; min-height: 250px; gap: 6px; }.table-state { min-height: 130px; }.table-cards { min-height: 70px; flex-wrap: wrap; font-size: 16px; }.inline-log { min-height: 90px; max-height: 105px; overflow: hidden; border-left: 0; border-top: 1px solid #c5d0c8; padding: 8px 0 0; }.inline-log ol { max-height: 65px; margin: 5px 0 0; padding-left: 18px; font-size: 10px; }.seat-hand { min-height: 88px; padding: 7px; }.hand-seat-1 { grid-area: h2; position: relative; left: 0; width: auto; margin: 0; }.hand-seat-2 { grid-area: h3; display: block; width: 64px; min-height: 60px; padding: 4px; margin: 0; }.hand-seat-3 { grid-area: h4; display: block; width: 64px; min-height: 60px; padding: 4px; margin: 0; }.seat-hand-heading { margin-bottom: 4px; font-size: 11px; }.seat-hand-cards { gap: 3px; padding: 2px 0; }.seat-hand-cards .card { flex-basis: 32px; width: 32px; height: 48px; padding: 4px; font-size: 11px; }.bot-hand .seat-hand-cards { justify-content: center; flex-wrap: nowrap; overflow: hidden; }.bot-hand .seat-hand-cards .card { flex-basis: 24px; width: 24px; height: 42px; margin-left: -8px; border: 1px dashed #91a39b; color: transparent; }.bot-hand .seat-hand-cards .card span, .bot-hand .seat-hand-cards .card small { visibility: hidden; }.bot-hand .seat-hand-cards .card:nth-child(n+8) { display: none; }.play-area { grid-template-columns: 80px minmax(0, 1fr); gap: 8px; align-items: stretch; }.player-one-slot { grid-column: 1; align-self: center; }.player-one-slot .player { width: 76px; height: 96px; }.hand-panel { grid-column: 2; min-height: 210px; padding: 8px; }.hand-status { top: 8px; right: 8px; font-size: 10px; }.hand { margin-top: 26px; gap: 4px; }.hand .card { flex: 0 0 39px; width: 39px; height: 58px; padding: 5px; font-size: 12px; }.seat-actions { margin-top: 8px; padding-top: 6px; }.seat-action-hint { font-size: 10px; }.seat-action-buttons { gap: 4px; }.seat-action-buttons button { min-height: 30px; padding: 0 7px; font-size: 11px; } }

/* 세로형 게임 보드: 봇 손패는 숨겨진 카드 묶음으로, 내 영역은 하단 전체 폭으로 배치한다. */
body { overflow-x: hidden; }
.board { grid-template-columns: minmax(72px, .8fr) minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(72px, .8fr); grid-template-rows: auto minmax(190px, auto) auto; grid-template-areas: ". p2 h2 ." "p3 center center p4" "h3 center center h4"; gap: 8px; align-items: stretch; }
.player.seat-1, .player.seat-2, .player.seat-3 { width: var(--player-card-size); height: var(--player-card-size); min-height: var(--player-card-size); align-self: center; padding: 7px 4px; }
.player.seat-1 { display: flex; grid-area: p2; justify-self: center; }
.player.seat-2 { grid-area: p3; justify-self: center; }
.player.seat-3 { grid-area: p4; justify-self: center; }
.hand-seat-1, .hand-seat-2, .hand-seat-3 { width: var(--player-card-size); min-height: 76px; height: 76px; align-self: center; margin: 0; overflow: hidden; }
.hand-seat-1 { grid-area: h2; justify-self: start; }
.hand-seat-2 { grid-area: h3; position: static; justify-self: center; }
.hand-seat-3 { grid-area: h4; justify-self: center; }
.game-grid { grid-area: center; min-width: 0; height: 100%; }
.table-panel { height: 100%; min-height: 270px; }
.table-layout { height: 100%; }
.lower-layout { margin-top: 10px; }
.play-area { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: stretch; }
.hand-panel { grid-column: 1; min-width: 0; min-height: 210px; }

@media (max-width: 620px) {
  .app-shell { display: flex; flex-direction: column; width: 100%; min-width: 0; padding: 5px 6px 10px; }
  .board { grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 64px; grid-template-rows: auto minmax(190px, auto) auto; grid-template-areas: ". p2 h2 ." "p3 center center p4" "h3 center center h4"; gap: 6px; margin: 6px 0; }
  .player.seat-1, .player.seat-2, .player.seat-3 { width: 64px; height: 88px; min-height: 88px; }
  .hand-seat-1, .hand-seat-2, .hand-seat-3 { width: 64px; min-height: 64px; height: 64px; padding: 6px; }
  .hand-seat-2, .hand-seat-3 { min-height: 64px; padding: 4px; }
  .seat-hand-heading { margin-bottom: 3px; font-size: 9px; }
  .seat-hand-heading span { font-size: 8px; }
  .seat-hand-cards { gap: 2px; padding: 1px 0 2px; }
  .bot-hand .seat-hand-cards .card { flex-basis: 22px; width: 22px; height: 38px; margin-left: -8px; border-style: dashed; }
  .bot-hand .seat-hand-cards .card:nth-child(n+8) { display: none; }
  .player.seat-2, .player.seat-3 { min-height: 64px; padding: 5px 2px; }
  .player strong { font-size: 10px; }
  .player small { font-size: 9px; }
  .player span, .red-ten-tag, .ting-tag, .declaration-tag { font-size: 8px; }
  .table-panel { min-height: 250px; padding: 7px; }
  .table-layout { grid-template-columns: 1fr; min-height: 230px; gap: 5px; }
  .table-state { min-height: 132px; }
  .table-cards { min-height: 60px; font-size: 15px; gap: 7px; }
  .inline-log { min-height: 84px; max-height: 92px; padding-top: 5px; }
  .inline-log ol { max-height: 58px; margin-top: 3px; padding-left: 15px; font-size: 9px; }
  .lower-layout { display: flex; flex: 1 1 auto; min-height: 0; }
  .play-area { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
  body .hand-panel { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; height: auto; padding: 7px; }
  .hand-status { top: 7px; right: 7px; font-size: 9px; }
  .hand { margin-top: 23px; gap: 4px; }
  .hand .card { flex: 0 0 38px; width: 38px; height: 56px; padding: 5px; font-size: 12px; }
  .seat-actions { margin-top: auto; padding-top: 5px; }
  .seat-action-hint { font-size: 9px; margin-bottom: 4px; }
  .seat-action-buttons { gap: 3px; }
  .seat-action-buttons button { min-height: 27px; padding: 0 6px; font-size: 10px; }
}

/* Final mobile alignment: keep bot 2 consistent with the side players. */
@media (max-width: 620px) {
  .player.seat-1 { width: 64px; height: 88px; min-height: 88px; justify-self: end; align-self: center; margin-right: -5px; }
  .hand-seat-1 { width: 64px; height: 64px; min-height: 64px; justify-self: start; align-self: center; margin-left: -5px; }
  .hand-seat-2, .hand-seat-3 { width: 64px; height: 64px; min-height: 64px; }
  body .hand .card { margin-left: -12px; }
  body .hand .card:first-child { margin-left: 0; }
  body .seat-action-buttons button { min-height: 40px; padding: 0 12px; border-radius: 21px; font-size: 14px; }
  body .hand { gap: 0; }
  body .hand .card { margin-left: -10px; }
  body .hand .card:first-child { margin-left: 0; }
}

/* Reference game table skin */
:root {
  --felt-deep: #061b16;
  --felt: #0b2c22;
  --felt-light: #123e30;
  --gold: #d7bd7b;
  --gold-dark: #806b3d;
  --paper: #f4e8c5;
  --paper-shadow: #c5a875;
  --ink: #2c1d13;
}

html, body { background: var(--felt-deep); }
body {
  min-width: 320px;
  overflow: hidden;
  color: #f7e8bf;
  background-color: var(--felt-deep);
  background-image: radial-gradient(ellipse at 50% 35%, rgba(41, 102, 71, .26), transparent 58%), repeating-linear-gradient(115deg, rgba(255,255,255,.025) 0 1px, transparent 1px 7px);
}
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .22;
  background-image: repeating-radial-gradient(ellipse at 15% 20%, transparent 0 13px, rgba(211, 191, 124, .18) 14px 15px, transparent 16px 26px);
  mix-blend-mode: screen;
}
.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 680px);
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: 14px 8px 10px;
  overflow: hidden;
}
.board {
  display: grid;
  flex: 0 0 64%;
  grid-template-columns: 82px minmax(0, 1fr) minmax(0, 1fr) 82px;
  grid-template-rows: 92px minmax(0, 1fr) 76px;
  grid-template-areas: ". p2 h2 ." "p3 center center p4" "h3 center center h4";
  gap: 7px;
  min-height: 0;
  margin: 0;
  align-items: stretch;
}
.player {
  width: 100%;
  min-width: 0;
  border: 2px solid var(--gold-dark);
  border-radius: 10px;
  background: linear-gradient(135deg, #132d24, #061b16 76%);
  box-shadow: inset 0 0 0 1px rgba(240, 213, 144, .16), 0 4px 14px rgba(0,0,0,.34);
  color: #f3db9f;
  padding: 7px;
}
.player.seat-1 { grid-area: p2; justify-self: stretch; align-self: center; height: 82px; flex-direction: row; justify-content: flex-start; gap: 8px; }
.player.seat-2 { grid-area: p3; justify-self: stretch; align-self: center; height: min(190px, 100%); min-height: 130px; flex-direction: column; justify-content: center; }
.player.seat-3 { grid-area: p4; justify-self: stretch; align-self: center; height: min(190px, 100%); min-height: 130px; flex-direction: column; justify-content: center; }
.player.active { border-color: #f0c95f; background: linear-gradient(145deg, #18382b, #0b241c); box-shadow: inset 0 0 0 1px #e6c16e, 0 0 14px rgba(234, 190, 82, .18); }
.player.active { box-shadow: inset 0 0 0 2px #f5d26d, 0 0 20px rgba(245, 191, 63, .65); }
.avatar-frame { flex: 0 0 auto; width: 54px; height: 54px; overflow: hidden; border: 2px solid var(--gold); border-radius: 9px; background: #132d24; box-shadow: 0 2px 6px #0008; }
.avatar-frame img { display: block; width: 100%; height: 100%; }
.player.seat-2 .avatar-frame, .player.seat-3 .avatar-frame { width: 52px; height: 52px; border-radius: 8px; }
.player-card-copy { display: flex; min-width: 0; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.player.seat-1 .player-card-copy { align-items: flex-start; text-align: left; }
.player-status-tags { min-height: 12px; align-items: center; }
.player-status-tags:empty { display: none; }
.player.seat-2 .player-status-tags, .player.seat-3 .player-status-tags { min-height: 0; margin-bottom: 3px; }
.player span, .player small { color: #d3bc84; }
.player strong { max-width: 100%; color: #f2d99d; font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.player small { font-size: 11px; }
.declaration-tag, .red-ten-tag, .ting-tag { border: 1px solid rgba(215,189,123,.5); border-radius: 3px; padding: 2px 4px; font-size: 9px; }
.red-ten-tag { background: #6e2822; color: #ffd5ae; }
.ting-tag { background: #24536a; color: #d6eced; }
.declaration-tag { background: #67502a; color: #f7dda0; }
.game-grid { grid-area: center; min-width: 0; min-height: 0; height: 100%; }
.table-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--gold-dark);
  border-radius: 14px;
  padding: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 5px #162f24, inset 0 0 0 7px #c9ad70, 0 4px 18px #0009;
}
.table-panel::before { position: absolute; inset: 10px; pointer-events: none; content: ""; border: 1px solid #a7854d; border-radius: 8px; opacity: .7; }
.table-layout { position: relative; z-index: 1; display: flex; height: 100%; min-height: 0; flex-direction: column; gap: 8px; }
.table-state { display: flex; min-height: 0; flex: 1 1 63%; flex-direction: column; align-items: stretch; }
.table-banner { margin: 2px 8px 8px; padding: 7px 10px; border: 2px solid #a87e43; border-radius: 9px; background: linear-gradient(#6c4b2e, #402918); color: #f3d596; font-family: Georgia, "Times New Roman", serif; font-size: clamp(17px, 4vw, 25px); text-align: center; text-shadow: 0 1px 1px #000; }
.table-meta { min-height: 24px; color: #7f633b; font-size: 11px; }
.table-meta strong { border: 1px solid #a8822c; border-radius: 4px; background: #d2a52d; color: #35230e; padding: 3px 9px; }
.table-state > .panel-kicker, .inline-log > .panel-kicker { height: auto; color: #665034; font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.table-cards { display: flex; min-height: 92px; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #352116; font-family: Georgia, "Times New Roman", serif; font-size: clamp(18px, 4vw, 26px); font-weight: 700; text-align: center; }
.start-button { min-height: 45px; border: 3px solid #b7a263; border-radius: 26px; padding: 0 28px; background: linear-gradient(#24985e, #075632); color: #f5df9e; box-shadow: 0 0 0 3px #31553d, 0 4px 0 #4a321d, inset 0 0 0 2px #62c17d; font-family: Georgia, "Times New Roman", serif; font-size: 19px; font-weight: 700; text-shadow: 0 1px #163a25; }
.start-button:disabled { background: linear-gradient(#628f7a, #477568); color: #e5dfc5; }
.turn-label { min-height: 18px; color: #80653e; font-size: 11px; text-align: center; }
.inline-log { min-height: 0; flex: 0 1 37%; overflow: hidden; border: 0; border-top: 1px solid #b28e58; padding: 7px 12px 4px; background: linear-gradient(180deg, rgba(232,205,151,.35), rgba(255,247,220,.75)); }
.inline-log::before, .inline-log::after { position: absolute; content: ""; pointer-events: none; }
.inline-log ol { max-height: calc(100% - 24px); margin: 4px 0 0; padding-left: 20px; overflow: auto; color: #5a4630; font-family: Georgia, "Times New Roman", serif; font-size: 11px; }
.inline-log li + li { margin-top: 4px; }
.seat-hand { min-width: 0; border: 2px solid var(--gold-dark); border-radius: 8px; background: rgba(7, 30, 23, .74); padding: 5px; box-shadow: inset 0 0 0 1px rgba(219,190,116,.18), 0 3px 12px #0007; }
.hand-seat-1 { grid-area: h2; align-self: center; width: 100%; height: 72px; min-height: 72px; }
.hand-seat-2 { grid-area: h3; align-self: center; width: 100%; height: 72px; min-height: 72px; }
.hand-seat-3 { grid-area: h4; align-self: center; width: 100%; height: 72px; min-height: 72px; }
.seat-hand-heading { margin-bottom: 3px; color: #d6bb7a; font-family: Georgia, "Times New Roman", serif; font-size: 10px; }
.seat-hand-heading span { color: #ae9a67; font-size: 9px; }
.bot-hand .seat-hand-cards { flex-wrap: nowrap; justify-content: center; gap: 0; overflow: hidden; padding: 0; }
.bot-hand .seat-hand-cards .card { flex: 0 0 27px; width: 27px; height: 50px; margin-left: -9px; border: 1px solid #f0d27c; border-radius: 4px; background: #9a7530 url("assets/card-back.svg") center / cover; color: transparent; box-shadow: 0 2px 4px #0008, 0 0 0 1px rgba(22, 43, 29, .55); }
.bot-hand .seat-hand-cards .card:first-child { margin-left: 0; }
.bot-hand .seat-hand-cards .card span, .bot-hand .seat-hand-cards .card small { visibility: hidden; }
.lower-layout { display: flex; flex: 1 1 auto; min-height: 0; margin-top: 10px; }
.play-area { display: flex; width: 100%; min-height: 0; flex-direction: column; }
.hand-panel { position: relative; display: flex; min-height: 0; flex: 1 1 auto; flex-direction: column; overflow: hidden; border: 2px solid var(--gold-dark); border-radius: 14px; padding: 9px 12px 7px; background: linear-gradient(150deg, #0d3024, #061c16); color: #f3d89b; box-shadow: inset 0 0 0 1px rgba(228,201,132,.3), 0 4px 15px #0009; }
.hand-panel::before { position: absolute; top: -1px; left: 16px; width: 175px; height: 28px; content: ""; border: 2px solid var(--gold); border-top: 0; border-radius: 0 0 15px 15px; background: var(--felt); }
.player-one-hand-title { position: relative; z-index: 1; display: inline-flex; width: fit-content; align-items: center; gap: 7px; border: 1px solid var(--gold); border-top: 0; border-radius: 0 0 10px 10px; padding: 3px 10px 5px; color: #f1d49a; font-family: Georgia, "Times New Roman", serif; font-size: 13px; }
.player-one-hand-title span { color: #f4dba2; font-size: 12px; }
.player-one-hand-title em { border: 1px solid #c6a45c; border-radius: 3px; background: #214735; color: #e9d290; padding: 2px 5px; font-size: 9px; font-style: normal; }
.hand-status { top: 11px; right: 13px; color: #d7be86; font-size: 10px; }
.hand-status .error { color: #ff9e83; }
.hand { display: flex; min-height: 0; flex: 1 1 auto; align-items: flex-end; justify-content: center; gap: 0; overflow: visible; padding: 4px 8px 0; }
.hand .card { flex: 0 0 clamp(34px, 9.5vw, 53px); width: clamp(34px, 9.5vw, 53px); height: clamp(94px, 16vh, 145px); margin-left: -16px; border: 2px solid #d8d5c2; border-radius: 6px; background: linear-gradient(150deg, #fffef2, #dcded2); box-shadow: -2px 1px 5px #0009; color: #20201e; padding: 7px 5px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(12px, 2.8vw, 19px); }
.hand .card:first-child { margin-left: 0; }
.hand .card:disabled { opacity: 1; }
.hand .card { position: relative; display: block; padding: 7px 5px; }
.hand .card span { position: absolute; top: 7px; left: 7px; z-index: 1; line-height: 1; }
.hand .card small { position: absolute; top: 50%; left: 50%; z-index: 1; transform: translate(-50%, -50%); font-size: clamp(25px, 7vw, 46px); line-height: 1; opacity: 1; text-shadow: 0 1px 1px rgba(255,255,255,.45); }
.hand .card:first-child { margin-left: 0; }
.hand .card.red { color: #a6252a; }
.hand .card.selected { z-index: 3; transform: translateY(-18px) !important; border-color: #e6bc56; box-shadow: 0 4px 0 #b37c28, 0 3px 10px #000b; }
.hand .card:nth-child(1) { transform: rotate(-22deg) translateY(25px); }
.hand .card:nth-child(2) { transform: rotate(-18deg) translateY(17px); }
.hand .card:nth-child(3) { transform: rotate(-14deg) translateY(10px); }
.hand .card:nth-child(4) { transform: rotate(-10deg) translateY(5px); }
.hand .card:nth-child(5) { transform: rotate(-7deg) translateY(2px); }
.hand .card:nth-child(6) { transform: rotate(-3deg); }
.hand .card:nth-child(7) { z-index: 1; transform: translateY(-2px); }
.hand .card:nth-child(8) { transform: rotate(3deg); }
.hand .card:nth-child(9) { transform: rotate(7deg) translateY(2px); }
.hand .card:nth-child(10) { transform: rotate(10deg) translateY(5px); }
.hand .card:nth-child(11) { transform: rotate(14deg) translateY(10px); }
.hand .card:nth-child(12) { transform: rotate(18deg) translateY(17px); }
.hand .card:nth-child(13) { transform: rotate(22deg) translateY(25px); }
.hand-caption { align-self: center; margin-top: -3px; border: 2px solid var(--gold-dark); border-bottom: 0; border-radius: 15px 15px 0 0; background: #102d23; color: #f1d295; padding: 4px 30px 2px; font-family: Georgia, "Times New Roman", serif; font-size: 13px; }
.seat-actions { margin-top: 5px; border-top: 1px solid rgba(216,190,121,.45); padding-top: 5px; }
.seat-action-hint { margin: 0 0 4px; color: #d3bb81; font-size: 10px; }
.seat-action-hint:empty { display: none; }
.seat-action-buttons { gap: 7px; }
.seat-action-buttons button { min-height: 34px; border: 2px solid #c8ae70; border-radius: 18px; padding: 0 13px; color: #f7e3b0; font-family: Georgia, "Times New Roman", serif; font-size: 12px; font-weight: 700; box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 2px 5px #0008; }
.seat-action-buttons button:nth-child(1) { background: linear-gradient(#b88b45, #543516); }
.seat-action-buttons button:nth-child(2) { background: linear-gradient(#9561aa, #3d225a); }
.seat-action-buttons button:nth-child(3) { background: linear-gradient(#6c9acb, #234f83); }
.seat-action-buttons button:nth-child(4) { background: linear-gradient(#c96b6d, #6a2227); }
.seat-action-buttons button:disabled { opacity: .5; }
.reaction-wait { color: #e3c879; }
.result-dialog { border: 2px solid var(--gold); border-radius: 14px; background: var(--paper); color: var(--ink); }

@media (max-width: 620px) {
  .app-shell { width: 100%; height: 100dvh; padding: 8px 6px 7px; }
  .board { flex: 0 0 62%; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 64px; grid-template-rows: 82px minmax(0, 1fr) 72px; gap: 5px; }
  .player.seat-1 { width: 100%; height: 74px; padding: 5px; }
  .player.seat-2, .player.seat-3 { height: min(165px, 100%); min-height: 110px; padding: 5px 2px; }
  .avatar-frame { width: 46px; height: 46px; }
  .player.seat-2 .avatar-frame, .player.seat-3 .avatar-frame { width: 43px; height: 43px; }
  .player strong { font-size: 11px; }
  .player small { font-size: 9px; }
  .player span, .red-ten-tag, .ting-tag, .declaration-tag { font-size: 8px; }
  .hand-seat-1, .hand-seat-2, .hand-seat-3 { height: 64px; min-height: 64px; padding: 4px; }
  .seat-hand-heading { font-size: 8px; }
  .seat-hand-heading span { font-size: 7px; }
  .bot-hand .seat-hand-cards .card { flex-basis: 22px; width: 22px; height: 43px; margin-left: -8px; }
  .table-panel { border-radius: 11px; padding: 8px; }
  .table-banner { margin: 1px 5px 5px; padding: 5px 6px; font-size: 17px; }
  .table-state > .panel-kicker, .inline-log > .panel-kicker { font-size: 14px; }
  .table-cards { min-height: 72px; font-size: 16px; }
  .start-button { min-height: 39px; padding: 0 22px; font-size: 17px; }
  .inline-log { padding: 4px 7px 2px; }
  .inline-log ol { font-size: 9px; padding-left: 15px; }
  .hand-panel { padding: 7px 8px 5px; border-radius: 11px; }
  .player-one-hand-title { padding: 2px 7px 4px; font-size: 11px; }
  .hand-status { top: 9px; right: 8px; font-size: 9px; }
  .hand { padding: 4px 3px 48px; }
  body .hand .card { flex-basis: clamp(34px, 9.5vw, 53px); width: clamp(34px, 9.5vw, 53px); height: clamp(88px, 25vw, 145px); margin: 0 0 24px -16px; padding: 7px 5px; font-size: clamp(12px, 2.8vw, 19px); }
  body .hand .card:first-child { margin-left: 0; }
  .hand-caption { padding-inline: 24px; font-size: 11px; }
  .seat-action-buttons { gap: 4px; }
  .seat-action-buttons button { min-height: 29px; padding: 0 8px; font-size: 10px; }
}

@media (min-width: 480px) and (max-width: 620px) {
  .seat-action-buttons { gap: 8px; }
  body .seat-action-buttons button { min-height: 42px; padding: 0 16px; border-radius: 22px; font-size: 14px; }
}

/* Final layout overrides after the reference skin. */
@media (max-width: 620px) {
  .board { grid-template-rows: 165px minmax(0, 1fr) 64px; }
  .player.seat-1 { width: 64px; height: 165px; min-height: 165px; justify-self: end; align-self: center; margin-right: -5px; }
  .hand-seat-1 { width: 64px; height: 64px; min-height: 64px; justify-self: start; align-self: center; margin-left: -5px; }
  .player.seat-2, .player.seat-3 { width: 64px; height: 165px; min-height: 165px; align-self: end; }
  .hand-seat-2, .hand-seat-3 { width: 64px; height: 64px; min-height: 64px; align-self: start; }
  body .hand .card { margin-left: -12px; }
  body .hand .card:first-child { margin-left: 0; }
  body .seat-action-buttons button { min-height: 40px; padding: 0 12px; border-radius: 21px; font-size: 14px; }
}

/* Keep the supplied Pretendard font and enlarge the readable game text. */
body, button {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Malgun Gothic", sans-serif;
}
.player strong, .table-state > .panel-kicker, .inline-log > .panel-kicker, .table-cards, .start-button,
.inline-log ol, .seat-hand-heading, .player-one-hand-title, .hand .card, .hand-caption,
.seat-action-buttons button { font-family: inherit; }
.player strong { font-size: 16px; }
.player small { font-size: 12px; }
.table-state > .panel-kicker, .inline-log > .panel-kicker { font-size: 18px; }
.table-cards { font-size: clamp(20px, 4.6vw, 29px); }
.inline-log ol { font-size: 12px; }
.hand .card span { font-size: clamp(16px, 4.8vw, 24px); font-weight: 800; }
.hand .card small { font-size: clamp(29px, 8vw, 52px); font-weight: 700; }
.hand-caption { font-size: 14px; }
.seat-action-buttons button { font-size: 14px; }

@media (max-width: 620px) {
  .player strong { font-size: 13px; }
  .player small { font-size: 10px; }
  .player span, .red-ten-tag, .ting-tag, .declaration-tag { font-size: 9px; }
  .table-state > .panel-kicker, .inline-log > .panel-kicker { font-size: 16px; }
  .table-cards { font-size: 18px; }
  .start-button { min-height: 42px; font-size: 18px; }
  .inline-log ol { font-size: 10px; }
  .player-one-hand-title { font-size: 13px; }
  body .hand .card { font-size: clamp(14px, 3.8vw, 21px); }
  body .hand .card span { font-size: clamp(17px, 5.2vw, 25px); }
  body .hand .card small { font-size: clamp(30px, 9vw, 54px); }
  .hand-caption { font-size: 13px; }
  body .seat-action-buttons button { min-height: 31px; padding: 0 8px; font-size: 12px; }
}

/* Mobile layout final overrides */
@media (max-width: 620px) {
  .board { grid-template-rows: 165px minmax(0, 1fr) 64px; }
  .player.seat-1 { width: 64px; height: 165px; min-height: 165px; justify-self: end; align-self: center; margin-right: -5px; }
  .hand-seat-1 { width: 64px; height: 64px; min-height: 64px; justify-self: start; align-self: center; margin-left: -5px; }
  .player.seat-2, .player.seat-3 { width: 64px; height: 165px; min-height: 165px; align-self: end; }
  .hand-seat-2, .hand-seat-3 { width: 64px; height: 64px; min-height: 64px; align-self: start; }
  body .hand .card { margin-left: -12px; }
  body .hand .card:first-child { margin-left: 0; }
  body .seat-action-buttons button { min-height: 40px; padding: 0 12px; border-radius: 21px; font-size: 14px; }
}

@media (max-width: 620px) {
  body .hand { gap: 0; }
  body .hand .card { margin-left: -11px; }
  body .hand .card:first-child { margin-left: 0; }
}

/* Seat 2 sits horizontally over the center table; seats 3 and 4 stay vertical. */
.bot-two-zone { grid-area: top; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
#bot-two-card { display: flex; }
.bot-two-zone .player.seat-1 { width: 172px; height: 82px; min-height: 82px; margin: 0; align-self: center; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px; }
.bot-two-zone .hand-seat-1 { width: 88px; height: 70px; min-height: 70px; margin: 0; align-self: center; justify-self: auto; }
.bot-two-zone .player-card-copy { align-items: flex-start; text-align: left; }
.bot-two-zone .player-status-tags { justify-content: flex-start; }

@media (max-width: 620px) {
  .board { grid-template-rows: 88px minmax(0, 1fr) 64px; grid-template-areas: ". top top ." "p3 center center p4" "h3 center center h4"; }
  .bot-two-zone { gap: 5px; }
  .bot-two-zone .player.seat-1 { width: 142px; height: 78px; min-height: 78px; padding: 5px; gap: 7px; }
  .bot-two-zone .hand-seat-1 { width: 72px; height: 64px; min-height: 64px; padding: 4px; }
  .bot-two-zone .avatar-frame { width: 48px; height: 48px; }
  .player.seat-2, .player.seat-3 { align-self: end; }
  .hand-seat-2, .hand-seat-3 { align-self: start; }
}

/* Align the side player cards with the table's vertical midpoint. */
@media (max-width: 620px) {
  .player.seat-2, .player.seat-3 {
    grid-row: 2 / span 2;
    align-self: center;
  }
  .hand-seat-2, .hand-seat-3 {
    grid-row: 2 / span 2;
    align-self: center;
    transform: translateY(116px);
  }
}

/* Seat map: 1 at the bottom, 2 left, 3 top, 4 right. */
.bot-three-zone { grid-area: top; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
#bot-three-card { display: flex; }
.bot-three-zone .player.seat-2 { width: 172px; height: 82px; min-height: 82px; margin: 0; align-self: center; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px; }
.bot-three-zone .hand-seat-2 { width: 88px; height: 70px; min-height: 70px; margin: 0; align-self: center; justify-self: auto; }
.bot-three-zone .player-card-copy { align-items: flex-start; text-align: left; }
.bot-three-zone .player-status-tags { justify-content: flex-start; }
.player.seat-1 { grid-area: p3; }
.player.seat-3 { grid-area: p4; }
.hand-seat-1 { grid-area: h3; }
.hand-seat-3 { grid-area: h4; }
.player.seat-1 .player-status-tags, .player.seat-3 .player-status-tags { min-height: 0; margin-bottom: 3px; }

@media (max-width: 620px) {
  .bot-three-zone { gap: 5px; }
  .bot-three-zone .player.seat-2 { width: 142px; height: 78px; min-height: 78px; padding: 5px; gap: 7px; }
  .bot-three-zone .hand-seat-2 { width: 72px; height: 64px; min-height: 64px; margin: 0; padding: 4px; transform: none; }
  .bot-three-zone .avatar-frame { width: 48px; height: 48px; }
  .player.seat-1, .player.seat-3 {
    grid-row: 2 / span 2;
    width: 64px;
    height: 165px;
    min-height: 165px;
    align-self: center;
    flex-direction: column;
    justify-content: center;
  }
  .hand-seat-1, .hand-seat-3 {
    grid-row: 2 / span 2;
    width: 64px;
    height: 64px;
    min-height: 64px;
    align-self: center;
    transform: translateY(116px);
  }
  .hand-seat-1 { justify-self: center; margin: 0; }
  .player.seat-1 .avatar-frame, .player.seat-3 .avatar-frame { width: 43px; height: 43px; }
}

/* Reset seat 2 to the same vertical card layout as seat 4. */
@media (max-width: 620px) {
  .player.seat-1, .player.seat-3 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 2px;
    text-align: center;
  }
  .player.seat-1 .player-card-copy, .player.seat-3 .player-card-copy {
    width: 100%;
    align-items: center;
    gap: 3px;
    text-align: center;
  }
  .player.seat-1 .player-status-tags, .player.seat-3 .player-status-tags {
    width: 100%;
    justify-content: center;
  }
  .bot-three-zone .player.seat-2 {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
  }
}

/* Give the game record enough vertical room to read several events. */
@media (max-width: 620px) {
  .table-state { flex: 0 1 53%; }
  body .inline-log { flex: 1 1 47%; min-height: 0; max-height: none; }
  body .inline-log ol { max-height: calc(100% - 26px); }
}

/* Phone readability: favor legible text and a compact eight-entry game log. */
@media (max-width: 620px) {
  .table-state { flex: 0 1 58%; }
  body .inline-log { flex: 1 1 42%; }
  .table-meta { font-size: 12px; }
  .table-state > .panel-kicker, .inline-log > .panel-kicker { font-size: 17px; }
  .table-cards { font-size: 20px; }
  .start-button { min-height: 44px; font-size: 20px; }
  .turn-label { font-size: 12px; }
  body .inline-log ol { max-height: calc(100% - 27px); font-size: 11px; line-height: 1.3; }
  .inline-log li { white-space: normal; overflow-wrap: anywhere; }
  .player strong { font-size: 14px; }
  .player small { font-size: 11px; }
  .player span, .red-ten-tag, .ting-tag, .declaration-tag { font-size: 10px; }
  body .hand .card span { font-size: 22px; }
  body .hand .card small { font-size: 38px; }
  .hand-status { font-size: 12px; }
  body .seat-action-buttons button { min-height: 44px; padding: 0 14px; font-size: 15px; }
}

/* The 13-card hand is always a single fanned row. */
@media (max-width: 620px) {
  body .hand { flex-wrap: nowrap; }
}

/* Poker card faces: standard ratio, pip layouts, and illustrated court cards. */
.hand { --playing-card-width: clamp(58px, 16vw, 72px); }
.hand { flex-wrap: nowrap; }
.hand .card {
  flex: 0 0 var(--playing-card-width);
  width: var(--playing-card-width);
  height: calc(var(--playing-card-width) * 1.4);
  margin-left: calc((100% - var(--playing-card-width)) / 12 - var(--playing-card-width));
  overflow: hidden;
  border: 1.5px solid #d5cab0;
  border-radius: 7px;
  padding: 0;
  background: #fffef5;
  box-shadow: -2px 2px 6px rgba(0, 0, 0, .65);
}
.hand .card:first-child { margin-left: 0; }
.hand .card .card-corner {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: inherit;
  font-family: "Pretendard Variable", Pretendard, sans-serif;
  line-height: .86;
  text-shadow: none;
  padding: 1px 2px;
  border-radius: 3px;
  background: #fffef5;
}
.hand .card .card-corner b { font-size: clamp(15px, 4.5vw, 22px); font-weight: 900; }
.hand .card .card-corner i { margin-top: 1px; font-size: clamp(13px, 3.8vw, 19px); font-style: normal; }
.hand .card .card-corner-bottom {
  top: auto;
  right: 5px;
  bottom: 5px;
  left: auto;
  transform: rotate(180deg);
}
.pip-field { position: absolute; inset: 17% 9% 15%; }
.hand .card .card-pip {
  position: absolute;
  top: var(--y);
  left: var(--x);
  color: inherit;
  font-size: clamp(14px, 4vw, 19px);
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  transform: translate(-50%, -50%);
}
.pip-count-3 .card-pip, .pip-count-4 .card-pip, .pip-count-5 .card-pip { font-size: clamp(17px, 4.8vw, 23px); }
.pip-count-14 .card-pip { font-size: clamp(31px, 9vw, 46px); }
.pip-count-15 .card-pip { font-size: clamp(20px, 5vw, 26px); }
.court-art { position: absolute; inset: 15% 10% 13%; display: flex; align-items: center; justify-content: center; }
.court-art-svg { width: 100%; height: 100%; overflow: visible; }
.hand .card:has(.court-art) { z-index: auto; }
.hand .card:nth-child(1) { transform: rotate(-15deg) translateY(15px); }
.hand .card:nth-child(2) { transform: rotate(-12deg) translateY(10px); }
.hand .card:nth-child(3) { transform: rotate(-9deg) translateY(6px); }
.hand .card:nth-child(4) { transform: rotate(-6deg) translateY(3px); }
.hand .card:nth-child(5) { transform: rotate(-3deg) translateY(1px); }
.hand .card:nth-child(6) { transform: rotate(-1deg); }
.hand .card:nth-child(7) { transform: translateY(-1px); }
.hand .card:nth-child(8) { transform: rotate(1deg); }
.hand .card:nth-child(9) { transform: rotate(3deg) translateY(1px); }
.hand .card:nth-child(10) { transform: rotate(6deg) translateY(3px); }
.hand .card:nth-child(11) { transform: rotate(9deg) translateY(6px); }
.hand .card:nth-child(12) { transform: rotate(12deg) translateY(10px); }
.hand .card:nth-child(13) { transform: rotate(15deg) translateY(15px); }
.hand .card:nth-child(1) { z-index: 1; transform: rotate(-10deg) translateY(9px); }
.hand .card:nth-child(2) { z-index: 2; transform: rotate(-8deg) translateY(6px); }
.hand .card:nth-child(3) { z-index: 3; transform: rotate(-6deg) translateY(4px); }
.hand .card:nth-child(4) { z-index: 4; transform: rotate(-4deg) translateY(2px); }
.hand .card:nth-child(5) { z-index: 5; transform: rotate(-2deg) translateY(1px); }
.hand .card:nth-child(6) { z-index: 6; transform: rotate(-1deg); }
.hand .card:nth-child(7) { z-index: 7; transform: translateY(-1px); }
.hand .card:nth-child(8) { z-index: 8; transform: rotate(1deg); }
.hand .card:nth-child(9) { z-index: 9; transform: rotate(2deg) translateY(1px); }
.hand .card:nth-child(10) { z-index: 10; transform: rotate(4deg) translateY(2px); }
.hand .card:nth-child(11) { z-index: 11; transform: rotate(6deg) translateY(4px); }
.hand .card:nth-child(12) { z-index: 12; transform: rotate(8deg) translateY(6px); }
.hand .card:nth-child(13) { z-index: 13; transform: rotate(10deg) translateY(9px); }
.hand .card.selected { z-index: 30; }
.hand .card.reaction-candidate {
  border-color: #f3c84e;
  box-shadow: 0 0 0 3px rgba(243, 200, 78, .95), -2px 2px 6px rgba(0, 0, 0, .65);
}
.bot-hand .seat-hand-cards .card > * { visibility: hidden; }

/* Opponent hands use a compact fan of card backs instead of a flat stack. */
.bot-hand .seat-hand-cards {
  position: relative;
  display: block;
  height: 50px;
  overflow: visible;
}
.bot-hand .seat-hand-cards .card {
  position: absolute;
  bottom: 1px;
  left: calc(50% - 11px);
  margin: 0;
  transform-origin: 50% 115%;
}
.bot-hand .seat-hand-cards .card:nth-child(n + 7) { display: none; }
.bot-hand .seat-hand-cards .card:nth-child(1) { transform: translateX(-15px) rotate(-25deg); }
.bot-hand .seat-hand-cards .card:nth-child(2) { transform: translateX(-9px) rotate(-15deg); }
.bot-hand .seat-hand-cards .card:nth-child(3) { transform: translateX(-3px) rotate(-5deg); }
.bot-hand .seat-hand-cards .card:nth-child(4) { transform: translateX(3px) rotate(5deg); }
.bot-hand .seat-hand-cards .card:nth-child(5) { transform: translateX(9px) rotate(15deg); }
.bot-hand .seat-hand-cards .card:nth-child(6) { transform: translateX(15px) rotate(25deg); }

@media (max-width: 620px) {
  .hand { --playing-card-width: clamp(58px, 16vw, 66px); }
  body .hand .card { margin-left: calc((100% - var(--playing-card-width)) / 12 - var(--playing-card-width)); }
  body .hand .card:first-child { margin-left: 0; }
  .hand .card .card-corner b { font-size: 17px; }
  .hand .card .card-corner i { font-size: 15px; }
  .hand .card .card-pip { font-size: 15px; }
  .hand .card .pip-count-3 .card-pip, .hand .card .pip-count-4 .card-pip, .hand .card .pip-count-5 .card-pip { font-size: 18px; }
  .hand .card .pip-count-14 .card-pip { font-size: 34px; }
  .hand .card .pip-count-15 .card-pip { font-size: 21px; }
}

/* Keep only meaningful status tags on the owner's hand. */
.hand-panel::before { display: none; }
.player-one-hand-title {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 2;
  width: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: none;
}
.player-one-hand-title em:empty { display: none; }
.player-one-hand-title .hand-status-tag {
  display: inline-flex;
  border: 1px solid #9b8060;
  border-radius: 4px;
  padding: 3px 7px;
  background: #4e4433;
  color: #f1d59c;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.player-one-hand-title .hand-status-tag.red-ten { border-color: #f09182; background: #7d2626; color: #ffe0d9; }
.player-one-hand-title .hand-status-tag.ju { border-color: #e3c363; background: #685423; color: #fff0b5; }
.player-one-hand-title .hand-status-tag.ting { border-color: #81c8d2; background: #1d5961; color: #d8f5f5; }
.player-one-hand-title .current-turn-tag { border-color: #fff0a2; background: #d79a1d; color: #1e2519; }
.hand-panel.my-turn { border-color: #f5d26d; box-shadow: inset 0 0 0 2px #f5d26d, 0 0 20px rgba(245, 191, 63, .45); }
.bot-hand { display: flex; align-items: center; }
.bot-hand .seat-hand-cards { width: 100%; }
.bot-hand .seat-actions { display: none; }

@media (max-width: 620px) {
  .player-one-hand-title { top: 8px; left: 9px; }
  .player-one-hand-title .hand-status-tag { padding: 3px 6px; font-size: 10px; }
}

/* Start mode selection */
.mode-dialog {
  width: min(92vw, 430px);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 24px;
  color: #f3d99e;
  background: linear-gradient(145deg, #123a2c, #061c16);
  box-shadow: inset 0 0 0 2px rgba(235, 205, 132, .22), 0 18px 70px #000c;
  text-align: center;
}
.mode-dialog::backdrop { background: rgba(0, 18, 13, .78); backdrop-filter: blur(3px); }
.mode-eyebrow { margin: 0 0 6px; color: #d7bd7b; font-size: 12px; font-weight: 700; }
.mode-dialog h2 { margin: 0; color: #fff0c4; font-size: 24px; }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.mode-option {
  min-height: 128px;
  border: 2px solid #9e8347;
  border-radius: 9px;
  padding: 15px 10px;
  background: linear-gradient(145deg, #1d4c38, #0b281f);
  color: #f6dfaa;
  box-shadow: inset 0 0 0 1px rgba(255, 239, 192, .13);
}
.mode-option strong, .mode-option span { display: block; }
.mode-option strong { font-size: 17px; }
.mode-option span { margin-top: 8px; color: #cdbb8e; font-size: 12px; line-height: 1.45; }
.mode-option.selected { border-color: #f0ca63; background: linear-gradient(145deg, #2c6d4d, #123d2d); box-shadow: inset 0 0 0 2px #d9b457, 0 0 18px rgba(232, 187, 69, .2); }
.mode-note { min-height: 20px; margin: 15px 0 11px; color: #d1bd8b; font-size: 12px; }
.mode-start { width: 100%; min-height: 46px; border: 2px solid #e1bd63; border-radius: 24px; background: linear-gradient(#289b61, #075632); color: #fff0bf; font-size: 16px; font-weight: 800; box-shadow: inset 0 0 0 2px rgba(255,255,255,.22), 0 3px 0 #3b2615; }
.mode-start:disabled { cursor: not-allowed; border-color: #6e785f; background: #394a42; color: #a7afa2; box-shadow: none; }

@media (max-width: 420px) {
  .mode-dialog { padding: 20px 16px; }
  .mode-options { gap: 8px; }
  .mode-option { min-height: 116px; padding: 12px 7px; }
  .mode-option strong { font-size: 16px; }
  .mode-option span { font-size: 11px; }
}

/* All available actions share one horizontal control row. */
.seat-action-buttons { flex-wrap: nowrap; min-width: 0; }
.seat-action-buttons button { min-width: 0; flex: 0 1 auto; white-space: nowrap; }

@media (max-width: 620px) {
  body .seat-action-buttons { gap: 6px; }
  body .seat-action-buttons button { min-height: 40px; padding: 0 11px; font-size: 14px; }
}

/* Final authority over earlier compact-card rules. */
@media (max-width: 620px) {
  body .hand .card {
    flex: 0 0 var(--playing-card-width);
    width: var(--playing-card-width);
    height: calc(var(--playing-card-width) * 1.4);
    margin-left: calc((100% - var(--playing-card-width)) / 12 - var(--playing-card-width));
    padding: 0;
  }
  body .hand .card:first-child { margin-left: 0; }
}

/* Tablet and desktop: expand the game board with the available viewport. */
@media (min-width: 621px) {
  .app-shell {
    width: min(96vw, 1100px);
    max-width: none;
    padding: 14px 18px 10px;
  }
  .board {
    flex: 0 0 64%;
    grid-template-columns: 112px minmax(0, 1fr) minmax(0, 1fr) 112px;
    grid-template-rows: 96px minmax(0, 1fr) 80px;
    grid-template-areas: ". top top ." "p2 center center p4" "h2 center center h4";
    gap: 10px;
    min-height: 0;
  }
  .bot-three-zone { grid-area: top; }
  .player.seat-1 {
    grid-area: p2;
    grid-row: 2 / span 2;
    width: 112px;
    height: 188px;
    min-height: 188px;
    align-self: center;
    justify-self: center;
    flex-direction: column;
  }
  .player.seat-3 {
    grid-area: p4;
    grid-row: 2 / span 2;
    width: 112px;
    height: 188px;
    min-height: 188px;
    align-self: center;
    justify-self: center;
    flex-direction: column;
  }
  .hand-seat-1 {
    grid-area: h2;
    grid-row: 2 / span 2;
    width: 106px;
    height: 76px;
    min-height: 76px;
    align-self: center;
    justify-self: center;
    transform: translateY(136px);
  }
  .hand-seat-3 {
    grid-area: h4;
    grid-row: 2 / span 2;
    width: 106px;
    height: 76px;
    min-height: 76px;
    align-self: center;
    justify-self: center;
    transform: translateY(136px);
  }
  .game-grid { grid-area: center; width: 100%; height: 100%; }
  .table-panel { width: 100%; height: 100%; min-height: 0; }
  .table-layout { height: 100%; }
  .lower-layout { flex: 1 1 auto; min-height: 0; }
  .play-area, .hand-panel { min-height: 0; }
  .hand-panel { height: 100%; }
}

.compact-log-trigger { display: none; }
.compact-log-dialog {
  width: min(90vw, 360px);
  max-height: min(72dvh, 500px);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 14px;
  background: #f5e7c1;
  color: #352116;
}
.compact-log-dialog::backdrop { background: rgba(0, 18, 13, .72); }
.compact-log-dialog header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #b28e58; padding-bottom: 8px; }
.compact-log-dialog h2 { margin: 0; font-size: 18px; }
.compact-log-dialog header button { border: 1px solid #8d6a36; border-radius: 4px; padding: 5px 8px; background: #fff8df; color: #50391f; font-weight: 700; }
.compact-log-dialog ol { max-height: calc(min(72dvh, 500px) - 70px); margin: 12px 0 0; padding-left: 20px; overflow: auto; font-size: 13px; line-height: 1.5; }

/* Compact phone game mode: controls and cards always stay inside the viewport. */
@media (max-width: 767px), (max-width: 900px) and (max-height: 700px) and (orientation: landscape) {
  body, body .app-shell { min-width: 0; height: 100svh; min-height: 0; overflow: hidden; }
  body .app-shell { padding: 3px 4px; }
  .board {
    flex: 0 0 55%;
    grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr) 60px;
    grid-template-rows: 58px minmax(0, 1fr) 44px;
    grid-template-areas: ". top top ." "p2 center center p4" "h2 center center h4";
    gap: 3px;
    margin: 0;
  }
  .bot-three-zone { grid-area: top; }
  .bot-three-zone .player.seat-2 { width: 100px; height: 54px; min-height: 54px; gap: 4px; padding: 3px; }
  .bot-three-zone .hand-seat-2 { width: 42px; height: 48px; min-height: 48px; padding: 2px; }
  .bot-three-zone .avatar-frame { width: 34px; height: 34px; }
  .player.seat-1, .player.seat-3 { grid-row: 2 / span 2; width: 52px; height: 96px; min-height: 96px; padding: 3px 1px; }
  .player.seat-1 .avatar-frame, .player.seat-3 .avatar-frame { width: 31px; height: 31px; }
  .player strong { font-size: 11px; }
  .player small { font-size: 8px; }
  .hand-seat-1, .hand-seat-3 { grid-row: 2 / span 2; width: 48px; height: 40px; min-height: 40px; transform: translateY(68px); }
  .bot-hand .seat-hand-cards { height: 34px; }
  .bot-hand .seat-hand-cards .card { transform-origin: 50% 120%; }
  .bot-hand .seat-hand-cards .card:nth-child(1) { transform: translateX(-9px) rotate(-22deg); }
  .bot-hand .seat-hand-cards .card:nth-child(2) { transform: translateX(-5px) rotate(-13deg); }
  .bot-hand .seat-hand-cards .card:nth-child(3) { transform: translateX(-2px) rotate(-4deg); }
  .bot-hand .seat-hand-cards .card:nth-child(4) { transform: translateX(2px) rotate(4deg); }
  .bot-hand .seat-hand-cards .card:nth-child(5) { transform: translateX(5px) rotate(13deg); }
  .bot-hand .seat-hand-cards .card:nth-child(6) { transform: translateX(9px) rotate(22deg); }
  .table-panel { padding: 5px; }
  .table-layout { gap: 0; }
  .table-state { flex: 1 1 auto; min-height: 0; }
  .inline-log { display: none; }
  .table-meta { min-height: 17px; gap: 4px; font-size: 9px; }
  .table-meta { justify-content: space-between; }
  .table-meta strong { padding: 2px 5px; }
  #table-label { display: none; }
  .table-state > .panel-kicker { font-size: 13px; }
  .table-cards { min-height: 0; gap: 3px; font-size: 15px; }
  .table-pile { min-height: 58px; }
  .table-pile-entry.latest { --table-card-width: 34px; }
  .table-play-card { --table-card-width: 23px; }
  .start-button { min-height: 33px; padding: 0 15px; font-size: 15px; }
  .turn-label { display: none; }
  .compact-log-trigger { display: inline-flex; align-items: center; justify-content: center; border: 1px solid #9a7639; border-radius: 3px; padding: 2px 4px; background: #fff4ce; color: #583f20; font-size: 9px; font-weight: 800; }
  .lower-layout { flex: 1 1 auto; min-height: 0; margin-top: 3px; }
  .play-area { min-height: 0; }
  .hand-panel { min-height: 0; padding: 3px 4px 2px; }
  .hand { --playing-card-width: clamp(32px, 14vw, 42px); min-height: 0; flex: 1 1 auto; align-items: center; padding: 14px 1px 2px; }
  body .hand .card { flex-basis: var(--playing-card-width); width: var(--playing-card-width); height: calc(var(--playing-card-width) * 1.4); margin: 0 0 0 calc((100% - var(--playing-card-width)) / 12 - var(--playing-card-width)); }
  body .hand .card:first-child { margin-left: 0; }
  .hand .card .card-corner { top: 2px; left: 2px; }
  .hand .card .card-corner b { font-size: 12px; }
  .hand .card .card-corner i { font-size: 10px; }
  .hand .card .card-corner-bottom { right: 2px; bottom: 2px; left: auto; }
  .hand .card .card-pip { font-size: 12px; }
  .hand .card .pip-count-3 .card-pip, .hand .card .pip-count-4 .card-pip, .hand .card .pip-count-5 .card-pip { font-size: 14px; }
  .hand .card .pip-count-14 .card-pip { font-size: 21px; }
  .seat-actions { flex: 0 0 42px; margin-top: 0; padding-top: 2px; }
  .seat-action-hint { margin: 0 0 1px; font-size: 8px; }
  body .seat-action-buttons { gap: 3px; }
  body .seat-action-buttons button { min-height: 34px; padding: 0 6px; font-size: 11px; }
}

/* Actual submitted cards remain piled on the table for the whole round. */
.table-pile {
  --table-card-width: clamp(34px, 9vw, 58px);
  position: relative;
  display: block;
  width: 100%;
  min-height: 112px;
  flex: 1 1 auto;
  overflow: hidden;
}
.table-pile.empty-pile {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #352116;
  font-size: inherit;
  text-align: center;
}
.table-pile-entry {
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: min(92%, 310px);
  height: calc(var(--table-card-width) * 1.65);
  transform-origin: 50% 100%;
}
.table-pile-entry.previous { opacity: .9; }
.table-pile-entry.latest { --table-card-width: clamp(48px, 13vw, 70px); }
.table-play-card {
  position: relative;
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--table-card-width);
  height: calc(var(--table-card-width) * 1.4);
  margin: 0;
  overflow: hidden;
  border: 1px solid #d5cab0;
  border-radius: 4px;
  background: #fffef5;
  box-shadow: -1px 1px 3px rgba(0, 0, 0, .5);
  color: #20201e;
}
.table-play-card.red { color: #a6252a; }
.table-play-card .card-corner {
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 2px;
  padding: 1px;
  background: #fffef5;
  color: inherit;
  font-family: "Pretendard Variable", Pretendard, sans-serif;
  line-height: .85;
}
.table-play-card .card-corner b { font-size: clamp(9px, 2.7vw, 13px); font-weight: 900; }
.table-play-card .card-corner i { margin-top: 1px; font-size: clamp(8px, 2.3vw, 11px); font-style: normal; }
.table-play-card .card-corner-bottom { top: auto; right: 2px; bottom: 2px; left: auto; transform: rotate(180deg); }
.table-play-card .pip-field { position: absolute; inset: 17% 8% 14%; }
.table-play-card .card-pip {
  position: absolute;
  top: var(--y);
  left: var(--x);
  color: inherit;
  font-size: clamp(10px, 3vw, 16px);
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  transform: translate(-50%, -50%);
}
.table-play-card .pip-count-3 .card-pip, .table-play-card .pip-count-4 .card-pip, .table-play-card .pip-count-5 .card-pip { font-size: clamp(12px, 3.5vw, 19px); }
.table-play-card .pip-count-14 .card-pip { font-size: clamp(17px, 5vw, 28px); }
.table-play-card .pip-count-15 .card-pip { font-size: clamp(13px, 3.7vw, 21px); }
.table-play-card .court-art { position: absolute; inset: 15% 10% 13%; display: flex; align-items: center; justify-content: center; }
.table-play-card .court-art-svg { width: 100%; height: 100%; }
.pile-action-label {
  position: absolute;
  top: -18px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  border: 1px solid #e3bd5e;
  border-radius: 3px;
  padding: 1px 4px;
  background: #6c4924;
  color: #fff0ba;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 620px) {
  .table-pile { --table-card-width: clamp(32px, 9vw, 42px); min-height: 108px; }
  .table-play-card .card-corner b { font-size: 10px; }
  .table-play-card .card-corner i { font-size: 9px; }
  .table-play-card .card-pip { font-size: 11px; }
  .table-play-card .pip-count-3 .card-pip, .table-play-card .pip-count-4 .card-pip, .table-play-card .pip-count-5 .card-pip { font-size: 13px; }
  .table-play-card .pip-count-14 .card-pip { font-size: 19px; }
  .table-play-card .pip-count-15 .card-pip { font-size: 14px; }
}
