:root {
  --page: #030b07;
  --background: #07140f;
  --surface: #10251c;
  --surface-strong: #173328;
  --surface-soft: rgba(255, 255, 255, 0.045);
  --text: #f5fff9;
  --text-soft: #c2d7cb;
  --muted: #8ca699;
  --line: rgba(177, 255, 214, 0.14);
  --line-strong: rgba(119, 241, 176, 0.42);
  --primary: #45e49a;
  --primary-strong: #24c77d;
  --primary-ink: #06150e;
  --warning: #ffd166;
  --danger: #ff646d;
  --danger-soft: rgba(255, 100, 109, 0.11);
  --success-soft: rgba(69, 228, 154, 0.1);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.34);
  --radius-sm: 14px;
  --radius-md: 19px;
  --radius-lg: 26px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--page);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 16% 8%, rgba(42, 191, 120, 0.16), transparent 28rem),
    radial-gradient(circle at 92% 86%, rgba(255, 209, 102, 0.07), transparent 22rem),
    var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:not(:disabled),
.select-card:not([aria-disabled="true"]) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.select-card:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(99, 242, 168, 0.76);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 800;
  transform: translateY(-150%);
}

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

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(4, 15, 10, 0.2), rgba(4, 13, 9, 0.88)),
    radial-gradient(circle at 100% 4%, rgba(69, 228, 154, 0.16), transparent 19rem),
    linear-gradient(145deg, #0d2a20 0%, var(--background) 50%, #050e0a 100%);
  box-shadow: var(--shadow);
}

.app-shell::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(30deg, rgba(255, 255, 255, 0.025) 12%, transparent 12.5%, transparent 87%, rgba(255, 255, 255, 0.025) 87.5%),
    linear-gradient(150deg, rgba(255, 255, 255, 0.025) 12%, transparent 12.5%, transparent 87%, rgba(255, 255, 255, 0.025) 87.5%);
  background-size: 18px 31px;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding:
    max(18px, env(safe-area-inset-top))
    20px
    max(20px, env(safe-area-inset-bottom));
  animation: screen-in 240ms var(--ease);
}

.screen.with-footer {
  padding-bottom: calc(116px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 16px;
}

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

.brand-ball,
.loading-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  background:
    radial-gradient(circle at 31% 22%, rgba(255, 255, 255, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 50% 50%, #fff 0 12px, #0b1010 13px 100%);
  box-shadow:
    inset -8px -10px 15px rgba(0, 0, 0, 0.46),
    0 8px 20px rgba(0, 0, 0, 0.24);
  color: #0c1511;
  font-weight: 900;
}

.brand-ball {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.brand-copy {
  min-width: 0;
}

.brand-copy strong {
  display: block;
  overflow: hidden;
  font-size: 17px;
  letter-spacing: 0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.step-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.11em;
}

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

.card {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.015)),
    rgba(14, 34, 26, 0.92);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.21);
  backdrop-filter: blur(16px);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 17px;
  font-size: 16px;
  font-weight: 850;
  letter-spacing: 0.02em;
  transition:
    transform 160ms var(--ease),
    background 180ms ease,
    border-color 180ms ease,
    opacity 180ms ease;
}

.primary-button {
  width: 100%;
  border: 0;
  background: linear-gradient(135deg, #6af0ae, #2dcd84);
  box-shadow:
    0 13px 28px rgba(41, 206, 132, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  color: var(--primary-ink);
}

.secondary-button {
  width: 100%;
  border: 1px solid rgba(117, 255, 183, 0.24);
  background: rgba(69, 228, 154, 0.08);
  color: #b9fbd5;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text-soft);
}

.danger-button {
  border: 1px solid rgba(255, 100, 109, 0.24);
  background: var(--danger-soft);
  color: #ffb4b9;
}

.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.ghost-button:active:not(:disabled),
.danger-button:active:not(:disabled),
.select-card:active:not([aria-disabled="true"]) {
  transform: scale(0.97);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  opacity: 0.48;
}

.button-spinner {
  width: 18px;
  height: 18px;
  margin-right: 9px;
  border: 2px solid rgba(4, 26, 16, 0.25);
  border-top-color: var(--primary-ink);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.inline-error {
  min-height: 21px;
  margin: 8px 2px 0;
  color: #ffadb2;
  font-size: 13px;
  line-height: 1.55;
}

.screen-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(69, 228, 154, 0.1);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
}

.connection-pill.reconnecting .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.09);
}

