:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-soft: #eef2f7;
  --surface: #ffffff;
  --surface-strong: #f9fafc;
  --surface-tint: #fff2f2;
  --line: #dce2eb;
  --line-strong: #c5ceda;
  --text: #182033;
  --text-soft: #3f4a5e;
  --muted: #6d7789;
  --accent: #c63d44;
  --accent-hover: #aa3037;
  --accent-soft: #fbe8e9;
  --accent-strong: #8f242c;
  --danger: #b52f38;
  --danger-soft: #fce9eb;
  --success: #27735a;
  --success-soft: #e9f5f0;
  --info: #476889;
  --info-soft: #eaf0f7;
  --shadow-sm: 0 8px 24px rgba(54, 70, 96, .08);
  --shadow: 0 22px 65px rgba(49, 65, 91, .14);
  --header-height: 72px;
  --card-radius: 16px;
  --control-radius: 10px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 2% 4%, rgba(190, 204, 224, .34), transparent 26rem),
    linear-gradient(180deg, #f8f9fc 0%, var(--bg) 72%);
  font-size: 15px;
  line-height: 1.6;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.16;
  text-wrap: balance;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(2rem, 6vw, 4.5rem);
  letter-spacing: -.045em;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.4rem, 3vw, 2.15rem);
  letter-spacing: -.025em;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.04rem;
}

::selection {
  color: #ffffff;
  background: var(--accent);
}

:focus-visible {
  outline: 3px solid rgba(198, 61, 68, .36);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 140;
  padding: 8px 12px;
  border-radius: var(--control-radius);
  color: #ffffff;
  background: var(--accent);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

.app-shell {
  min-height: 100dvh;
}

.page {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100dvh - var(--header-height));
  margin: 0 auto;
  padding: 44px 0 80px;
}

.page-wide {
  width: min(1380px, calc(100% - 32px));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 70;
  height: var(--header-height);
  border-bottom: 1px solid rgba(213, 221, 232, .9);
  background: rgba(250, 251, 253, .9);
  backdrop-filter: blur(18px) saturate(125%);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
}

.header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  width: min(1380px, calc(100% - 32px));
  height: 100%;
  margin: 0 auto;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  gap: 11px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: .01em;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--accent-strong);
  border-radius: 11px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .16), 0 5px 14px rgba(198, 61, 68, .2);
  font-size: 1rem;
  font-weight: 850;
}

.brand-name {
  font-size: .96rem;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 4px;
}

.nav-link {
  min-height: 40px;
  padding: 9px 13px;
  border-radius: var(--control-radius);
  color: var(--muted);
  font-size: .9rem;
  font-weight: 650;
  white-space: nowrap;
  transition: color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}

.nav-link:hover {
  color: var(--text);
  background: #edf1f6;
}

.nav-link[aria-current="page"] {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.points-chip {
  padding: 4px 9px;
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

.mobile-nav-toggle,
.mobile-nav {
  display: none;
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  cursor: pointer;
  font-weight: 750;
  line-height: 1.1;
  white-space: nowrap;
  transition: transform .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease), opacity .18s var(--ease);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(.985);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.btn-primary {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(198, 61, 68, .2);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  box-shadow: 0 10px 24px rgba(170, 48, 55, .23);
}

.btn-secondary {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(53, 69, 94, .04);
}

.btn-secondary:hover:not(:disabled) {
  border-color: #9ca8b8;
  background: #f8f9fb;
}

.btn-quiet {
  min-height: 38px;
  padding: 8px 11px;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.btn-quiet:hover:not(:disabled) {
  color: var(--text);
  background: #edf1f6;
}

.btn-danger {
  border-color: #e4b4b8;
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: #f8dadd;
}

.btn-sm {
  min-height: 36px;
  padding: 8px 13px;
  font-size: .86rem;
}

.mobile-nav-toggle {
  display: none;
}

.icon-text-btn {
  gap: 8px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field label,
.field-label {
  color: var(--text-soft);
  font-size: .86rem;
  font-weight: 720;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
}

.field-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: .8rem;
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  outline: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 1px 2px rgba(55, 70, 94, .03);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: #7e8898;
  opacity: 1;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(198, 61, 68, .12);
}

.input:disabled {
  color: #7b8492;
  background: #f0f3f7;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(181, 47, 56, .1);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--text-soft);
  font-size: .88rem;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 30px;
  gap: 24px;
}

.page-heading h1 {
  margin-bottom: 7px;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.page-heading p {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 11px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-pad {
  padding: clamp(20px, 3vw, 30px);
}

.muted {
  color: var(--muted);
}

.gold {
  color: var(--accent);
}

.mono,
.number {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.divider {
  height: 1px;
  margin: 20px 0;
  border: 0;
  background: var(--line);
}

.app-boot {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  background: var(--bg);
}

.app-boot .brand-mark {
  width: 54px;
  height: 58px;
  font-size: 1.4rem;
}

.app-boot p {
  margin: 0;
}

/* Home */
.home-page {
  display: grid;
  min-height: calc(100dvh - var(--header-height));
  align-content: center;
  padding-top: 24px;
  padding-bottom: 28px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(390px, .98fr);
  min-height: min(660px, calc(100dvh - var(--header-height) - 124px));
  align-items: center;
  gap: clamp(42px, 7vw, 100px);
}

.hero-copy {
  max-width: 650px;
}

.hero-copy h1 {
  max-width: 11ch;
  margin-bottom: 22px;
  color: var(--text);
  font-size: clamp(3.4rem, 6.6vw, 5.7rem);
  letter-spacing: -.065em;
}

.hero-copy h1 span {
  display: block;
  color: var(--accent);
}

.hero-copy > p:not(.eyebrow) {
  max-width: 42ch;
  margin-bottom: 28px;
  color: var(--text-soft);
  font-size: clamp(1rem, 1.5vw, 1.14rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 720px;
  margin-top: 12px;
  border-top: 1px solid var(--line-strong);
}

.proof-item {
  position: relative;
  padding: 18px 28px 0 0;
}

.proof-item:not(:first-child) {
  padding-left: 28px;
}

.proof-item:not(:first-child)::before {
  position: absolute;
  top: 20px;
  bottom: 0;
  left: 0;
  width: 1px;
  content: "";
  background: var(--line);
}

.proof-item strong,
.proof-item span {
  display: block;
}

.proof-item strong {
  color: var(--text);
  font-size: .91rem;
}

.proof-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: .76rem;
}

.hero-visual {
  position: relative;
  min-height: min(58dvh, 570px);
  isolation: isolate;
}

.table-halo {
  position: absolute;
  inset: 8% 3% 8% 5%;
  z-index: -1;
  overflow: hidden;
  border: 1px solid #d5dde8;
  border-radius: 34% 55% 38% 52%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .92), rgba(231, 236, 244, .92)),
    #e9edf4;
  box-shadow: 0 35px 70px rgba(64, 80, 107, .15), inset 0 0 0 10px rgba(255, 255, 255, .46);
  transform: rotate(-4deg);
}

.table-halo::after {
  position: absolute;
  right: -10%;
  bottom: -26%;
  width: 70%;
  height: 58%;
  border-radius: 50%;
  content: "";
  background: rgba(198, 61, 68, .075);
}

.hero-cards {
  position: absolute;
  top: 48%;
  left: 50%;
  width: 260px;
  height: 236px;
  transform: translate(-50%, -50%);
}

.playing-card {
  display: flex;
  width: 88px;
  height: 126px;
  flex-direction: column;
  justify-content: space-between;
  padding: 9px 10px;
  border: 1px solid #d9dee6;
  border-radius: 10px;
  color: #1f2735;
  background: #fffefa;
  box-shadow: 0 18px 32px rgba(54, 66, 87, .2), inset 0 0 0 2px rgba(82, 96, 117, .04);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 760;
  line-height: 1;
  transform-origin: 50% 115%;
}

.hero-cards .playing-card {
  position: absolute;
  bottom: 18px;
  left: 78px;
  width: 110px;
  height: 158px;
  font-size: 1.35rem;
}

.hero-cards .playing-card:nth-child(1) {
  transform: rotate(-23deg) translateX(-44px);
}

.hero-cards .playing-card:nth-child(2) {
  z-index: 2;
  transform: rotate(-1deg) translateY(-20px);
}

.hero-cards .playing-card:nth-child(3) {
  transform: rotate(20deg) translateX(44px);
}

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

.card-suit-large {
  align-self: center;
  font-size: 2.25em;
}

.floating-chip {
  position: absolute;
  display: grid;
  min-width: 54px;
  height: 48px;
  padding: 0 12px;
  place-items: center;
  border: 1px solid #d9c4c6;
  border-radius: 14px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 12px 26px rgba(57, 70, 92, .13);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .82rem;
  font-weight: 800;
}

.floating-chip::after {
  margin-left: 4px;
  color: var(--muted);
  content: "分";
  font-size: .62rem;
  font-weight: 650;
}

.floating-chip.one { top: 14%; right: 7%; transform: rotate(7deg); }
.floating-chip.two { right: 1%; bottom: 17%; min-width: 48px; height: 44px; transform: rotate(-8deg); }
.floating-chip.three { bottom: 9%; left: 11%; min-width: 50px; height: 46px; transform: rotate(10deg); }

/* Authentication */
.auth-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(360px, .7fr);
  min-height: calc(100dvh - var(--header-height) - 88px);
  align-items: center;
  justify-content: center;
  gap: clamp(40px, 8vw, 120px);
}

.auth-layout::before {
  position: absolute;
  top: 12%;
  bottom: 12%;
  left: 44%;
  width: 1px;
  content: "";
  background: var(--line);
}

.auth-intro {
  max-width: 530px;
}

.auth-intro h1 {
  max-width: 10ch;
  font-size: clamp(2.6rem, 5vw, 4.6rem);
}

.auth-intro p {
  max-width: 43ch;
  color: var(--text-soft);
}

.auth-note {
  display: grid;
  max-width: 440px;
  margin-top: 32px;
  padding: 18px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  color: var(--text-soft);
  background: var(--accent-soft);
  gap: 5px;
}

.auth-note strong {
  color: var(--accent-strong);
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  justify-self: end;
  padding: clamp(26px, 4vw, 40px);
  border-color: #d5dce6;
  box-shadow: var(--shadow);
}

.auth-card::before {
  position: absolute;
  top: 0;
  right: 28px;
  left: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  content: "";
  background: var(--accent);
}

.auth-card h2 {
  margin-bottom: 6px;
}

.auth-card > p {
  margin-bottom: 26px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 15px;
}

.auth-form .btn-primary {
  width: 100%;
  margin-top: 5px;
}

.form-switch {
  margin: 20px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: .87rem;
}

.form-switch a {
  color: var(--accent);
  font-weight: 720;
}

/* Lobby */
.lobby-toolbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto auto;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

.segmented {
  display: inline-flex;
  min-width: max-content;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #e9edf3;
}

.segment-btn {
  min-height: 38px;
  padding: 7px 13px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  font-size: .84rem;
  font-weight: 700;
  transition: color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}

.segment-btn:hover {
  color: var(--text);
}

.segment-btn.active {
  color: var(--accent-strong);
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(53, 69, 94, .09);
}

.join-bar {
  display: flex;
  gap: 8px;
}

.join-bar .input {
  width: 158px;
  text-transform: uppercase;
}

.room-list-shell {
  overflow: hidden;
}

.room-list-head,
.room-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.45fr) 110px 100px 110px 120px;
  align-items: center;
  gap: 14px;
}

.room-list-head {
  padding: 13px 20px;
  color: var(--muted);
  background: #f0f3f7;
  font-size: .74rem;
  font-weight: 750;
  letter-spacing: .04em;
}

.room-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-row {
  min-height: 80px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  transition: background .18s var(--ease), transform .18s var(--ease);
}

.room-row:hover {
  background: #fafbfc;
}

.room-name {
  min-width: 0;
}

.room-name strong,
.room-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-name small {
  margin-top: 3px;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .72rem;
}

.status-badge,
.tag {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-soft);
  background: #f4f6f9;
  font-size: .72rem;
  white-space: nowrap;
}

