/* ============================================================
   MONOLITO · Truco Argentino
   Midnight holotable — deep blue gradients, flowing gold waves
   ============================================================ */

:root {
  --abyss: #040a1c;
  --navy: #0a1a3a;
  --royal: #12306e;
  --azure: #1d5cd6;
  --ice: #9cc4ff;
  --gold-deep: #8a6410;
  --gold: #d4a02a;
  --gold-bright: #f2c94c;
  --cream: #f5ead1;
  --danger: #e05252;

  --font-display: "Cinzel", serif;
  --font-hud: "Rajdhani", sans-serif;

  --card-w: clamp(78px, 9.5vw, 118px);
  --card-h: calc(var(--card-w) * 1.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

/* The table (150vw) and the gold waves (200%) deliberately bleed past the
   viewport edges. On mobile the document element is the scroller, so clipping
   must live on <html> — body overflow alone lets iOS pan the table sideways. */
html {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-hud);
  color: var(--cream);
  background:
    radial-gradient(120% 90% at 50% -10%, var(--royal) 0%, var(--navy) 45%, var(--abyss) 100%);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ---------- flowing gold waves ---------- */

.ocean {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.wave {
  position: absolute;
  left: -50%;
  width: 200%;
  height: 38vh;
  filter: blur(2px);
}

.wave-1 { top: 8vh;  animation: drift 26s linear infinite; opacity: .5; }
.wave-2 { top: 34vh; animation: drift 38s linear infinite reverse; opacity: .35; height: 46vh; }
.wave-3 { top: 62vh; animation: drift 50s linear infinite; opacity: .45; height: 42vh; }

@keyframes drift {
  from { transform: translateX(0) }
  to   { transform: translateX(25%) }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .05;
  background-image: 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='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ---------- splash ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    radial-gradient(80% 70% at 50% 35%, rgba(18, 48, 110, .55) 0%, rgba(4, 10, 28, .92) 75%);
  transition: opacity .7s ease, visibility .7s;
}

.splash.gone { opacity: 0; visibility: hidden; }

.splash-inner {
  text-align: center;
  animation: rise 1.1s cubic-bezier(.2, .9, .25, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: none; }
}

.splash-coin {
  width: 92px;
  height: 92px;
  margin: 0 auto 26px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, var(--gold-bright) 0%, var(--gold) 45%, var(--gold-deep) 100%);
  box-shadow:
    0 0 40px rgba(242, 201, 76, .45),
    0 0 120px rgba(212, 160, 42, .25),
    inset 0 0 0 6px rgba(4, 10, 28, .35),
    inset 0 0 0 9px rgba(242, 201, 76, .8);
  animation: coinspin 6s ease-in-out infinite;
}

@keyframes coinspin {
  0%, 100% { transform: rotateY(0deg); }
  50%      { transform: rotateY(180deg); }
}

.splash-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.6rem, 7vw, 5rem);
  letter-spacing: .14em;
  background: linear-gradient(115deg, var(--cream) 20%, var(--gold-bright) 42%, var(--gold) 55%, var(--cream) 80%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 5s linear infinite;
}

@keyframes shimmer {
  from { background-position: 0% 0; }
  to   { background-position: 220% 0; }
}

.splash-sub {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: .6em;
  text-indent: .6em;
  color: var(--ice);
  margin-top: 6px;
  font-size: clamp(.8rem, 2vw, 1.1rem);
}

.splash-tag {
  margin: 22px 0 34px;
  color: rgba(245, 234, 209, .55);
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .85rem;
}

.splash-stats {
  margin: -18px 0 26px;
  color: rgba(156, 196, 255, .7);
  font-family: var(--font-hud);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: .74rem;
}

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .18em;
  font-size: .95rem;
  padding: 13px 34px;
  margin: 0 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  user-select: none;
}

.btn:active { transform: scale(.96); }

.btn-gold {
  border: 1px solid var(--gold-bright);
  color: var(--abyss);
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 0 24px rgba(242, 201, 76, .35), inset 0 1px 0 rgba(255, 255, 255, .45);
}

.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 44px rgba(242, 201, 76, .55), inset 0 1px 0 rgba(255, 255, 255, .45);
}

.btn-ghost {
  border: 1px solid rgba(156, 196, 255, .45);
  color: var(--ice);
  background: rgba(18, 48, 110, .25);
  backdrop-filter: blur(6px);
}

.btn-ghost:hover {
  border-color: var(--ice);
  box-shadow: 0 0 24px rgba(156, 196, 255, .25);
  transform: translateY(-2px);
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(4, 10, 28, .82);
  backdrop-filter: blur(10px);
}

/* The panel is capped at 86vh, so anything taller has to scroll inside it —
   without this the 2v2 lobby (code + link + four seats + four buttons) spills
   past the bottom of a phone screen and CANCEL becomes unreachable. */
.overlay-panel {
  width: min(640px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 34px 38px max(34px, env(safe-area-inset-bottom));
  border-radius: 18px;
  border: 1px solid rgba(212, 160, 42, .5);
  background: linear-gradient(170deg, rgba(18, 48, 110, .65), rgba(10, 26, 58, .9));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(245, 234, 209, .12);
}

/* scroll the panel rather than squashing its contents… */
.overlay-panel > * { flex: 0 0 auto; }

.overlay-panel h2 {
  font-family: var(--font-display);
  letter-spacing: .2em;
  color: var(--gold-bright);
  text-align: center;
}

/* …except the rules body, which owns its own scrollbar and should take
   whatever height is left over. */
.rules-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 10px;
  line-height: 1.65;
  font-size: 1.02rem;
  color: rgba(245, 234, 209, .9);
}

