/* Tongits (templates/games/tongits.html): the table HUD, the hand and the panels, from the approved prototype.
   Every class starts with tg- and every rule sits under .tg, so nothing leaks into the site.
   The stage colours (--g-*) come from .gm-stage in static/games.css. Bump ?v= on the link when this changes. */
.tg { --sign: "Bungee", Impact, "Arial Black", sans-serif; --g-panel: rgba(13, 14, 24, .84); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; font: 500 15px/1.4 var(--ui); }
.tg * { box-sizing: border-box; }
.tg button { font: inherit; color: inherit; }
.tg canvas { touch-action: none; }
.tg #badges { position: absolute; inset: 0; pointer-events: none; }
.tg-badge { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; white-space: nowrap; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 10px; padding: 3px 6px; font: 800 11px var(--ui); letter-spacing: .06em; text-transform: uppercase; transition: box-shadow .2s; }
.tg-badge .st { color: var(--g-marquee); letter-spacing: .02em; }
.tg-badge .st:empty { display: none; }
.tg-badge .n { min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center; border-radius: 7px; background: rgba(255, 255, 255, .1); font: 800 13px var(--display); letter-spacing: 0; }
.tg-badge.on { box-shadow: 0 0 0 2px var(--g-marquee), 0 0 18px rgba(255, 210, 63, .5); }
.tg-badge.win .n { background: var(--g-win); color: #062b14; }
.tg-badge.small { font-size: 10px; padding: 2px 6px; color: var(--g-muted); }

.tg-hud { --cw: 58px; --ch: 82px; position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 8px; }
.tg-hud > * { pointer-events: auto; }
.tg-top { display: flex; align-items: center; gap: 8px; pointer-events: none; }
.tg-top > * { pointer-events: auto; }
.tg-panel { background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 14px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tg-wallet { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 6px; min-height: 44px; }
.tg-dot { width: 26px; height: 26px; flex: none; background: url(coin.svg?v=1) center / contain no-repeat; }
.tg #bal { font: 800 22px var(--display); color: var(--g-marquee); font-variant-numeric: tabular-nums; }
.tg-tbl { padding: 4px 10px; min-height: 44px; display: grid; align-content: center; font-size: 12px; white-space: nowrap; flex: none; color: var(--g-muted); line-height: 1.2; }
.tg-tbl b { color: var(--g-ink); font: 800 14px var(--display); }
.tg-spacer { flex: 1; }
.tg-sign { display: none; font-family: var(--sign); font-size: 26px; letter-spacing: .04em; color: var(--g-marquee); background: var(--g-sign); padding: 6px 18px 4px; border-radius: 10px; text-shadow: 0 2px 0 #5a0d10, 0 0 18px rgba(255, 200, 60, .55); box-shadow: 0 0 0 3px #5a0d10, 0 0 0 6px var(--g-marquee), 0 0 30px rgba(255, 190, 40, .35); }
.tg-ibtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--g-line); background: var(--g-panel); cursor: pointer; display: grid; place-items: center; font: 800 18px var(--display); }
.tg-ibtn:hover { background: rgba(255, 255, 255, .12); }
.tg-ibtn svg { width: 22px; height: 22px; }
.tg-ibtn[aria-pressed="false"] .on, .tg-ibtn[aria-pressed="true"] .off { display: none; }

.tg-middle { flex: 1; display: grid; place-items: start center; pointer-events: none; padding-top: 8px; }
.tg-toast { max-width: min(92%, 460px); background: var(--g-sign); color: var(--g-ink); font-weight: 600; padding: 8px 14px; border-radius: 10px; box-shadow: 0 0 0 2px var(--g-marquee), 0 8px 24px rgba(0, 0, 0, .5); text-align: center; animation: tg-pop .3s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes tg-pop { from { transform: scale(.85); opacity: 0; } }

.tg-foot { display: grid; gap: 6px; justify-items: center; }
.tg-bar { width: 100%; max-width: 760px; padding: 6px 8px 8px; display: grid; gap: 6px; }
.tg-info { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.tg #prompt { flex: 1; font-weight: 600; font-size: 13.5px; line-height: 1.25; color: var(--g-ink); }
.tg #prompt.warn { color: var(--g-marquee); }
.tg-pts { display: grid; text-align: right; line-height: 1.1; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--g-muted); }
.tg-pts b { font: 800 20px var(--display); color: var(--g-ink); letter-spacing: 0; }
.tg-sbtn { min-width: 44px; height: 44px; padding: 0 10px; border-radius: 11px; border: 1px solid var(--g-line); background: rgba(255, 255, 255, .07); cursor: pointer; font: 800 12px var(--ui); }
.tg #hand { position: relative; height: calc(var(--ch) + 22px); }
.tg-card { position: absolute; bottom: 0; width: var(--cw); height: var(--ch); padding: 0; border-radius: 8px; border: 1px solid #cfc6b4; background: #fbf7ee; color: #1b1c22 !important; cursor: pointer; touch-action: none;
  box-shadow: -3px 3px 8px rgba(0, 0, 0, .45); transition: transform .15s, left .25s, box-shadow .15s; }
.tg-card.red { color: #c4202b !important; }
.tg-card .r { position: absolute; left: 4px; top: 3px; font: 800 20px/1 var(--ui); letter-spacing: -.04em; }
.tg-card .r.ten { font-size: 17px; letter-spacing: -.08em; left: 2px; }
.tg-card .s { position: absolute; left: 5px; top: 24px; font: 17px/1 serif; }
.tg-card .big { position: absolute; right: 5px; bottom: 5px; font: 30px/1 serif; }
.tg-card .big.face { font: 400 24px/1 var(--sign); }
.tg-card.meldable { border-color: #f5c542; box-shadow: 0 0 0 2px #f5c542, 0 0 16px 2px rgba(245, 197, 66, .8); }
.tg-card.fits { border-color: #b98cff; box-shadow: 0 0 0 2px #b98cff, 0 0 16px 2px rgba(185, 140, 255, .85); }
.tg-card.meldable.fits { border-color: #f5c542; box-shadow: 0 0 0 2px #f5c542, 0 0 0 4px #b98cff, 0 0 16px 4px rgba(185, 140, 255, .85); }
.tg-card[aria-pressed="true"] { transform: translateY(-18px); box-shadow: 0 0 0 3px var(--g-marquee), 0 10px 18px rgba(0, 0, 0, .55); }
.tg-card.drawn { box-shadow: 0 0 0 3px #35ded1, 0 0 18px rgba(53, 222, 209, .75); }
.tg-card.drawn[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--g-marquee), 0 0 0 6px #35ded1, 0 10px 18px rgba(0, 0, 0, .55); }
.tg-card.drawn::after { content: "New"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); padding: 1px 6px; border-radius: 6px; background: #35ded1; color: #06201e; font: 800 9.5px/1.4 var(--ui); letter-spacing: .08em; text-transform: uppercase; pointer-events: none; }
.tg-card.dragging { transition: none; z-index: 99 !important; transform: translateY(-24px) scale(1.06); box-shadow: 0 14px 24px rgba(0, 0, 0, .6); cursor: grabbing; }
.tg-card.new { animation: tg-deal .35s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes tg-deal { from { transform: translateY(60px) scale(.8); opacity: 0; } }
.tg-card:focus-visible { outline: 3px solid #8fd3ff; outline-offset: 2px; }
.tg-acts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.tg-acts.two { grid-template-columns: 1fr 1fr; }
.tg-btn { min-height: 48px; padding: 6px 2px; border-radius: 11px; border: 1px solid var(--g-line); background: rgba(255, 255, 255, .08); color: var(--g-ink); cursor: pointer; font: 800 12.5px var(--ui) !important; letter-spacing: .02em; white-space: nowrap; }
.tg-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .15); }
.tg-btn:disabled { opacity: .35; cursor: not-allowed; }
.tg-btn.hot { background: var(--g-marquee); color: #3a1a05; border: 0; box-shadow: 0 3px 0 #a5790c, 0 0 18px rgba(255, 210, 63, .35); }
.tg-btn.hot:hover:not(:disabled) { background: #ffe066; }
.tg-btn.red { background: var(--g-sign); border-color: #ff8270; }
.tg-btn:active:not(:disabled) { transform: translateY(2px); }
.tg button:focus-visible, .tg a:focus-visible { outline: 3px solid #8fd3ff; outline-offset: 2px; }

.tg-overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 12, .55); overflow-y: auto; }
.tg-sheet { width: min(100%, 440px); display: grid; gap: 14px; padding: 22px 18px 18px; border-radius: 18px; background: rgba(18, 19, 30, .94); border: 1px solid var(--g-line); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); text-align: center; animation: tg-pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.tg-title { font-family: var(--sign); font-size: clamp(38px, 12cqi, 56px); line-height: 1; color: var(--g-marquee); text-shadow: 0 3px 0 #5a0d10, 0 0 24px rgba(255, 200, 60, .55); margin: 4px 0 0; font-weight: 400; }
.tg-sub { margin: 0; color: var(--g-muted); font-size: 14px; }
.tg-group { display: grid; gap: 6px; text-align: left; }
.tg-group > span { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--g-muted); }
.tg-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.tg-seg button { min-height: 48px; border-radius: 11px; border: 1px solid var(--g-line); background: rgba(255, 255, 255, .06); cursor: pointer; font: 800 15px var(--display); display: grid; line-height: 1.1; }
.tg-seg button small { font: 600 11px var(--ui); color: var(--g-muted); }
.tg-seg button[aria-checked="true"] { background: rgba(255, 210, 63, .16); border-color: var(--g-marquee); box-shadow: inset 0 0 0 1px var(--g-marquee); }
.tg-seg button:disabled { opacity: .35; cursor: not-allowed; }
.tg-big { min-height: 54px; border-radius: 13px; border: 0; cursor: pointer; background: var(--g-marquee); color: #3a1a05 !important; font: 800 20px var(--display) !important; box-shadow: 0 4px 0 #a5790c, 0 0 28px rgba(255, 210, 63, .35); }
.tg-big:disabled { opacity: .4; cursor: not-allowed; }
.tg-link { min-height: 44px; border-radius: 11px; border: 1px solid var(--g-line); background: transparent; cursor: pointer; font: 700 14px var(--ui) !important; color: var(--g-ink) !important; display: grid; place-items: center; }
.tg-link:hover { text-decoration: none; background: rgba(255, 255, 255, .06); }
.tg-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tg-note { font-size: 12.5px; color: var(--g-muted); margin: 0; }
.tg-note.warn { color: var(--g-lose); }
.tg-rules { text-align: left; max-height: min(52vh, 560px); overflow-y: auto; padding-right: 4px; font-size: 14px; color: var(--g-ink); }
.tg-rules h3 { font: 800 15px var(--display); color: var(--g-marquee); margin: 14px 0 4px; }
.tg-rules h3:first-child { margin-top: 0; }
.tg-rules ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.tg-rules p { margin: 0 0 6px; }
.tg-res-head { font-family: var(--sign); font-size: clamp(30px, 9cqi, 44px); line-height: 1.05; color: var(--g-marquee); text-shadow: 0 3px 0 #5a0d10, 0 0 22px rgba(255, 200, 60, .5); margin: 0; font-weight: 400; }
.tg-res-head.lose { font: 800 28px var(--display); color: var(--g-lose); text-shadow: none; }
.tg-res-rows { display: grid; gap: 6px; }
.tg-res-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .05); text-align: left; }
.tg-res-row.win { box-shadow: inset 0 0 0 1px var(--g-win); }
.tg-res-row b { font: 800 15px var(--display); }
.tg-res-row small { display: block; color: var(--g-muted); font-size: 12px; }
.tg-res-row .p { font: 800 20px var(--display); font-variant-numeric: tabular-nums; }
.tg-coinline { font: 800 26px var(--display); }
.tg-coinline.up { color: var(--g-win); }
.tg-coinline.down { color: var(--g-lose); }

/* the stage reads its own width (container query), not the window's: the sidebar takes part of a wide window */
@container (min-width: 700px) {
  .tg-hud { --cw: 74px; --ch: 104px; }
  .tg-card .r { font-size: 25px; left: 6px; top: 5px; }
  .tg-card .r.ten { font-size: 22px; left: 4px; }
  .tg-card .s { font-size: 21px; top: 31px; left: 7px; }
  .tg-card .big { font-size: 40px; }
  .tg-card .big.face { font-size: 32px; }
  .tg-btn { font-size: 14px !important; min-height: 52px; }
  .tg-sign { display: block; }
  .tg #prompt { font-size: 15px; }
}
@media (max-width: 1024px) { .gm-stage.tg { height: max(600px, calc(100svh - 128px)); } }
.tg-ibtn { flex: none; }
/* a phone: four round buttons, the wallet and the table must fit one row */
@container (max-width: 420px) {
  .tg-top { gap: 4px; }
  .tg-top .tg-spacer + .tg-sign + .tg-spacer { display: none; }
  .tg-ibtn { width: 38px; height: 40px; }
  .tg-wallet { gap: 5px; padding: 4px 9px 4px 5px; }
  .tg-dot { width: 20px; height: 20px; }
  .tg #bal { font-size: 19px; }
  .tg-tbl { padding: 4px 8px; font-size: 11px; }
  .tg-wide { display: none; }
}
.gm-stage.tg:fullscreen { height: 100vh; height: 100dvh; border-radius: 0; }
@media (prefers-reduced-motion: reduce) { .tg-toast, .tg-sheet, .tg-card.new { animation: none; } .tg-card { transition: none; } }

/* Tables (games/tongits_tables.py): the lobby tab, the table panel, emotes */
.tg-pane { display: grid; gap: 14px; }
.tg-tabs button[aria-selected="true"] { background: rgba(255, 210, 63, .16); border-color: var(--g-marquee); box-shadow: inset 0 0 0 1px var(--g-marquee); }
.tg-biglink { display: grid; place-items: center; text-decoration: none !important; }
.tg-code { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.tg-code input { min-width: 0; min-height: 44px; border-radius: 11px; border: 1px dashed rgba(255, 246, 223, .35); background: rgba(255, 255, 255, .04); color: var(--g-ink); font: 600 17px ui-monospace, Menlo, monospace; letter-spacing: .2em; text-transform: uppercase; padding: 0 12px; user-select: text; -webkit-user-select: text; }
.tg-code input:focus { outline: 2px solid var(--g-marquee); outline-offset: 1px; }
.tg-code .tg-link { padding: 0 18px; }
.tg-list { display: grid; gap: 4px; max-height: 196px; overflow-y: auto; }
.tg-trow { width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, .05); border: 1px solid transparent; text-align: left; cursor: pointer; }
.tg-trow:hover:not(:disabled) { border-color: var(--g-line); }
.tg-trow:disabled { cursor: default; opacity: .6; }
.tg-trow b { font: 800 16px var(--display); color: var(--g-marquee); }
.tg-trow small { display: block; color: var(--g-muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-trow .go { font: 800 12.5px var(--ui); color: #35ded1; }
.tg-dots { display: flex; gap: 4px; }
.tg-dots i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--g-muted); }
.tg-dots i.f { background: var(--g-win); border-color: var(--g-win); }
.tg-codebox { display: grid; gap: 6px; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--g-line); }
.tg-codebox > span { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--g-muted); }
.tg-codebox b { font: 600 30px ui-monospace, Menlo, monospace; letter-spacing: .2em; user-select: all; -webkit-user-select: all; }
.tg-seats { display: grid; gap: 6px; }
.tg-seat { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 12px; border: 1px solid var(--g-line); background: rgba(13, 14, 24, .6); text-align: left; }
.tg-seat .av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font: 800 16px var(--display); color: #1b0d00; background: var(--g-marquee); }
.tg-seat.bot .av { background: var(--g-push); }
.tg-seat.empty { border-style: dashed; }
.tg-seat.empty .av { background: transparent; border: 1.5px dashed var(--g-muted); color: var(--g-muted); animation: tg-blink 1.6s ease-in-out infinite; }
.tg-seat b { font: 800 15px var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.tg-seat small { display: block; color: var(--g-muted); font-size: 11.5px; }
.tg-seat .ok { font: 800 11px var(--ui); color: var(--g-win); }
.tg-seat .ok.no { color: var(--g-muted); }
@keyframes tg-blink { 50% { opacity: .35; } }
.tg-emotes { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.tg-emotes::-webkit-scrollbar { display: none; }
.tg-emotes button { flex: none; min-height: 34px; border-radius: 999px; border: 1px solid var(--g-line); background: rgba(255, 255, 255, .05); padding: 0 12px; font: 700 12.5px var(--ui); color: var(--g-muted) !important; cursor: pointer; }
.tg-emotes button:hover { color: var(--g-ink) !important; }
.tg-sbtn.hot { background: var(--g-marquee); color: #3a1a05 !important; border-color: var(--g-marquee); }
.tg-badge .st.emote { color: #35ded1; }
@media (prefers-reduced-motion: reduce) { .tg-seat.empty .av { animation: none; } }
.tg-tmr { min-width: 40px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: rgba(255, 255, 255, .08); font: 800 15px var(--display); font-variant-numeric: tabular-nums; }
.tg-tmr.low { background: var(--g-sign); color: var(--g-marquee); }
