/* ============================================================================
   Chkobba shell: layout, screens, the frame + pill grammar, cards, text-fill,
   fx, overlays. Themes only change tokens.css; this file never branches on one
   except for the two Noir pill rules.
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui); background: var(--bg); color: var(--text);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hidden, [hidden] { display: none !important; }

/* ---- ground: shader canvas, css fallback, fx layers ---- */
#bg-shader, #bg-css { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }
#bg-shader { opacity: var(--swirl-opacity); image-rendering: auto; transition: opacity .6s; }
#bg-css {
  background:
    radial-gradient(70% 60% at 25% 30%, color-mix(in srgb, var(--swirl-1) 70%, transparent), transparent 70%),
    radial-gradient(50% 70% at 78% 70%, color-mix(in srgb, var(--swirl-2) 30%, transparent), transparent 70%),
    radial-gradient(40% 40% at 60% 15%, color-mix(in srgb, var(--swirl-3) 35%, transparent), transparent 70%),
    var(--bg);
  opacity: var(--swirl-opacity);
}
html.no-webgl #bg-shader, html.reduce #bg-shader { display: none; }
#felt { position: fixed; inset: 0; z-index: 0; background: var(--felt); pointer-events: none; }
.stage-fx { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.fx-grain { position: absolute; inset: -50%; opacity: var(--grain-opacity); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 1.2s steps(4) infinite; }
@keyframes grainShift { 0%{transform:translate(0,0)} 25%{transform:translate(-3%,2%)} 50%{transform:translate(2%,-2%)} 75%{transform:translate(-2%,-1%)} 100%{transform:translate(0,0)} }
.fx-scanline { position: absolute; inset: 0; opacity: var(--scanline-opacity);
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.28) 2px 3px); }
html.crt .fx-scanline { opacity: max(var(--scanline-opacity), .28); }
html.no-crt .fx-scanline { opacity: 0; }
html.no-grain .fx-grain { display: none; }
html.reduce * { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; }

/* ---- app + screens ---- */
#app { position: relative; z-index: 1; height: 100%; height: 100dvh; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }
.screen--center { align-items: flex-start; justify-content: center; overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.screen--center > .frame { margin: auto; }   /* centered when it fits, scrollable from the top when it does not */

/* ---- type helpers ---- */
.display { font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.term { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; }
.term b { font-family: var(--font-display); font-weight: 700; text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); }
.term.rtl b { font-family: var(--font-arabic); text-transform: none; letter-spacing: 0; font-size: 1.15em; }
.term small { font-family: var(--font-ui); font-size: .55em; letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim); margin-top: .25em; }
.term.row { flex-direction: row; gap: .5em; align-items: baseline; }

/* ---- the frame (Balatro's browse panel) ---- */
.frame {
  position: relative; background: var(--panel); border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px var(--panel-rim), 0 var(--drop) 0 var(--drop-color), 0 18px 40px rgba(0,0,0,.35);
  padding: 22px; width: min(100%, 640px);
}
.frame--wide { width: min(100%, 860px); }
.frame__title { font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-size: 22px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.frame__title .sub { font-family: var(--font-ui); font-size: 13px; color: var(--text-dim); letter-spacing: .04em; text-transform: none; }
.plate { background: var(--plate); color: var(--plate-ink); border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.plate .term small { color: color-mix(in srgb, var(--plate-ink) 60%, transparent); }
.rail { display: grid; grid-template-columns: 44px 1fr 44px; gap: 12px; align-items: center; }
.rail__btn { height: 44px; }
.rail__btn { border-radius: var(--radius-sm); background: var(--mult); color: #fff; font-size: 22px; display: grid; place-items: center; box-shadow: 0 var(--drop) 0 var(--drop-color); transition: transform .08s; }
.rail__btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--drop-color); }
.dots { display: flex; justify-content: center; gap: 5px; margin: 12px 0 4px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-mut); }
.dots i.on { background: var(--text); }

/* ---- pills ---- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-weight: 700;
  font-size: 17px; color: #fff; padding: 13px 22px 14px; border-radius: var(--radius-sm);
  background: var(--mult); box-shadow: 0 var(--drop) 0 var(--drop-color);
  transition: transform .12s var(--spring), box-shadow .12s, filter .12s; user-select: none; white-space: nowrap;
}
.pill:hover { transform: translateY(-2px) rotate(-.6deg); filter: brightness(1.08); }
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--drop-color); }
.pill:disabled { opacity: .45; filter: none; transform: none; cursor: default; }
.pill.chip { background: var(--chip); }
.pill.gold { background: var(--gold); color: #1a1408; }
.pill.green { background: var(--green); }
.pill.orange { background: var(--orange); color: #1a1408; }
.pill.ghost { background: var(--panel-hi); color: var(--text); box-shadow: inset 0 0 0 2px var(--panel-rim), 0 var(--drop) 0 var(--drop-color); }
.pill.big { font-size: 20px; padding: 16px 28px 17px; width: 100%; }
.pill.sm { font-size: 13px; padding: 8px 12px 9px; }
.pill .fill { font-size: inherit; }
html[data-theme="c"] .pill { border-radius: 4px; background: linear-gradient(180deg, rgba(201,162,75,.16), rgba(201,162,75,.05)); color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
html[data-theme="c"] .pill.gold { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #120f08; }
html[data-theme="c"] .pill.chip, html[data-theme="c"] .pill.green, html[data-theme="c"] .pill.orange { color: var(--text); }

/* ---- form rows (options / lobby) ---- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--panel-rim); }
.row:last-child { border-bottom: 0; }
.row label, .row .lbl { font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-size: 14px; color: var(--text-dim); }
.seg { display: inline-flex; gap: 4px; background: rgba(0,0,0,.28); padding: 4px; border-radius: var(--radius-sm); }
.seg button { padding: 7px 12px; border-radius: 6px; font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-size: 13px; color: var(--text-dim); transition: background .15s, color .15s, transform .12s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--gold); color: #1a1408; box-shadow: 0 2px 0 rgba(0,0,0,.4); }
.seg.chipset button.on { background: var(--chip); color: #fff; }
.input { width: 100%; background: rgba(0,0,0,.32); border: 2px solid var(--panel-rim); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 18px; color: var(--text); font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: .1em; }
.input::placeholder { color: var(--text-mut); text-transform: none; letter-spacing: 0; font-family: var(--font-ui); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions > * { flex: 1; }

/* ---- main menu ---- */
#screen-menu { flex-direction: column; align-items: center; justify-content: flex-start; gap: 28px; overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
/* centered when it fits, scrollable from the top when it does not */
#screen-menu > :first-child { margin-top: auto; } #screen-menu > :last-child { margin-bottom: auto; }
.wordmark { text-align: center; line-height: 1; filter: drop-shadow(0 6px 0 rgba(0,0,0,.45)); }
.wordmark .ar { font-family: var(--font-arabic); font-size: clamp(64px, 12vw, 132px); color: var(--gold); display: block; line-height: 1.05; }
.wordmark .la { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .18em; font-size: clamp(22px, 4vw, 38px); color: var(--text); display: block; margin-top: 6px; }
.wordmark .tag { font-family: var(--font-ui); font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: var(--text-dim); display: block; margin-top: 10px; }
.menu-stack { display: flex; flex-direction: column; gap: 12px; width: min(100%, 360px); }
.menu-stack .pill { width: 100%; }
.menu-foot { font-size: 12px; color: var(--text-mut); letter-spacing: .1em; text-transform: uppercase; }
.hero-cards { display: flex; gap: 10px; margin-bottom: -6px; }
.hero-cards .card { --card-w: clamp(56px, 7vw, 84px); }
.hero-cards .card:nth-child(1) { transform: rotate(-9deg) translateY(6px); }
.hero-cards .card:nth-child(3) { transform: rotate(9deg) translateY(6px); }