.rules-scroll h3 {
  font-family: var(--font-display);
  color: var(--gold);
  letter-spacing: .1em;
  margin: 18px 0 6px;
  font-size: 1.05rem;
}

.rules-scroll p { margin: 6px 0; }
.rules-scroll strong { color: var(--gold-bright); }
.rules-scroll em { color: var(--ice); font-style: normal; }

/* card power ladder — one face per tier, strongest first */
.card-ladder {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 12px 10px;
  margin: 12px 0 14px;
}

.ladder-card {
  position: relative;
  margin: 0;
  text-align: center;
}

.ladder-card svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.ladder-rank {
  position: absolute;
  top: -6px;
  left: -6px;
  z-index: 1;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 9px;
  border: 1px solid rgba(212, 160, 42, .6);
  background: rgba(4, 10, 28, .92);
  color: var(--gold-bright);
  font-family: var(--font-hud);
  font-size: .6rem;
  line-height: 1.4;
}

.ladder-card figcaption {
  margin-top: 5px;
  font-size: .66rem;
  letter-spacing: .04em;
  line-height: 1.3;
  color: rgba(245, 234, 209, .75);
}

.overlay-panel .btn { align-self: center; }

.lang-toggle {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 55;
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .12em;
  font-size: .72rem;
  width: 44px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(212, 160, 42, .45);
  color: var(--gold-bright);
  background: rgba(10, 26, 58, .6);
  backdrop-filter: blur(6px);
  transition: all .18s ease;
}
.lang-toggle:hover { border-color: var(--gold-bright); box-shadow: 0 0 16px rgba(242, 201, 76, .3); }

.settings-toggle {
  left: auto;
  right: calc(14px + env(safe-area-inset-right));
  font-size: 1rem;
}

/* ---------- settings ---------- */

.settings-panel { max-width: 460px; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.settings-label {
  font-weight: 700;
  letter-spacing: .22em;
  font-size: .78rem;
  color: var(--ice);
}

.settings-panel .settings-btn {
  align-self: auto;
  margin: 0;
  padding: 9px 22px;
  font-size: .8rem;
  min-width: 118px;
}

.settings-note {
  font-size: .8rem;
  line-height: 1.55;
  color: rgba(245, 234, 209, .6);
  border-top: 1px solid rgba(212, 160, 42, .25);
  padding-top: 14px;
}

.settings-version {
  text-align: center;
  font-size: .7rem;
  letter-spacing: .18em;
  color: rgba(156, 196, 255, .5);
}

.flor-toggle {
  align-self: center;
  letter-spacing: .14em;
  font-size: .72rem;
  padding: 6px 16px;
  opacity: .75;
}
.flor-toggle.flor-on {
  opacity: 1;
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(242, 201, 76, .25);
}

.solo-hint {
  text-align: center;
  font-size: .82rem;
  color: rgba(245, 234, 209, .55);
  margin: -6px 0 2px;
}

/* pass-the-device gate: a full, opaque cover so the next player can't peek
   at the outgoing hand behind it */
.passgate {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(18, 48, 110, .55), transparent 60%),
    #040a1c;
}

.passgate-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}

.passgate-title {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: .14em;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(242, 201, 76, .35);
}

