/* ==========================================================================
   Game page and the card table
   ========================================================================== */

/* ---------------------------------------------------------- game layout --- */
.game-layout { display: flex; gap: 18px; height: 100%; padding: 12px 18px; }
.table-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.table-area { flex: 1; min-height: 0; display: flex; }
.side-panel {
  width: 380px; flex: none;
  background: var(--panel);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
  max-height: 100%;
}
.panel-head { padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px; }
.panel-head h2 { font-size: 20px; font-weight: 800; }
.panel-body { flex: 1; overflow-y: auto; min-height: 0; }
.panel-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); }
.panel-pad { padding: 14px 16px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel-2); flex: none; }
.tab {
  flex: 1; padding: 10px 6px 8px; text-align: center; cursor: pointer;
  color: var(--text-3); font-weight: 700; font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; border-bottom: 3px solid transparent; background: none;
}
.tab .ico { width: 21px; height: 21px; }
.tab:hover { color: var(--text); background: var(--panel-3); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab .badge { background: var(--red-soft); color: #fff; border-radius: 9px; font-size: 10px; padding: 0 5px; margin-left: 4px; }

/* player bars */
.player-bar { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; }
.player-bar .pinfo { flex: 1; min-width: 0; }
.player-bar .pname { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .prating { color: var(--text-3); font-weight: 600; font-size: 13.5px; }
.player-bar .pmeta { font-size: 12.5px; color: var(--text-3); display: flex; gap: 10px; align-items: center; margin-top: 1px; }
.player-bar .pmeta .on-turn { color: var(--accent-hi); font-weight: 800; }
.player-bar .pmeta .opening { color: var(--gold); font-weight: 700; }
/* countdowns when a player has left, and for the first move or a slow untimed turn */
.player-bar .pmeta .gone-tag, .player-bar .pmeta .deadline-tag { color: #fff; background: var(--red-soft); border-radius: 6px; padding: 0 6px; font-weight: 800; white-space: nowrap; }
.player-bar .pmeta .deadline-tag[data-kind="first"] { background: rgba(231, 181, 75, .9); color: #2c1f02; }
.player-bar .pmeta:has(.gone-tag:not([hidden])) .pcount, .player-bar .pmeta:has(.deadline-tag:not([hidden])) .pcount { display: none; }
.player-bar .pmeta .gone-tag, .player-bar .pmeta .deadline-tag { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.foot-note { text-align: center; font-size: 13px; }
.go-note { margin: 12px 0 0; font-size: 13.5px; color: var(--text-2); text-align: center; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; }
.status-dot.off { background: #777; }
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 23px; font-weight: 600;
  padding: 5px 12px; border-radius: 5px; min-width: 112px; text-align: right;
  background: var(--panel-2); color: var(--text-3);
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.clock .ico { width: 17px; height: 17px; opacity: 0; }
.clock.active { background: #eeece6; color: #1f1d1b; box-shadow: inset 3px 0 0 var(--green); }
.clock.active .ico { opacity: .7; animation: spin 2s linear infinite; }
.clock.low.active { background: var(--red); color: #fff; }
.clock.low:not(.active) { color: #f08f7a; }
.clock.unlimited { font-size: 19px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* move log */
.log { font-size: 13.5px; }
.log-item { padding: 8px 14px; border-bottom: 1px solid #ffffff08; display: flex; gap: 10px; align-items: center; color: var(--text-2); line-height: 1.35; cursor: pointer; }
.log-item:hover { background: var(--panel-3); }
.log-item.current { background: #48443f; box-shadow: inset 3px 0 0 var(--green); }
.log-item .ply { color: var(--text-3); font-size: 11.5px; font-weight: 700; width: 24px; flex: none; text-align: right; font-family: var(--font-mono); }
.log-item .who { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.log-item .who.me { background: var(--accent); }
.log-item .who.opp { background: var(--red-soft); }
.log-item .mini { width: 26px; height: 36px; flex: none; }
.log-item .mini svg { width: 100%; height: 100%; display: block; }
.log-item .txt { flex: 1; min-width: 0; }
.log-item .txt b { color: var(--text); }
.log-item .fx { display: block; font-size: 12px; color: var(--text-3); }
.log-item .fx.sold { color: var(--gold); font-weight: 700; }
.empty-state { padding: 26px 18px; text-align: center; color: var(--text-3); }
.empty-state .ico { width: 40px; height: 40px; margin-bottom: 8px; opacity: .6; }
.nav-row { display: flex; gap: 6px; }
.nav-row .btn { flex: 1; padding: 8px; }
.action-row { display: flex; gap: 8px; }
.action-row .btn { flex: 1; }
.review-banner { background: #3a3424; color: var(--gold); font-size: 13px; font-weight: 700; padding: 6px 12px; text-align: center; cursor: pointer; }
.draw-offer { background: #26382a; padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.draw-offer span { flex: 1; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-3); font-weight: 800; padding: 14px 16px 6px; }
.stat-line { display: flex; justify-content: space-between; padding: 6px 16px; font-size: 14px; color: var(--text-2); }
.stat-line b { color: var(--text); }
.rules-mini { margin: 0; padding: 0 16px 0 34px; color: var(--text-2); font-size: 13.5px; line-height: 1.6; }

/* chat */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 14px; font-size: 14px; }
.chat-msg { margin-bottom: 6px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-msg b { margin-right: 6px; }
.chat-msg.sys { color: var(--text-3); font-style: italic; font-size: 13px; }
.chat-msg .me { color: #8fd092; }
.chat-msg .opp { color: #f5a28f; }
.chat-input { display: flex; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; background: var(--panel-2); border: 0; color: var(--text); padding: 12px 14px; font: inherit; outline: none; min-width: 0; }

/* waiting room and invites */
.spinner { width: 18px; height: 18px; border: 3px solid #ffffff22; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.spinner.lg { width: 44px; height: 44px; border-width: 5px; }
.invite-box { background: var(--panel-2); border-radius: 8px; padding: 12px; display: flex; gap: 8px; align-items: center; }
.invite-box input { flex: 1; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 13px; outline: none; min-width: 0; }
.room-code { font-size: 34px; font-weight: 900; letter-spacing: 6px; text-align: center; padding: 8px; color: var(--gold); }
.opp-status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--text-2); }
.mode-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }

/* ------------------------------------------------------------- the table --- */
.table {
  --cw: 80px; --ch: 120px; --hcw: 86px; --hch: 129px; --step: 30px;
  position: relative;
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  width: 100%;
  /* green baize inside a polished wooden rail */
  border: clamp(10px, 1.5vw, 18px) solid transparent;
  border-radius: 28px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E") padding-box,
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, .1), transparent 62%) padding-box,
    radial-gradient(ellipse at 50% 50%, var(--felt), var(--felt-2)) padding-box,
    repeating-linear-gradient(96deg, rgba(255, 255, 255, .045) 0 2px, rgba(0, 0, 0, .07) 2px 4px, transparent 4px 11px, rgba(0, 0, 0, .05) 11px 13px) border-box,
    linear-gradient(180deg, var(--rail-hi), var(--rail) 38%, var(--rail-lo)) border-box;
  box-shadow:
    inset 0 0 0 2px var(--trim),
    inset 0 0 0 3px rgba(0, 0, 0, .35),
    inset 0 14px 36px rgba(0, 0, 0, .38),
    0 1px 0 1px rgba(255, 255, 255, .06),
    0 14px 34px rgba(0, 0, 0, .55);
  padding: 10px 12px 8px;
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
  color: var(--felt-ink);
  overflow: hidden;
}
.pc { display: block; padding: 0; border: 0; background: none; border-radius: calc(var(--cw) * .083); box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 3px 8px rgba(0, 0, 0, .18); }
.pc svg, .pc img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.in-hand.pc { border-radius: calc(var(--hcw) * .083); }

/* strips */
.t-strip { display: flex; align-items: center; gap: 10px; flex: none; }
.t-strip.opp { height: calc(var(--ch) * .42 + 6px); }
.t-strip.me { height: calc(var(--hch) + 18px); align-items: flex-end; }
.t-hand-backs { flex: 1; display: flex; justify-content: center; height: 100%; align-items: center; padding-left: 20px; }
.back-mini { width: calc(var(--cw) * .42); height: calc(var(--ch) * .42); margin-left: calc(var(--cw) * -.2); transform: rotate(calc((var(--i) - 3) * 3deg)); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.back-mini svg { width: 100%; height: 100%; display: block; }
.t-counts { display: flex; gap: 8px; align-items: center; flex: none; }
.t-pile { position: relative; width: calc(var(--cw) * .5); height: calc(var(--ch) * .5); }
.t-strip.me .t-pile { width: calc(var(--cw) * .62); height: calc(var(--ch) * .62); }
.pile-card { width: 100%; height: 100%; border-radius: 5px; box-shadow: 1px 1px 0 rgba(0, 0, 0, .25), 2px 2px 0 rgba(0, 0, 0, .18), 0 3px 6px rgba(0, 0, 0, .3); }
.pile-card svg { width: 100%; height: 100%; display: block; }
.pile-card.empty { border: 2px dashed rgba(255, 255, 255, .22); box-shadow: none; }
.count-pill { position: absolute; bottom: -6px; right: -6px; background: #14100be6; color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 9px; padding: 1px 6px; }
.t-discard {
  width: calc(var(--cw) * .62); height: calc(var(--ch) * .62);
  border: 2px dashed rgba(255, 255, 255, .25); border-radius: 8px; background: rgba(0, 0, 0, .12);
  color: var(--felt-ink); opacity: .75; font-size: 11px; font-weight: 700; cursor: default;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
}
.t-discard .ico { width: 20px; height: 20px; flex: none; }
/* the table shrinks this to fit the box when the word is long or the table is small */
.t-discard-label { white-space: nowrap; line-height: 1.15; }
.t-discard.can { cursor: pointer; opacity: 1; }
.t-discard.target { border-color: var(--gold); background: rgba(231, 181, 75, .15); }
.t-discard.drop-over, .t-discard.can:hover { background: rgba(231, 181, 75, .3); }

/* columns and routes */
.t-cols { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; min-height: 0; }
.t-col { display: flex; flex-direction: column; min-height: 0; background: var(--lane); border-radius: 16px; padding: 6px 6px; box-shadow: inset 0 0 0 1.5px rgba(243, 226, 180, .2); }
.t-route { flex: 1; position: relative; min-height: calc(var(--ch) + 8px); border-radius: 10px; transition: background .15s, box-shadow .15s; }
.t-route .slot { position: absolute; left: calc(50% - var(--cw) * .82); top: calc(var(--k) * var(--step) + 4px); width: var(--cw); height: var(--ch); }
.t-route .pc.on-table, .t-route .pc.face-att { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); }
.t-route .pc.face-att { left: calc(var(--j) * var(--cw) * .24); top: calc(var(--j) * var(--ch) * .035); }
.t-empty { position: absolute; left: calc(50% - var(--cw) * .5); top: 4px; width: var(--cw); height: var(--ch); border: 2px dashed rgba(255, 255, 255, .16); border-radius: calc(var(--cw) * .07); display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .55); padding: 4px; }
.val-tag { position: absolute; right: calc(var(--cw) * -.1); top: calc(var(--ch) * .02); z-index: 9; background: var(--gold); color: #2c1f02; font-family: var(--font-mono); font-weight: 700; font-size: 11px; border-radius: 6px; padding: 0 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.t-route.selling { background: rgba(231, 181, 75, .09); box-shadow: inset 0 0 0 1px rgba(231, 181, 75, .35); }
.t-route.over { background: rgba(217, 80, 58, .1); }

/* middle strip */
.t-mid { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 6px 2px; flex-direction: column; }
.t-pair { height: 0; position: relative; width: 100%; display: flex; justify-content: center; }
.pair-dot { display: none; }
.pair-flag { position: absolute; top: -10px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; padding: 1px 8px; border-radius: 8px; background: var(--gold); color: #2c1f02; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); z-index: 60; white-space: nowrap; }
.t-pair.lost .pair-flag { background: #e9c9bf; color: #4a1d12; }
.lane-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(14, 10, 6, .55); color: #fff;
  border-radius: 999px; padding: 3px 10px 3px 12px; min-height: 28px;
  font-size: 13px; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.lane-chip .lane-total { font-size: 16px; font-weight: 700; min-width: 20px; text-align: center; }
.lane-chip .dir { display: inline-flex; width: 16px; height: 16px; align-items: center; justify-content: center; color: #f1e2b8; }
.lane-chip .dir .ico { width: 16px; height: 16px; }
.lane-chip .dir.none { color: rgba(255, 255, 255, .4); }
.lane-chip .suit { display: inline-flex; background: #fbf8f1; border-radius: 5px; padding: 2px; line-height: 0; }
.lane-chip.range { box-shadow: inset 0 0 0 2px rgba(241, 214, 140, .6); }
.lane-chip.sold { background: var(--gold); color: #2c1f02; box-shadow: 0 0 0 3px rgba(231, 181, 75, .3), 0 0 18px rgba(231, 181, 75, .45); }
.lane-chip.sold.pop { animation: soldPop .55s ease-out; }
.lane-chip.sold .dir { color: #2c1f02; }
.lane-chip.over { background: #8e2f20; }
.sold-tag, .over-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; }
.lane-chip .disband { border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; margin-left: 2px; }
.lane-chip .disband .ico { width: 14px; height: 14px; }
.lane-chip .disband:hover { background: var(--red); }
@keyframes soldPop { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: none; } }

/* hand */
.t-hand { flex: 1; display: flex; justify-content: center; align-items: flex-end; min-width: 0; padding: 0 0 2px 0; height: 100%; }
.pc.in-hand {
  width: var(--hcw); height: var(--hch); flex: none; cursor: pointer;
  margin-left: calc(var(--hcw) * -1 * var(--hov, .22));
  transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 1.6deg));
  transition: transform .14s ease, box-shadow .14s, opacity .14s;
  transform-origin: 50% 120%;
  touch-action: none;
}
.pc.in-hand:first-child { margin-left: 0; }
.pc.in-hand:hover { transform: translateY(-10px); z-index: 5; }
.pc.in-hand.selected { transform: translateY(-22px) scale(1.04); z-index: 6; box-shadow: 0 0 0 3px var(--gold), 0 12px 24px rgba(0, 0, 0, .45); }
.pc.in-hand.dead { opacity: .55; }
.pc.in-hand.drag-src { opacity: .3; }
.pc.in-hand.back { cursor: default; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 400; pointer-events: none; box-shadow: 0 18px 34px rgba(0, 0, 0, .5); border-radius: 7px; }
.ghost { position: fixed; z-index: 300; pointer-events: none; border-radius: 7px; }

/* legal-move highlighting */
.table.picking .t-route.target { background: rgba(231, 181, 75, .12); box-shadow: inset 0 0 0 2px rgba(231, 181, 75, .75); cursor: pointer; }
.table.picking .t-route.target .t-empty { border-color: var(--gold); color: var(--gold); }
.table.picking .pc.tgt { cursor: pointer; box-shadow: 0 0 0 3px var(--gold), 0 0 14px rgba(231, 181, 75, .65); animation: tgtPulse 1.3s ease-in-out infinite; }
.table.picking .pc.tgt:hover, .table .drop-over.pc.tgt { box-shadow: 0 0 0 4px #fff, 0 0 20px rgba(255, 255, 255, .8); }
.table .t-route.drop-over { background: rgba(231, 181, 75, .25); }
.table.no-hints .t-route.target, .table.no-hints .pc.tgt { box-shadow: none; animation: none; background: none; }
@keyframes tgtPulse { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(231, 181, 75, .9); } }
.pc.last { box-shadow: 0 0 0 2px rgba(255, 236, 170, .95), 0 3px 8px rgba(0, 0, 0, .3); }

.t-banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(16, 12, 8, .85); padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: 15px; z-index: 90; pointer-events: none; text-align: center; color: #fff; max-width: 80%; }
.t-flash { position: absolute; inset: 0; pointer-events: none; z-index: 80; border-radius: 18px; }
.t-flash.joker { background: radial-gradient(circle at 50% 50%, rgba(255, 220, 120, .35), transparent 60%); animation: flashFade .9s ease-out forwards; }
@keyframes flashFade { from { opacity: 1; } to { opacity: 0; } }

.no-anim .pc, .no-anim .lane-chip, .no-anim .pc.tgt { animation: none !important; transition: none !important; }

/* -------------------------------------------------------------- responsive --- */
@media (max-width: 1100px) {
  .side-panel { width: 330px; }
}
@media (max-width: 860px) {
  .game-layout { flex-direction: column; height: auto; padding: 8px 8px 24px; gap: 10px; }
  .table-col { width: 100%; }
  .table-area { height: min(78vh, 760px); height: min(78dvh, 760px); flex: none; }
  .table { padding: 6px 4px 4px; border-radius: 20px; border-width: 9px; }
  .t-cols { gap: 5px; }
  .t-col { padding: 4px 2px; border-radius: 10px; }
  .side-panel { width: 100%; max-height: none; min-height: 300px; }
  .clock { font-size: 18px; min-width: 86px; padding: 4px 8px; }
  .lane-chip { padding: 2px 7px; gap: 4px; font-size: 12px; min-height: 24px; }
  .lane-chip .lane-total { font-size: 14px; }
  .lane-chip .sold-tag, .lane-chip .over-tag { display: none; }
  .t-discard span { display: none; }
}

/* demo table on the home and Play pages */
.demo-table { width: 100%; height: min(72vh, 660px); display: flex; pointer-events: none; }
.hero-art .demo-table { height: min(70vh, 620px); }
.bot-hero { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.speech { position: relative; background: #f6f0e4; color: #2a2119; border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.speech::before { content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%); border: 8px solid transparent; border-left: 0; border-right-color: #f6f0e4; }
@media (max-width: 860px) {
  .hero-art .demo-table { height: 56vh; }
}
.lane-chip.empty { opacity: .45; }

/* phones: the table fills the screen between the two player bars */
@media (max-width: 860px) {
  .sidebar .side-legal { display: none; }
  .table-area { height: calc(100vh - 180px); height: calc(100dvh - 180px); min-height: 460px; max-height: 820px; }
  .player-bar { min-height: 40px; }
  .player-bar .avatar { width: 34px !important; height: 34px !important; }
}

/* mute and report above the game chat */
.chat-tools { display: flex; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-tools .btn { color: var(--text-3); }
.chat-tools .btn:hover:not(:disabled) { color: var(--text); }