/* ---- waiting room ---- */
.code { font-family: var(--font-display); font-size: clamp(40px, 8vw, 64px); letter-spacing: .2em; color: var(--gold); text-align: center; line-height: 1; text-shadow: 0 5px 0 rgba(0,0,0,.4); }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(0,0,0,.28); box-shadow: inset 0 0 0 2px var(--panel-rim); min-height: 56px; }
.slot .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; background: var(--team1); color: #fff; font-size: 14px; }
.slot.t2 .av { background: var(--team2); }
.slot .who { font-weight: 600; }
.slot .who small { display: block; font-size: 11px; color: var(--text-dim); letter-spacing: .1em; text-transform: uppercase; }
.slot.empty { justify-content: center; color: var(--text-mut); }

/* ============================================================================
   GAME VIEW
   ========================================================================== */
#screen-game { display: none; }
#screen-game.active { display: block; }
#screen-game { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#game-view { position: relative; height: 100%; display: grid; grid-template-rows: auto 1fr; }
#game-view[data-hud="rail"] { grid-template-rows: 1fr; grid-template-columns: 172px 1fr; }
#hud { position: relative; z-index: 4; display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
#game-view[data-hud="rail"] #hud { flex-direction: column; align-items: stretch; padding: 12px 10px; gap: 10px; background: rgba(0,0,0,.28); box-shadow: inset -2px 0 0 var(--panel-rim); }
#game-view[data-hud="top"] #hud { justify-content: space-between; flex-wrap: wrap; background: linear-gradient(180deg, rgba(0,0,0,.45), rgba(0,0,0,0)); }

.hud-box { background: var(--panel); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 2px var(--panel-rim), 0 var(--drop) 0 var(--drop-color); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hud-box .lbl { font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-size: 11px; color: var(--text-dim); }
.hud-box .val { font-family: var(--font-num); font-size: 24px; line-height: 1; font-weight: 700; }
.hud-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hud-team { border-radius: var(--radius-sm); padding: 6px 8px; text-align: center; box-shadow: 0 3px 0 rgba(0,0,0,.4); color: #fff; }
.hud-team.t1 { background: var(--team1); } .hud-team.t2 { background: var(--team2); }
.hud-team .lbl { font-family: var(--font-display); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.hud-team .val { font-family: var(--font-num); font-size: 26px; line-height: 1; font-weight: 700; }
.hud-team .shk { font-size: 10px; letter-spacing: .08em; opacity: .9; }
.hud-wordmark { font-family: var(--font-arabic); font-size: 30px; color: var(--gold); line-height: 1; text-align: center; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
#game-view[data-hud="top"] .hud-wordmark { font-size: 24px; }
#game-view[data-hud="top"] .hud-box { flex-direction: row; align-items: baseline; gap: 8px; }
#game-view[data-hud="top"] .hud-box .val { font-size: 18px; }
#game-view[data-hud="top"] .hud-scores { display: flex; }
#game-view[data-hud="top"] .hud-team { display: flex; align-items: baseline; gap: 6px; padding: 5px 10px; }
#game-view[data-hud="top"] .hud-team .val { font-size: 18px; }
.hud-turn { text-align: center; padding: 6px 4px; }
.hud-gear { margin-left: auto; width: 44px; height: 44px; flex: none; border-radius: var(--radius-sm); background: var(--panel); box-shadow: inset 0 0 0 2px var(--panel-rim), 0 var(--drop) 0 var(--drop-color); display: grid; place-items: center; font-size: 18px; }
#game-view[data-hud="rail"] .hud-gear { margin: auto 0 0; width: 100%; }
.hud-spacer { flex: 1; }

/* text fill (Deadlock): text is the mask, --p the stop. Driven by JS. */
.fill {
  --p: 100%; --fill-color: var(--gold);
  display: inline-block; font-family: var(--font-display); font-weight: 700; text-transform: var(--ui-case); letter-spacing: var(--ui-tracking);
  background: linear-gradient(90deg, var(--fill-color) var(--p), color-mix(in srgb, var(--text) 22%, transparent) var(--p));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.45));
  transition: --p .12s linear;
}
@property --p { syntax: "<percentage>"; inherits: false; initial-value: 100%; }
.fill.rtl { background: linear-gradient(270deg, var(--fill-color) var(--p), color-mix(in srgb, var(--text) 22%, transparent) var(--p)); -webkit-background-clip: text; background-clip: text; font-family: var(--font-arabic); text-transform: none; letter-spacing: 0; }
.fill.chip { --fill-color: var(--chip); } .fill.green { --fill-color: var(--green); } .fill.mult { --fill-color: var(--mult); } .fill.text { --fill-color: var(--text); }
.fill.lg { font-size: 22px; } .fill.xl { font-size: 28px; }
.fill.urgent { animation: urgent .5s ease-in-out infinite alternate; }
@keyframes urgent { from { filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)); } to { filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)) drop-shadow(0 0 10px var(--mult)); } }