.passgate-sub {
  color: rgba(245, 234, 209, .7);
  max-width: 28ch;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- online lobby ---------- */

.btn-online {
  border: 1px solid var(--azure);
  color: var(--ice);
  background: linear-gradient(160deg, rgba(29, 92, 214, .55), rgba(18, 48, 110, .55));
  box-shadow: 0 0 24px rgba(29, 92, 214, .35), inset 0 1px 0 rgba(156, 196, 255, .25);
}

.btn-online:hover {
  transform: translateY(-2px);
  border-color: var(--ice);
  box-shadow: 0 0 44px rgba(29, 92, 214, .55), inset 0 1px 0 rgba(156, 196, 255, .35);
}

.online-panel { align-items: center; text-align: center; }

.online-status {
  font-family: var(--font-hud);
  font-size: 1.05rem;
  letter-spacing: .08em;
  color: rgba(245, 234, 209, .88);
}

/* table code — the primary share artifact */
.online-codebox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.online-codelabel {
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .24em;
  font-size: .72rem;
  color: var(--ice);
}

.online-coderow {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: min(360px, 100%);
}

.online-code {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(242, 201, 76, .6);
  background: rgba(4, 10, 28, .72);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: .35em;
  text-indent: .35em;
  text-transform: uppercase;
  text-align: center;
  box-shadow: inset 0 0 22px rgba(242, 201, 76, .12);
  user-select: all;
}

.online-copycode { margin: 0; align-self: stretch; display: flex; align-items: center; }

.online-codehint {
  color: rgba(245, 234, 209, .7);
  font-size: .82rem;
  line-height: 1.45;
  max-width: 360px;
}

.online-codeinput {
  text-transform: uppercase;
  letter-spacing: .2em;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
}

.online-linkbox {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.online-link {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(212, 160, 42, .55);
  background: rgba(4, 10, 28, .7);
  color: var(--gold-bright);
  font-family: var(--font-hud);
  font-size: .92rem;
  letter-spacing: .03em;
  text-align: center;
  outline: none;
  box-shadow: inset 0 0 18px rgba(242, 201, 76, .08);
}

.online-linkbtns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.online-linkbtns .btn { margin: 0; }

/* name entry + mode choice */

.online-namebox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.online-namelabel {
  font-weight: 700;
  letter-spacing: .22em;
  font-size: .72rem;
  color: var(--ice);
}

.online-name {
  width: min(300px, 100%);
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(156, 196, 255, .45);
  background: rgba(4, 10, 28, .7);
  color: var(--cream);
  font-family: var(--font-hud);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: .08em;
  text-align: center;
  outline: none;
}

.online-name:focus { border-color: var(--gold-bright); box-shadow: 0 0 18px rgba(242, 201, 76, .25); }

/* the paste-a-link input holds a full URL — smaller, denser type */
#join-link { font-size: .82rem; letter-spacing: .02em; }

.online-modes {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.online-modes .btn { margin: 0; min-width: 150px; }

/* 2v2 lobby roster */

.lobby-roster {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.lobby-seat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid rgba(156, 196, 255, .25);
  background: rgba(4, 10, 28, .55);
  text-align: left;
}

.lobby-seat.filled { border-color: rgba(212, 160, 42, .55); }

.lobby-team {
  font-weight: 700;
  font-size: .66rem;
  letter-spacing: .14em;
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}

.lobby-team.team-0 { color: var(--gold-bright); border: 1px solid rgba(242, 201, 76, .55); }
.lobby-team.team-1 { color: var(--ice); border: 1px solid rgba(156, 196, 255, .55); }

.lobby-name {
  flex: 1;
  font-weight: 600;
  letter-spacing: .06em;
  font-size: .98rem;
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-name .lobby-tag { color: rgba(245, 234, 209, .5); font-size: .8rem; letter-spacing: .12em; }
.lobby-seat.empty .lobby-name { color: rgba(245, 234, 209, .4); font-style: italic; }

.lobby-btn {
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .12em;
  font-size: .68rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(156, 196, 255, .4);
  color: var(--ice);
  background: rgba(18, 48, 110, .35);
  transition: all .18s ease;
  flex-shrink: 0;
}

.lobby-btn:hover { border-color: var(--ice); box-shadow: 0 0 14px rgba(156, 196, 255, .25); }

.lobby-btn.lobby-btn-remove {
  border-color: rgba(224, 82, 82, .45);
  color: #f0a0a0;
}

.lobby-btn.lobby-btn-remove:hover { border-color: rgba(224, 82, 82, .8); box-shadow: 0 0 14px rgba(224, 82, 82, .25); }

.lobby-btn.lobby-btn-swap {
  border-color: rgba(212, 160, 42, .5);
  color: var(--gold-bright);
  background: rgba(60, 44, 10, .35);
}
.lobby-btn.lobby-btn-swap:hover { border-color: var(--gold-bright); box-shadow: 0 0 14px rgba(242, 201, 76, .3); }

.lobby-seat.swap-pick {
  border-color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(242, 201, 76, .35);
}

/* ---------- stage layout ---------- */

.stage {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* HUD */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px 6px;
  gap: 18px;
}

.hud-score {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  column-gap: 12px;
  min-width: 180px;
}

.hud-label {
  font-weight: 700;
  letter-spacing: .22em;
  font-size: .78rem;
  color: var(--ice);
}

.hud-points {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(242, 201, 76, .4);
}

.hud-track {
  grid-column: 1 / -1;
  position: relative;
  height: 5px;
  border-radius: 99px;
  background: rgba(156, 196, 255, .15);
  overflow: hidden;
}

.hud-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--azure), var(--gold-bright));
  box-shadow: 0 0 12px rgba(242, 201, 76, .5);
  transition: width .6s cubic-bezier(.2, .9, .3, 1);
}

.hud-mid {
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: rgba(245, 234, 209, .5);
}

.hud-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  align-self: flex-start;
}

.hud-actions-sub {
  display: flex;
  gap: 6px;
}

.hud-code {
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .14em;
  font-size: .62rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(212, 160, 42, .4);
  color: rgba(242, 201, 76, .85);
  background: rgba(10, 26, 58, .5);
  backdrop-filter: blur(6px);
  white-space: nowrap;
  transition: all .18s ease;
}

.hud-code:hover {
  border-color: rgba(242, 201, 76, .7);
  box-shadow: 0 0 16px rgba(212, 160, 42, .3);
}

.exit-btn {
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .16em;
  font-size: .72rem;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(156, 196, 255, .35);
  color: rgba(156, 196, 255, .75);
  background: rgba(10, 26, 58, .5);
  backdrop-filter: blur(6px);
  transition: all .18s ease;
}

.exit-btn:hover {
  border-color: rgba(224, 82, 82, .65);
  color: #f0a0a0;
  box-shadow: 0 0 18px rgba(224, 82, 82, .25);
}

.hud-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .3em;
  font-size: .95rem;
  color: rgba(245, 234, 209, .85);
}

.hud-stake {
  font-weight: 600;
  letter-spacing: .2em;
  font-size: .72rem;
  color: var(--gold);
}

/* ---------- 3D scene ---------- */

.scene {
  position: relative;
  flex: 1;
  perspective: 1300px;
  perspective-origin: 50% 30%;
}

.table-tilt {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(94vw, 1080px);
  height: min(66vh, 560px);
  transform: translate(-50%, -50%) rotateX(48deg);
  transform-style: preserve-3d;
}