.connection-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* 登录 */
.login-screen {
  overflow: hidden;
}

.login-hero {
  position: relative;
  padding: clamp(48px, 10vh, 86px) 4px 32px;
}

.login-orbit {
  position: absolute;
  top: 18px;
  right: -24px;
  width: 140px;
  height: 140px;
  border: 1px solid rgba(86, 235, 158, 0.12);
  border-radius: 50%;
}

.login-orbit::before,
.login-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  box-shadow: inset -7px -8px 12px rgba(0, 0, 0, 0.35);
}

.login-orbit::before {
  top: 7px;
  left: 7px;
  width: 31px;
  height: 31px;
  background: #f3bf38;
}

.login-orbit::after {
  right: 5px;
  bottom: 14px;
  width: 44px;
  height: 44px;
  background: #d94f52;
}

.login-hero h1 {
  position: relative;
  max-width: 340px;
  margin: 13px 0 0;
  font-size: clamp(38px, 10vw, 47px);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.login-hero h1 em {
  color: var(--primary);
  font-style: normal;
}

.login-hero p {
  max-width: 340px;
  margin: 17px 0 0;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.75;
}

.login-card {
  padding: 23px;
  border-radius: var(--radius-lg);
}

.login-card h2 {
  margin: 0;
  font-size: 21px;
}

.login-card > p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.field-label {
  display: block;
  margin: 22px 0 9px;
  color: #d9ebe0;
  font-size: 13px;
  font-weight: 800;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-icon {
  position: absolute;
  z-index: 1;
  left: 16px;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.8;
  pointer-events: none;
}

.password-input {
  width: 100%;
  height: 56px;
  padding: 0 72px 0 46px;
  border: 1px solid rgba(117, 255, 183, 0.25);
  border-radius: 17px;
  outline: none;
  background: rgba(3, 12, 8, 0.65);
  box-shadow: 0 0 0 3px rgba(69, 228, 154, 0.035);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0.08em;
}

.password-input::placeholder {
  color: #678174;
  letter-spacing: 0;
}

.toggle-password {
  position: absolute;
  right: 6px;
  min-width: 58px;
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #94ad9f;
  font-size: 13px;
  font-weight: 800;
}

.login-card .primary-button {
  margin-top: 14px;
}

.capacity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.seat-icons {
  display: flex;
  gap: 6px;
}

.seat-icon {
  width: 23px;
  height: 23px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  padding-top: 24px;
  gap: 8px;
  color: #789184;
  font-size: 12px;
  text-align: center;
}

.privacy-note svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

/* 选择球色与角色 */
.setup-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 24px;
  gap: 12px;
}

.setup-heading h1 {
  margin: 7px 0 0;
  font-size: 29px;
  letter-spacing: -0.035em;
}

.host-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(255, 209, 102, 0.22);
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.08);
  color: #ffe3a0;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.section-title {
  margin: 28px 0 0;
  font-size: 20px;
}

.ball-set-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.select-card {
  position: relative;
  min-width: 0;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  transition:
    transform 160ms var(--ease),
    border-color 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.select-card[aria-pressed="true"] {
  border-color: rgba(91, 239, 164, 0.86);
  background: rgba(69, 228, 154, 0.08);
  box-shadow: 0 0 0 3px rgba(69, 228, 154, 0.11);
}

.select-card[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.42;
}

.ball-set-card img,
.locked-ball-set img {
  display: block;
  width: 100%;
  height: 116px;
  border-radius: 15px;
  object-fit: cover;
}

.ball-set-card img {
  object-position: 50% 0%;
}

.ball-set-card[data-ball-set="candy"] img {
  object-position: 50% 42%;
}

.locked-ball-set img[src*="ball-set-classic"] {
  object-position: 50% 0%;
}

.select-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 4px 2px;
  gap: 6px;
}

.select-caption strong {
  display: block;
  font-size: 14px;
}

.select-caption small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.check-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 950;
  opacity: 0;
  transform: scale(0.78);
  transition: 160ms var(--ease);
}

[aria-pressed="true"] .check-badge {
  opacity: 1;
  transform: scale(1);
}

.setup-helper {
  display: flex;
  align-items: flex-start;
  margin: 12px 2px 0;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.setup-helper::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.08);
}