/* ---- board ---- */
#game-board { position: relative; z-index: 2; display: grid; grid-template-rows: auto 1fr auto; min-height: 0; height: 100%; padding: 6px 10px 10px; }
#game-view[data-hud="rail"] #game-board { padding-top: 14px; }
#opponents-top { display: flex; justify-content: center; gap: 14px; padding: 4px 0; min-height: 0; }
#play-area { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 0; }
#opponent-left, #opponent-right { display: flex; align-items: center; justify-content: center; min-width: 0; }
#opponent-left:empty, #opponent-right:empty { display: none; }
#play-area:has(#opponent-left:empty) { grid-template-columns: 1fr; }

.opp { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--panel); box-shadow: inset 0 0 0 2px var(--panel-rim), 0 var(--drop) 0 var(--drop-color); transition: box-shadow .3s; }
.opp.side { flex-direction: column; padding: 10px 8px; }
.opp .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 14px; color: #fff; background: var(--team2); flex: none; }
.opp.t1 .av { background: var(--team1); }
.opp .meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.opp .name { font-family: var(--font-display); font-size: 14px; text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); }
.opp .fill { font-size: 14px; }
.opp .backs { display: flex; }
.opp .backs .card-back.mini { margin-left: -9px; } .opp .backs .card-back.mini:first-child { margin-left: 0; }
.opp .cap { font-size: 11px; color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.opp .cap b { color: var(--gold); font-family: var(--font-num); font-size: 13px; }
.opp.active-turn { box-shadow: inset 0 0 0 2px var(--gold), 0 var(--drop) 0 var(--drop-color), var(--glow-gold); }

#table-area { position: relative; display: flex; align-items: center; justify-content: center; gap: clamp(12px, 3vw, 34px); min-height: calc(var(--card-h) + 40px); }
.deck-pile { position: relative; width: var(--card-w); height: var(--card-h); flex: none; }
.deck-pile .card-back { position: absolute; inset: 0; }
.deck-pile .card-back:nth-child(2) { transform: translate(-3px, -3px); } .deck-pile .card-back:nth-child(3) { transform: translate(-6px, -6px); }
.deck-count { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-family: var(--font-num); font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.table-center { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: min(60vw, 560px); }
.card-row { display: flex; align-items: center; justify-content: center; gap: clamp(6px, 1.2vw, 12px); flex-wrap: wrap; min-height: var(--card-h); }
#table-msg { font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-size: 13px; color: var(--text-dim); min-height: 1.2em; text-align: center; }
#fx-table { position: absolute; inset: -40px 0; pointer-events: none; display: grid; place-items: center; z-index: 30; }

#hand-area { position: relative; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 6px; }
#player-label { font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 10px; }
#my-captured { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; min-height: 22px; }
#my-captured .backs { display: flex; } #my-captured .backs .card-back.mini { margin-left: -9px; } #my-captured .backs .card-back.mini:first-child { margin-left: 0; }
#my-captured b { color: var(--gold); font-family: var(--font-num); font-size: 15px; }
#hand-cards { gap: clamp(8px, 1.4vw, 16px); padding-top: 12px; }   /* room for a lifted card under the labels */
#hand-actions { display: flex; gap: 10px; min-height: 52px; align-items: center; }
#hand-actions .pill { min-width: 128px; min-height: 48px; }

/* ============================================================================
   CARD
   ========================================================================== */
/* --card-h is re-derived here so a card that sets its own --card-w (menu, rules, deck)
   keeps the right shape instead of inheriting the page-level height */
.card, .deck-pile { --card-h: calc(var(--card-w) * 1.42); }
.card { position: relative; width: var(--card-w); height: var(--card-h); perspective: 760px; flex: none; border-radius: var(--card-radius);
  --rx: 0deg; --ry: 0deg; --lift-now: 0px; --scale: 1; --mx: 50%; --my: 50%; --holo: 0; }
.card__inner { position: absolute; inset: 0; transform-style: preserve-3d; border-radius: inherit; background: var(--card-face); box-shadow: var(--card-shadow); border: 1px solid var(--card-edge); overflow: hidden;
  transform: translateY(var(--lift-now)) scale(var(--scale)) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .26s var(--spring), box-shadow .26s var(--ease-out); will-change: transform; }
.card__face { position: absolute; inset: 0; color: var(--suit-color); }
.card__photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card__corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: .9; gap: 1px; }
.card__corner--tl { top: 5%; left: 7%; } .card__corner--br { bottom: 5%; right: 7%; transform: rotate(180deg); }
.card__rank { font-family: var(--font-num); font-weight: var(--rank-weight); font-size: calc(var(--card-w) * .26); color: var(--suit-color); }
.card__corner .pip { width: calc(var(--card-w) * .15); height: calc(var(--card-w) * .15); }
.card__center { position: absolute; inset: 15% 12%; }
.pip { position: absolute; width: calc(var(--card-w) * .21); height: calc(var(--card-w) * .21); transform: translate(-50%, -50%); color: var(--suit-color); }
.pip svg { width: 100%; height: 100%; display: block; fill: currentColor; }
.pip.flip { transform: translate(-50%, -50%) rotate(180deg); }
.card__court { position: absolute; inset: 16% 12%; display: grid; place-items: center; border: 2px solid color-mix(in srgb, var(--suit-color) 45%, transparent); border-radius: 6px; }
.card__court span { font-family: var(--font-display); font-weight: 700; font-size: calc(var(--card-w) * .5); color: var(--suit-color); }
.card__court .court-suit { position: absolute; bottom: 8%; width: 26%; height: 26%; }
.card__watermark { position: absolute; inset: 0; display: grid; place-items: center; opacity: .07; pointer-events: none; }
.card__watermark svg { width: 64%; height: 64%; fill: var(--suit-color); }

/* pixel style: crisp bitmaps, square-ish corners, chunky ink */
html[data-cards="pixel"] .card { --card-radius: 4px; }
html[data-cards="pixel"] .card__inner { border: 2px solid var(--card-ink); image-rendering: pixelated; box-shadow: 0 4px 0 rgba(0,0,0,.45); }
html[data-cards="pixel"] .card__rank { font-family: 'Pixelify Sans', monospace; font-size: calc(var(--card-w) * .3); }
html[data-cards="pixel"] .pip svg { shape-rendering: crispEdges; image-rendering: pixelated; }
html[data-cards="pixel"] .card__court { border-width: 3px; border-radius: 0; }
html[data-cards="pixel"] .card__court span { font-family: 'Pixelify Sans', monospace; }
html[data-cards="pixel"] .card-back { border: 2px solid var(--card-ink); border-radius: 4px; }

/* suits */
.card[data-suit="diamonds"], .card[data-suit="hearts"] { --suit-color: var(--card-red); }
.card[data-suit="clubs"], .card[data-suit="spades"] { --suit-color: var(--card-ink); }
html[data-suitstyle="coin"] .card[data-suit="diamonds"] { --suit-color: #b8862b; }
html[data-suitstyle="coin"] .card[data-suit="hearts"]   { --suit-color: #1e5a8a; }
html[data-suitstyle="coin"] .card[data-suit="spades"]   { --suit-color: #5b6b73; }
html[data-suitstyle="coin"] .card[data-suit="clubs"]    { --suit-color: #b3582a; }
.card.is-haya { --suit-color: var(--haya); }

/* sheen */
.card__holo { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; mix-blend-mode: screen;
  background: linear-gradient(105deg, transparent 30%, rgba(255,246,224,.5) 46%, rgba(255,255,255,.7) 50%, rgba(255,246,224,.5) 54%, transparent 70%);
  background-size: 220% 220%; background-position: var(--mx) var(--my);
  opacity: calc(var(--holo) * var(--juice-k) * .6); transition: opacity .2s; }
.card__glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(110px 110px at var(--mx) var(--my), rgba(255,250,235,.45), rgba(255,255,255,0) 62%);
  opacity: calc(var(--holo) * var(--juice-k) * .8); transition: opacity .2s; }
html[data-theme="a"] .card.is-haya .card__holo {
  background: linear-gradient(115deg, rgba(255,0,90,.35) 0%, rgba(255,200,0,.35) 20%, rgba(0,255,170,.35) 40%, rgba(0,160,255,.35) 60%, rgba(180,0,255,.35) 80%, rgba(255,0,90,.35) 100%);
  background-size: 300% 300%; mix-blend-mode: hard-light; }

/* states */
.card.is-interactive { cursor: pointer; }
.card.is-interactive:hover { --lift-now: var(--lift); --scale: calc(1 + .05 * var(--juice-k)); --holo: 1; z-index: 5; }
.card.is-interactive:hover .card__inner { box-shadow: 0 calc(16px + 8px * var(--juice-k)) 26px rgba(0,0,0,.5), 0 0 0 2px var(--gold); }
.card.selected { --lift-now: calc(var(--lift) * 1.5); --scale: calc(1 + .07 * var(--juice-k)); z-index: 6; }
.card.selected .card__inner { box-shadow: 0 18px 30px rgba(0,0,0,.55), 0 0 0 3px var(--gold), var(--glow-gold); }
.card.capture-target .card__inner { box-shadow: var(--card-shadow), 0 0 0 3px var(--green), 0 0 16px color-mix(in srgb, var(--green) 60%, transparent); }
.card.capture-target { --lift-now: calc(var(--lift) * .6); }
.card.capture-picked .card__inner { box-shadow: var(--card-shadow), 0 0 0 3px var(--gold), var(--glow-gold); }
.card.is-haya .card__inner { box-shadow: var(--card-shadow), 0 0 0 2px var(--haya), var(--glow-haya); }
.card.is-haya .card__holo { opacity: calc(.4 * var(--juice-k)); animation: hayaSheen 4.5s linear infinite; }
@keyframes hayaSheen { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
.card.idle .card__inner { animation: breathe calc(5s + var(--phase, 0) * 2s) var(--ease-out) calc(var(--phase, 0) * -3s) infinite; }
@keyframes breathe { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(calc(-2px * var(--juice-k))) rotate(calc(.5deg * var(--juice-k))); } }
.card.is-interactive:hover.idle .card__inner, .card.selected.idle .card__inner, .card.capture-target.idle .card__inner { animation: none; }
.card.lifting .card__inner { animation: liftPop calc(.34s * var(--time-scale, 1)) var(--spring); }
@keyframes liftPop { 0% { transform: translateY(0) scale(1); } 45% { transform: translateY(calc(-18px * var(--juice-k))) scale(calc(1 + .1 * var(--juice-k))) rotate(-2deg); } 100% { transform: translateY(0) scale(1); } }
.card.slot-hidden { visibility: hidden; }
.card.landed .card__inner { animation: land calc(.36s * var(--time-scale, 1)) var(--spring); }
@keyframes land { 0% { transform: scale(1.06) rotate(-3deg); } 100% { transform: scale(1) rotate(0); } }
.card.flying { position: fixed; z-index: 60; pointer-events: none; margin: 0; }
.card.flying .card__inner { animation: none; }
.card-back.flying { position: fixed; z-index: 60; pointer-events: none; }

/* backs are inert by construction: no hover, no tilt, no phase */
.card-back { width: var(--card-w); height: var(--card-h); border-radius: var(--card-radius); background: var(--card-back); border: 1px solid var(--card-edge); box-shadow: var(--card-shadow); position: relative; overflow: hidden; flex: none; }
.card-back::after { content: ""; position: absolute; inset: 10%; border: 2px solid color-mix(in srgb, var(--card-back-ink) 55%, transparent); border-radius: 5px; }
.card-back.mini { width: 24px; height: 34px; border-radius: 4px; box-shadow: 0 2px 0 rgba(0,0,0,.4); } .card-back.mini::after { inset: 3px; border-radius: 2px; border-width: 1px; }
.card-back.landed-back { animation: land .36s var(--spring); }

/* ============================================================================
   FX
   ========================================================================== */
.fx-tag { position: fixed; z-index: 70; transform: translate(-50%, -100%); pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .04em; text-transform: uppercase; color: #fff; white-space: nowrap;
  padding: 4px 10px 5px; border-radius: 6px; background: var(--chip); box-shadow: 0 3px 0 rgba(0,0,0,.45);
  animation: tagPop 1.1s var(--ease-out) forwards; }
.fx-tag.below { transform: translate(-50%, 0); }
.fx-tag.mult { background: var(--mult); } .fx-tag.gold { background: var(--gold); color: #1a1408; } .fx-tag.green { background: var(--green); } .fx-tag.haya { background: var(--haya); }
.fx-tag.diamond { border-radius: 4px; transform: translate(-50%, 0) rotate(45deg); width: 30px; height: 30px; padding: 0; display: grid; place-items: center; }
@keyframes tagPop { 0% { opacity: 0; transform: translate(-50%, -80%) scale(.4) rotate(-6deg); } 18% { opacity: 1; transform: translate(-50%, -110%) scale(1.15) rotate(2deg); } 30% { transform: translate(-50%, -105%) scale(1); } 80% { opacity: 1; transform: translate(-50%, -140%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -170%) scale(.9); } }
.fx-tag.below { animation-name: tagPopBelow; }
@keyframes tagPopBelow { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.4); } 18% { opacity: 1; transform: translate(-50%, 10%) scale(1.15); } 30% { transform: translate(-50%, 5%) scale(1); } 80% { opacity: 1; transform: translate(-50%, 40%); } 100% { opacity: 0; transform: translate(-50%, 70%) scale(.9); } }
.fx-tag.still { animation: none; opacity: 1; }

.fx-slam { position: absolute; z-index: 40; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: clamp(44px, 9vw, 108px); line-height: 1; letter-spacing: .02em; color: #fff;
  text-shadow: 0 6px 0 rgba(0,0,0,.55), 0 0 30px rgba(0,0,0,.5); animation: slamIn .55s var(--spring) forwards; }
/* white letters, the team color as the hard shadow: the fire behind is already the color */
.fx-slam.mult { text-shadow: 0 6px 0 var(--mult), 0 0 30px rgba(0,0,0,.6); } .fx-slam.chip { text-shadow: 0 6px 0 var(--chip), 0 0 30px rgba(0,0,0,.6); } .fx-slam.gold { text-shadow: 0 6px 0 var(--gold), 0 0 30px rgba(0,0,0,.6); } .fx-slam.haya { text-shadow: 0 6px 0 var(--haya), 0 0 30px rgba(0,0,0,.6); } .fx-slam.green { text-shadow: 0 6px 0 var(--green), 0 0 30px rgba(0,0,0,.6); }
.fx-slam .word { display: flex !important; flex-direction: row; white-space: nowrap; }
.fx-slam .word span { display: inline-block; animation: jitter .12s steps(2) infinite; transform: translate(0, calc(var(--j) * 1px)) rotate(calc(var(--j) * .8deg)); }
.fx-slam small { font-family: var(--font-ui); font-size: .22em; letter-spacing: .3em; color: var(--text); text-shadow: 0 3px 0 rgba(0,0,0,.5); }
.fx-slam.out { animation: slamOut .35s var(--ease-out) forwards; }
.fx-slam.still .word span { animation: none; }
@keyframes slamIn { 0% { opacity: 0; transform: scale(3.2) rotate(-14deg); } 55% { opacity: 1; transform: scale(.94) rotate(3deg); } 100% { transform: scale(1) rotate(-2deg); } }
@keyframes slamOut { to { opacity: 0; transform: scale(.7) translateY(-30px); } }
@keyframes jitter { 0% { transform: translate(calc(var(--j) * 1px), calc(var(--j) * -1px)) rotate(calc(var(--j) * .8deg)); } 50% { transform: translate(calc(var(--j) * -1px), calc(var(--j) * 1px)) rotate(calc(var(--j) * -.6deg)); } 100% { transform: translate(calc(var(--j) * 1px), 0) rotate(calc(var(--j) * .8deg)); } }
html.reduce .fx-slam .word span { animation: none; }

.fire { position: absolute; left: -2%; width: 104%; bottom: 60%; height: 130%; image-rendering: pixelated; pointer-events: none; z-index: 0;
  -webkit-mask-image: linear-gradient(to top, transparent 0, transparent 30%, #000 55%); mask-image: linear-gradient(to top, transparent 0, transparent 30%, #000 55%); }
.burnable { position: relative; }
.burnable > :not(.fire) { position: relative; z-index: 1; }
.fire-host { position: absolute; left: -8%; right: -8%; top: -30%; bottom: -10%; pointer-events: none; z-index: 0; }
.fire-host .fire { position: absolute; inset: 0; width: 100%; height: 100%; -webkit-mask-image: linear-gradient(to top, transparent 0, transparent 18%, #000 45%), linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%); -webkit-mask-composite: source-in; mask-image: linear-gradient(to top, transparent 0, transparent 18%, #000 45%), linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%); mask-composite: intersect; }
#fx-table .fx-slam { z-index: 2; }

@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(calc(var(--shake,4px) * -1), calc(var(--shake,4px) * .6)); } 40% { transform: translate(var(--shake,4px), calc(var(--shake,4px) * -.5)); } 60% { transform: translate(calc(var(--shake,4px) * -.7), 0); } 80% { transform: translate(calc(var(--shake,4px) * .5), calc(var(--shake,4px) * .4)); } }
.shaking { animation: shake calc(.42s * var(--time-scale, 1)) var(--ease-out); }
.bumping { animation: bump calc(.3s * var(--time-scale, 1)) var(--spring); }
@keyframes bump { 0% { transform: scale(1); } 45% { transform: scale(1.3) rotate(-2deg); } 100% { transform: scale(1); } }

/* ============================================================================
   OVERLAYS
   ========================================================================== */
.overlay { position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-start; justify-content: center; overflow-y: auto; background: rgba(4,8,14,.62); backdrop-filter: blur(3px);
  padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.overlay.open { display: flex; }
.overlay > .frame { margin: auto; }   /* centered when it fits, scrollable when it does not */
.overlay .frame { animation: framePop .34s var(--spring); }
@keyframes framePop { 0% { transform: scale(.86) translateY(20px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* card info + rules: card on the left, plate on the right */
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.info-grid .big { --card-w: clamp(110px, 16vw, 150px); }
.info-title { font-size: 24px; margin-bottom: 8px; }
.info-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.info-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.badge { display: inline-block; font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 7px 4px; border-radius: 5px; color: #fff; background: var(--chip); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.badge.mult { background: var(--mult); } .badge.gold { background: var(--gold); color: #1a1408; } .badge.haya { background: var(--haya); } .badge.green { background: var(--green); }
.combo { display: inline-flex; gap: 4px; align-items: center; }
.combo .mini-card { font-family: var(--font-num); font-weight: 700; font-size: 13px; padding: 2px 6px; border-radius: 4px; background: var(--card-face); color: var(--card-ink); box-shadow: 0 2px 0 rgba(0,0,0,.3); }
.combo .mini-card.red { color: var(--card-red); }

/* ceremony */
#ov-ceremony .frame { width: min(100%, 720px); }
.cer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.cer-teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.cer-team { text-align: center; font-family: var(--font-display); font-size: 14px; letter-spacing: .1em; text-transform: uppercase; padding: 6px; border-radius: 6px; color: #fff; }
.cer-team.t1 { background: var(--team1); } .cer-team.t2 { background: var(--team2); }
/* the names sit above the tally's flames, and the flames stay short, so a burning
   first line never hides who won it */
.cer-teams { position: relative; z-index: 3; }
.cer-lines .fire { height: 85%; bottom: 70%; }
.cer-lines { display: flex; flex-direction: column; gap: 8px; }
.cer-line { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; opacity: .35; transition: opacity .25s; }
.cer-line.on { opacity: 1; }
.cer-line .fill { font-size: 20px; text-align: center; }
.cer-line .term small { font-size: 10px; }
.cer-box { position: relative; font-family: var(--font-num); font-weight: 700; font-size: 28px; line-height: 1; text-align: center; padding: 10px 12px 11px; border-radius: var(--radius-sm); color: #fff; box-shadow: 0 var(--drop) 0 var(--drop-color); background: var(--panel-hi); transition: background .3s; }
.cer-box.t1.win { background: var(--team1); } .cer-box.t2.win { background: var(--team2); }
.cer-box .pt { position: absolute; top: -10px; right: -8px; font-size: 13px; padding: 2px 7px; border-radius: 5px; background: var(--gold); color: #1a1408; box-shadow: 0 2px 0 rgba(0,0,0,.4); opacity: 0; transform: scale(.5); transition: opacity .2s, transform .25s var(--spring); }
.cer-box.win .pt { opacity: 1; transform: scale(1); }
.cer-total { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 2px solid var(--panel-rim); }
.cer-total .cer-box { font-size: 40px; padding: 14px; }
.cer-total .x { font-family: var(--font-display); font-size: 22px; color: var(--text-dim); text-align: center; }
.cer-skip { text-align: center; margin-top: 12px; font-size: 12px; color: var(--text-mut); letter-spacing: .12em; text-transform: uppercase; }

/* match end */
#ov-match .frame { text-align: center; width: min(100%, 560px); }
#ov-match.lost .frame__title { color: var(--text-dim); }
#ov-match.lost .match-sub { color: var(--text); }
.match-score { font-family: var(--font-num); font-size: clamp(44px, 10vw, 84px); line-height: 1; font-weight: 700; margin: 14px 0; text-shadow: 0 6px 0 rgba(0,0,0,.45); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 14px; background: var(--gold); animation: confetti 2.6s linear forwards; }
@keyframes confetti { to { transform: translateY(110vh) rotate(720deg); } }

/* in-game side menu */
.overlay.side { justify-content: flex-end; padding: 0; }
.overlay.side .frame { height: 100%; width: min(100%, 360px); border-radius: 0; animation: slideIn .3s var(--ease-out); overflow-y: auto; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs button { flex: 1; padding: 8px; border-radius: 6px; font-family: var(--font-display); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); background: rgba(0,0,0,.25); }
.tabs button.on { background: var(--gold); color: #1a1408; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.dt { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dt span { text-align: center; font-family: var(--font-num); font-size: 12px; padding: 6px 0; border-radius: 5px; background: rgba(0,0,0,.25); color: var(--text-mut); }
.dt span.t1 { background: var(--team1); color: #fff; } .dt span.t2 { background: var(--team2); color: #fff; }

/* toast */
#toast { position: fixed; left: 50%; top: calc(18px + env(safe-area-inset-top)); max-width: calc(100% - 24px); text-align: center; transform: translateX(-50%); z-index: 80; font-family: var(--font-display); font-size: 14px; letter-spacing: .06em; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--panel); box-shadow: inset 0 0 0 2px var(--panel-rim), 0 var(--drop) 0 var(--drop-color); opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--spring); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  #game-view[data-hud="rail"] { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #game-view[data-hud="rail"] #hud { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: none; }
  #game-view[data-hud="rail"] .hud-box { flex-direction: row; align-items: baseline; gap: 8px; } #game-view[data-hud="rail"] .hud-box .val { font-size: 18px; }
  #game-view[data-hud="rail"] .hud-scores { display: flex; } #game-view[data-hud="rail"] .hud-team { display: flex; align-items: baseline; gap: 6px; padding: 5px 10px; } #game-view[data-hud="rail"] .hud-team .val { font-size: 18px; }
  #game-view[data-hud="rail"] .hud-gear { margin: 0 0 0 auto; width: 40px; }
  #game-view[data-hud="rail"] .hud-wordmark { font-size: 24px; }
  .hud-turn { order: 5; width: 100%; padding: 2px; }
}
@media (max-width: 640px) {
  :root { --card-w: clamp(52px, 15vw, 74px); }
  #play-area { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; gap: 6px; }
  #opponent-left, #opponent-right { justify-content: center; }
  .opp.side { flex-direction: row; padding: 6px 10px; }
  /* phone: the deck sits beside the table cards instead of above them, so it can
     neither run into the opponent panel nor put its count under a lifted card */
  #table-area { flex-direction: row; align-items: center; gap: 14px; min-height: 0; padding: 4px 0 18px; }
  .table-center { min-width: 0; flex: 1; }
  .deck-pile { --card-w: 40px; margin-left: 6px; }
  .deck-count { font-size: 11px; bottom: -19px; }
  #table-area .card-row { gap: 6px; }
  /* no dead band between the table and the hand: the free height is shared out */
  #game-board { grid-template-rows: auto auto auto; align-content: space-evenly; padding-top: 2px; }
  #play-area { align-content: center; }
  /* name and captured pile share a line, with room above the hand for a lifted card */
  #hand-area { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 14px; row-gap: 6px; }
  #hand-area > #hand-cards, #hand-area > #hand-actions, #hand-area > #emote-bar, #hand-area > #possess-banner { flex-basis: 100%; }
  #hand-cards { padding-top: 16px; }
  .info-grid { grid-template-columns: 1fr; justify-items: center; }
  .cer-line .fill { font-size: 15px; }
  .cer-box { font-size: 22px; }
  .slots { grid-template-columns: 1fr; }
  #hand-actions .pill { min-width: 0; flex: 1; }
  #hand-actions { width: 100%; }
}

/* ============================================================================
   REAL-GAME ADDITIONS (menu name field, waiting room controls, side menu tabs,
   settings groups, move log, guest notes)
   ========================================================================== */
.menu-stack .input { text-align: center; }
.menu-foot a { color: inherit; }

.slot .btns { margin-left: auto; display: flex; gap: 6px; }
.slot .btns .pill { padding: 6px 9px 7px; font-size: 12px; }
.slot .who .bot { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin-right: 6px; }
.waiting-note { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 12px; letter-spacing: .06em; }
.frame__title .pill { margin-left: auto; }

/* side menu */
.tabs button { min-width: 0; }
.setting-group { margin-top: 16px; }
.setting-group:first-child { margin-top: 0; }
.setting-group .gtitle { font-family: var(--font-display); text-transform: var(--ui-case); letter-spacing: var(--ui-tracking); font-size: 12px; color: var(--gold); margin-bottom: 2px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.setting-group .gtitle small { font-family: var(--font-ui); font-size: 11px; color: var(--text-mut); letter-spacing: .04em; text-transform: none; }
.seg[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.seg.wrap { flex-wrap: wrap; }
.row.compact { padding: 8px 0; }
.row.compact .seg button { padding: 6px 9px; font-size: 12px; }
.move-log { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto; }
.move-log .entry { display: flex; gap: 8px; font-size: 13px; padding: 5px 6px; border-radius: 5px; }
.move-log .entry:nth-child(odd) { background: rgba(0,0,0,.18); }
.move-log .entry .t { font-family: var(--font-num); color: var(--text-mut); flex: none; font-size: 12px; }
.empty-note { color: var(--text-mut); font-size: 13px; padding: 10px 0; text-align: center; }

/* ceremony as a guest */
.cer-skip.waiting { color: var(--text-dim); }

/* match end subtitle (instant win, surrender) */
.match-sub { font-family: var(--font-ui); font-size: 14px; color: var(--text-dim); margin-top: -6px; margin-bottom: 8px; letter-spacing: .06em; }

/* emotes */
#emote-bar { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
#emote-bar .pill { padding: 0 12px; min-height: 44px; font-size: 12px; }
#emote-display { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 45; font-family: var(--font-display); font-size: 16px; letter-spacing: .04em; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--plate); color: var(--plate-ink); box-shadow: 0 var(--drop) 0 var(--drop-color); animation: framePop .3s var(--spring); }

/* a player whose connection dropped */
.opp.away { opacity: .7; }
.opp .name .badge { font-size: 9px; padding: 2px 5px 3px; vertical-align: middle; }

/* opponent's turn label inside the card */
.opp .turnfill { font-size: 11px; letter-spacing: .1em; }

@media (max-width: 640px) {
  #emote-bar .pill { padding: 0 9px; font-size: 11px; }
  .overlay.side .frame { width: 100%; }
}

/* a blocked move: the table card the rules require you to take */
.card.must-take .card__inner { box-shadow: var(--card-shadow), 0 0 0 4px var(--green), 0 0 22px var(--green); }
.card.must-take { animation: mustTake .6s ease-in-out 3; }
@keyframes mustTake { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* capture assist: cards that can take something right now */
.card.can-capture .card__inner { box-shadow: var(--card-shadow), 0 0 0 2px var(--green); }
.pill.mult { background: var(--mult); }

/* saved bot game offer on the menu */
.resume-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel); box-shadow: inset 0 0 0 2px var(--gold), 0 var(--drop) 0 var(--drop-color); font-size: 14px; text-align: center; }
.resume-box[hidden] { display: none; }
.resume-actions { display: flex; gap: 8px; }
.resume-actions .pill { flex: 1; }

/* a player dropped out of an online game */
.away-banner { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 46; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 8px 10px; width: max-content; max-width: calc(100% - 24px); padding: 8px 12px; border-radius: var(--radius-sm); background: var(--panel); box-shadow: inset 0 0 0 2px var(--mult), 0 var(--drop) 0 var(--drop-color); font-size: 13px; }
.away-banner[hidden] { display: none; }
.away-actions { display: flex; gap: 8px; }
.away-banner .pill { flex: none; }

/* this browser lost its connection: the room keeps the seat while it reconnects */
.net-banner { position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 85; padding: 6px 14px; border-radius: 999px; background: var(--mult); color: #fff; font-family: var(--font-display); font-size: 13px; letter-spacing: .06em; box-shadow: 0 3px 0 rgba(0,0,0,.4); animation: netPulse 1.2s ease-in-out infinite alternate; }
.net-banner[hidden] { display: none; }
@keyframes netPulse { from { opacity: 1; } to { opacity: .65; } }

/* a button waiting on the server: dimmed, with a small spinner, never stuck (it comes
   back on the answer, an error or a timeout) */
.pill.pending { opacity: .7; cursor: progress; }
.pill.pending::after { content: ""; width: .8em; height: .8em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; }
#hand-actions .pill.pending::after { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.left-text { color: var(--text-dim); font-size: 14px; line-height: 1.5; }

/* ============================================================================
   PHONES
   Portrait: one compact HUD row, the opponents of a 4-player game side by side
   above the table (never on top of it), the hand and its buttons below.
   Landscape (a short screen): one HUD row, smaller cards, and the action buttons
   beside the hand so nothing stacks past the bottom edge.
   ========================================================================== */
.overlay.side > .frame { margin: 0 0 0 auto; padding-top: max(22px, env(safe-area-inset-top)); padding-bottom: max(22px, env(safe-area-inset-bottom)); }
.gm-emotes { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-emotes .pill { flex: 1; min-height: 44px; }
.hud-team .lbl { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  #game-view #hud { gap: 6px; padding: 6px 10px 2px; }
  #game-view .hud-deck { display: none; }          /* the deck pile on the table shows the count */
  #game-view .hud-box { padding: 6px 9px; }
  #game-view .hud-team { padding: 6px 9px; }
  #game-view .hud-team .lbl { max-width: 6.5em; }
  .hud-turn { padding: 0 2px 2px; }
  .hud-turn .fill.lg { font-size: 20px; }

  /* the board as one grid: [left | top | right] / table / hand. #play-area steps
     aside so a 4-player game seats its three opponents in one row */
  #game-board { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "left top right" "table table table" "hand hand hand"; column-gap: 6px; align-content: stretch; padding: 4px 8px 8px; }
  #play-area { display: contents; }
  #opponents-top { grid-area: top; padding: 2px 0; }
  #opponent-left { grid-area: left; justify-content: flex-end; }
  #opponent-right { grid-area: right; justify-content: flex-start; }
  #table-area { grid-area: table; align-self: center; }
  #hand-area { grid-area: hand; }
  #game-view[data-players="4"] .opp { flex-direction: column; gap: 3px; padding: 6px 7px; text-align: center; min-width: 0; }
  #game-view[data-players="4"] .opp .av { width: 26px; height: 26px; font-size: 10px; }
  #game-view[data-players="4"] .opp .meta { align-items: center; }
  #game-view[data-players="4"] .opp .name { font-size: 12px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #game-view[data-players="4"] .opp .cap { font-size: 10px; }
  .opp .backs .card-back.mini { width: 20px; height: 28px; }

  #hand-actions { min-height: 48px; }
  #emote-bar { gap: 5px; }
}
@media (max-width: 420px) {
  #game-view .hud-wordmark { display: none; }
  #game-view .hud-team .shk { display: none; }   /* the chkobba count is on the player panels too */
}

@media (max-height: 500px) and (orientation: landscape) {
  :root { --card-w: clamp(46px, 7.4vw, 60px); --lift: calc(-8px * var(--juice-k)); }

  /* menu: the wordmark on the left, the buttons on the right */
  #screen-menu { display: none; }
  #screen-menu.active { display: grid; grid-template-columns: 1fr minmax(260px, 340px); grid-template-areas: "hero stack" "word stack" "foot stack";
    align-content: center; justify-content: center; column-gap: 40px; row-gap: 10px; }
  #screen-menu > :first-child, #screen-menu > :last-child { margin: 0; }
  .hero-cards { grid-area: hero; justify-self: center; }
  .hero-cards .card { --card-w: 52px; }
  .wordmark { grid-area: word; }
  .wordmark .ar { font-size: 64px; }
  .wordmark .la { font-size: 22px; }
  .menu-stack { grid-area: stack; align-self: center; width: 100%; gap: 8px; }
  .menu-stack .pill.big { font-size: 16px; padding: 12px 16px; min-height: 44px; }
  .menu-stack .input { padding: 9px 12px; font-size: 16px; }
  .menu-foot { grid-area: foot; text-align: center; }

  /* frames: tighter so the lobby and the tallies fit a short screen */
  .frame { padding: 14px 16px; }
  .frame__title { font-size: 18px; margin-bottom: 8px; }
  .code { font-size: 28px; }
  #screen-waiting .plate { margin: 8px 0 !important; padding: 6px 12px; }
  .slots { gap: 6px; }
  .waiting-note { margin-top: 6px; }
  .slot { min-height: 46px; padding: 6px 10px; }
  .actions { margin-top: 10px; }
  .cer-head { margin-bottom: 6px; }
  .cer-teams { margin-bottom: 4px; }
  .cer-team { padding: 3px; font-size: 12px; }
  .cer-lines { gap: 4px; }
  .cer-line .fill { font-size: 15px; }
  .cer-box { font-size: 18px; padding: 5px 10px 6px; }
  .cer-total { margin-top: 8px; padding-top: 8px; }
  .cer-total .cer-box { font-size: 26px; padding: 7px; }
  .cer-skip { margin-top: 6px; }
  .match-score { font-size: 44px; margin: 8px 0; }

  /* game: one HUD row with the turn in it */
  #game-view #hud { flex-wrap: nowrap; gap: 6px; padding: 4px 10px; }
  #game-view .hud-wordmark { display: none; }
  #game-view .hud-box, #game-view .hud-team { padding: 5px 9px; }
  .hud-turn { order: 0; width: auto; flex: 1; min-width: 0; padding: 0; overflow: hidden; white-space: nowrap; }
  .hud-turn .fill.lg { font-size: 18px; }
  .hud-spacer { display: none; }
  #game-board { grid-template-rows: auto minmax(0, 1fr) auto; padding: 0 10px 4px; }
  #opponents-top { padding: 0; }
  .opp { padding: 4px 10px; gap: 8px; }
  .opp .av { width: 26px; height: 26px; font-size: 10px; }
  .opp:not(.side) .meta { flex-direction: row; align-items: center; gap: 10px; }
  .opp.side { padding: 6px; gap: 4px; }
  .opp.side .meta { align-items: center; }
  .opp .backs .card-back.mini { width: 18px; height: 26px; }
  #table-area { min-height: 0; padding: 2px 0 16px; gap: 14px; }
  .deck-pile { --card-w: 38px; }
  .deck-count { font-size: 11px; bottom: -17px; }
  .table-center { gap: 2px; }
  #table-area .card-row { gap: 6px; }
  #table-msg { font-size: 12px; }

  /* the hand in the middle, who-I-am on the left, the buttons on the right */
  #hand-area { display: grid; grid-template-columns: minmax(0, .6fr) auto minmax(0, 1.4fr); grid-template-areas: "label hand actions" "cap hand actions";
    align-items: center; column-gap: 14px; row-gap: 2px; padding-top: 0; }
  #player-label { grid-area: label; justify-self: end; align-self: end; }
  #my-captured { grid-area: cap; justify-self: end; align-self: start; }
  #hand-cards { grid-area: hand; padding-top: 10px; }
  #hand-actions { grid-area: actions; justify-self: start; min-height: 48px; width: auto; }
  #hand-actions .pill { min-width: 0; flex: none; padding: 0 16px; font-size: 15px; }
  #emote-bar { display: none; }   /* emotes are in the game menu on a short screen */
  #emote-display { top: 52px; }
}