.table-surface {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(75% 75% at 50% 42%, #16407e 0%, var(--royal) 38%, var(--navy) 72%, #071224 100%);
  box-shadow:
    0 0 0 3px rgba(212, 160, 42, .65),
    0 0 0 7px rgba(138, 100, 16, .35),
    0 60px 120px rgba(0, 0, 0, .65),
    inset 0 0 90px rgba(4, 10, 28, .8);
}

.table-rim {
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  border: 1px solid rgba(242, 201, 76, .25);
  pointer-events: none;
}

.table-emblem {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(242, 201, 76, .22);
  background:
    radial-gradient(circle at 50% 50%, rgba(242, 201, 76, .07) 0%, transparent 65%);
  pointer-events: none;
}

/* ---------- hands ---------- */

.hand {
  position: absolute;
  left: 50%;
  display: flex;
  gap: clamp(8px, 1.4vw, 18px);
  transform: translateX(-50%);
  z-index: 6;
}

.hand-you { bottom: 1.5vh; }
.hand-ai  { top: 1vh; }

/* ---------- cards ---------- */

.card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.1);
  border-radius: calc(var(--card-w) * .09);
  flex-shrink: 0;
}

.card.dealt-in { animation: dealin .55s cubic-bezier(.2, .9, .3, 1) both; }

@keyframes dealin {
  from { opacity: 0; transform: translateY(60px) rotateY(180deg) scale(.7); }
  to   { opacity: 1; transform: none; }
}

.card .face,
.card .back {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
}

.card .face svg,
.card .back svg {
  display: block;
  width: 100%;
  height: 100%;
}

.card .back { transform: rotateY(180deg); }

.card.facedown { transform: rotateY(180deg); }

.card.playable { cursor: pointer; }

/* A playable card is a button, so keyboard focus has to be visible on it.
   :focus-visible keeps the ring away from taps and mouse clicks. */
.card.playable:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
  border-radius: 8px;
}

@media (hover: hover) {
  .card.playable:hover {
    transform: translateY(-22px) rotateX(8deg) scale(1.06);
    z-index: 9;
  }

  .card.playable:hover .face {
    box-shadow:
      0 24px 44px rgba(0, 0, 0, .6),
      0 0 30px rgba(242, 201, 76, .45);
  }
}

.card.playable:active {
  transform: translateY(-10px) scale(1.04);
  z-index: 9;
}

.card.disabled { filter: grayscale(.4) brightness(.75); }

/* played cards on table */

.battle {
  position: absolute;
  left: 50%;
  top: 47%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.6vh, 16px);
  z-index: 5;
}

.battle-row {
  display: flex;
  gap: clamp(10px, 2vw, 26px);
  min-height: calc(var(--card-h) * .78);
  align-items: center;
}

.battle-row .card {
  width: calc(var(--card-w) * .78);
  height: calc(var(--card-h) * .78);
}

.battle-row .card.thrown { animation: throw .5s cubic-bezier(.2, .9, .3, 1.1) both; }

@keyframes throw {
  from { opacity: 0; transform: translateY(-40px) rotateZ(-8deg) scale(1.2); }
  to   { opacity: 1; transform: none; }
}

.battle-row-you .card.thrown { animation-name: throwup; }

@keyframes throwup {
  from { opacity: 0; transform: translateY(40px) rotateZ(6deg) scale(1.2); }
  to   { opacity: 1; transform: none; }
}

.card.trick-win .face { box-shadow: 0 0 34px rgba(242, 201, 76, .8), 0 10px 26px rgba(0,0,0,.5); }
.card.trick-lose { filter: brightness(.55) saturate(.6); }

/* trick pips */

.trick-pips {
  display: flex;
  gap: 14px;
}

.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(245, 234, 209, .4);
  background: transparent;
  transition: all .3s;
}

.pip.you { background: var(--gold-bright); border-color: var(--gold-bright); box-shadow: 0 0 12px rgba(242, 201, 76, .7); }
.pip.ai  { background: var(--azure); border-color: var(--azure); box-shadow: 0 0 12px rgba(29, 92, 214, .7); }
.pip.tie { background: rgba(245, 234, 209, .55); }

/* ---------- speech bubbles ---------- */

.bubble {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 26px;
  border-radius: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .12em;
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  z-index: 20;
  white-space: nowrap;
  animation: bubblein .35s cubic-bezier(.2, .9, .3, 1.4) both;
}

.bubble-ai {
  top: calc(2vh + var(--card-h) + 12px);
  color: var(--ice);
  background: rgba(18, 48, 110, .85);
  border: 1px solid rgba(156, 196, 255, .5);
  box-shadow: 0 0 30px rgba(29, 92, 214, .4);
}

.bubble-you {
  bottom: calc(3vh + var(--card-h) + 12px);
  color: var(--abyss);
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  border: 1px solid var(--gold-bright);
  box-shadow: 0 0 30px rgba(242, 201, 76, .45);
}