.status-badge.waiting,
.tag.success {
  border-color: #aed8c9;
  color: #1d654e;
  background: var(--success-soft);
}

.status-badge.playing {
  border-color: #d8b5b8;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.tag.danger {
  border-color: #e4b4b8;
  color: var(--danger);
  background: var(--danger-soft);
}

.tag.muted-tag {
  color: var(--muted);
}

.room-count,
.room-bet {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.room-row-actions {
  display: flex;
  justify-content: flex-end;
}

.lobby-footnote {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 4px;
  color: var(--muted);
  font-size: .8rem;
}

.empty-state,
.error-state {
  display: grid;
  min-height: 280px;
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
}

.empty-state-mark {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
  place-items: center;
  border: 1px solid #ddbec1;
  border-radius: 18px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 1.45rem;
  font-weight: 800;
  transform: rotate(-3deg);
}

.empty-state h2,
.error-state h2 {
  margin-bottom: 7px;
  font-size: 1.26rem;
}

.empty-state p,
.error-state p {
  max-width: 38ch;
  margin-bottom: 18px;
  color: var(--muted);
}

.skeleton-list {
  display: grid;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 1.4fr .6fr .5fr .7fr;
  min-height: 80px;
  align-items: center;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  gap: 28px;
}

.skeleton {
  height: 13px;
  border-radius: 6px;
  background: #e6eaf0;
}

.skeleton.short {
  width: 56%;
}

/* Dialogs */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 32, 51, .38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal {
  width: min(570px, 100%);
  max-height: min(820px, calc(100dvh - 36px));
  overflow-y: auto;
  border: 1px solid #d4dbe5;
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 23px 25px 14px;
  border-top: 3px solid var(--accent);
  gap: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.modal-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .84rem;
}

.modal-body {
  display: grid;
  padding: 8px 25px 25px;
  gap: 15px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 5px;
  gap: 9px;
}

.rule-option {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  gap: 20px;
}

.rule-option:first-child {
  border-top: 0;
}

.rule-option strong,
.rule-option span {
  display: block;
}

.rule-option span {
  margin-top: 2px;
  color: var(--muted);
  font-size: .79rem;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #e6eaf0;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  content: "";
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(49, 63, 85, .2);
  transition: transform .2s var(--ease), background .2s var(--ease);
}

.switch input:checked + .switch-track {
  border-color: var(--accent);
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid rgba(198, 61, 68, .3);
  outline-offset: 3px;
}

.connection-banner {
  position: sticky;
  top: var(--header-height);
  z-index: 62;
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-bottom: 1px solid #c8d5e4;
  color: #314d6b;
  background: #e7eef7;
  font-size: .82rem;
  text-align: center;
}

.connection-banner.error {
  border-color: #e3b3b7;
  color: var(--danger);
  background: var(--danger-soft);
}

/* Game room */
.room-page {
  padding-top: 18px;
}

.room-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 14px;
  gap: 14px;
}

.room-title {
  min-width: 0;
}