.locked-ball-set {
  display: grid;
  grid-template-columns: 116px 1fr;
  align-items: center;
  margin-top: 16px;
  padding: 9px;
  gap: 14px;
  border-radius: 21px;
}

.locked-ball-set img {
  height: 88px;
}

.locked-ball-set strong {
  display: block;
  font-size: 17px;
}

.locked-ball-set p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.role-card {
  min-height: 128px;
  padding: 12px 7px;
  text-align: center;
}

.role-avatar {
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  margin: 0 auto 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: linear-gradient(145deg, #28483a, #11261c);
  color: #dff9e9;
  font-size: 24px;
  font-weight: 950;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[aria-pressed="true"] .role-avatar {
  background: linear-gradient(145deg, #6af0ae, #20be78);
  color: #082017;
}

.role-card strong {
  display: block;
  min-height: 33px;
  font-size: 13px;
  line-height: 1.3;
}

.role-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.setup-actions {
  display: grid;
  margin-top: auto;
  padding-top: 28px;
  gap: 10px;
}

/* 准备与实战 */
.room-screen {
  min-height: 100dvh;
}

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

.room-topbar-title strong {
  display: block;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-topbar-title small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.exit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 70px;
  min-height: 48px;
  padding: 0 12px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

.exit-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.players-card {
  margin-top: 15px;
  padding: 16px;
  border-radius: 22px;
}

.players-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.players-head-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.players-head strong {
  font-size: 14px;
}

.players-summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #91eebb;
  font-size: 11px;
  font-weight: 850;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.player-card {
  position: relative;
  min-width: 0;
  min-height: 82px;
  padding: 11px 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.035);
  text-align: center;
}

.player-card.is-me {
  border-color: rgba(69, 228, 154, 0.25);
  background: rgba(69, 228, 154, 0.06);
}

.player-card strong {
  display: -webkit-box;
  overflow: hidden;
  min-height: 33px;
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.player-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.player-card small.ready {
  color: #78e4a9;
}

.player-card small.restart {
  color: #ffdd8a;
}

.me-badge {
  position: absolute;
  top: -7px;
  right: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 9px;
  font-weight: 900;
}

.lobby-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 8px 38px;
  text-align: center;
}

.lobby-orbit {
  position: relative;
  display: grid;
  place-items: center;
  width: 166px;
  height: 166px;
  border: 1px solid rgba(83, 231, 155, 0.16);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(69, 228, 154, 0.06), transparent 68%);
}

.lobby-orbit::before,
.lobby-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.35);
}

.lobby-orbit::before {
  top: 8px;
  left: 9px;
  width: 29px;
  height: 29px;
  background: #efbd37;
}

.lobby-orbit::after {
  right: 9px;
  bottom: 18px;
  width: 39px;
  height: 39px;
  background: #d94d52;
}

.lobby-eight {
  display: grid;
  place-items: center;
  width: 83px;
  height: 83px;
  border: 3px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  background: radial-gradient(circle at center, #fff 0 25px, #0a0d0d 26px);
  box-shadow:
    inset -14px -17px 22px rgba(0, 0, 0, 0.55),
    0 18px 32px rgba(0, 0, 0, 0.28);
  color: #0d1512;
  font-size: 29px;
  font-weight: 950;
}

.lobby-content h1 {
  margin: 28px 0 0;
  font-size: 29px;
  letter-spacing: -0.035em;
}

.lobby-content p {
  max-width: 330px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 21px;
  gap: 12px;
}

.game-heading h1 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.025em;
}

.game-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.private-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 10px;
  gap: 6px;
  border: 1px solid rgba(104, 231, 167, 0.2);
  border-radius: 999px;
  background: rgba(69, 228, 154, 0.075);
  color: #aaf2c9;
  font-size: 11px;
  font-weight: 850;
}

.private-pill svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
}

.ball-list {
  display: grid;
  margin-top: 14px;
  gap: 9px;
}

.ball-row {
  display: flex;
  align-items: center;
  min-height: 78px;
  padding: 9px 9px 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 19px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.024));
  transition:
    border-color 180ms ease,
    background 180ms ease;
}

.ball-row.is-pocketed {
  border-color: rgba(255, 100, 109, 0.18);
  background: linear-gradient(90deg, rgba(255, 100, 109, 0.07), rgba(255, 255, 255, 0.02));
}