@keyframes bubblein {
  from { opacity: 0; transform: translateX(-50%) scale(.6); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* big call flash */

.callflash {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 30;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.4rem, 8vw, 5.5rem);
  letter-spacing: .16em;
  background: linear-gradient(115deg, var(--cream) 15%, var(--gold-bright) 45%, var(--gold) 60%, var(--cream) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(242, 201, 76, .35);
  pointer-events: none;
  animation: flash 1.5s cubic-bezier(.2, .9, .3, 1) both;
}

@keyframes flash {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotateX(40deg); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotateX(0deg); }
  30%  { transform: translate(-50%, -50%) scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
}

/* ---------- dock ---------- */

.dock {
  position: relative;
  z-index: 10;
  padding: 4px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dock-msg {
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: .82rem;
  color: rgba(245, 234, 209, .65);
  min-height: 1.2em;
  text-align: center;
}

.dock-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
}

.chip {
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .14em;
  font-size: .88rem;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(212, 160, 42, .65);
  color: var(--gold-bright);
  background: rgba(10, 26, 58, .6);
  backdrop-filter: blur(8px);
  transition: all .18s ease;
  animation: chipin .3s ease both;
}

@keyframes chipin {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.chip:hover {
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  color: var(--abyss);
  box-shadow: 0 0 28px rgba(242, 201, 76, .5);
  transform: translateY(-2px);
}

.chip:active { transform: scale(.95); }

.chip.chip-no {
  border-color: rgba(156, 196, 255, .4);
  color: var(--ice);
}

.chip.chip-no:hover {
  background: rgba(29, 92, 214, .8);
  color: #fff;
  box-shadow: 0 0 28px rgba(29, 92, 214, .5);
}

.chip.chip-danger {
  border-color: rgba(224, 82, 82, .55);
  color: #f0a0a0;
}

.chip.chip-danger:hover {
  background: rgba(160, 40, 40, .85);
  color: #fff;
  box-shadow: 0 0 28px rgba(224, 82, 82, .4);
}

/* ---------- 2v2 stage ---------- */

.hand-side {
  top: 50%;
  left: auto;
  transform: translateY(-58%);
  flex-direction: column;
  gap: clamp(4px, 1vh, 10px);
  z-index: 4;
}

.hand-left  { left: clamp(4px, 2vw, 28px); }
.hand-right { right: clamp(4px, 2vw, 28px); }

.hand-side .card {
  width: calc(var(--card-w) * .55);
  height: calc(var(--card-h) * .55);
}

.stage.mode-2v2 .hand-ai .card {
  width: calc(var(--card-w) * .68);
  height: calc(var(--card-h) * .68);
}

/* nameplates */

.plate {
  position: absolute;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 13px;
  border-radius: 999px;
  border: 1px solid rgba(156, 196, 255, .3);
  background: rgba(4, 10, 28, .72);
  backdrop-filter: blur(6px);
  font-weight: 700;
  letter-spacing: .12em;
  font-size: .72rem;
  color: rgba(245, 234, 209, .85);
  white-space: nowrap;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all .25s ease;
}

.plate.team-0 { border-color: rgba(242, 201, 76, .4); }
.plate.team-1 { border-color: rgba(156, 196, 255, .4); }

.plate.turn {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  box-shadow: 0 0 18px rgba(242, 201, 76, .45);
}

.plate::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(156, 196, 255, .35);
  flex-shrink: 0;
}

.plate.team-0::before { background: var(--gold); }
.plate.team-1::before { background: var(--azure); }
.plate.turn::before { background: var(--gold-bright); box-shadow: 0 0 8px var(--gold-bright); }

.plate-top   { top: calc(1vh + var(--card-h) * .68 + 6px); left: 50%; transform: translateX(-50%); }
.plate-you   { bottom: calc(1.5vh + var(--card-h) + 6px); left: 50%; transform: translateX(-50%); }
.plate-left  { left: clamp(4px, 2vw, 28px); top: calc(50% + var(--card-h) * .95); }
.plate-right { right: clamp(4px, 2vw, 28px); top: calc(50% + var(--card-h) * .95); }

/* 2v2 played-card cross */

.battle-mid {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 40px);
}

.battle-slot {
  display: flex;
  min-width: calc(var(--card-w) * .78);
  min-height: calc(var(--card-h) * .78);
  align-items: center;
  justify-content: center;
}

.battle-slot .card {
  width: calc(var(--card-w) * .78);
  height: calc(var(--card-h) * .78);
}

.battle-slot-left .card.thrown { animation-name: throwleft; }
.battle-slot-right .card.thrown { animation-name: throwright; }

@keyframes throwleft {
  from { opacity: 0; transform: translateX(-50px) rotateZ(-8deg) scale(1.2); }
  to   { opacity: 1; transform: none; }
}

@keyframes throwright {
  from { opacity: 0; transform: translateX(50px) rotateZ(8deg) scale(1.2); }
  to   { opacity: 1; transform: none; }
}

/* side bubbles */

.bubble-left, .bubble-right {
  top: 38%;
  left: auto;
  transform: none;
  color: var(--ice);
  background: rgba(18, 48, 110, .85);
  border: 1px solid rgba(156, 196, 255, .5);
  box-shadow: 0 0 30px rgba(29, 92, 214, .4);
  animation-name: bubbleside;
}

.bubble-left  { left: clamp(8px, 3vw, 40px); }
.bubble-right { right: clamp(8px, 3vw, 40px); }

@keyframes bubbleside {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- chat ---------- */

.chat-toggle {
  position: relative;
  font-size: 1.05rem;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(156, 196, 255, .35);
  background: rgba(10, 26, 58, .5);
  backdrop-filter: blur(6px);
  transition: all .18s ease;
  align-self: flex-start;
}

.chat-toggle:hover { border-color: var(--ice); box-shadow: 0 0 18px rgba(156, 196, 255, .25); }

.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--gold-bright);
  color: var(--abyss);
  font-family: var(--font-hud);
  font-weight: 700;
  font-size: .68rem;
  line-height: 18px;
  text-align: center;
}

.chat {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  width: min(320px, calc(100vw - 28px));
  height: min(420px, 60vh);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid rgba(212, 160, 42, .5);
  background: linear-gradient(170deg, rgba(18, 48, 110, .92), rgba(10, 26, 58, .96));
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(212, 160, 42, .3);
}

.chat-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .2em;
  font-size: .78rem;
  color: var(--gold-bright);
}

.chat-close {
  border: none;
  background: none;
  color: rgba(245, 234, 209, .6);
  font-size: .95rem;
  cursor: pointer;
  padding: 2px 6px;
}

.chat-close:hover { color: var(--cream); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  user-select: text;
}