.room-title h1 {
  overflow: hidden;
  margin: 0 0 2px;
  font-size: 1.12rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-title p {
  margin: 0;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .72rem;
}

.game-status {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-self: center;
  padding: 7px 13px;
  border: 1px solid #d8b7ba;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: .8rem;
  font-weight: 720;
}

.room-top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.game-stage {
  position: relative;
  height: clamp(650px, calc(100dvh - 162px), 770px);
  min-height: 650px;
}

.game-table {
  position: absolute;
  inset: 42px 6% 150px;
  overflow: hidden;
  border: 1px solid #cad4e1;
  border-radius: 42%;
  background:
    radial-gradient(circle at 50% 46%, #f7f9fc 0%, #e9eef5 68%, #dfe6ef 100%);
  box-shadow:
    0 24px 60px rgba(55, 70, 96, .13),
    inset 0 0 0 10px rgba(255, 255, 255, .58),
    inset 0 0 0 12px rgba(138, 153, 174, .14);
}

.game-table::before {
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(151, 164, 183, .33);
  border-radius: inherit;
  content: "";
}

.game-table::after {
  position: absolute;
  top: 18%;
  right: 20%;
  width: 90px;
  height: 90px;
  border: 1px solid rgba(198, 61, 68, .09);
  border-radius: 22px;
  content: "";
  transform: rotate(17deg);
}

.table-center {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 4;
  display: grid;
  width: min(270px, 40%);
  justify-items: center;
  padding: 14px 18px;
  border: 1px solid rgba(199, 208, 220, .9);
  border-radius: 14px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 10px 26px rgba(53, 69, 94, .08);
  text-align: center;
  transform: translate(-50%, -50%);
}

.pot-label {
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .06em;
}

.pot-value {
  margin: 2px 0 5px;
  color: var(--accent);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 820;
  line-height: 1.1;
}

.round-meta {
  color: var(--text-soft);
  font-size: .73rem;
}

.turn-timer {
  position: absolute;
  top: calc(48% + 83px);
  left: 50%;
  z-index: 4;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 50%;
  color: var(--text);
  background: conic-gradient(var(--accent) var(--timer-progress, 100%), #d9e0e9 0);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .84rem;
  font-weight: 760;
  transform: translateX(-50%);
}

.turn-timer::after {
  position: absolute;
  inset: 4px;
  z-index: -1;
  border-radius: 50%;
  content: "";
  background: #ffffff;
}

.player-seat {
  position: absolute;
  z-index: 8;
  width: clamp(136px, 15vw, 184px);
  transform: translate(-50%, -50%);
}

.seat-slot-0 { left: 50%; top: calc(100% - 112px); }
.seat-slot-1 { left: 13%; top: 67%; }
.seat-slot-2 { left: 13%; top: 27%; }
.seat-slot-3 { left: 50%; top: 72px; }
.seat-slot-4 { left: 87%; top: 27%; }
.seat-slot-5 { left: 87%; top: 67%; }

.player-box {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  min-height: 64px;
  padding: 9px 10px;
  border: 1px solid #d4dce6;
  border-radius: 13px;
  gap: 9px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 26px rgba(53, 69, 94, .12);
}

.player-seat.current .player-box {
  border-color: var(--accent);
  box-shadow: 0 11px 28px rgba(53, 69, 94, .13), 0 0 0 3px rgba(198, 61, 68, .11);
}

.player-seat.self .player-box {
  border-color: #d5b2b5;
  background: #fff7f7;
}

.player-avatar {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #ddbdc0;
  border-radius: 12px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: .72rem;
  font-weight: 800;
}

.online-state {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--success);
}

.online-state.offline {
  background: #8792a1;
}

.player-info {
  min-width: 0;
}

.player-name {
  overflow: hidden;
  color: var(--text);
  font-size: .8rem;
  font-weight: 740;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-points {
  overflow: hidden;
  color: var(--accent-strong);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-state-line {
  display: flex;
  min-height: 19px;
  margin-top: 3px;
  align-items: center;
  gap: 5px;
}

.player-state-line .tag {
  padding: 1px 6px;
  font-size: .62rem;
}

.contribution {
  position: absolute;
  top: -16px;
  right: 8px;
  padding: 2px 7px;
  border: 1px solid #d9b7ba;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(53, 69, 94, .08);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .65rem;
}

.seat-cards {
  position: absolute;
  top: 50%;
  width: 54px;
  height: 31px;
  transform: translateY(-50%);
}

.seat-slot-1 .seat-cards,
.seat-slot-2 .seat-cards { right: -59px; }
.seat-slot-4 .seat-cards,
.seat-slot-5 .seat-cards { left: -59px; }
.seat-slot-0 .seat-cards { top: -36px; left: 50%; transform: translateX(-50%); }
.seat-slot-3 .seat-cards { top: 70px; left: 50%; transform: translateX(-50%); }

.mini-card {
  position: absolute;
  width: 25px;
  height: 34px;
  border: 1px solid #c7a4a7;
  border-radius: 5px;
  background:
    linear-gradient(135deg, transparent 44%, rgba(255, 255, 255, .28) 44%, rgba(255, 255, 255, .28) 56%, transparent 56%),
    var(--accent);
  box-shadow: 0 4px 8px rgba(57, 69, 91, .14);
}

.mini-card:nth-child(1) { left: 2px; transform: rotate(-8deg); }
.mini-card:nth-child(2) { left: 15px; z-index: 2; }
.mini-card:nth-child(3) { left: 28px; transform: rotate(8deg); }

.my-hand-area {
  position: absolute;
  bottom: 164px;
  left: 50%;
  z-index: 10;
  display: grid;
  justify-items: center;
  transform: translateX(-50%);
}

.my-hand-label {
  margin-bottom: 7px;
  padding: 3px 8px;
  border-radius: 7px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, .86);
  font-size: .68rem;
}

.my-cards {
  display: flex;
  min-height: 101px;
  align-items: flex-end;
  padding: 0 18px;
}

.my-cards .playing-card {
  width: 68px;
  height: 98px;
  margin-left: -11px;
  padding: 7px;
  font-size: 1rem;
  transition: transform .2s var(--ease);
}

.my-cards .playing-card:first-child {
  margin-left: 0;
  transform: rotate(-5deg) translateY(2px);
}

.my-cards .playing-card:nth-child(2) {
  z-index: 2;
  transform: translateY(-5px);
}

.my-cards .playing-card:nth-child(3) {
  transform: rotate(5deg) translateY(2px);
}

.card-back {
  justify-content: center;
  align-items: center;
  border-color: #b9858a;
  color: #ffffff;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, .1) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .1) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .1) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .1) 75%),
    var(--accent);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
  box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 4px rgba(255, 255, 255, .44), 0 12px 22px rgba(64, 76, 97, .18);
}

.card-back-mark {
  display: grid;
  width: 31px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 6px;
  background: rgba(143, 36, 44, .18);
  font-family: inherit;
  font-size: .84rem;
  font-weight: 800;
}

.action-dock {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid #d3dbe5;
  border-radius: var(--card-radius);
  gap: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 -10px 34px rgba(53, 69, 94, .09);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.action-dock .btn {
  min-width: 84px;
}

.action-dock .primary-action {
  min-width: 114px;
}

.action-message {
  color: var(--muted);
  text-align: center;
}

.table-notice {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 12;
  max-width: min(520px, 78%);
  padding: 7px 13px;
  border: 1px solid #d0d8e3;
  border-radius: 999px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 6px 18px rgba(53, 69, 94, .07);
  font-size: .76rem;
  text-align: center;
  transform: translateX(-50%);
}

.waiting-room {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .52fr);
  min-height: calc(100dvh - 166px);
  gap: 18px;
}

.waiting-table {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  background: #f8fafc;
}

.waiting-table .game-table {
  inset: 48px 5% 48px;
}

.waiting-table .player-seat {
  width: clamp(138px, 16vw, 184px);
}

.waiting-table .seat-slot-0 {
  top: calc(100% - 64px);
}

.waiting-center {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  width: min(330px, 48%);
  padding: 20px;
  border: 1px solid rgba(207, 216, 227, .9);
  border-radius: 15px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 12px 28px rgba(53, 69, 94, .08);
  text-align: center;
  transform: translate(-50%, -50%);
}

.waiting-center h2 {
  margin-bottom: 5px;
  font-size: clamp(1.3rem, 3vw, 2rem);
}

.waiting-center p {
  margin-bottom: 17px;
  color: var(--muted);
  font-size: .82rem;
}

.room-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
}

.room-chat-layer {
  --chat-safe-bottom: 0px;
}

.room-chat-launcher {
  position: fixed;
  top: calc(var(--header-height) + 118px);
  right: 0;
  z-index: 84;
  display: grid;
  width: 62px;
  min-height: 92px;
  place-items: center;
  padding: 13px 8px;
  border: 1px solid #d3dbe5;
  border-right: 0;
  border-radius: 15px 0 0 15px;
  color: var(--text);
  background: rgba(255, 255, 255, .96);
  box-shadow: -10px 14px 34px rgba(53, 69, 94, .13);
  cursor: pointer;
  gap: 7px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}

.room-chat-launcher:hover {
  box-shadow: -14px 18px 38px rgba(53, 69, 94, .17);
  transform: translateX(-3px);
}

.room-chat-launcher-title {
  font-size: .82rem;
  font-weight: 800;
}

.room-chat-launcher-preview {
  display: none;
}

.chat-unread-badge {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .62rem;
  font-weight: 800;
  line-height: 1;
}

.room-chat-top-trigger .chat-unread-badge {
  margin-left: 4px;
}

.room-chat-backdrop {
  display: none;
}

.room-chat-panel {
  display: grid;
  min-width: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.room-chat-drawer {
  position: fixed;
  top: calc(var(--header-height) + 16px);
  right: 16px;
  bottom: 16px;
  z-index: 85;
  width: min(370px, calc(100vw - 32px));
  min-height: 420px;
  opacity: 0;
  box-shadow: -18px 24px 64px rgba(49, 65, 91, .2);
  pointer-events: none;
  transform: translateX(calc(100% + 28px));
  transition: opacity .2s var(--ease), transform .28s var(--ease);
}

.room-chat-layer.game-in-progress .room-chat-drawer {
  bottom: 96px;
}

.room-chat-layer.open .room-chat-drawer {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.room-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 17px 13px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}

.room-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.room-chat-close {
  min-width: 54px;
}

.room-chat-header h2 {
  margin: 0;
  font-size: 1rem;
}

.room-chat-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .68rem;
}

.chat-connection {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 700;
  gap: 5px;
}

.chat-connection::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca6b4;
  content: "";
}

.chat-connection.online {
  color: var(--success);
}

.chat-connection.online::before {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(40, 136, 97, .11);
}

.room-chat-log {
  min-height: 0;
  margin: 0;
  padding: 13px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #f8fafc, #ffffff 56%);
  list-style: none;
  scrollbar-color: #c7d0dc transparent;
  scrollbar-width: thin;
}

.chat-empty {
  display: grid;
  min-height: 100%;
  place-content: center;
  color: var(--muted);
  font-size: .75rem;
  text-align: center;
  gap: 4px;
}

.chat-empty strong {
  color: var(--text-soft);
  font-size: .82rem;
}

.chat-message {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  margin-bottom: 12px;
  gap: 8px;
}

.chat-message:last-child {
  margin-bottom: 0;
}

.chat-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid #d6dee8;
  border-radius: 9px;
  color: #516176;
  background: #edf2f7;
  font-size: .6rem;
  font-weight: 800;
}

