/* The table is a viewport, with separate space for actions and physical cards. */
[hidden] { display: none !important; }
body.in-game { overflow: hidden; }
body.in-game .app-shell > :not(#game) { display: none; }
body:not(.in-game) #game { display: none; }
body.in-game .app-shell { width: 100%; max-width: none; padding: 0; margin: 0; }
#game { margin: 0; padding: 0; width: 100%; max-width: none; height: 100dvh; min-height: 0; }
#game .table-panel {
  height: 100dvh; padding: 12px; border-radius: 0; border: 0;
  grid-template-rows: 48px minmax(0, 1fr) 280px;
}
.table-header { min-width: 0; gap: 10px; flex-direction: row; align-items: center; }
.table-header h2 { font-size: 17px; margin: 0; }
.table-header .eyebrow { font-size: 11px; margin: 0 0 3px; }
.round-stats { gap: 5px; }
.round-stats span { padding: 0 8px; font-size: 12px; border-radius: 4px; }
#wildIndicator { color: #ffe18d; border-color: #bd9c46; }
#fullscreen { min-width: 38px; height: 38px; padding: 0; font-size: 24px; }
button .lucide { display: block; width: 19px; height: 19px; margin: auto; }
.table-arena { margin: 6px 0 0; padding: 0; min-height: 0; }
/* Decorative layers share one cut-corner outline; game controls stay above them. */
#game .table-panel {
  background: linear-gradient(180deg, #151d1b, #0d1412 68%, #101613);
}
#game .table-arena {
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
#game .table-arena::before, #game .table-arena::after { content: none; }
.table-craft {
  --table-cut: 44px;
  position: absolute;
  inset: 4px 4px 8px;
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 5px 3px #0009);
}
.table-craft__rail, .table-craft__inlay, .table-craft__felt, .table-craft__stitch {
  position: absolute;
  clip-path: polygon(var(--table-cut) 0, calc(100% - var(--table-cut)) 0,
    100% var(--table-cut), 100% calc(100% - var(--table-cut)),
    calc(100% - var(--table-cut)) 100%, var(--table-cut) 100%,
    0 calc(100% - var(--table-cut)), 0 var(--table-cut));
}
.table-craft__rail {
  inset: 0;
  background:
    linear-gradient(135deg, #c6a967 0, #75623c 3%, transparent 3.2%, transparent 96%, #af9256 96.2%),
    linear-gradient(45deg, #b49658 0, #655636 3%, transparent 3.2%, transparent 96%, #c0a164 96.2%),
    repeating-linear-gradient(95deg, #ffffff04 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #42423a, #222c28 12%, #111c18 82%, #37392e);
  box-shadow: inset 0 2px 0 #e6d39b70, inset 0 -3px 0 #0008;
}
.table-craft__inlay {
  --table-cut: 36px;
  inset: 13px;
  background: linear-gradient(130deg, #d0b879, #665b3b 24%, #b29f69 48%, #5a5137 72%, #c1a96c);
}
.table-craft__felt {
  --table-cut: 35px;
  inset: 15px;
  background:
    repeating-linear-gradient(0deg, #ffffff03 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, #0000000a 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 44%, #347562 0, #245b4d 45%, #123c32 100%);
  box-shadow: inset 0 0 35px #061d17b3, inset 0 2px 6px #000b;
}
.table-craft__stitch {
  --table-cut: 25px;
  inset: 27px;
  border: 1px dashed #cbba8240;
}
.table-craft__suit {
  position: absolute;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #c1b17b80;
  font: 26px/1 Georgia, serif;
  text-shadow: 0 1px 1px #001d17;
}
.table-craft__suit--tl { left: 37px; top: 33px; }
.table-craft__suit--tr { right: 37px; top: 33px; }
.table-craft__suit--bl { left: 37px; bottom: 33px; }
.table-craft__suit--br { right: 37px; bottom: 33px; }
.table-craft__signature {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  color: #c9bf9359;
  font: 12px/1.4 Georgia, serif;
  white-space: nowrap;
  padding: 0 18px;
}
.table-craft__signature::before, .table-craft__signature::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 36px;
  height: 1px;
  background: #c9bf9333;
}
.table-craft__signature::before { right: 100%; }
.table-craft__signature::after { left: 100%; }
#game .opponent {
  border: 1px solid #9f96644d;
  background: linear-gradient(145deg, #192923f5, #0c1916eb);
  box-shadow: 0 5px 16px #0005, inset 0 1px 0 #e9d9aa12;
}
#game .opponent.is-acting {
  border-color: #e4c574;
  box-shadow: 0 0 0 2px #d5b25a30, 0 6px 18px #0006;
}
#game .center-table { z-index: 1; }
#game .last-play__label { color: #d6cfb4; }
#game .last-play__meta { text-shadow: 0 2px 4px #061d16; }
#game .played-cards .card { box-shadow: 0 4px 7px #061e1870; }
#game .player-console {
  border: 0;
  border-top: 1px solid #a28e5559;
  border-radius: 0;
  background: linear-gradient(180deg, #1a2621, #101915 38%, #0d1512);
  box-shadow: inset 0 1px 0 #dfc17a0d;
}
.opponent-row { position: absolute; inset: 0; display: block; }
.opponent { width: 100px; min-height: 0; padding: 5px; }
.opponent--left { position: absolute; left: 12px; top: 52%; right: auto; transform: translateY(-50%); }
.opponent--right { position: absolute; right: 12px; top: 52%; left: auto; transform: translateY(-50%); }
.opponent--top { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); }
.opponent strong { font-size: 14px; }
.opponent > span { font-size: 11px; }
.opponent .seat-avatar { width: 64px; height: 64px; flex-shrink: 0; aspect-ratio: 1; }
.opponent--top { display: grid; grid-template-columns: 64px 1fr; column-gap: 10px; width: 210px; text-align: left; align-items: center; }
.opponent--top .seat-avatar { grid-row: span 3; margin: 0; }
.opponent--top .visible-cards { grid-column: 1 / -1; }
.center-table { position: absolute; left: 50%; top: 59%; width: calc(100% - 250px); margin: 0; transform: translate(-50%, -50%); gap: 5px; }
.last-play { min-height: 0; padding: 8px 0; background: none; border: 0; }
.last-play__label { font-size: 11px; }
.last-play__meta { color: #f3f4ee; font-size: 13px; margin: 6px 0 0; }
.played-cards { flex-wrap: nowrap; gap: 0; min-height: 70px; margin-top: 6px; }
.played-cards .card { position: relative; width: 54px; height: 74px; flex-shrink: 0; font-size: 21px; padding: 5px; }
.played-cards .card + .card { margin-left: -14px; }
.event-feed { height: 22px; overflow: hidden; padding: 0; background: none; border: 0; text-align: center; }
.event-feed p { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#game .player-console { margin-top: 6px; padding: 6px 10px 8px; display: grid; grid-template-rows: 40px 24px minmax(0, 1fr); }
#game .player-console__topline { position: static; flex-direction: row; justify-content: flex-end; gap: 0; }
.console-actions { flex-wrap: nowrap; align-items: center; gap: 7px; }
.console-actions button { min-width: 62px; min-height: 36px; padding: 0 12px; font-size: 14px; }
.console-actions #skillInfo, .console-actions #clearSelection { min-width: 36px; padding: 0; font-size: 22px; }
.console-actions #playSelected { color: #142921; border-color: #72d9a5; background: #79d7a3; }
#game.is-opening #playSelected, #game.is-opening #passTurn, #game.is-opening #hintPlay { display: none; }
#finishOpening { color: #162c23; background: #edce7b; }
button:disabled { opacity: 0.38; cursor: not-allowed; }
.selection-bar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; min-width: 0; color: #d7dace; font-size: 12px; }
.selection-bar select { max-width: 270px; height: 24px; font: inherit; background: #203d34; color: #ffe9ad; border: 1px solid #967641; border-radius: 4px; }
#game .player-console__play-area { grid-template-columns: 100px minmax(0, 1fr); gap: 12px; min-height: 0; align-items: stretch; }
#game.has-skill .player-console__play-area { grid-template-columns: 190px minmax(0, 1fr); }
#game .player-rail { min-height: 0; padding: 0; gap: 8px; align-content: start; border: 0; background: none; transform: translateY(-48px); }
#game .player-seat { min-height: 0; padding: 5px; border: 0; background: none; }
#game.has-skill .player-seat { grid-template-columns: 64px 1fr; }
#game .player-seat .seat-avatar { width: 64px; height: 64px; aspect-ratio: 1; }
#game .player-seat strong { font-size: 14px; }
#game .player-seat span { font-size: 11px; }
#game .skill-card { height: auto; min-height: 0; padding: 8px 0 0; border: 0; border-top: 1px solid #756039; background: none; }
#game .skill-card strong { font-size: 13px; color: #efd38b; }
#game .skill-card span { font-size: 11px; line-height: 1.5; }
#game .skill-card span:first-of-type { display: none; }
.hand-zone { min-height: 0; height: 100%; }
#game .hand { height: 100%; min-height: 0; padding: 16px 6px 0; gap: 0; overflow: visible; align-items: flex-end; }
#game .hand-stack { flex: 0 0 var(--column-step, 40px); min-width: 0; max-width: none; align-items: start; transition: none; }
#game .hand-stack:last-child { flex-basis: var(--card-width, 62px); }
#game .hand-stack .card {
  position: relative; width: var(--card-width, 62px); height: var(--card-height, 88px);
  min-width: 0; min-height: 0; padding: 4px 3px; font-size: var(--card-font, 24px); border-radius: 5px;
  background: linear-gradient(#fff, #eeefec); transition: transform .12s, box-shadow .12s;
}
#game .hand-stack .card + .card { margin-top: calc(var(--stack-step, 25px) - var(--card-height, 88px)); }
#game .hand-stack .card.is-selected { transform: translateY(-9px); background: #e3ffef; border-color: #257a51; box-shadow: 0 0 0 2px #61d493; }
.card-corner { position: relative; z-index: 1; white-space: nowrap; }
.card-pip { position: absolute; right: 10%; bottom: 8%; font-size: 1.7em; pointer-events: none; line-height: 1; }
.card--level { border-color: #caa853 !important; }
.wild-star { position: absolute; left: 10%; bottom: 9%; color: #d29c23; font-size: 1.4em; line-height: 1; text-shadow: 0 0 9px #ffcd54; }
.hand .joker-face { display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.hand .joker-mask { width: 42%; height: 36%; flex: 0 0 auto; min-height: 16px; margin: 12px 0 3px; }
.hand .joker-title { font-size: 9px; }
.hand .joker-title { align-self: center; }
.hand .joker-mark { display: none; }
.card--wild .card-pip { opacity: .18; }
.card--wild { box-shadow: 0 0 10px #dbb35088, inset 0 0 0 1px #ecc365; animation: wild-glow 2.4s ease-in-out infinite alternate; }
.card--wild::after { content: none !important; }
.card--wild .wild-star { z-index: 2; }
.seat-avatar img, .player-seat .seat-avatar img, .skill-target-avatar img { width: 100%; height: auto; object-fit: contain; object-position: top; transform: scale(2.2); transform-origin: 50% 0; }
@keyframes wild-glow { to { box-shadow: 0 0 16px #ffd46388, inset 0 0 0 1px #d6a63d; } }
.visible-cards { max-width: 100%; max-height: 52px; overflow: auto; }
.tiny-card { position: relative; overflow: hidden; }
.tiny-card .card-pip { display: none; }
.skill-target-panel {
  position: absolute; z-index: 20; inset: 0; display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 20px; background: #0009; backdrop-filter: blur(3px);
}
.skill-target-shell { width: min(900px, 100%); max-height: 90dvh; overflow-y: auto; padding: 18px; background: #122a24; border: 1px solid #b69b57; border-radius: 8px; box-shadow: 0 20px 90px #0009; }
.skill-target-head { display: flex; flex-direction: row; gap: 10px; align-items: center; }
.skill-target-head > span { flex: 1; font-size: 12px; }
.skill-target-head button { margin-left: auto; min-width: 36px; min-height: 36px; font-size: 24px; padding: 0; }
.skill-target-players { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.skill-card-strip { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); overflow: visible; gap: 5px; padding: 14px 0 0; }
.skill-card-strip .card, .skill-card-strip .tiny-card { width: 100%; min-width: 0; height: 72px; min-height: 0; font-size: 18px; padding: 4px; position: relative; }
.skill-card-strip .card-pip { font-size: 25px; }
.character-draft { width: min(1120px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: visible; padding: 20px; }
.character-draft .section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.character-draft .section-heading .eyebrow { display: none; }
.character-draft .section-heading h2 { margin: 0; font-size: 24px; }
#backHome { margin-left: auto; }
.character-draft .mini-roster { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.character-draft .mini-character { min-height: 0; padding: 6px; grid-template-rows: minmax(0, 1fr) auto; }
.character-draft .mini-avatar { height: min(43dvh, 340px); border: 0; margin: 0; }
.character-draft .mini-avatar img { padding: 0; }
.character-draft .mini-avatar { background: #0b100e; }
.character-draft .mini-avatar img { object-position: center; }
.character-draft .mini-character .mode-pill, .character-draft small { display: none; }
.character-draft .mini-character strong { font-size: 20px; }
.character-draft .mini-character span { font-size: 12px; margin-top: 2px; }
.character-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
#skillDialog { width: min(440px, calc(100% - 32px)); padding: 24px; border: 1px solid #b69b57; border-radius: 8px; background: #152d27; color: #eef2e9; }
#skillDialog::backdrop { background: #0009; }
#skillDialog p { line-height: 1.75; }
.result-card small { color: #e2dabd; font-size: 14px; }
.result-overlay { inset: 0; }
.result-card strong { font-size: 112px; }
@media (prefers-reduced-motion: reduce) { .card--wild { animation: none; } }
@media (max-width: 980px) {
  #game .table-panel { padding: 6px; grid-template-rows: 40px minmax(0, 1fr) 238px; }
  #game.has-skill .player-console__play-area { grid-template-columns: 128px minmax(0, 1fr); gap: 8px; }
  .table-header h2 { display: none; }
  #skillState { display: none; }
  .round-stats span { font-size: 11px; padding: 0 5px; }
  #game .skill-card span { font-size: 10px; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .table-craft { --table-cut: 26px; inset: 2px 0 5px; }
  .table-craft__inlay { --table-cut: 21px; inset: 6px; }
  .table-craft__felt { --table-cut: 20px; inset: 8px; }
  .table-craft__stitch { --table-cut: 15px; inset: 16px; }
  .table-craft__suit { width: 20px; height: 20px; font-size: 19px; }
  .table-craft__suit--tl { top: 23px; left: 21px; }
  .table-craft__suit--tr { top: 23px; right: 21px; }
  .table-craft__suit--bl { bottom: 23px; left: 21px; }
  .table-craft__suit--br { bottom: 23px; right: 21px; }
  .table-craft__signature { bottom: 20px; font-size: 10px; }
  .result-card strong { font-size: 72px; }
  #game .table-panel { padding: max(4px, env(safe-area-inset-top)) 4px max(4px, env(safe-area-inset-bottom)); grid-template-rows: 66px minmax(0, 1fr) min(270px, 40dvh); }
  .table-header { flex-wrap: wrap; gap: 4px; justify-content: space-between; }
  .table-header > div:first-of-type { margin: 0; }
  .round-stats { order: 4; width: 100%; justify-content: center; flex-wrap: nowrap; }
  .round-stats span { min-height: 24px; font-size: 10px; }
  #turnLabel { display: none; }
  #fullscreen { height: 30px; min-width: 32px; }
  .table-exit-action { min-width: 50px; min-height: 30px; padding: 0 10px; font-size: 12px; }
  .opponent { width: 64px; }
  .opponent--left { left: 3px; top: 42%; }
  .opponent--right { right: 3px; top: 42%; }
  .opponent--top { width: 156px; top: 8px; grid-template-columns: 46px 1fr; gap: 0 6px; }
  .opponent .seat-avatar { width: 46px; height: 46px; }
  .opponent strong { font-size: 12px; }
  .opponent > span { font-size: 10px; }
  .center-table { top: 67%; width: calc(100% - 14px); }
  .last-play__meta { font-size: 11px; }
  .played-cards .card { width: 42px; height: 61px; font-size: 16px; }
  .played-cards .card + .card { margin-left: -17px; }
  .event-feed { height: 18px; }
  #game .player-console { padding: 4px; grid-template-rows: 40px 25px minmax(0, 1fr); }
  .console-actions { gap: 4px; width: 100%; justify-content: center; }
  .console-actions button { min-width: 44px; min-height: 36px; padding: 0 7px; font-size: 12px; }
  .console-actions #skillInfo, .console-actions #clearSelection { min-width: 28px; font-size: 19px; }
  #sortHand { font-size: 11px; }
  #game .player-console__play-area, #game.has-skill .player-console__play-area { grid-template-columns: minmax(0, 1fr); position: relative; }
  #game .player-rail { position: absolute; left: 4px; top: 0; z-index: 2; pointer-events: none; transform: none; }
  #game .player-seat, #game.has-skill .player-seat { display: grid; grid-template-columns: 28px auto; gap: 3px; padding: 0; align-items: center; }
  #game .player-seat .seat-avatar { width: 26px; height: 26px; margin: 0; grid-row: span 2; }
  #game .player-seat strong { font-size: 10px; }
  #game .player-seat > span { font-size: 9px; margin: 0; }
  #game .skill-strip { display: none; }
  #game .hand { padding-top: 40px; }
  .selection-bar { gap: 4px; font-size: 10px; justify-content: center; }
  .selection-bar select { max-width: 210px; font-size: 10px; }
  .character-draft { width: calc(100% - 16px); padding: 12px; }
  .character-draft .mini-roster { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .character-draft .mini-avatar { height: min(23dvh, 190px); }
  .character-draft .mini-character strong { font-size: 16px; }
  .character-draft .mini-character span { font-size: 10px; }
  .skill-target-panel { padding: 8px; }
  .skill-target-shell { padding: 12px; }
  .skill-target-head > span { display: none; }
  .skill-target-players { gap: 4px; }
  .skill-target-player { padding: 5px; flex-direction: column; min-width: 0; }
  .skill-target-avatar { width: 34px; height: 34px; }
  .skill-card-strip { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .skill-card-strip .card, .skill-card-strip .tiny-card { height: 60px; font-size: 15px; }
  .hero__content { padding-top: 36px; }
  .hero h1 { font-size: 54px; }
  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 550px) and (orientation: landscape) {
  .table-craft { --table-cut: 24px; inset: 1px 0 4px; }
  .table-craft__inlay { --table-cut: 19px; inset: 5px; }
  .table-craft__felt { --table-cut: 18px; inset: 7px; }
  .table-craft__stitch { --table-cut: 13px; inset: 13px; }
  .table-craft__suit { display: none; }
  .table-craft__signature { display: none; }
  #game .table-panel { padding: 3px max(6px, env(safe-area-inset-right)) 3px max(6px, env(safe-area-inset-left)); grid-template-rows: 32px minmax(0, 1fr) min(205px, 51dvh); }
  .table-header .eyebrow { font-size: 10px; }
  .table-header h2, #turnLabel, #skillState { display: none; }
  .table-exit-action, #fullscreen { min-height: 28px; height: 28px; min-width: 38px; font-size: 13px; }
  .round-stats span { min-height: 24px; font-size: 10px; }
  .opponent { width: 104px; display: grid; grid-template-columns: 40px 1fr; column-gap: 4px; text-align: left; }
  .opponent .seat-avatar { width: 40px; height: 40px; margin: 0; grid-row: span 3; }
  .opponent strong { font-size: 10px; }
  .opponent > span { font-size: 9px; }
  .opponent--top { top: 3px; width: 120px; }
  .opponent--top .visible-cards { position: absolute; left: calc(100% + 8px); top: 3px; width: 140px; max-width: none; max-height: 44px; display: flex; gap: 3px; }
  .opponent--top .tiny-card { flex: 0 0 30px; width: 30px; min-width: 30px; height: 40px; min-height: 0; font-size: 12px; padding: 3px; }
  .center-table { top: 66%; width: calc(100% - 215px); }
  .last-play { padding: 0; }
  .last-play__label, .event-feed { display: none; }
  .played-cards { min-height: 42px; margin: 0; }
  .played-cards .card { width: 35px; height: 46px; font-size: 14px; }
  .last-play__meta { font-size: 10px; margin-top: 3px; }
  #game .player-console { padding: 3px 6px; grid-template-rows: 30px 20px minmax(0, 1fr); }
  .console-actions button { min-height: 28px; min-width: 48px; font-size: 12px; }
  .selection-bar { font-size: 10px; }
  .selection-bar select { height: 20px; font-size: 10px; }
  #game .player-console__play-area, #game.has-skill .player-console__play-area { grid-template-columns: 92px minmax(0, 1fr); gap: 6px; }
  #game .player-seat .seat-avatar { width: 32px; height: 32px; }
  #game .player-rail { transform: translateY(-30px); }
  #game .player-seat strong { font-size: 11px; }
  #game .player-seat span { font-size: 9px; }
  #game.has-skill .player-seat { grid-template-columns: 32px 1fr; gap: 4px; }
  #game .skill-card strong { font-size: 10px; }
  #game .skill-card span { font-size: 9px; }
  .character-draft { padding: 10px; }
  .character-draft .section-heading { margin-bottom: 6px; }
  .character-draft .section-heading h2 { font-size: 18px; }
  .character-draft .mini-avatar { height: min(49dvh, 230px); }
  .character-draft .mini-character strong { font-size: 16px; }
  .skill-card-strip .card, .skill-card-strip .tiny-card { height: 54px; }
  .skill-target-shell { padding: 10px; }
}