.chat-msg { font-size: .9rem; line-height: 1.35; color: rgba(245, 234, 209, .92); overflow-wrap: break-word; }
.chat-msg .chat-who { font-weight: 700; letter-spacing: .04em; color: var(--ice); margin-right: 6px; }
.chat-msg.chat-mine .chat-who { color: var(--gold-bright); }
.chat-msg.chat-sys { color: rgba(156, 196, 255, .65); font-style: italic; font-size: .82rem; }

/* Someone else's message is tappable — it opens the report/block menu.
   Own messages and system lines stay inert. */
.chat-msg.chat-actionable { cursor: pointer; border-radius: 8px; padding: 2px 6px; margin: 0 -6px; }
.chat-msg.chat-actionable:hover,
.chat-msg.chat-actionable:focus-visible {
  background: rgba(156, 196, 255, .1);
  outline: none;
}
.chat-msg.chat-blocked { opacity: .45; font-style: italic; color: rgba(156, 196, 255, .6); }

.chat-hint {
  margin: 0;
  padding: 0 12px 8px;
  font-size: .68rem;
  letter-spacing: .04em;
  color: rgba(156, 196, 255, .5);
  text-align: center;
}

/* Report / block sheet */
.mod-panel { max-width: 340px; }
.mod-who {
  margin: 0;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--gold-bright);
  text-align: center;
}
.mod-text {
  margin: 0;
  font-size: .88rem;
  line-height: 1.4;
  color: rgba(245, 234, 209, .8);
  text-align: center;
  overflow-wrap: break-word;
  max-height: 5.6em;
  overflow-y: auto;
}
.mod-btn { width: 100%; }

.terms-panel { max-width: 380px; }
.terms-body {
  margin: 0;
  font-size: .86rem;
  line-height: 1.6;
  color: rgba(245, 234, 209, .82);
}

.settings-link { color: var(--gold-bright); text-decoration: underline; }
.settings-link:hover { color: var(--ice); }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(212, 160, 42, .3);
}

.chat-input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(156, 196, 255, .35);
  background: rgba(4, 10, 28, .7);
  color: var(--cream);
  font-family: var(--font-hud);
  font-size: .92rem;
  outline: none;
}

.chat-input:focus { border-color: var(--gold-bright); }

.chat-send {
  border: 1px solid var(--gold-bright);
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  color: var(--abyss);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: .95rem;
  flex-shrink: 0;
}

/* lobby buttons that carry an unread badge */
.btn-badged { position: relative; }