.pool-ball {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 50%;
  background-color: var(--ball-color);
  background-image: var(--ball-sheet);
  background-repeat: no-repeat;
  background-position: var(--ball-position);
  background-size: var(--ball-sheet-size);
  box-shadow:
    inset 0 0 2px rgba(255, 255, 255, 0.55),
    0 8px 10px -5px rgba(0, 0, 0, 0.72),
    0 2px 3px rgba(0, 0, 0, 0.38);
  transform: translateZ(0);
}

.pool-ball::before {
  content: none;
}

.set-classic {
  --ball-sheet: url("/assets/ball-set-classic.jpg");
  --ball-sheet-size: 461.54px 307.21px;
}

.set-candy {
  --ball-sheet: url("/assets/ball-set-candy.jpg");
  --ball-sheet-size: 480px 320px;
}

.pool-ball.is-pocketed::after {
  content: "×";
  position: absolute;
  z-index: 5;
  inset: -8px;
  display: grid;
  place-items: center;
  color: #ff303b;
  font-family: Arial, sans-serif;
  font-size: 56px;
  font-weight: 400;
  line-height: 1;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 0 7px rgba(255, 48, 59, 0.5);
  transform: rotate(-6deg);
}

.ball-1 { --ball-color: #e9b92e; }
.ball-2 { --ball-color: #2d76d3; }
.ball-3 { --ball-color: #d8474d; }
.ball-4 { --ball-color: #e782a5; }
.ball-5 { --ball-color: #ee8731; }
.ball-6 { --ball-color: #1d9367; }
.ball-7 { --ball-color: #9b6b39; }
.ball-8 { --ball-color: #171b1a; }
.ball-9 { --ball-color: #e2b831; }
.ball-10 { --ball-color: #2d76d3; }
.ball-11 { --ball-color: #d8474d; }
.ball-12 { --ball-color: #e782a5; }
.ball-13 { --ball-color: #ee8731; }
.ball-14 { --ball-color: #1d9367; }
.ball-15 { --ball-color: #9b6b39; }

.set-classic .ball-1 { --ball-position: -59.62px -48.56px; }
.set-classic .ball-2 { --ball-position: -135.58px -48.56px; }
.set-classic .ball-3 { --ball-position: -211.06px -48.56px; }
.set-classic .ball-4 { --ball-position: -285.58px -48.56px; }
.set-classic .ball-5 { --ball-position: -359.13px -48.56px; }
.set-classic .ball-6 { --ball-position: -59.13px -119.71px; }
.set-classic .ball-7 { --ball-position: -135.1px -119.71px; }
.set-classic .ball-8 { --ball-position: -210.58px -119.71px; }
.set-classic .ball-9 { --ball-position: -285.1px -119.71px; }
.set-classic .ball-10 { --ball-position: -359.13px -119.71px; }
.set-classic .ball-11 { --ball-position: -56.73px -192.31px; }
.set-classic .ball-12 { --ball-position: -133.65px -192.31px; }
.set-classic .ball-13 { --ball-position: -208.65px -192.31px; }
.set-classic .ball-14 { --ball-position: -283.17px -192.31px; }
.set-classic .ball-15 { --ball-position: -359.62px -192.31px; }

.set-candy .ball-1 { --ball-color: #f4b82e; }
.set-candy .ball-2 { --ball-color: #54add2; }
.set-candy .ball-3 { --ball-color: #ef6264; }
.set-candy .ball-4 { --ball-color: #a483b2; }
.set-candy .ball-5 { --ball-color: #f08b2e; }
.set-candy .ball-6 { --ball-color: #56c6ae; }
.set-candy .ball-7 { --ball-color: #a8d4c6; }
.set-candy .ball-9 { --ball-color: #e8b747; }
.set-candy .ball-10 { --ball-color: #4b9dca; }
.set-candy .ball-11 { --ball-color: #ed5961; }
.set-candy .ball-12 { --ball-color: #a080ae; }
.set-candy .ball-13 { --ball-color: #ef8138; }
.set-candy .ball-14 { --ball-color: #9aca46; }
.set-candy .ball-15 { --ball-color: #57bca9; }

.set-candy .ball-1 { --ball-position: -59.5px -53.5px; }
.set-candy .ball-2 { --ball-position: -136.5px -53.5px; }
.set-candy .ball-3 { --ball-position: -215.5px -53.5px; }
.set-candy .ball-4 { --ball-position: -295.5px -53.5px; }
.set-candy .ball-5 { --ball-position: -374.5px -53.5px; }
.set-candy .ball-6 { --ball-position: -59px -127px; }
.set-candy .ball-7 { --ball-position: -136.5px -127px; }
.set-candy .ball-8 { --ball-position: -215.5px -127px; }
.set-candy .ball-9 { --ball-position: -295.5px -127px; }
.set-candy .ball-10 { --ball-position: -374.5px -127px; }
.set-candy .ball-11 { --ball-position: -59.5px -202.5px; }
.set-candy .ball-12 { --ball-position: -136.5px -202.5px; }
.set-candy .ball-13 { --ball-position: -215.5px -202.5px; }
.set-candy .ball-14 { --ball-position: -295.5px -202.5px; }
.set-candy .ball-15 { --ball-position: -374.5px -202.5px; }

.ball-copy {
  flex: 1;
  min-width: 0;
  padding-left: 12px;
}

.ball-copy strong {
  display: block;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.ball-copy small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.pocket-button {
  min-width: 82px;
  min-height: 46px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.065);
  color: #d8ebe0;
  font-size: 12px;
  font-weight: 850;
  transition:
    transform 160ms var(--ease),
    background 180ms ease,
    border-color 180ms ease;
}

.pocket-button:active:not(:disabled) {
  transform: scale(0.96);
}

.pocket-button.recorded {
  border-color: rgba(255, 100, 109, 0.25);
  background: var(--danger-soft);
  color: #ffadb2;
}

.pocket-button:disabled {
  opacity: 0.72;
}

.sticky-footer {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding:
    14px
    20px
    max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(164, 255, 206, 0.09);
  background: linear-gradient(180deg, rgba(5, 16, 11, 0.2), rgba(5, 16, 11, 0.96) 26%);
  backdrop-filter: blur(16px);
}

.sticky-footer .screen-note {
  margin: 8px 0 0;
}

.room-screen.is-playing {
  padding:
    max(10px, env(safe-area-inset-top))
    14px
    calc(76px + env(safe-area-inset-bottom));
}

.room-screen.is-playing .topbar {
  min-height: 40px;
}

.room-screen.is-playing .room-topbar-title strong {
  font-size: 15px;
}

.room-screen.is-playing .room-topbar-title small {
  margin-top: 1px;
  font-size: 9px;
}

.room-screen.is-playing .exit-button {
  min-width: 58px;
  min-height: 38px;
  padding-inline: 9px;
  border-radius: 13px;
  font-size: 11px;
}

.room-screen.is-playing .exit-button svg {
  width: 15px;
  height: 15px;
}

.room-screen.is-playing .players-card {
  margin-top: 7px;
  padding: 8px 9px 9px;
  border-radius: 16px;
}

.room-screen.is-playing .players-head {
  margin-bottom: 6px;
  gap: 7px;
}

.room-screen.is-playing .players-head strong {
  font-size: 12px;
}

.room-screen.is-playing .players-head-meta {
  gap: 6px;
}

.room-screen.is-playing .players-summary {
  gap: 4px;
  font-size: 9px;
}

.room-screen.is-playing .players-summary .status-dot,
.room-screen.is-playing .connection-pill .status-dot {
  width: 5px;
  height: 5px;
  box-shadow: 0 0 0 3px rgba(69, 228, 154, 0.08);
}

.room-screen.is-playing .connection-pill {
  min-height: 22px;
  padding-inline: 7px;
  gap: 4px;
  font-size: 9px;
}

.room-screen.is-playing .player-grid {
  gap: 5px;
}

.room-screen.is-playing .player-card {
  min-height: 48px;
  padding: 7px 3px 5px;
  border-radius: 12px;
}

.room-screen.is-playing .player-card strong {
  display: block;
  overflow: hidden;
  min-height: auto;
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-screen.is-playing .player-card small {
  margin-top: 3px;
  font-size: 8px;
}

.room-screen.is-playing .me-badge {
  top: -6px;
  right: 4px;
  padding: 1px 4px;
  font-size: 8px;
}

.room-screen.is-playing .game-heading {
  margin-top: 8px;
  gap: 8px;
}

.room-screen.is-playing .game-heading h1 {
  font-size: 19px;
}

.room-screen.is-playing .game-heading p {
  margin-top: 2px;
  font-size: 9px;
}

.room-screen.is-playing .private-pill {
  min-height: 27px;
  padding-inline: 8px;
  gap: 4px;
  font-size: 9px;
}

.room-screen.is-playing .private-pill svg {
  width: 12px;
  height: 12px;
}

.room-screen.is-playing .ball-list {
  margin-top: 6px;
  gap: 5px;
}

.room-screen.is-playing .ball-row {
  min-height: 56px;
  padding: 3px 6px 3px 7px;
  border-radius: 15px;
}

.room-screen.is-playing .ball-copy {
  padding-left: 9px;
}

.room-screen.is-playing .ball-copy strong {
  font-size: 14px;
}

.room-screen.is-playing .ball-copy small {
  margin-top: 2px;
  font-size: 9px;
}

.room-screen.is-playing .pocket-button {
  min-width: 72px;
  min-height: 38px;
  padding-inline: 8px;
  border-radius: 12px;
  font-size: 11px;
}

.room-screen.is-playing .sticky-footer {
  padding:
    6px
    14px
    max(7px, env(safe-area-inset-bottom));
}

.room-screen.is-playing .sticky-footer .secondary-button {
  min-height: 42px;
  border-radius: 14px;
  font-size: 14px;
}

.room-screen.is-playing .sticky-footer .screen-note {
  margin-top: 4px;
  font-size: 9px;
  line-height: 1.3;
}

.footer-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
}

.footer-actions .primary-button {
  min-width: 0;
}

.footer-actions .ghost-button {
  padding-inline: 14px;
  font-size: 13px;
}

.toast {
  position: fixed;
  z-index: 100;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  width: calc(100% - 32px);
  max-width: 430px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 15px;
  background: rgba(24, 45, 36, 0.97);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -18px);
  transition:
    opacity 180ms ease,
    transform 220ms var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  border-color: rgba(255, 100, 109, 0.28);
  background: rgba(67, 27, 31, 0.97);
}

.loading-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}

.loading-mark {
  width: 76px;
  height: 76px;
  font-size: 28px;
  animation: loading-pulse 1.1s ease-in-out infinite alternate;
}

.loading-shell p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.fatal-state {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 40px 24px;
  text-align: center;
}

.fatal-state h1 {
  margin: 0;
  font-size: 25px;
}

.fatal-state p {
  max-width: 330px;
  margin: 12px 0 24px;
  color: var(--muted);
  line-height: 1.7;
}

.fatal-state .primary-button {
  max-width: 260px;
}

noscript {
  display: block;
  padding: 20px;
  color: #fff;
  text-align: center;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loading-pulse {
  to {
    transform: scale(1.05);
    filter: brightness(1.12);
  }
}

@media (min-width: 620px) {
  body {
    padding: 24px;
  }

  .app-shell {
    min-height: calc(100dvh - 48px);
    border: 1px solid rgba(196, 255, 222, 0.14);
    border-radius: 34px;
  }

  .app-shell::before {
    top: 24px;
    bottom: 24px;
    max-height: calc(100dvh - 48px);
    border-radius: 34px;
  }

  .screen,
  .room-screen {
    min-height: calc(100dvh - 48px);
  }

  .sticky-footer {
    bottom: 24px;
    border-radius: 0 0 34px 34px;
  }
}

@media (max-width: 374px) {
  .screen {
    padding-right: 16px;
    padding-left: 16px;
  }

  .login-hero {
    padding-top: 42px;
  }

  .login-hero h1 {
    font-size: 36px;
  }

  .ball-set-grid {
    gap: 9px;
  }

  .ball-set-card img {
    height: 102px;
  }

  .role-grid {
    gap: 7px;
  }

  .role-avatar {
    width: 49px;
    height: 49px;
    font-size: 21px;
  }

  .players-card {
    padding: 13px;
  }

  .player-grid {
    gap: 6px;
  }

  .ball-copy {
    padding-left: 9px;
  }

  .pocket-button {
    min-width: 75px;
  }

  .sticky-footer {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .screen {
    min-height: 100dvh;
  }

  .login-hero {
    padding: 26px 4px 22px;
  }

  .login-hero h1 {
    font-size: 34px;
  }

  .privacy-note {
    margin-top: 22px;
  }

  .lobby-content {
    padding-block: 24px 100px;
  }
}

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