.chat-message.mine .chat-avatar {
  border-color: #e3b7bb;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.chat-message-body {
  min-width: 0;
}

.chat-message-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 3px;
  gap: 8px;
}

.chat-message-meta strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message-meta time {
  flex: 0 0 auto;
  color: #909bab;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .58rem;
}

.chat-message-body p {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #dce3ec;
  border-radius: 4px 12px 12px;
  color: var(--text);
  background: #ffffff;
  font-size: .77rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.chat-message.mine .chat-message-body p {
  border-color: #e7c5c8;
  color: #77262d;
  background: #fff3f4;
}

.room-chat-form {
  padding: 11px 12px 10px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.room-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.room-chat-compose input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  outline: 0;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: .78rem;
}

.room-chat-compose input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198, 61, 68, .11);
}

.room-chat-compose input:disabled {
  color: var(--muted);
  background: #f1f4f8;
  cursor: not-allowed;
}

.room-chat-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: .58rem;
  gap: 8px;
}

.room-chat-help .over-limit {
  color: var(--danger);
  font-weight: 750;
}

.room-info-list {
  display: grid;
  margin: 0;
  gap: 0;
}

.room-info-list div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  gap: 16px;
}

.room-info-list div:first-child {
  border-top: 0;
}

.room-info-list dt {
  color: var(--muted);
  font-size: .8rem;
}

.room-info-list dd {
  margin: 0;
  color: var(--text-soft);
  font-size: .84rem;
  font-weight: 700;
  text-align: right;
}

.room-member-list {
  display: grid;
  margin-top: 15px;
  gap: 8px;
}

.room-member-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  min-height: 54px;
  padding: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  gap: 9px;
  background: var(--surface-soft);
}

.room-member-row .player-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.room-member-row .btn {
  min-width: 58px;
  min-height: 44px;
}