/* incoming-message toast: pops in under the chat icon while the panel is closed */
.chat-toast {
  position: fixed;
  top: 56px;
  right: 14px;
  z-index: 75;
  max-width: min(300px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(212, 160, 42, .55);
  background: linear-gradient(170deg, rgba(18, 48, 110, .94), rgba(10, 26, 58, .97));
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
  font-family: var(--font-hud);
  font-size: .9rem;
  line-height: 1.35;
  color: rgba(245, 234, 209, .95);
  overflow-wrap: break-word;
  cursor: pointer;
  animation: toast-in .25s ease both;
}

.chat-toast-who {
  display: block;
  font-weight: 700;
  letter-spacing: .06em;
  font-size: .78rem;
  color: var(--ice);
}

.chat-toast.chat-toast-sys { font-style: italic; color: rgba(156, 196, 255, .8); }
.chat-toast.chat-toast-sys .chat-toast-who { display: none; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- edit-name popover ---------- */

.name-pop {
  position: fixed;
  top: 56px;
  right: 14px;
  z-index: 80;
  width: min(280px, calc(100vw - 28px));
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(212, 160, 42, .5);
  background: linear-gradient(170deg, rgba(18, 48, 110, .94), rgba(10, 26, 58, .97));
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  animation: toast-in .2s ease both;
}

.name-pop .online-namelabel { display: block; margin-bottom: 8px; }

.name-pop-row { display: flex; gap: 8px; }

.name-pop-row .online-name { flex: 1; min-width: 0; width: auto; }

.name-save {
  border: 1px solid var(--gold-bright);
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  color: var(--abyss);
  border-radius: 999px;
  padding: 0 16px;
  cursor: pointer;
  font-family: var(--font-hud);
  font-weight: 700;
  letter-spacing: .12em;
  font-size: .74rem;
  flex-shrink: 0;
}

/* ---------- end banner ---------- */

.endgame {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  background: rgba(4, 10, 28, .85);
  backdrop-filter: blur(8px);
}

.endgame-inner { text-align: center; animation: rise .8s cubic-bezier(.2,.9,.25,1) both; }

.endgame-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.2rem, 7vw, 4.6rem);
  letter-spacing: .12em;
  background: linear-gradient(115deg, var(--cream) 20%, var(--gold-bright) 45%, var(--gold) 60%, var(--cream) 85%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 5s linear infinite;
  margin-bottom: 10px;
}

.endgame-sub {
  color: var(--ice);
  letter-spacing: .2em;
  font-weight: 600;
  margin-bottom: 18px;
}

.endgame-taunt {
  color: rgba(245, 234, 209, .8);
  font-style: italic;
  font-size: 1.05rem;
  letter-spacing: .04em;
  margin: 0 auto 10px;
  max-width: 32ch;
}

.endgame-stats {
  color: rgba(156, 196, 255, .7);
  font-family: var(--font-hud);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: .78rem;
  margin-bottom: 34px;
}

/* ---------- responsive: phones (portrait) ---------- */

@media (max-width: 640px) {
  :root { --card-w: clamp(56px, 21vw, 80px); }

  .hud {
    position: relative;
    flex-wrap: wrap;
    padding: calc(6px + env(safe-area-inset-top)) 64px 2px 10px;
    column-gap: 8px;
    row-gap: 2px;
  }
  .hud-score { min-width: 0; flex: 1; }
  .hud-points { font-size: 1.15rem; }
  .hud-label { font-size: .6rem; letter-spacing: .12em; }
  .hud-center { order: 4; width: 100%; }
  .hud-title { display: none; }
  .hud-stake { font-size: .6rem; }
  .hud-actions {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top));
    right: 10px;
    z-index: 5;
  }
  .exit-btn {
    padding: 5px 9px;
    font-size: .58rem;
    letter-spacing: .1em;
  }

  .scene { perspective: 800px; }
  .table-tilt { width: 150vw; height: 54vh; top: 49%; }
  .table-emblem { display: none; }

  .battle { gap: 6px; }
  .battle-row { gap: 10px; min-height: calc(var(--card-h) * .62); }
  .battle-row .card { width: calc(var(--card-w) * .62); height: calc(var(--card-h) * .62); }

  .hand { gap: 6px; }
  .hand-you { bottom: .6vh; }
  .hand-ai { top: .4vh; }
  .hand-ai .card { width: calc(var(--card-w) * .68); height: calc(var(--card-h) * .68); }

  .bubble { font-size: .9rem; padding: 7px 16px; border-radius: 10px; }
  .bubble-ai { top: calc(.4vh + var(--card-h) * .68 + 8px); }
  .bubble-you { bottom: calc(.6vh + var(--card-h) + 8px); }

  .dock { padding: 2px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .dock-msg { font-size: .64rem; letter-spacing: .08em; }
  .dock-buttons { gap: 6px; min-height: 36px; }
  .chip { padding: 8px 12px; font-size: .7rem; letter-spacing: .08em; }

  .splash-inner { padding: 0 18px; max-width: 100vw; }
  .splash-coin { width: 68px; height: 68px; margin-bottom: 18px; }
  .splash-title { font-size: clamp(1.5rem, 8vw, 2.4rem); letter-spacing: .08em; }
  .splash-sub { letter-spacing: .35em; text-indent: .35em; }
  .splash-tag { font-size: .68rem; margin: 16px 0 24px; }
  .splash .btn { display: block; margin: 10px auto; width: min(260px, 82vw); }

  .overlay-panel { padding: 22px 18px max(22px, env(safe-area-inset-bottom)); gap: 14px; }
  .rules-scroll { font-size: .92rem; }
  .online-status { font-size: .9rem; }
  .online-link { font-size: .76rem; padding: 10px 10px; }
  .online-linkbtns .btn { width: min(260px, 82vw); }
  .online-modes .btn { min-width: 0; width: min(260px, 82vw); }
  .online-code { font-size: 1.3rem; letter-spacing: .26em; text-indent: .26em; padding: 10px 8px; }
  .online-codehint { font-size: .78rem; }
  .lobby-seat { padding: 7px 10px; gap: 8px; }
  .lobby-name { font-size: .86rem; }
  .lobby-btn { font-size: .6rem; padding: 5px 9px; }

  .hand-side .card { width: calc(var(--card-w) * .5); height: calc(var(--card-h) * .5); }
  .stage.mode-2v2 .battle-row .card,
  .stage.mode-2v2 .battle-slot .card { width: calc(var(--card-w) * .58); height: calc(var(--card-h) * .58); }
  .stage.mode-2v2 .battle-slot { min-width: calc(var(--card-w) * .58); min-height: calc(var(--card-h) * .58); }
  .battle-mid { gap: 8px; }
  .plate { font-size: .58rem; padding: 3px 9px; max-width: 44vw; }
  .plate-left  { left: 4px; top: calc(50% + var(--card-h) * .8); }
  .plate-right { right: 4px; top: calc(50% + var(--card-h) * .8); }
  .chat { right: 8px; bottom: 8px; height: min(360px, 55vh); }
  .chat-toggle {
    padding: 3px 9px;
    font-size: .85rem;
  }
  .chat-toast, .name-pop { top: calc(80px + env(safe-area-inset-top)); right: 8px; }

  .endgame-sub { margin-bottom: 24px; }
  .endgame .btn { display: block; margin: 10px auto; width: min(260px, 82vw); }
}

/* ---------- responsive: phones (landscape, short screens) ---------- */

