/*
 * Khooti web — "Khooti Toon", the same design system as the mobile app (KhootiToon.kt):
 * deep night-indigo ink, indigo panels with a thin champagne-gold rim and a darker lip, gem buttons
 * (gold primary, sapphire, jade, crimson, amethyst) with a small 3D lip, dark "coin" icon buttons,
 * fully rounded chips, gold outlined titles and Kanit type.
 */

@font-face {
  font-family: 'Kanit';
  src: url('/khooti/fonts/kanit-medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Kanit';
  src: url('/khooti/fonts/kanit-semibold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Kanit';
  src: url('/khooti/fonts/kanit-bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #120c26;
  --ink-soft: #4a4170;
  --cream: #fff6e3;
  --text-soft: #d9d3ee;
  --gold: #e9c063;
  --gold-text: #f2d27c;
  --panel-top: #2e2566;
  --panel-bottom: #191340;
  --rim: #c9a55a;
  --lip: #0e0a24;
  --inset: #120e30;
  --vk-blue: #2787f5;
  --red: #e53935;
  --navy: #1f3a6e;
  --font: 'Kanit', 'Segoe UI', system-ui, sans-serif;
  --col-w: min(100vw, max(460px, 56.25vh));
  --kh-card-w: 60px;
  --kh-card-h: 85px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  max-height: 100%;
  background: #0b0a1e;
  color: #fff;
  font-family: var(--font);
  font-weight: 500;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
}

img {
  -webkit-user-drag: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.screen--active {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ toon components */

.panel {
  position: relative;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  box-shadow:
    inset 0 0 0 1.5px rgba(201, 165, 90, 0.7),
    inset 0 -3px 0 1.5px var(--lip),
    0 10px 28px rgba(5, 3, 15, 0.55);
}

.panel::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0) 45%);
  pointer-events: none;
}

.inset {
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: linear-gradient(180deg, #1a1442, var(--inset));
  box-shadow: inset 0 10px 12px -8px rgba(0, 0, 0, 0.45);
}

.toon-title,
.toon-logo {
  margin: 0;
  font-weight: 700;
  line-height: 1.1;
  color: transparent;
  background: linear-gradient(180deg, #fff1c4 15%, #e3b24f 90%) 0 0 / 100% 1.1em repeat-y;
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 1px var(--ink)) drop-shadow(0 0 1px var(--ink)) drop-shadow(0 2px 0 var(--ink));
}

.toon-title {
  font-size: 30px;
}

.toon-title--sm {
  font-size: 22px;
}

.toon-logo {
  font-size: 64px;
  letter-spacing: 3px;
  background-image: linear-gradient(180deg, #fff1c4 10%, #f0c86a 55%, #b8862e 95%);
  filter: drop-shadow(0 0 1.5px var(--ink)) drop-shadow(0 0 1px var(--ink)) drop-shadow(0 3px 0 rgba(18, 12, 38, 0.9));
}

/* Gem buttons: ink outline, tinted face, darker lip, glossy top band. */
.gem {
  --t: #f6dc8e;
  --b: #c9952f;
  --l: #7a5418;
  --c: #2a1a05;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 8px 18px 12px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--t), var(--b));
  box-shadow:
    inset 0 -4px 0 var(--l),
    inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  color: var(--c);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.gem::before {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 3px;
  height: 11px;
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.03));
  pointer-events: none;
}

.gem:hover {
  filter: brightness(1.06);
}

.gem:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 -1px 0 var(--l),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.gem:disabled {
  --t: #6a6488;
  --b: #4e4868;
  --l: #3a3550;
  --c: #d9d3ee;
  cursor: default;
  filter: none;
  transform: none;
}

.gem--lg {
  min-height: 56px;
  font-size: 20px;
  border-radius: 16px;
}

.gem small {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
}

.gem--green,
.gem--blue,
.gem--red,
.gem--purple {
  --c: #fff;
  text-shadow: 0 1px 0 var(--ink), 0 0 2px var(--ink);
}

.gem--green {
  --t: #5fd3a0;
  --b: #1f8a5e;
  --l: #0f5238;
}

.gem--blue {
  --t: #7fa8ff;
  --b: #3a5bd0;
  --l: #1c2f7a;
}

.gem--red {
  --t: #f07a84;
  --b: #b8283c;
  --l: #6a1020;
}

.gem--purple {
  --t: #a98bf0;
  --b: #6a49c8;
  --l: #3a2580;
}

/* Round dark "coin" icon buttons with a gold rim. */
.coin {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(180deg, #3a3080, #1e1848);
  box-shadow:
    inset 0 0 0 1.5px rgba(201, 165, 90, 0.65),
    inset 0 -3px 0 1px #0b0820,
    0 3px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  flex: none;
}

.coin img {
  width: 58%;
  height: 58%;
  pointer-events: none;
}

.coin:active {
  transform: translateY(2px);
}

.coin--sm {
  width: 34px;
  height: 34px;
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #191340;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.pill {
  min-width: 64px;
  height: 36px;
  padding: 0 16px;
  font-size: 16px;
  box-shadow: inset 0 0 0 1px rgba(201, 165, 90, 0.35), 0 2px 6px rgba(0, 0, 0, 0.35);
}

.chip {
  height: 28px;
  padding: 0 11px;
  font-size: 13px;
  background: #120e30;
}

.chip img {
  width: 16px;
  height: 16px;
}

.chip--green {
  color: #7ee0b0;
  background: #0f3a2c;
}

.chip--gold {
  color: var(--gold-text);
}

.ribbon {
  display: inline-block;
  padding: 3px 14px 6px;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: linear-gradient(180deg, #e8606f, #a8233a);
  box-shadow: inset 0 -3px 0 #6a1020, inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-shadow: 0 1px 0 var(--ink);
}

.ribbon--gold {
  background: linear-gradient(180deg, #f6dc8e, #c9952f);
  box-shadow: inset 0 -3px 0 #7a5418;
  color: #2a1a05;
  text-shadow: none;
}

/* Medallion behind mode art: ink outline, gold ring, deep centre. */
.medal {
  --accent: #a8323a;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background:
    radial-gradient(circle at 45% 35%, color-mix(in srgb, var(--accent) 80%, transparent), #120e30 68%) padding-box,
    linear-gradient(180deg, #f6dc8e, #b8862e) border-box;
  box-shadow: 0 0 0 6px #e0b860 inset, 0 0 0 9px var(--ink) inset, 0 4px 0 #5c3f12, 0 8px 18px rgba(0, 0, 0, 0.45);
}

.medal img {
  width: 52%;
  height: 52%;
}

.medal--sm {
  width: 42px;
  height: 42px;
  border-width: 2px;
  box-shadow: 0 0 0 2px #e0b860 inset, 0 0 0 4px var(--ink) inset;
  --accent: #3a5bd0;
}

.medal--sm img {
  width: 56%;
  height: 56%;
}

.xp-track {
  position: relative;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #0e0a24;
  overflow: hidden;
}

.xp-track__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #f6dc8e, #c9952f);
  transition: width 0.6s ease;
}

.toggle {
  position: relative;
  width: 62px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(180deg, #3a3550, #24203a);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  flex: none;
}

.toggle[aria-checked='true'] {
  background: linear-gradient(180deg, #5fd3a0, #1f8a5e);
}

.toggle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #dcd8ee);
  transition: transform 0.18s ease;
}

.toggle[aria-checked='true'] .toggle__knob {
  transform: translateX(28px);
}

.count-badge {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #3a3080;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(201, 165, 90, 0.5);
}

/* ------------------------------------------------------------------ avatars */

.kh-avatar-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  height: 100%;
}

.kh-avatar {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, #4a3c9a, #2a2266);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}

.kh-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kh-avatar--fallback {
  background: linear-gradient(180deg, hsl(var(--h, 260) 40% 42%), hsl(var(--h, 260) 45% 26%));
}

.kh-avatar-crown,
.kh-avatar-meta {
  display: none;
}

.avatar-slot {
  display: block;
  width: 64px;
  height: 64px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ink);
  overflow: hidden;
  background: #2a2266;
}

.avatar-slot--lg {
  width: 72px;
  height: 72px;
}

.avatar-slot--xl {
  width: 96px;
  height: 96px;
}

/* ------------------------------------------------------------------ welcome / lobby art stages */

.art-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0b0a1e;
}

.art-stage::before {
  content: '';
  position: absolute;
  inset: -40px;
  background-size: cover;
  background-position: center;
  filter: blur(26px) brightness(0.45) saturate(1.1);
}

.art-stage__img {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: var(--col-w);
  transform: translateX(-50%);
  background-size: cover;
}

.art-stage--welcome::before,
.art-stage--welcome .art-stage__img {
  background-image:
    linear-gradient(180deg, rgba(10, 8, 24, 0.2), rgba(10, 8, 24, 0) 30%, rgba(10, 8, 24, 0.15) 65%, rgba(10, 8, 24, 0.75)),
    url('/khooti/img/welcome.jpg');
  background-position: center;
}

.art-stage--lobby::before,
.art-stage--lobby .art-stage__img {
  background-image:
    linear-gradient(180deg, rgba(10, 8, 24, 0.4), rgba(10, 8, 24, 0) 30%, rgba(10, 8, 24, 0) 65%, rgba(10, 8, 24, 0.55)),
    url('/khooti/img/lobby.jpg');
  background-position: center bottom;
}

@media (min-aspect-ratio: 3/4) {
  .art-stage__img {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  }
}

.lobby-winter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: var(--col-w);
  transform: translateX(-50%);
  pointer-events: none;
}

/* ------------------------------------------------------------------ welcome */

.welcome__col,
.lobby__col,
.boot-cover__col {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(var(--col-w), 520px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  padding: max(16px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}

.welcome__col {
  justify-content: flex-end;
  gap: 14px;
}

.welcome__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.welcome__brand .toon-logo {
  font-size: clamp(54px, 10vh, 76px);
}

.welcome__tagline {
  margin: 0;
  padding: 5px 16px 7px;
  border-radius: 999px;
  background: rgba(14, 10, 36, 0.72);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

.welcome__panel {
  width: 100%;
  padding: 18px 18px 20px;
}

.welcome__actions {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome__actions .gem {
  width: 100%;
}

.welcome__hello {
  margin: 0;
  text-align: center;
  color: var(--text-soft);
  font-size: 15px;
}

.welcome__hello strong {
  color: var(--gold-text);
}

.welcome__hint {
  margin: 0;
  text-align: center;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.4;
}

.inat-footer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.inat-footer img {
  height: 24px;
  width: auto;
}

.inat-footer__sep {
  opacity: 0.75;
}

.inat-footer__link {
  color: var(--gold-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.lobby__col {
  gap: 10px;
}

.lobby-head {
  width: 100%;
  padding: 14px 14px 12px;
  flex: none;
}

.lobby-head__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lobby-head__avatar {
  position: relative;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ink);
  background: #2a2266;
  cursor: pointer;
  flex: none;
}

.lobby-head__avatar .kh-avatar {
  font-size: 18px;
}

.lobby-head__avatar[data-level]::after {
  content: attr(data-level);
  position: absolute;
  right: -7px;
  bottom: -5px;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 4px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(180deg, #f6dc8e, #c9952f);
  color: #2a1a05;
  font-size: 12px;
  font-weight: 700;
}

.lobby-head__who {
  flex: 1;
  min-width: 0;
}

.lobby-head__name {
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lobby-head__rank {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 2px 0 0;
  color: var(--gold-text);
  font-size: 13.5px;
  font-weight: 600;
}

.lobby-head__rank img {
  width: 16px;
  height: 16px;
}

.lobby-head__coins {
  height: 32px;
  background: #0e0a24;
}

.lobby-head__coins img {
  width: 20px;
  height: 20px;
}

.lobby-head__xp {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 12px 2px 6px;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
}

.lobby-head__stats-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold-text);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

.lobby-head__stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 12px 0 0;
  text-align: center;
}

.lobby-head__stats div {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
}

.lobby-head__stats dt {
  color: var(--text-soft);
  font-size: 12px;
}

.lobby-head__stats dd {
  margin: 0;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
}

.lobby-head__stats .is-win {
  color: #5fd3a0;
}

.lobby-head__stats .is-lose {
  color: #f07a84;
}

.lobby__logo {
  margin: 4px 0 6px;
  font-size: clamp(44px, 7.5vh, 60px);
}

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

.mode-card {
  --t: #7fa8ff;
  --b: #3a5bd0;
  --l: #1c2f7a;
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 84px;
  padding: 10px 14px 14px 12px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--t), var(--b));
  box-shadow:
    inset 0 -5px 0 var(--l),
    inset 0 0 0 1px rgba(255, 255, 255, 0.28),
    0 6px 14px rgba(0, 0, 0, 0.4);
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.mode-card::before {
  content: '';
  position: absolute;
  left: 5px;
  right: 5px;
  top: 4px;
  height: 18px;
  border-radius: 14px 14px 8px 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.02));
  pointer-events: none;
}

.mode-card:hover {
  filter: brightness(1.07);
}

.mode-card:active {
  transform: translateY(3px);
}

.mode-card--green {
  --t: #5fd3a0;
  --b: #1f8a5e;
  --l: #0f5238;
}

.mode-card--red {
  --t: #f07a84;
  --b: #b8283c;
  --l: #6a1020;
}

.mode-card__medal {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background:
    radial-gradient(circle at 45% 35%, #2a2266, #120e30 70%) padding-box,
    linear-gradient(180deg, #f6dc8e, #b8862e) border-box;
  box-shadow: inset 0 0 0 3px #e0b860, inset 0 0 0 5px var(--ink);
  flex: none;
}

.mode-card__medal img {
  width: 56%;
  height: 56%;
}

.mode-card__title {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 var(--ink), 0 0 2px var(--ink);
}

.mode-card__go {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(180deg, #f6dc8e, #c9952f);
  box-shadow: inset 0 -3px 0 #7a5418;
  flex: none;
}

.mode-card__go img {
  width: 50%;
  height: 50%;
  margin-left: 3px;
  filter: brightness(0.2);
}

/* ------------------------------------------------------------------ modals */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(180deg, rgba(10, 8, 24, 0.7), rgba(7, 6, 18, 0.8));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: kh-fade 0.18s ease-out;
}

.modal__scrim {
  position: absolute;
  inset: 0;
}

.modal__card {
  width: min(380px, 100%);
  max-height: calc(100% - 8px);
  overflow-y: auto;
  scrollbar-width: none;
  padding: 22px 18px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  animation: kh-pop 0.26s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.modal__card > * {
  position: relative;
}

.modal__close {
  position: absolute !important;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  z-index: 2;
}

.modal__sub {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.4;
}

.modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.modal__actions .gem {
  width: 100%;
}

.modal__row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.modal__row .gem {
  flex: 1;
}

.modal__chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

@keyframes kh-fade {
  from {
    opacity: 0;
  }
}

@keyframes kh-pop {
  from {
    transform: scale(0.88);
    opacity: 0;
  }
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #1a1442;
  cursor: pointer;
  text-align: left;
}

.setting-row__label {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.setting-row__label strong {
  font-size: 16px;
}

.setting-row__label small {
  color: var(--text-soft);
  font-size: 12.5px;
}

.kh-settings .gem {
  width: 100%;
}

.load-error {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 95;
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(180deg, #b8283c, #6a1020);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.btn-quit {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 70;
}

/* Finding / matchmaking */
.finding__versus {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  padding: 14px 8px;
}

.finding__seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.finding__name {
  font-weight: 700;
  font-size: 14px;
}

.finding__vs {
  color: var(--text-soft);
  font-weight: 700;
}

.finding .is-searching {
  display: grid;
  place-items: center;
  animation: kh-pulse 1.4s ease-in-out infinite;
}

.finding__q {
  color: var(--gold-text);
  font-size: 30px;
  font-weight: 700;
}

.finding__dots i {
  font-style: normal;
  animation: kh-dot 1.2s infinite;
}

.finding__dots i:nth-child(2) {
  animation-delay: 0.2s;
}

.finding__dots i:nth-child(3) {
  animation-delay: 0.4s;
}

.finding.is-matched .finding__dots {
  display: none;
}

@keyframes kh-dot {
  50% {
    opacity: 0.2;
  }
}

@keyframes kh-pulse {
  50% {
    box-shadow: 0 0 0 2px var(--ink), 0 0 0 8px rgba(233, 192, 99, 0.25);
  }
}

/* Mode chooser */
.mode-modal .medal {
  margin-top: 4px;
}

.mode-modal .modal__actions .gem {
  min-height: 56px;
}

/* Player card */
.kh-pcard__top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding-right: 44px;
}

.kh-pcard__top .chip {
  text-transform: capitalize;
}

.kh-pcard__hero {
  position: relative;
}

.kh-pcard__lv {
  position: absolute;
  right: -12px;
  top: -2px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(180deg, #f6dc8e, #c9952f);
  color: #2a1a05;
  line-height: 0.9;
}

.kh-pcard__lv small {
  font-size: 9px;
  font-weight: 700;
}

.kh-pcard__lv b {
  font-size: 15px;
}

.kh-pcard__online {
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
}

.kh-pcard__xp {
  width: 100%;
}

.kh-pcard__xp-label {
  margin: -6px 0 0;
  color: var(--text-soft);
  font-size: 12px;
}

.kh-pcard__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.kh-pcard__stats {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.kh-pcard__ring {
  display: grid;
  place-items: center;
  align-content: center;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, #1a1442 78%, transparent 80%),
    conic-gradient(#5fd3a0 calc(var(--pct) * 1%), #3a3550 0);
  flex: none;
}

.kh-pcard__ring b {
  font-size: 20px;
}

.kh-pcard__ring small {
  color: var(--text-soft);
  font-size: 11px;
}

.kh-pcard__tiles {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kh-pcard__tile {
  display: flex;
  flex-direction: column;
  padding: 6px 4px;
  border-radius: 10px;
  background: #241d5a;
}

.kh-pcard__tile b {
  font-size: 18px;
}

.kh-pcard__tile small {
  color: var(--text-soft);
  font-size: 11px;
}

.kh-pcard__tile.is-win b {
  color: #5fd3a0;
}

.kh-pcard__tile.is-lose b {
  color: #f07a84;
}

.kh-pcard__h2h,
.kh-pcard__form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #1a1442;
  font-size: 13px;
}

.kh-pcard__h2h {
  flex-wrap: wrap;
}

.kh-pcard__h2h-score b {
  font-size: 18px;
}

.kh-pcard__h2h-score i {
  margin: 0 6px;
  color: var(--text-soft);
}

.kh-pcard__h2h-sides {
  display: flex;
  gap: 10px;
  color: var(--text-soft);
}

.kh-pcard__form {
  display: flex;
  gap: 4px;
}

.kh-pcard__pip {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #3a3550;
  font-size: 11px;
  font-weight: 700;
}

.kh-pcard__pip--w {
  background: #1f8a5e;
}

.kh-pcard__pip--l {
  background: #b8283c;
}

.kh-pcard__streak {
  color: var(--gold-text);
}

.kh-pcard__status {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

/* Boot / loading cover */
.boot-cover {
  position: fixed;
  inset: 0;
  z-index: 90;
}

.boot-cover__col {
  justify-content: center;
  gap: 24px;
}

.boot-load {
  width: min(320px, 80%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.boot-load__label {
  color: var(--text-soft);
  font-weight: 600;
}

.boot-load__track {
  width: 100%;
  height: 14px;
}

.boot-load__pct {
  color: var(--gold-text);
  font-weight: 700;
}

/* ------------------------------------------------------------------ arena */

.arena {
  --band: 120px;
  --hand-w: clamp(52px, min(16.5vw, 11vh), 92px);
  --hand-h: calc(var(--hand-w) * 1.42);
  --tbl-w: clamp(40px, min(12.5vw, 8.4vh), 74px);
  background: #140e09;
}

.room-layer {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.room-floor {
  z-index: 0;
}

.room-windows {
  z-index: 1;
}

.room-light {
  z-index: 3;
}

.room-fire {
  z-index: 4;
}

.arena-hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.arena-hud > * {
  pointer-events: auto;
}

.arena-hud__mid {
  display: flex;
  gap: 8px;
  align-items: center;
}

.arena-hud__round {
  background: rgba(25, 19, 64, 0.92);
}

.arena-hud__watch {
  height: 30px;
  min-width: 0;
  font-size: 13px;
}

.arena-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--band) + 2px) 10px max(8px, env(safe-area-inset-bottom));
}

/* Seats: chair + avatar + score, the opponent's fan and a side table with their captured pile. */
.seats {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 74px;
  flex: none;
  display: flex;
  justify-content: center;
}

.seat {
  position: relative;
  width: 84px;
  height: 74px;
  flex: none;
}

.seat__chair {
  position: absolute;
  left: 50%;
  top: -6px;
  width: 84px;
  height: 110px;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}

.seat__avatar {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 50px;
  height: 50px;
  transform: translateX(-50%);
  z-index: 2;
}

.seat__flag {
  position: absolute;
  right: -2px;
  bottom: -2px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #141028;
  border: 1px solid #fff;
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

.seat__face {
  position: absolute;
  inset: 3px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ink), 0 3px 6px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  background: #2a2266;
  cursor: pointer;
}

.seat__face .kh-avatar {
  font-size: 14px;
}

.seat__ring {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: conic-gradient(#5fd3a0 calc(var(--kh-left, 1) * 360deg), rgba(255, 255, 255, 0.15) 0);
  -webkit-mask: radial-gradient(circle, transparent 60%, #000 61%);
  mask: radial-gradient(circle, transparent 60%, #000 61%);
}

.seat__ring.is-warn {
  background: conic-gradient(#e9c063 calc(var(--kh-left, 1) * 360deg), rgba(255, 255, 255, 0.15) 0);
}

.seat__ring.is-urgent {
  background: conic-gradient(#f07a84 calc(var(--kh-left, 1) * 360deg), rgba(255, 255, 255, 0.15) 0);
}

.seat--active .seat__face {
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px #5fd3a0, 0 0 16px 4px rgba(95, 211, 160, 0.6);
}

.seat__timer {
  position: absolute;
  right: -10px;
  top: -6px;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(180deg, #f6b76a, #d9752a);
  color: #2a1a05;
  font-size: 12px;
  font-weight: 700;
  z-index: 3;
}

.seat__timer.is-urgent {
  background: linear-gradient(180deg, #f07a84, #b8283c);
  color: #fff;
}

.seat__score {
  position: absolute;
  left: 50%;
  top: -12px;
  transform: translateX(-50%);
  min-width: 28px;
  height: 22px;
  padding: 0 7px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #241d5a;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  z-index: 3;
}

.seat__lv,
.seat__count {
  position: absolute;
  z-index: 3;
  height: 20px;
  padding: 0 6px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #2a2266;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 16px;
}

.seat__lv {
  left: 50%;
  top: 50px;
  transform: translateX(-50%);
}

.seat__count {
  right: 6px;
  top: 34px;
  background: #3a5bd0;
}

.seat__fan {
  position: absolute;
  left: 50%;
  top: 46px;
  width: 116px;
  height: 54px;
  transform: translateX(-50%);
  z-index: 1;
  pointer-events: none;
}

.seat__mute {
  position: absolute;
  left: -50px;
  top: 4px;
}

.seat__mute.is-muted {
  filter: grayscale(0.6);
}

.seat--targetable .seat__face {
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--vk-blue), 0 0 18px 6px rgba(39, 135, 245, 0.6);
  animation: kh-pulse-blue 1s ease-in-out infinite;
}

@keyframes kh-pulse-blue {
  50% {
    box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--vk-blue), 0 0 6px 2px rgba(39, 135, 245, 0.3);
  }
}

/* Side table: a little gold-rimmed felt stand on a pedestal holding the captured pile. */
.side-table {
  position: absolute;
  left: calc(100% + 6px);
  top: -10px;
  width: 64px;
  height: 86px;
  pointer-events: auto;
}

.side-table::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 46px;
  height: 12px;
  transform: translateX(-50%);
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(180deg, #4a3c9a, #241d5a);
}

.side-table::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 9px;
  width: 8px;
  height: 18px;
  transform: translateX(-50%);
  border: 2px solid var(--ink);
  border-top: 0;
  background: linear-gradient(90deg, #2a2266, #4a3c9a, #2a2266);
}

.side-table__top {
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background:
    radial-gradient(ellipse at 50% 46%, #1c6c40, #0e462a) padding-box,
    linear-gradient(180deg, #f6de96, #d4a852 50%, #a0722c) border-box;
  box-shadow: inset 0 0 0 4px transparent, 0 4px 8px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.side-table__top::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 3px solid #d4a852;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1.5px var(--ink);
  pointer-events: none;
}

.side-table .captured-stack {
  --cw: 34px;
}

/* Table */
.table-block {
  position: relative;
  flex: 1 1 auto;
  min-height: 150px;
  width: min(100% - 8px, 880px);
  margin: 26px 0 4px;
  display: flex;
}

.table-rim {
  position: relative;
  flex: 1;
  display: flex;
  padding: 8px;
  border-radius: 20px;
  background: linear-gradient(180deg, #f6de96, #d4a852 50%, #a0722c);
  box-shadow:
    0 0 0 2.2px var(--ink),
    inset 0 1.4px 0 rgba(255, 248, 225, 0.6),
    inset 0 -1.6px 0 #604216,
    0 6px 16px rgba(6, 4, 18, 0.65);
}

.table-felt {
  position: relative;
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 46%, rgb(28, 108, 64), rgb(14, 70, 42) 70%);
  box-shadow: 0 0 0 1.6px var(--ink), inset 0 0 14px 2px rgba(10, 40, 20, 0.55);
  overflow: hidden;
}

.fx-board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.draw-deck {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2;
}

.draw-deck .card {
  --cw: calc(var(--tbl-w) * 0.82);
}

.draw-deck .deck-count {
  right: -16px;
  top: -12px;
}

.draw-deck--empty .card {
  opacity: 0.35;
}

.table-cards {
  position: absolute;
  inset: 12px 14px 12px calc(var(--tbl-w) * 0.82 + 34px);
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 8px;
}

.table-cards .card {
  --cw: var(--tbl-fit, var(--tbl-w));
}

.table-callout {
  position: absolute;
  left: 50%;
  top: 8px;
  z-index: 5;
  transform: translate(-50%, 0) scale(0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 9px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(180deg, #2e2566, #191340);
  box-shadow: inset 0 0 0 1.5px rgba(201, 165, 90, 0.7), 0 8px 20px rgba(0, 0, 0, 0.5);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.table-callout.is-on {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.table-callout__title {
  color: var(--gold-text);
  font-weight: 700;
  font-size: 18px;
}

.table-callout__sub {
  color: var(--text-soft);
  font-size: 13px;
}

/* Your row: chair + avatar, your side table, the mic. */
.you-row {
  position: relative;
  width: 100%;
  height: 80px;
  flex: none;
  display: flex;
  justify-content: center;
  z-index: 1;
}

.seat--you {
  height: 80px;
}

.seat--you .seat__chair {
  top: -2px;
  width: 80px;
  height: 104px;
}

.seat--you .seat__avatar {
  top: 6px;
}

.seat--you .seat__lv {
  top: 54px;
}

.seat--you .seat__score {
  top: -8px;
}

.you-row .side-table {
  left: calc(50% + 50px);
  top: -6px;
}

.you-row__voice {
  position: absolute;
  right: 6px;
  top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.you-row__voice .coin.is-held {
  background: linear-gradient(180deg, #5fd3a0, #1f8a5e);
}

.you-row__voice-status {
  max-width: 120px;
  color: var(--text-soft);
  font-size: 12px;
}

/* Hand tray: gold rim around a deep indigo desk. */
.hand-tray {
  position: relative;
  width: min(100%, 760px);
  flex: none;
  z-index: 1;
}

.hand-tray__turn {
  position: absolute;
  left: 50%;
  top: -2px;
  z-index: 4;
  transform: translate(-50%, 0);
  padding: 2px 12px 3px;
  border-radius: 12px;
  background: #2787f5;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 0 #120c26;
}

.hand-tray__turn.is-pop {
  animation: khooti-turn-pop 220ms cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes khooti-turn-pop {
  from { transform: translate(-50%, 4px) scale(0.72); opacity: 0; }
  to { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

.hand-tray__desk {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--hand-h) + 26px);
  padding: 7px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f6de96, #d4a852 50%, #a0722c);
  box-shadow:
    0 0 0 2.2px var(--ink),
    inset 0 1.4px 0 rgba(255, 248, 225, 0.6),
    0 6px 14px rgba(6, 4, 18, 0.65);
}

.hand-tray__desk::before {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 40%, rgb(44, 38, 100), rgb(20, 16, 52) 70%);
  box-shadow: 0 0 0 1.6px var(--ink), inset 0 0 12px rgba(20, 8, 50, 0.6);
}

.player-zone--your-turn .hand-tray__desk {
  box-shadow:
    0 0 0 2.2px var(--ink),
    0 0 0 4px #5fd3a0,
    0 0 22px 4px rgba(95, 211, 160, 0.45),
    inset 0 1.4px 0 rgba(255, 248, 225, 0.6);
}

.hand-cards {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 0 4px;
}

.hand-cards .card {
  --cw: var(--hand-fit, var(--hand-w));
}

/* 4 players: partner / opponent on top, the other two at the sides of the table. */
.arena--four .seat[data-pos='left'],
.arena--four .seat[data-pos='right'] {
  position: absolute;
  top: 130px;
}

.arena--four .seat[data-pos='left'] {
  left: 14px;
}

.arena--four .seat[data-pos='right'] {
  right: 14px;
}

.arena--four .seat[data-pos='left'] .seat__chair {
  transform: translateX(-50%) rotate(-90deg);
}

.arena--four .seat[data-pos='right'] .seat__chair {
  transform: translateX(-50%) rotate(90deg);
}

.arena--four .seat[data-pos='left'] .side-table,
.arena--four .seat[data-pos='right'] .side-table {
  left: 10px;
  top: 92px;
}

.arena--four .seat[data-pos='left'] .seat__fan,
.arena--four .seat[data-pos='right'] .seat__fan {
  display: none;
}

.arena--four .table-block {
  width: min(100% - 220px, 820px);
}

@media (max-width: 620px) {
  .arena--four .seat[data-pos='right'] {
    top: 104px;
  }
  .arena--four .seat[data-pos='left'] {
    left: auto;
    right: 14px;
    top: 286px;
  }
  .arena--four .seat[data-pos='right'] .seat__chair,
  .arena--four .seat[data-pos='left'] .seat__chair {
    transform: translateX(-50%) rotate(90deg);
  }
  .arena--four .table-block {
    width: calc(100% - 104px);
    margin-right: 96px;
  }
}

/* Toast at the top of the table (deck empty, extra move, time's up). */
.phase-banner {
  position: absolute;
  left: 50%;
  top: calc(var(--band) + 86px);
  z-index: 7;
  transform: translate(-50%, -8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 18px 9px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(180deg, #2e2566, #191340);
  box-shadow: inset 0 0 0 1.5px rgba(201, 165, 90, 0.7), 0 8px 18px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}

.phase-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.phase-banner__main {
  color: var(--gold-text);
  font-weight: 700;
  font-size: 16px;
}

.phase-banner__sub {
  color: var(--text-soft);
  font-size: 12.5px;
}

.phase-banner--lost .phase-banner__main,
.phase-banner--perilous .phase-banner__main {
  color: #ff9aa4;
}

.fx-flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  opacity: 0;
  pointer-events: none;
}

.card-fly-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.match-zoom-dim {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 46%, rgba(7, 6, 18, 0.45), rgba(7, 6, 18, 0.7));
  opacity: 0;
}

.fx-magic {
  position: fixed;
  inset: 0;
  z-index: 45;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.arena .modal {
  position: absolute;
  z-index: 20;
}

/* Start panel + dice */
.kickoff__card {
  gap: 14px;
}

.kickoff__count {
  margin: 0;
  color: var(--gold-text);
  font-size: 54px;
  font-weight: 700;
}

.dice-duel {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 28px;
  width: 100%;
  padding: 6px 0 2px;
}

.die-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  max-width: 110px;
}

.die-slot span {
  overflow: hidden;
  max-width: 100%;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.die {
  width: 62px;
  height: 62px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #e6e2f4);
  box-shadow: inset 0 -4px 0 #bdb6d8, 0 4px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s linear;
}

.die svg {
  width: 100%;
  height: 100%;
}

.die.is-winner {
  box-shadow: inset 0 -4px 0 #bdb6d8, 0 0 0 4px var(--gold), 0 0 20px 4px rgba(233, 192, 99, 0.6);
  animation: kh-die-pop 0.38s cubic-bezier(0.34, 1.9, 0.64, 1);
}

@keyframes kh-die-pop {
  from {
    transform: scale(1.35);
  }
}

.dice-banner {
  margin: 0;
  color: var(--gold-text);
  font-size: 17px;
  font-weight: 700;
  animation: kh-fade 0.24s ease-out;
}

/* Target picker */
.target-picker .gem {
  width: 100%;
}

/* ------------------------------------------------------------------ cards: flat vector faces */

.card {
  --cw: var(--kh-card-w);
  position: relative;
  flex: none;
  width: var(--cw);
  height: calc(var(--cw) * 1.42);
  border-radius: clamp(4px, calc(var(--cw) * 0.14), 10px);
  background: #fff;
  box-shadow: inset 0 0 0 1px #e3e6ec, 0 2px 5px rgba(0, 0, 0, 0.35);
  container-type: inline-size;
  color: var(--navy);
  overflow: hidden;
}

.card--red {
  color: var(--red);
}

.card__rank {
  position: absolute;
  left: 12%;
  top: 4%;
  font-family: 'Arial Narrow', 'Roboto Condensed', 'Helvetica Neue', Arial, sans-serif;
  font-stretch: condensed;
  font-weight: 700;
  font-size: 38cqw;
  line-height: 1;
  letter-spacing: -0.02em;
}

.card__rank--10 {
  letter-spacing: -0.09em;
  transform: scaleX(0.82);
  transform-origin: left top;
}

.card__pip {
  position: absolute;
  right: 10%;
  top: 9%;
  width: 16cqw;
  height: 16cqw;
}

.card__big {
  position: absolute;
  left: 50%;
  top: 62%;
  width: 56cqw;
  height: 56cqw;
  transform: translate(-50%, -50%);
}

.card--ace .card__big {
  width: 60cqw;
  height: 60cqw;
}

.card__court {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Arial Narrow', 'Roboto Condensed', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 700;
  font-size: 46cqw;
  line-height: 0.9;
}

.card__court svg {
  width: 22cqw;
  height: 22cqw;
  margin-top: 4cqw;
}

@container (max-width: 40px) {
  .card__rank {
    font-size: 44cqw;
  }
  .card__pip {
    width: 19cqw;
    height: 19cqw;
  }
}

.card--back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.13) 0 1px, transparent 1px calc(var(--cw) * 0.16)),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.13) 0 1px, transparent 1px calc(var(--cw) * 0.16)),
    linear-gradient(135deg, #3a95f7, #1a6ed8);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.card--back::before {
  content: '';
  position: absolute;
  inset: max(2.5px, 8%);
  border: max(1px, calc(var(--cw) * 0.018)) solid rgba(255, 255, 255, 0.85);
  border-radius: max(1.5px, calc(var(--cw) * 0.08));
}

.card--back::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1'%3E%3Cpath fill='%232787F5' d='M.5 0Q.66.27.9.5Q.66.73.5 1Q.34.73.1.5Q.34.27.5 0Z'/%3E%3C/svg%3E") center / 62% no-repeat;
  box-shadow: 0 0 0 max(1px, calc(var(--cw) * 0.04)) rgba(255, 255, 255, 0.4);
}

.card--clickable {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.hand-cards .card--clickable:hover {
  transform: translateY(-6px);
}

.card--glow {
  box-shadow: inset 0 0 0 2px #e8c547, 0 0 0 1px var(--ink), 0 0 14px 2px rgba(232, 197, 71, 0.55), 0 3px 6px rgba(0, 0, 0, 0.4);
}

.card--selected {
  background: #f4f9ff;
  box-shadow: inset 0 0 0 2px var(--vk-blue), 0 0 0 1px var(--ink), 0 0 14px 3px rgba(39, 135, 245, 0.65);
}

.hand-cards .card--selected {
  transform: translateY(-10px);
}

.card--dimmed {
  filter: brightness(0.82) saturate(0.7);
}

.card--source-hidden,
.card--dealing {
  visibility: hidden;
}

.card--flying {
  position: fixed;
  z-index: 31;
  margin: 0;
  will-change: transform;
}

.card--flying-special {
  box-shadow: 0 0 0 2px #c084fc, 0 0 22px 6px rgba(192, 132, 252, 0.6);
}

.card--flying-good {
  box-shadow: 0 0 0 2px #5fd3a0, 0 0 18px 4px rgba(95, 211, 160, 0.55);
}

.card--flying-lost {
  box-shadow: 0 0 0 2px #f07a84, 0 0 18px 4px rgba(240, 122, 132, 0.55);
}

.deal-ghost {
  position: fixed;
  z-index: 32;
  --cw: calc(var(--tbl-w) * 0.82);
  pointer-events: none;
}

/* Opponent's face-down fan */
.opponent-hand-fan {
  position: absolute;
  inset: 0;
}

.opponent-hand-fan__card {
  position: absolute;
  left: 50%;
  top: 4px;
  margin-left: -15px;
  --cw: 30px;
}

/* Captured pile */
.captured-stack {
  --cw: 34px;
  position: relative;
  width: var(--cw);
  height: calc(var(--cw) * 1.42);
}

.captured-stack--deck.captured-stack--l1::before,
.captured-stack--deck.captured-stack--l2::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #d8dbe3, 0 1px 3px rgba(0, 0, 0, 0.35);
}

.captured-stack--deck.captured-stack--l1::before {
  transform: translate(-2px, 2px) rotate(-4deg);
}

.captured-stack--deck.captured-stack--l2::after {
  transform: translate(2px, 3px) rotate(5deg);
}

.captured-stack .card {
  --cw: inherit;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.captured-stack--held {
  visibility: hidden;
}

.captured-stack--target {
  outline: 3px solid var(--vk-blue);
  outline-offset: 3px;
  border-radius: 6px;
  animation: kh-pulse-blue 1s ease-in-out infinite;
  cursor: pointer;
}

.stack-depth-badge {
  position: absolute;
  left: 50%;
  right: auto;
  top: -32px;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: auto;
  min-height: 22px;
  padding: 1px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #3a3080;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
}

.stack-depth-badge.is-pop {
  animation: khooti-stack-pop 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes khooti-stack-pop {
  from { transform: translateX(-50%) scale(0.72); }
  to { transform: translateX(-50%) scale(1); }
}

.stack-lintar-badge {
  position: absolute;
  left: 50%;
  bottom: -10px;
  z-index: 2;
  transform: translateX(-50%);
  padding: 0 6px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: linear-gradient(180deg, #a98bf0, #6a49c8);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
}

/* ------------------------------------------------------------------ result card */

.overlay {
  z-index: 40;
}

.tally-board {
  width: min(420px, 100%);
  gap: 10px;
}

.tally-hero {
  display: none;
}

.tally-trophy {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 4px 0 var(--ink));
}

.tally-grid {
  isolation: isolate;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  width: 100%;
  padding: 14px 8px 10px;
}

.tally-vs {
  margin-top: 26px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
}

.tally-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.tally-col__face {
  position: relative;
}

.tally-col__face .avatar-slot {
  width: 64px;
  height: 64px;
}

.tally-ready {
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  padding: 0 6px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #1f8a5e;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.tally-col__name {
  margin: 6px 0 0;
  max-width: 130px;
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tally-col__score {
  margin: 0;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
}

.tally-col:first-child .tally-col__score {
  color: var(--gold-text);
}

.tally-col__final {
  display: none;
  margin: 0;
}

.overlay.is-final .tally-col__final {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
}

.tally-col__add {
  margin: 0;
  min-height: 18px;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
}

.tally-col__stage {
  position: relative;
  width: 100%;
  height: 64px;
}

.tally-col__focus {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  z-index: 2;
}

.tally-col__focus .card {
  --cw: 42px;
}

.tally-col__deck {
  position: absolute;
  inset: 0;
}

.tally-col__deck .card {
  position: absolute;
  --cw: 40px;
}

.tally-card--focus {
  animation: kh-pop 0.16s ease-out;
}

.tally-card--focus.is-shelve {
  transform: translate(var(--tally-dx), var(--tally-dy)) scale(var(--tally-sc));
  transition: transform 0.05s linear;
}

.overlay.is-final .tally-col__stage,
.overlay--match .tally-col__stage {
  display: none;
}

.tally-col.is-winner .avatar-slot {
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--gold), 0 0 18px 4px rgba(233, 192, 99, 0.5);
}

.tally-status {
  margin: 0;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
}

.tally-go-count {
  margin: 0;
  color: var(--gold-text);
  font-size: 40px;
  font-weight: 700;
}

.tally-coins {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.tally-coins__row {
  display: flex;
  gap: 10px;
}

.tally-coin {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.tally-coin img {
  width: 18px;
  height: 18px;
}

.tally-coin b {
  color: var(--gold-text);
}

.tally-coins__burst {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
}

.tally-coin-fly {
  position: absolute;
  font-size: 16px;
  animation: kh-coin-fly 0.9s ease-out forwards;
}

@keyframes kh-coin-fly {
  to {
    transform: translate(var(--dx), var(--dy));
    opacity: 0;
  }
}

.tally-points-total {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
}

.tally-levelup {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tally-levelup__lv {
  color: var(--gold-text);
  font-weight: 700;
  font-size: 18px;
}

.tally-board .modal__row {
  margin-top: 4px;
}

.see-cards {
  position: absolute !important;
  inset: 8px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(180deg, #2e2566, #191340);
  overflow-y: auto;
}

.see-cards__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.see-cards__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.see-cards__title {
  margin: 0 0 6px;
  color: var(--gold-text);
  font-weight: 700;
}

.see-cards__cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.see-cards__cards .card {
  --cw: 34px;
}

.tally-fx-vfx {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------------ short / embedded frames */

@media (max-height: 640px) {
  .arena {
    --hand-w: clamp(46px, min(15vw, 10.5vh), 76px);
  }
  .table-block {
    margin-top: 20px;
  }
  .you-row,
  .seat--you {
    height: 70px;
  }
  .seat--you .seat__lv {
    top: 48px;
  }
  .seats,
  .seat {
    height: 66px;
  }
  .lobby-head__stats {
    margin-top: 8px;
  }
  .mode-card {
    min-height: 70px;
  }
  .mode-card__medal {
    width: 50px;
    height: 50px;
  }
  .toon-title {
    font-size: 26px;
  }
}

/* Welcome and lobby stay fixed to the screen. Below this height the lobby's natural
   stack (player card + logo + three mode rows) is taller than the viewport — including
   the portal play popup — so the rows shrink instead of turning the page into a scroller. */
@media (max-height: 560px) {
  .lobby__col {
    gap: 6px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .lobby-head {
    flex: 0 1 auto;
    min-height: 0;
    padding: 8px 12px;
  }
  .lobby-head__avatar {
    width: 46px;
    height: 46px;
  }
  .lobby-head__name {
    font-size: 17px;
  }
  .lobby-head__xp {
    margin: 6px 2px 4px;
  }
  .lobby-head__stats {
    margin-top: 6px;
  }
  .lobby-head__stats dd {
    font-size: 16px;
  }
  .lobby__logo {
    margin: 0;
    font-size: clamp(26px, 5.4vh, 40px);
    flex: 0 0 auto;
  }
  .lobby-modes {
    flex: 1 1 auto;
    min-height: 0;
    gap: 6px;
  }
  .mode-card {
    flex: 1 1 0;
    min-height: 0;
    max-height: 78px;
    padding: 6px 12px 8px 10px;
  }
  .mode-card__medal {
    width: 42px;
    height: 42px;
  }
  .mode-card__title {
    min-width: 0;
    overflow: hidden;
    font-size: 18px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

@media (max-height: 400px) {
  .lobby-head {
    padding: 6px 10px;
  }
  .lobby-head__avatar {
    width: 36px;
    height: 36px;
  }
  .lobby-head__xp {
    margin: 2px 2px 2px;
  }
  .lobby-head__stats {
    margin-top: 4px;
  }
  .lobby-head__stats dd {
    font-size: 14px;
  }
  .lobby-head__stats dt {
    font-size: 11px;
  }
  .lobby__logo {
    font-size: 22px;
  }
  .lobby-modes {
    gap: 4px;
  }
  .mode-card {
    max-height: 64px;
    min-height: 44px;
    padding: 4px 10px 6px;
  }
  .mode-card__medal {
    width: 32px;
    height: 32px;
  }
  .mode-card__title {
    font-size: 16px;
  }
  .mode-card__go {
    width: 28px;
    height: 28px;
  }
  .welcome__col {
    gap: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .welcome__brand .toon-logo {
    font-size: 36px;
  }
  .welcome__tagline {
    font-size: 13px;
    padding: 3px 12px 4px;
  }
  .welcome__panel {
    padding: 10px 14px 12px;
  }
  .welcome__actions {
    gap: 8px;
  }
  .welcome__actions .gem--lg {
    min-height: 44px;
    font-size: 17px;
  }
}

@media (max-height: 330px) {
  .lobby__col {
    gap: 4px;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .lobby__logo {
    font-size: 18px;
  }
  .mode-card {
    min-height: 40px;
    max-height: 52px;
  }
}

/* Portal play window is short. Lobby and arena must fit that frame instead of clipping. */
html.khooti-embed .arena {
  --band: 44px;
  --hand-w: clamp(34px, 8vh, 58px);
  --tbl-w: clamp(28px, 6.4vh, 52px);
}

html.khooti-embed .arena-stage {
  padding: 42px 8px 4px;
  overflow: hidden;
}

html.khooti-embed .seats,
html.khooti-embed .seat {
  height: 92px;
}

html.khooti-embed .seat__chair {
  height: 78px;
  top: -4px;
}

html.khooti-embed .seat__fan {
  top: 42px;
  height: 46px;
}

html.khooti-embed .side-table {
  top: 0;
  transform: scale(0.84);
  transform-origin: top left;
}

html.khooti-embed .you-row,
html.khooti-embed .seat--you {
  height: 54px;
}

html.khooti-embed .seat--you .seat__lv {
  top: 36px;
}

html.khooti-embed .table-block {
  min-height: 0;
  margin: 8px 0 4px;
}

html.khooti-embed .hand-tray {
  margin-top: 12px;
}

html.khooti-embed .hand-tray__turn {
  top: -14px;
}

html.khooti-embed .lobby__col,
html.khooti-embed .welcome__col {
  gap: 6px;
  padding-top: 8px;
  padding-bottom: 8px;
  overflow: hidden;
}

html.khooti-embed .lobby-head {
  flex: 0 1 auto;
  min-height: 0;
  padding: 8px 12px;
}

html.khooti-embed .lobby-head__avatar {
  width: 44px;
  height: 44px;
}

html.khooti-embed .lobby-head__name {
  font-size: 16px;
}

html.khooti-embed .lobby-head__xp {
  margin: 6px 2px 4px;
}

html.khooti-embed .lobby-head__stats {
  margin-top: 6px;
}

html.khooti-embed .lobby-head__stats dd {
  font-size: 15px;
}

html.khooti-embed .lobby__logo {
  margin: 0;
  flex: 0 0 auto;
  font-size: clamp(22px, 5.6vh, 36px);
}

html.khooti-embed .lobby-modes {
  flex: 1 1 auto;
  min-height: 0;
  gap: 6px;
}

html.khooti-embed .mode-card {
  flex: 1 1 0;
  min-height: 0;
  max-height: 78px;
  padding: 6px 12px 8px 10px;
}

html.khooti-embed .mode-card__medal {
  width: 40px;
  height: 40px;
}

html.khooti-embed .mode-card__title {
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