.room-member-name {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.room-member-name strong,
.room-member-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-member-name strong {
  color: var(--text);
  font-size: .82rem;
}

.room-member-name small {
  color: var(--muted);
  font-size: .7rem;
}

.sidebar-actions {
  display: grid;
  gap: 9px;
}

.sidebar-actions .btn {
  width: 100%;
}

.result-panel {
  position: fixed;
  right: 18px;
  bottom: 20px;
  z-index: 82;
  width: min(500px, calc(100% - 36px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 19px;
  border: 1px solid #d9b9bc;
  border-top: 3px solid var(--accent);
  border-radius: var(--card-radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.result-panel h2 {
  margin-bottom: 4px;
  font-size: 1.15rem;
}

.result-panel > p {
  margin-bottom: 13px;
  color: var(--muted);
  font-size: .8rem;
}

.result-players {
  display: grid;
  gap: 7px;
}

.result-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  gap: 12px;
}

.result-player strong {
  font-size: .86rem;
}

.result-player .positive { color: var(--success); }
.result-player .negative { color: var(--danger); }

.result-revealed-hands {
  display: grid;
  margin-bottom: 14px;
  gap: 8px;
}

.result-hand-row {
  display: grid;
  grid-template-columns: minmax(112px, .65fr) minmax(0, 1fr);
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
  gap: 12px;
}

.result-hand-row.winner {
  border-color: #b9d8c8;
  background: #f4faf7;
}

.result-hand-player {
  display: grid;
  min-width: 0;
  justify-items: start;
  gap: 5px;
}

.result-hand-player strong {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-list {
  display: grid;
  gap: 8px;
}

.compare-target {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  color: var(--text);
  background: #ffffff;
  gap: 10px;
  text-align: left;
}

.compare-target:hover {
  border-color: #d2a8ac;
  background: #fff8f8;
}

.raise-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
}

.raise-option {
  display: grid;
  min-height: 64px;
  place-content: center;
  border: 1px solid #d9b9bc;
  border-radius: 12px;
  cursor: pointer;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-weight: 800;
}

.raise-option:hover {
  border-color: var(--accent);
  background: #f8dadd;
}

/* Profile and history */
.profile-grid {
  display: grid;
  grid-template-columns: minmax(270px, .5fr) minmax(0, 1fr);
  gap: 18px;
}

.profile-summary {
  align-self: start;
  text-align: center;
}

.profile-avatar {
  display: grid;
  width: 88px;
  height: 88px;
  margin: 0 auto 17px;
  place-items: center;
  border: 1px solid #d6aeb2;
  border-radius: 24px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, .45);
  font-size: 1.42rem;
  font-weight: 820;
  transform: rotate(-3deg);
}

.profile-summary h2 {
  margin-bottom: 3px;
}

.profile-summary .username {
  color: var(--muted);
  font-size: .82rem;
}

.points-balance {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #e0c1c4;
  border-radius: 14px;
  background: var(--accent-soft);
}

.points-balance span,
.points-balance strong {
  display: block;
}

.points-balance span {
  color: var(--muted);
  font-size: .76rem;
}

.points-balance strong {
  color: var(--accent-strong);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 1.8rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 17px;
  border-top: 1px solid var(--line);
}

.stat-item {
  padding: 13px 6px 2px;
}

.stat-item + .stat-item {
  border-left: 1px solid var(--line);
}

.stat-item strong,
.stat-item span {
  display: block;
}

.stat-item strong {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 1rem;
}

.stat-item span {
  color: var(--muted);
  font-size: .7rem;
}

.profile-form {
  display: grid;
  align-content: start;
  gap: 17px;
}

.profile-form header {
  margin-bottom: 4px;
}

.profile-form header p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
}

.profile-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
  gap: 10px;
}

.profile-link {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-soft);
  background: #fafbfc;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}

.profile-link:hover {
  border-color: #d4aeb1;
  background: #fff7f7;
  transform: translateY(-1px);
}

.profile-link strong,
.profile-link span {
  display: block;
}

.profile-link span {
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
}

.history-tabs {
  margin-bottom: 18px;
}

.data-panel {
  overflow: hidden;
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 14px 17px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.data-table thead th {
  border-top: 0;
  color: var(--muted);
  background: #f0f3f7;
  font-size: .74rem;
  font-weight: 750;
  letter-spacing: .04em;
  white-space: nowrap;
}

.data-table tbody td {
  color: var(--text-soft);
  font-size: .84rem;
}

.data-table tbody tr:hover td {
  background: #fafbfc;
}

.data-table .positive { color: var(--success); font-weight: 750; }
.data-table .negative { color: var(--danger); font-weight: 750; }

.history-table {
  min-width: 850px;
}

.history-table .history-time {
  width: 120px;
  white-space: nowrap;
}

.history-table .history-hand-cell {
  min-width: 220px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.history-table .history-detail-action {
  width: 130px;
  text-align: right;
}

.history-round-info {
  display: grid;
  min-width: 120px;
  justify-items: start;
  gap: 7px;
}

.history-round-info strong {
  color: var(--text);
  font-size: .86rem;
}

.revealed-hand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.revealed-hand-cards {
  display: flex;
  min-width: 112px;
  min-height: 61px;
  align-items: flex-end;
  padding: 2px 0 2px 4px;
}

.revealed-hand-cards .playing-card {
  width: 42px;
  height: 59px;
  flex: 0 0 auto;
  padding: 5px 6px;
  border-radius: 7px;
  box-shadow: 0 7px 14px rgba(54, 66, 87, .13), inset 0 0 0 1px rgba(82, 96, 117, .03);
  font-size: .68rem;
  transform: none;
  transform-origin: center;
}

.revealed-hand-cards .playing-card + .playing-card {
  margin-left: -7px;
}

.revealed-hand-cards .playing-card:nth-child(2) {
  transform: translateY(-2px);
}

.revealed-hand-cards .card-suit-large {
  font-size: 1.7em;
}

.revealed-hand-type {
  color: var(--accent-strong);
  font-size: .8rem;
  white-space: nowrap;
}

.revealed-hand-empty {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--muted);
  font-size: .76rem;
}

.revealed-hand-result {
  justify-content: space-between;
  gap: 7px;
}

.revealed-hand-result .revealed-hand-cards {
  min-width: 89px;
  min-height: 48px;
}

.revealed-hand-result .playing-card {
  width: 34px;
  height: 47px;
  padding: 4px;
  border-radius: 6px;
  font-size: .58rem;
}

.revealed-hand-result .playing-card + .playing-card {
  margin-left: -5px;
}

.revealed-hand-result .revealed-hand-type {
  font-size: .72rem;
}

.history-mobile-item .revealed-hand-history {
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid #e1e5eb;
  border-radius: 12px;
  background: #fafbfc;
}

.mobile-history-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-detail-button {
  width: 100%;
}

.history-detail-modal {
  width: min(780px, 100%);
}

.history-detail-body {
  gap: 17px;
}

.history-detail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid #dfc4c7;
  border-radius: 12px;
  color: var(--muted);
  background: var(--accent-soft);
  font-size: .8rem;
  gap: 16px;
}

.history-detail-summary strong {
  color: var(--accent-strong);
}

.history-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.history-player-card {
  display: grid;
  min-width: 0;
  padding: 14px;
  border: 1px solid #dce2ea;
  border-radius: 14px;
  background: #fbfcfd;
  box-shadow: 0 8px 20px rgba(54, 70, 96, .06);
  gap: 12px;
}

.history-player-card.winner {
  border-color: #b9d8c8;
  background: #f7fbf9;
  box-shadow: inset 3px 0 0 var(--success), 0 8px 20px rgba(54, 70, 96, .06);
}

.history-player-head {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.history-player-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #dfbdc1;
  border-radius: 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: .72rem;
  font-weight: 800;
}

.history-player-name {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.history-player-name strong {
  overflow: hidden;
  color: var(--text);
  font-size: .88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-player-name small {
  color: var(--muted);
  font-size: .7rem;
}

.revealed-hand-detail {
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 11px;
  background: #f1f4f7;
}

.revealed-hand-detail .revealed-hand-cards {
  min-width: 125px;
  min-height: 69px;
}

.revealed-hand-detail .playing-card {
  width: 48px;
  height: 67px;
  font-size: .72rem;
}

.revealed-hand-detail .playing-card + .playing-card {
  margin-left: -8px;
}

.history-player-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: .73rem;
  gap: 10px;
}

.history-player-meta .positive { color: var(--success); }
.history-player-meta .negative { color: var(--danger); }

.history-detail-state {
  display: grid;
  min-height: 250px;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
  gap: 10px;
}

.history-detail-state > p {
  max-width: 42ch;
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.65;
}

.history-detail-state.error {
  color: var(--danger);
}

.history-detail-skeleton {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  width: min(100%, 480px);
  margin-top: 12px;
  gap: 10px;
}

.history-detail-skeleton .skeleton {
  height: 82px;
  border-radius: 12px;
}

.mobile-data-list {
  display: none;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
}

.pagination-actions {
  display: flex;
  gap: 7px;
}

/* Rules */
.rules-layout {
  display: grid;
  grid-template-columns: minmax(220px, .32fr) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}

.rules-nav {
  position: sticky;
  top: calc(var(--header-height) + 22px);
  display: grid;
  padding: 12px;
  gap: 3px;
}

.rules-nav a {
  min-height: 42px;
  padding: 10px 11px;
  border-left: 2px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 650;
}

.rules-nav a:hover {
  border-left-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.rules-content {
  display: grid;
  gap: 16px;
}

.rule-section {
  scroll-margin-top: calc(var(--header-height) + 24px);
}

.rule-section h2 {
  margin-bottom: 11px;
  font-size: 1.36rem;
}

.rule-section p,
.rule-section li {
  color: var(--text-soft);
}

.rule-section ul,
.rule-section ol {
  padding-left: 1.25rem;
}

.hand-ranking {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 10px 0;
  border-top: 1px solid var(--line);
}

.hand-rank {
  display: grid;
  grid-template-columns: 44px 1fr;
  min-height: 82px;
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}

.hand-rank:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.hand-rank-number {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #ddbdc0;
  border-radius: 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-family: "Cascadia Mono", Consolas, monospace;
}

.hand-rank h3 {
  margin-bottom: 2px;
}

.hand-rank p {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
}

.rule-details {
  border-top: 1px solid var(--line);
}

.rule-details summary {
  min-height: 48px;
  padding: 13px 0;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.rule-details summary::marker {
  color: var(--accent);
}

.rule-details p {
  padding-bottom: 13px;
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
}

.not-found {
  display: grid;
  min-height: calc(100dvh - var(--header-height) - 80px);
  place-content: center;
  justify-items: center;
  text-align: center;
}

.not-found strong {
  color: var(--accent);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 820;
  line-height: .9;
  opacity: .86;
}

.not-found h1 {
  margin: 17px 0 8px;
  font-size: 1.6rem;
}

.not-found p {
  margin-bottom: 20px;
  color: var(--muted);
}

/* Feedback */
.toast-region {
  position: fixed;
  top: calc(var(--header-height) + 14px);
  right: 16px;
  z-index: 120;
  display: grid;
  width: min(370px, calc(100% - 32px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--info);
  border-radius: 12px;
  color: var(--text);
  background: #ffffff;
  box-shadow: 0 14px 35px rgba(54, 69, 94, .16);
  gap: 10px;
  pointer-events: auto;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  margin-bottom: 2px;
  font-size: .86rem;
}

.toast span {
  color: var(--text-soft);
  font-size: .78rem;
}

.toast-close {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  font-size: 1.1rem;
}

.toast-close:hover {
  color: var(--text);
  background: #eef1f5;
}

.modal-header .toast-close {
  width: 38px;
  height: 38px;
  margin: -7px -8px 0 0;
}

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.loading-bars {
  display: inline-flex;
  align-items: flex-end;
  height: 15px;
  gap: 2px;
}

.loading-bars i {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: currentColor;
}

@media (prefers-reduced-motion: no-preference) {
  .app-boot .brand-mark {
    animation: boot-pulse 1.8s var(--ease) infinite;
  }

  .home-hero > * {
    animation: enter-up .62s var(--ease) both;
  }

  .home-hero .hero-visual {
    animation-delay: .07s;
  }

  .hero-proof {
    animation: enter-up .62s .12s var(--ease) both;
  }

  .floating-chip.one { animation: chip-float-one 4.6s ease-in-out infinite; }
  .floating-chip.two { animation: chip-float-two 5.2s ease-in-out infinite; }
  .floating-chip.three { animation: chip-float-three 5.7s ease-in-out infinite; }

  .skeleton {
    background: linear-gradient(100deg, #e4e8ee 25%, #f4f6f8 45%, #e4e8ee 65%);
    background-size: 300% 100%;
    animation: shimmer 1.6s linear infinite;
  }

  .toast {
    animation: toast-in .28s var(--ease) both;
  }

  .loading-bars i {
    animation: bars .75s ease-in-out infinite alternate;
  }

  .loading-bars i:nth-child(2) { animation-delay: .12s; }
  .loading-bars i:nth-child(3) { animation-delay: .24s; }
}

@keyframes boot-pulse {
  0%, 100% { transform: translateY(0); opacity: .82; }
  50% { transform: translateY(-4px); opacity: 1; }
}

@keyframes enter-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chip-float-one {
  0%, 100% { transform: translateY(0) rotate(7deg); }
  50% { transform: translateY(-7px) rotate(10deg); }
}

@keyframes chip-float-two {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(8px) rotate(-11deg); }
}

@keyframes chip-float-three {
  0%, 100% { transform: translateY(0) rotate(10deg); }
  50% { transform: translateY(-6px) rotate(6deg); }
}

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

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

@keyframes bars {
  from { height: 5px; opacity: .55; }
  to { height: 14px; opacity: 1; }
}

@media (max-width: 1023px) {
  .header-inner {
    grid-template-columns: auto 1fr auto;
  }

  .main-nav,
  .header-actions .desktop-only {
    display: none;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  .mobile-nav.open {
    position: fixed;
    top: var(--header-height);
    right: 0;
    left: 0;
    z-index: 68;
    display: grid;
    padding: 12px 16px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 18px 35px rgba(53, 69, 94, .13);
    gap: 4px;
  }

  .mobile-nav .nav-link,
  .mobile-nav .btn {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: flex-start;
  }

  .home-hero {
    grid-template-columns: minmax(0, 1fr) minmax(320px, .82fr);
    gap: 28px;
  }

  .hero-visual {
    min-height: 500px;
  }

  .auth-layout::before {
    left: 47%;
  }

  .waiting-room {
    grid-template-columns: 1fr;
  }

  .room-sidebar {
    grid-template-columns: 1fr 1fr;
  }

  .game-table {
    right: 2%;
    left: 2%;
  }

  .player-seat {
    width: 148px;
  }
}

@media (max-width: 767px) {
  :root {
    --header-height: 60px;
  }

  body.chat-open {
    overflow: hidden;
  }

  body {
    font-size: 14px;
  }

  .page,
  .page-wide {
    width: min(100% - 24px, 720px);
    padding: 28px 0 68px;
  }

  .header-inner {
    width: calc(100% - 24px);
    gap: 10px;
  }

  .brand-mark {
    width: 32px;
    height: 34px;
    border-radius: 9px;
  }

  .brand-name {
    display: none;
  }

  .points-chip {
    padding: 3px 7px;
    font-size: .76rem;
  }

  .btn {
    min-height: 44px;
    padding: 10px 14px;
  }

  .btn-sm {
    min-height: 40px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .page-heading {
    display: grid;
    align-items: start;
    margin-bottom: 21px;
    gap: 15px;
  }

  .page-heading .btn {
    width: 100%;
  }

  .home-page {
    align-content: start;
    padding-top: 32px;
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 12px;
  }

  .hero-copy h1 {
    max-width: 9.5ch;
    font-size: clamp(3rem, 15vw, 4.5rem);
  }

  .hero-copy > p:not(.eyebrow) {
    max-width: 35ch;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
  }

  .hero-proof {
    margin-top: 20px;
  }

  .proof-item {
    padding-right: 10px;
  }

  .proof-item:not(:first-child) {
    padding-left: 14px;
  }

  .proof-item strong {
    font-size: .8rem;
  }

  .proof-item span {
    font-size: .67rem;
  }

  .hero-visual {
    min-height: 360px;
  }

  .table-halo {
    inset: 10% 1% 4%;
  }

  .hero-cards {
    transform: translate(-50%, -50%) scale(.82);
  }

  .floating-chip.one { right: 2%; }
  .floating-chip.three { left: 5%; }

  .auth-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 24px;
  }

  .auth-layout::before,
  .auth-intro {
    display: none;
  }

  .auth-card {
    max-width: 520px;
    justify-self: center;
    padding: 26px 20px;
  }

  .lobby-toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .segmented {
    width: 100%;
  }

  .segment-btn {
    min-height: 44px;
    flex: 1;
  }

  .join-bar .input {
    width: 100%;
  }

  .room-list-head {
    display: none;
  }

  .room-row {
    grid-template-areas:
      "name name action"
      "status count action"
      "bet bet action";
    grid-template-columns: minmax(0, 1fr) auto 82px;
    min-height: 118px;
    padding: 15px 14px;
    gap: 6px 10px;
  }

  .room-name { grid-area: name; }
  .room-row .status-badge { grid-area: status; display: inline-flex; }
  .room-count { grid-area: count; justify-self: end; }
  .room-bet { grid-area: bet; }
  .room-row-actions { grid-area: action; align-self: center; }

  .room-row-actions .btn {
    width: 100%;
    height: auto;
    min-height: 48px;
  }

  .room-count,
  .room-bet {
    font-size: .75rem;
  }

  .lobby-footnote {
    display: grid;
    gap: 7px;
  }

  .modal-layer {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: min(88dvh, 760px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
  }

  .modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 20px 18px 11px;
    background: #ffffff;
  }

  .modal-body {
    padding: 7px 18px calc(20px + env(safe-area-inset-bottom));
  }

  .room-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 8px;
    gap: 7px 10px;
  }

  .game-status {
    grid-row: 1;
    grid-column: 2;
    justify-self: end;
  }

  .room-top-actions {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .room-top-actions .btn {
    flex: 1;
  }

  .room-top-actions .desktop-label {
    display: none;
  }

  .room-page {
    width: 100%;
    padding: 10px 8px calc(118px + env(safe-area-inset-bottom));
  }

  .game-stage {
    height: calc(100dvh - var(--header-height) - 104px);
    min-height: 620px;
  }

  .game-table {
    inset: 52px 1px 172px;
    border-radius: 38%;
    box-shadow:
      0 18px 45px rgba(55, 70, 96, .12),
      inset 0 0 0 7px rgba(255, 255, 255, .62),
      inset 0 0 0 9px rgba(138, 153, 174, .14);
  }

  .game-table::before {
    inset: 13px;
  }

  .game-table::after {
    width: 55px;
    height: 55px;
  }

  .player-seat {
    width: 108px;
  }

  .seat-slot-0 { left: 50%; top: calc(100% - 148px); }
  .seat-slot-1 { left: 17%; top: 65%; }
  .seat-slot-2 { left: 17%; top: 27%; }
  .seat-slot-3 { left: 50%; top: 82px; }
  .seat-slot-4 { left: 83%; top: 27%; }
  .seat-slot-5 { left: 83%; top: 65%; }

  .player-box {
    grid-template-columns: 30px minmax(0, 1fr);
    min-height: 50px;
    padding: 6px 7px;
    border-radius: 11px;
    gap: 6px;
  }

  .player-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: .6rem;
  }

  .player-name {
    font-size: .69rem;
  }

  .player-points {
    font-size: .59rem;
  }

  .player-state-line {
    display: none;
  }

  .contribution {
    top: -14px;
    right: 4px;
    font-size: .58rem;
  }

  .seat-cards {
    transform: translateY(-50%) scale(.75);
  }

  .seat-slot-0 .seat-cards,
  .seat-slot-3 .seat-cards {
    transform: translateX(-50%) scale(.75);
  }

  .table-center {
    width: 50%;
    padding: 10px 8px;
  }

  .pot-value {
    font-size: 1.55rem;
  }

  .round-meta {
    max-width: 22ch;
    font-size: .65rem;
  }

  .turn-timer {
    top: calc(48% + 70px);
    width: 46px;
    height: 46px;
  }

  .my-hand-area {
    bottom: 190px;
  }

  .my-cards {
    min-height: 88px;
  }

  .my-cards .playing-card {
    width: 59px;
    height: 85px;
  }

  .action-dock {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
    gap: 7px;
  }

  .action-dock .btn,
  .action-dock .primary-action {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px 6px;
    font-size: .78rem;
  }

  .action-message {
    grid-column: 1 / -1;
    min-height: 44px;
    align-content: center;
  }

  .table-notice {
    top: 6px;
    max-width: 92%;
  }

  .waiting-room {
    min-height: 0;
  }

  .waiting-table {
    min-height: 590px;
  }

  .waiting-table .game-table {
    inset: 46px 1px 50px;
  }

  .waiting-table .player-seat {
    width: 102px;
  }

  .waiting-table .seat-slot-0 {
    top: calc(100% - 58px);
  }

  .waiting-center {
    width: 54%;
    padding: 15px 10px;
  }

  .waiting-center .btn {
    min-width: 112px;
  }

  .room-sidebar {
    grid-template-columns: 1fr;
  }

  .room-chat-layer.game-in-progress {
    --chat-safe-bottom: calc(112px + env(safe-area-inset-bottom));
  }

  .room-chat-launcher {
    top: auto;
    right: 8px;
    bottom: calc(var(--chat-safe-bottom) + 8px);
    left: 8px;
    width: auto;
    min-height: 50px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    place-items: center stretch;
    padding: 8px 10px 8px 13px;
    border-right: 1px solid #d3dbe5;
    border-radius: 14px;
    text-align: left;
    gap: 9px;
  }

  .room-chat-launcher:hover {
    transform: none;
  }

  .room-chat-launcher-title {
    color: var(--accent-strong);
  }

  .room-chat-launcher-preview {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: .72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .room-chat-backdrop {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: var(--chat-safe-bottom);
    left: 0;
    z-index: 83;
    display: block;
    padding: 0;
    border: 0;
    background: rgba(24, 32, 51, .28);
  }

  .room-chat-drawer {
    top: auto;
    right: 8px;
    bottom: var(--chat-safe-bottom);
    left: 8px;
    width: auto;
    height: min(62dvh, 520px);
    min-height: 340px;
    border-radius: 18px 18px 0 0;
    opacity: 0;
    transform: translateY(calc(100% + 24px));
  }

  .room-chat-layer.game-in-progress .room-chat-drawer {
    bottom: var(--chat-safe-bottom);
    border-radius: 18px;
  }

  .room-chat-layer.open .room-chat-drawer {
    opacity: 1;
    transform: translateY(0);
  }

  .room-chat-header {
    padding: 14px 14px 11px;
  }

  .room-chat-log {
    padding: 12px;
  }

  .room-chat-compose input {
    min-height: 44px;
    font-size: 16px;
  }

  .room-chat-form {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .room-chat-layer.game-in-progress .room-chat-form {
    padding-bottom: 10px;
  }

  .result-panel {
    right: 10px;
    bottom: calc(112px + env(safe-area-inset-bottom));
    width: calc(100% - 20px);
    max-height: calc(100dvh - 142px - env(safe-area-inset-bottom));
    padding: 15px;
  }

  .result-hand-row {
    grid-template-columns: minmax(82px, .55fr) minmax(0, 1fr);
    padding: 8px;
    gap: 8px;
  }

  .result-hand-player strong {
    font-size: .78rem;
  }

  .revealed-hand-result {
    gap: 5px;
  }

  .revealed-hand-result .revealed-hand-type {
    font-size: .68rem;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-links {
    grid-template-columns: 1fr;
  }

  .data-table-wrap {
    display: none;
  }

  .mobile-data-list {
    display: grid;
  }

  .mobile-data-item {
    display: grid;
    padding: 16px;
    border-top: 1px solid var(--line);
    gap: 7px;
  }

  .mobile-data-item:first-child {
    border-top: 0;
  }

  .mobile-data-head,
  .mobile-data-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-data-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-data-head span,
  .mobile-data-line span {
    color: var(--muted);
    font-size: .74rem;
  }

  .history-mobile-item {
    gap: 11px;
  }

  .history-detail-modal {
    max-height: 92dvh;
  }

  .history-detail-grid {
    grid-template-columns: 1fr;
  }

  .history-detail-summary {
    align-items: flex-start;
  }

  .history-player-card {
    padding: 12px;
  }

  .history-detail-skeleton {
    grid-template-columns: 1fr;
  }

  .pagination {
    align-items: stretch;
    gap: 10px;
  }

  .pagination-actions .btn {
    min-height: 40px;
  }

  .rules-layout {
    grid-template-columns: 1fr;
  }

  .rules-nav {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rules-nav a {
    border-left: 0;
    text-align: center;
  }

  .hand-ranking {
    grid-template-columns: 1fr;
  }

  .hand-rank:nth-child(odd) {
    border-right: 0;
  }

  .toast-region {
    top: auto;
    right: 10px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: calc(100% - 20px);
  }

  .app-shell:has(.room-page) .toast-region {
    bottom: calc(120px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .result-hand-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .revealed-hand-result .revealed-hand-cards {
    min-width: 78px;
  }

  .revealed-hand-result .playing-card {
    width: 31px;
    height: 44px;
  }

  .history-detail-summary {
    display: grid;
    gap: 4px;
  }

  .revealed-hand-detail .playing-card {
    width: 44px;
    height: 63px;
  }

  .revealed-hand-detail .revealed-hand-cards {
    min-width: 114px;
  }

  .hero-proof {
    grid-template-columns: 1fr;
  }

  .proof-item,
  .proof-item:not(:first-child) {
    padding: 10px 0;
    border-top: 1px solid var(--line);
  }

  .proof-item:first-child {
    border-top: 0;
  }

  .proof-item:not(:first-child)::before {
    display: none;
  }

  .room-row {
    grid-template-columns: minmax(0, 1fr) auto 76px;
  }

  .player-seat {
    width: 102px;
  }

  .seat-slot-1,
  .seat-slot-2 { left: 16%; }
  .seat-slot-4,
  .seat-slot-5 { left: 84%; }

  .waiting-center p {
    display: none;
  }

  .rules-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pagination {
    display: grid;
  }

  .pagination-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

.admin-page {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100dvh - var(--header-height));
  background: #f3f5f9;
}

.admin-sidebar {
  position: sticky;
  top: var(--header-height);
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-height));
  padding: 30px 20px 20px;
  color: #f8fafc;
  background:
    radial-gradient(circle at 12% 8%, rgba(198, 61, 68, .28), transparent 15rem),
    linear-gradient(180deg, #202536 0%, #171c2a 100%);
}

.admin-sidebar-head {
  padding: 0 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.admin-kicker,
.admin-section-label {
  color: var(--accent);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.admin-sidebar .admin-kicker {
  color: #f18b91;
}

.admin-sidebar-head h1 {
  margin: 8px 0 4px;
  font-size: 1.65rem;
  letter-spacing: -.04em;
}

.admin-sidebar-head p,
.admin-topbar p,
.admin-loading p {
  margin: 0;
  color: var(--muted);
}

.admin-sidebar-head p {
  color: #929aad;
  font-size: .78rem;
}

.admin-nav {
  display: grid;
  padding: 22px 0;
  gap: 5px;
}

.admin-nav button {
  display: grid;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 10px;
  color: #c3c8d3;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.admin-nav button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, .06);
  transform: translateX(2px);
}

.admin-nav button[aria-current="page"] {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(198, 61, 68, .95), rgba(198, 61, 68, .72));
  box-shadow: 0 8px 20px rgba(151, 34, 43, .25);
}

.admin-nav span {
  font-weight: 700;
}

.admin-nav small {
  margin-top: 1px;
  color: inherit;
  font-size: .67rem;
  opacity: .6;
}

.admin-identity {
  display: flex;
  align-items: center;
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
  gap: 10px;
}

.admin-identity > span:last-child {
  display: grid;
  min-width: 0;
}

.admin-identity strong {
  overflow: hidden;
  font-size: .8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-identity small {
  color: #8f97a9;
  font-size: .65rem;
}

.avatar-dot {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: #ffffff;
  background: var(--avatar, var(--accent));
  font-size: .75rem;
  font-weight: 800;
}

.admin-main {
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 136px;
  padding: 28px clamp(24px, 4vw, 54px) 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
}

.admin-topbar h2 {
  margin: 5px 0 4px;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
}

.admin-breadcrumb {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-live {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: .72rem;
  gap: 7px;
}

.admin-live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #37a579;
  box-shadow: 0 0 0 5px rgba(55, 165, 121, .12);
}

.admin-mobile-nav {
  display: none;
}

.admin-content {
  width: min(1380px, 100%);
  padding: 28px clamp(24px, 4vw, 54px) 60px;
}

.admin-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.admin-metric {
  position: relative;
  min-height: 156px;
  padding: 23px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 9px 30px rgba(52, 67, 91, .06);
}

.admin-metric > span,
.admin-metric > small {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--muted);
  font-size: .72rem;
}

.admin-metric > strong {
  position: relative;
  z-index: 1;
  display: block;
  margin: 11px 0 8px;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  line-height: 1;
  letter-spacing: -.05em;
}

.admin-metric > i {
  position: absolute;
  right: -26px;
  bottom: -38px;
  width: 112px;
  height: 112px;
  border: 20px solid var(--accent-soft);
  border-radius: 50%;
  opacity: .8;
}

.admin-metric.online > i {
  border-color: var(--success-soft);
}

.admin-metric.rooms > i {
  border-color: var(--info-soft);
}

.admin-metric.rounds > i {
  border-color: #f7efe0;
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, .75fr);
  margin-top: 16px;
  gap: 16px;
}

.admin-summary-card,
.admin-guard-card {
  padding: 26px;
}

.admin-summary-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.admin-summary-card h3,
.admin-guard-card h3 {
  margin: 5px 0 0;
  font-size: 1.3rem;
}

.admin-summary-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.admin-summary-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 12px 20px 0;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}

.admin-summary-list > div:nth-last-child(-n+2) {
  border-bottom: 0;
}

.admin-summary-list > div:nth-child(even) {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.admin-summary-list span {
  color: var(--muted);
  font-size: .76rem;
}

.admin-summary-list strong {
  font-size: 1.05rem;
}

.admin-guard-card {
  color: #edf0f6;
  border-color: #292f42;
  background: linear-gradient(145deg, #22283a, #171c29);
}

.admin-guard-card .admin-section-label {
  color: #f18b91;
}

.admin-guard-card p {
  margin: 15px 0 18px;
  color: #aab1c1;
  font-size: .78rem;
}

.admin-guard-card ul {
  display: grid;
  padding: 0;
  margin: 0;
  list-style: none;
  gap: 12px;
}

.admin-guard-card li {
  display: flex;
  align-items: center;
  color: #d4d8e0;
  font-size: .74rem;
  gap: 9px;
}

.admin-guard-card li span {
  color: #f18b91;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .65rem;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  min-height: 64px;
  padding: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #ffffff;
  gap: 10px;
}

.admin-search {
  display: flex;
  flex: 1 1 360px;
  gap: 8px;
}

.admin-toolbar input,
.admin-toolbar select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #f8fafc;
}

.admin-toolbar input {
  width: 100%;
  padding: 0 13px;
}

.admin-toolbar select {
  min-width: 132px;
  padding: 0 34px 0 12px;
}

.admin-table-card {
  overflow: hidden;
  border-radius: 13px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-mobile-list {
  display: none;
}

.admin-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: .77rem;
}

.admin-table th {
  padding: 12px 16px;
  color: var(--muted);
  background: #f3f5f8;
  font-size: .67rem;
  font-weight: 750;
  letter-spacing: .03em;
  text-align: left;
  white-space: nowrap;
}

.admin-table td {
  padding: 15px 16px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: #fbfcfe;
}

.admin-table th.actions,
.admin-table td.actions {
  text-align: right;
  white-space: nowrap;
}

.admin-table td.message {
  min-width: 280px;
  max-width: 480px;
  word-break: break-word;
}

.admin-user {
  display: flex;
  align-items: center;
  min-width: 190px;
  gap: 10px;
}

.admin-user > i {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  color: #ffffff;
  background: var(--avatar, var(--accent));
  font-size: .68rem;
  font-style: normal;
  font-weight: 800;
}

.admin-user > span,
.admin-date {
  display: grid;
}

.admin-user small,
.admin-date small,
.table-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 400;
}

.btn-xs {
  min-height: 30px;
  padding: 5px 9px;
  font-size: .68rem;
}

.btn-danger-ghost {
  color: var(--danger);
  border: 1px solid #efc5c9;
  background: #fff8f8;
}

.btn-danger-ghost:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.admin-table td.actions .btn + .btn {
  margin-left: 6px;
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 2px;
  color: var(--muted);
  font-size: .72rem;
}

.admin-pagination > div {
  display: flex;
  gap: 8px;
}

.admin-empty,
.admin-loading,
.admin-denied {
  padding: 64px 24px;
  text-align: center;
}

.admin-loading {
  display: grid;
  min-height: 260px;
  place-content: center;
}

.admin-action-form textarea {
  width: 100%;
  resize: vertical;
}

@media (max-width: 1120px) {
  .admin-page {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .admin-sidebar {
    padding-inline: 14px;
  }

  .admin-metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .admin-page {
    display: block;
  }

  .admin-sidebar {
    display: none;
  }

  .admin-topbar {
    align-items: flex-start;
    min-height: auto;
    padding: 22px 16px 18px;
  }

  .admin-topbar p {
    max-width: 28rem;
    font-size: .76rem;
  }

  .admin-topbar-actions {
    padding-top: 5px;
  }

  .admin-live {
    display: none;
  }

  .admin-mobile-nav {
    display: flex;
    padding: 10px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    gap: 6px;
    scrollbar-width: none;
  }

  .admin-mobile-nav::-webkit-scrollbar {
    display: none;
  }

  .admin-mobile-nav button {
    flex: 0 0 auto;
    padding: 7px 11px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
  }

  .admin-mobile-nav button[aria-current="page"] {
    color: var(--accent-strong);
    border-color: #efc9cc;
    background: var(--accent-soft);
  }

  .admin-content {
    padding: 16px 14px 42px;
  }

  .admin-metric {
    min-height: 130px;
    padding: 18px;
  }

  .admin-overview-grid {
    grid-template-columns: 1fr;
  }

  .admin-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .admin-search {
    flex-basis: 100%;
  }

  .admin-toolbar > label:not(.admin-search) {
    flex: 1;
  }

  .admin-toolbar select {
    width: 100%;
  }

  .admin-table {
    min-width: 780px;
  }

  .admin-table-wrap {
    display: none;
  }

  .admin-mobile-list {
    display: grid;
  }

  .admin-mobile-card {
    display: grid;
    padding: 16px;
    border-top: 1px solid var(--line);
    gap: 14px;
  }

  .admin-mobile-card:first-child {
    border-top: 0;
  }

  .admin-mobile-card > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .admin-mobile-card > header > span:first-child {
    display: grid;
    min-width: 0;
  }

  .admin-mobile-card > header small {
    color: var(--muted);
    font-size: .67rem;
    font-weight: 400;
  }

  .admin-mobile-card > header > .number {
    color: var(--accent-strong);
    font-size: 1rem;
  }

  .admin-mobile-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    border-radius: 10px;
    background: #f6f8fb;
    gap: 12px;
  }

  .admin-mobile-meta > span {
    font-size: .74rem;
    font-weight: 650;
  }

  .admin-mobile-meta small {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: .63rem;
    font-weight: 500;
  }

  .admin-mobile-meta i {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 5px;
    border-radius: 50%;
  }

  .admin-mobile-meta i.online {
    background: var(--success);
  }

  .admin-mobile-meta i.offline {
    background: var(--danger);
  }

  .admin-mobile-card > footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .admin-message-card p {
    margin: 0;
    color: var(--text-soft);
    font-size: .78rem;
    word-break: break-word;
  }

  .admin-message-card time {
    color: var(--muted);
    font-size: .65rem;
  }
}

@media (max-width: 460px) {
  .admin-topbar {
    display: grid;
    gap: 12px;
  }

  .admin-topbar-actions .btn {
    width: 100%;
  }

  .admin-metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .admin-metric {
    min-height: 118px;
    padding: 15px;
  }

  .admin-metric > strong {
    font-size: 1.65rem;
  }

  .admin-metric > i {
    right: -38px;
    bottom: -48px;
  }

  .admin-summary-list {
    grid-template-columns: 1fr;
  }

  .admin-summary-list > div,
  .admin-summary-list > div:nth-child(even) {
    padding: 15px 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-summary-list > div:nth-last-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .admin-summary-list > div:last-child {
    border-bottom: 0;
  }

  .admin-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .admin-pagination {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .admin-pagination > div .btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .app-header,
  .action-dock,
  .modal-layer {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .app-header,
  .action-dock {
    background: #ffffff;
  }
}