@media (max-height: 520px) {
  :root { --card-w: clamp(44px, 9vw, 60px); }

  .hud { padding: 4px 14px 0; }
  .hud-score { min-width: 110px; }
  .hud-points { font-size: .95rem; }
  .hud-label { font-size: .58rem; }
  .hud-title { display: none; }
  .hud-stake { font-size: .58rem; }
  .hud-track { height: 3px; }
  .exit-btn { padding: 4px 8px; font-size: .56rem; }

  .scene { perspective: 700px; }
  .table-tilt { width: min(96vw, 760px); height: 72vh; top: 50%; }
  .table-emblem { display: none; }

  .battle { top: 46%; gap: 4px; flex-direction: row; }
  .battle-row { gap: 8px; min-height: calc(var(--card-h) * .7); }
  .battle-row .card { width: calc(var(--card-w) * .7); height: calc(var(--card-h) * .7); }
  .trick-pips { flex-direction: column; gap: 8px; }
  .pip { width: 9px; height: 9px; }

  .hand { gap: 5px; }
  .hand-you { bottom: 2px; }
  .hand-ai { top: 2px; }
  .hand-ai .card { width: calc(var(--card-w) * .6); height: calc(var(--card-h) * .6); }

  .bubble { font-size: .8rem; padding: 5px 12px; border-radius: 8px; }
  .bubble-ai { top: calc(var(--card-h) * .6 + 8px); }
  .bubble-you { bottom: calc(var(--card-h) + 8px); }

  .dock { padding: 0 8px 5px; gap: 3px; }
  .dock-msg { font-size: .58rem; min-height: 1em; }
  .dock-buttons { gap: 5px; min-height: 30px; }
  .chip { padding: 5px 10px; font-size: .62rem; letter-spacing: .08em; }

  .splash-coin { width: 54px; height: 54px; margin-bottom: 12px; }
  .splash-title { font-size: clamp(1.6rem, 6vh, 2.4rem); }
  .splash-tag { margin: 10px 0 16px; font-size: .66rem; }
  .splash .btn { padding: 9px 22px; font-size: .78rem; }

  .hand-side .card { width: calc(var(--card-w) * .55); height: calc(var(--card-h) * .55); }
  .plate { font-size: .54rem; padding: 2px 8px; }
  .plate-left  { top: calc(50% + var(--card-h) * .75); }
  .plate-right { top: calc(50% + var(--card-h) * .75); }
  .plate-top { top: calc(2px + var(--card-h) * .6 + 4px); }
  .plate-you { bottom: calc(2px + var(--card-h) + 4px); }
  .chat { height: min(280px, 80vh); }
  .chat-toggle { padding: 3px 8px; font-size: .8rem; }
  .chat-toast, .name-pop { top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .wave { animation: none; }
  .splash-coin { animation: none; }
  .splash-title, .endgame-title { animation: none; }
}

/* ============================================================
   Light theme — a daylight room around the same navy holotable.
   The table, cards, bubbles and chat keep their midnight look;
   the chrome (backgrounds, panels, HUD, text) goes ivory/navy.
   ============================================================ */

body.theme-light {
  color: #14224a;
  background: radial-gradient(120% 90% at 50% -10%, #fdf6e3 0%, #f3e8cd 55%, #e7d9b8 100%);
}
body.theme-light .wave { opacity: .22; }
body.theme-light .splash {
  background:
    radial-gradient(80% 70% at 50% 35%, rgba(255, 250, 235, .6) 0%, rgba(240, 229, 202, .92) 75%);
}
body.theme-light .splash-title {
  background: linear-gradient(115deg, #14224a 20%, #a87b12 45%, #8a6410 60%, #14224a 80%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}
body.theme-light .splash-sub { color: #1d5cd6; }
body.theme-light .splash-tag { color: rgba(20, 34, 74, .6); }
body.theme-light .splash-stats { color: rgba(29, 92, 214, .85); }
body.theme-light .btn-ghost {
  color: #1d5cd6;
  border-color: rgba(29, 92, 214, .45);
  background: rgba(255, 255, 255, .5);
}
body.theme-light .btn-ghost:hover { border-color: #1d5cd6; box-shadow: 0 0 24px rgba(29, 92, 214, .2); }
body.theme-light .overlay { background: rgba(240, 229, 202, .8); }
body.theme-light .overlay-panel {
  border-color: rgba(168, 123, 18, .55);
  background: linear-gradient(170deg, rgba(253, 247, 232, .96), rgba(240, 228, 198, .98));
  box-shadow: 0 30px 80px rgba(90, 70, 20, .28), inset 0 1px 0 rgba(255, 255, 255, .8);
}
body.theme-light .overlay-panel h2 { color: #8a6410; }
body.theme-light .online-status,
body.theme-light .solo-hint,
body.theme-light .online-codehint,
body.theme-light .rules-scroll { color: rgba(20, 34, 74, .85); }
body.theme-light .rules-scroll strong { color: #8a6410; }
body.theme-light .rules-scroll h3 { color: #a87b12; }
body.theme-light .rules-scroll em { color: #1d5cd6; }
body.theme-light .ladder-card figcaption { color: rgba(20, 34, 74, .8); }
body.theme-light .ladder-rank { background: rgba(255, 255, 255, .92); color: #8a6410; }
body.theme-light .online-namelabel,
body.theme-light .settings-label,
body.theme-light .online-codelabel { color: #1d5cd6; }
body.theme-light .online-name,
body.theme-light .online-link { background: rgba(255, 255, 255, .75); color: #14224a; border-color: rgba(29, 92, 214, .4); }
body.theme-light .online-code { background: rgba(255, 255, 255, .75); color: #8a6410; }
body.theme-light .settings-note { color: rgba(20, 34, 74, .7); }
body.theme-light .terms-body { color: rgba(20, 34, 74, .85); }
body.theme-light .mod-text { color: rgba(20, 34, 74, .8); }
body.theme-light .settings-link { color: #9a6b13; }
body.theme-light .settings-version { color: rgba(29, 92, 214, .6); }
body.theme-light .lang-toggle { background: rgba(255, 255, 255, .6); color: #8a6410; }
body.theme-light .lobby-name { color: #14224a; }
body.theme-light .lobby-seat { background: rgba(255, 255, 255, .5); }
body.theme-light .hud-label { color: #1d5cd6; }
body.theme-light .hud-points { color: #a87b12; text-shadow: none; }
body.theme-light .hud-title { color: rgba(20, 34, 74, .85); }
body.theme-light .hud-stake { color: #8a6410; }
body.theme-light .hud-track { background: rgba(29, 92, 214, .18); }
body.theme-light .dock-msg { color: rgba(20, 34, 74, .78); }
body.theme-light .passgate {
  background:
    radial-gradient(circle at 50% 38%, rgba(242, 201, 76, .3), transparent 60%),
    #f3e8cd;
}
body.theme-light .passgate-title { color: #8a6410; text-shadow: none; }
body.theme-light .passgate-sub { color: rgba(20, 34, 74, .7); }
