:root {
  --ink: #16211d;
  --muted: #64716d;
  --line: #d8ded7;
  --paper: #fbfcf7;
  --panel: #ffffff;
  --sage: #2f6657;
  --sage-2: #e5f0e8;
  --coral: #f06c55;
  --gold: #f1b84b;
  --sky: #67a7c8;
  --violet: #6f68b3;
  --shadow: 0 18px 50px rgba(25, 37, 31, 0.14);
  --app-bg:
    linear-gradient(90deg, rgba(103, 167, 200, 0.14), transparent 30%),
    linear-gradient(180deg, #f5f9f1 0%, #eef5f6 100%);
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.96);
  --surface-muted: #f3f7ef;
  --control-bg: #ffffff;
  --control-hover: #eef4ec;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --topbar-border: rgba(216, 222, 215, 0.9);
  --thumb-bg: #f3f7ef;
  --thumb-letterbox: #ffffff;
  --board-bg:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), transparent 42%, rgba(47, 102, 87, 0.05)),
    linear-gradient(rgba(22, 33, 29, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 33, 29, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(47, 102, 87, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 102, 87, 0.055) 1px, transparent 1px),
    linear-gradient(135deg, #fbfcf6 0%, #eef6f0 52%, #f5f1e8 100%);
  --board-bg-size:
    100% 100%,
    28px 28px,
    28px 28px,
    112px 112px,
    112px 112px,
    100% 100%;
  --tray-bg: rgba(255, 255, 255, 0.9);
  --overlay-panel: rgba(14, 14, 16, 0.72);
  --inverse-ink: #ffffff;
  --app-height: 100dvh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body[data-theme="dark"] {
  --ink: #f2f4ef;
  --muted: #a7ada9;
  --line: #323a36;
  --paper: #101412;
  --panel: #1a201d;
  --sage-2: #203a34;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  --app-bg:
    linear-gradient(90deg, rgba(47, 102, 87, 0.16), transparent 34%),
    linear-gradient(180deg, #0d1110 0%, #111817 100%);
  --surface: #181d1a;
  --surface-soft: rgba(24, 29, 26, 0.96);
  --surface-muted: #121816;
  --control-bg: #171d1a;
  --control-hover: #24342f;
  --topbar-bg: rgba(18, 23, 21, 0.94);
  --topbar-border: #29322f;
  --thumb-bg: #171d1a;
  --thumb-letterbox: #0d1110;
  --board-bg:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 42%, rgba(103, 167, 200, 0.055)),
    linear-gradient(rgba(242, 244, 239, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242, 244, 239, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(103, 167, 200, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 167, 200, 0.055) 1px, transparent 1px),
    linear-gradient(135deg, #101412 0%, #121b17 54%, #171712 100%);
  --board-bg-size:
    100% 100%,
    28px 28px,
    28px 28px,
    112px 112px,
    112px 112px,
    100% 100%;
  --tray-bg: rgba(24, 29, 26, 0.92);
  --overlay-panel: rgba(10, 12, 11, 0.78);
  --inverse-ink: #101412;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--app-bg);
}

body[data-screen="lobby"],
body[data-screen="profile"],
body[data-screen="legal"] {
  overflow: auto;
  background: var(--app-bg);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  padding: 10px;
}

body[data-screen="game"] {
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  overflow: hidden;
}

body[data-screen="game"] .app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: var(--app-height, 100dvh);
  min-height: 0;
  padding-bottom: 0;
}

.topbar {
  position: relative;
  z-index: 160;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 560px) minmax(220px, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  max-width: none;
  margin: 0 auto 8px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.brand:focus-visible {
  outline: 3px solid rgba(47, 102, 87, 0.28);
  outline-offset: 6px;
  border-radius: 16px;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow:
    0 10px 24px rgba(20, 31, 28, 0.18),
    inset 0 0 0 1px rgba(15, 23, 21, 0.08);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-chip {
  fill: url("#jignextChip");
  stroke: rgba(114, 247, 215, 0.48);
  stroke-width: 1.2;
}

.logo-grid {
  opacity: 0.16;
  fill: none;
  stroke: #a5fff0;
  stroke-width: 0.8;
}

.logo-puzzle {
  fill: rgba(114, 247, 215, 0.1);
  stroke: url("#jignextNeon");
  stroke-width: 2;
  filter: url("#jignextGlow");
}

.logo-next {
  fill: none;
  stroke: url("#jignextNeon");
  stroke-width: 4.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url("#jignextGlow");
}

.logo-circuit {
  fill: none;
  stroke: rgba(114, 247, 215, 0.72);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.logo-node {
  fill: #72f7d7;
  filter: url("#jignextGlow");
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.room-summary {
  display: none;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.room-summary-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.top-avatar-list {
  display: flex;
  align-items: center;
  min-width: 0;
  padding-left: 6px;
}

.top-host-avatar {
  display: inline-grid;
  place-items: center;
  margin-left: -6px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.top-host-avatar:first-child {
  margin-left: 0;
}

.top-host-avatar .avatar {
  margin-left: 0;
  outline: 2px solid rgba(47, 102, 87, 0.28);
}

.top-host-avatar:hover .avatar {
  transform: translateY(-1px);
}

.top-avatar-list .avatar {
  width: 32px;
  height: 32px;
  margin-left: -6px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(18, 32, 27, 0.16);
}

.top-avatar-list .avatar:first-child {
  margin-left: 0;
}

.top-avatar-list .avatar::before {
  top: 6px;
  width: 8px;
  height: 8px;
}

.top-avatar-list .avatar::after {
  bottom: 6px;
  width: 16px;
  height: 8px;
}

.room-name-input {
  width: min(320px, 48vw);
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  outline: 0;
}

.room-name-input:read-only {
  cursor: default;
}

.room-name-input:not(:read-only):hover,
.room-name-input:not(:read-only):focus {
  border-color: rgba(47, 102, 87, 0.28);
  background: var(--control-bg);
}

.room-progress {
  display: grid;
  grid-template-columns: minmax(120px, 170px) auto auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 22%, transparent);
}

.mini-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--sage));
}

.room-progress strong {
  min-width: 34px;
  color: var(--ink);
  font-size: 13px;
}

.room-online-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.timer-button {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-width: 92px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: var(--control-bg);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.board-timer {
  position: absolute;
  z-index: 125;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  min-width: 118px;
  height: 40px;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border-color: rgba(22, 33, 29, 0.16);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 10px 28px rgba(25, 37, 31, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.board-timer svg {
  width: 15px;
  height: 15px;
}

.timer-button svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.6;
}

.timer-button .timer-icon-play {
  display: none;
}

.timer-button.paused .timer-icon-pause {
  display: none;
}

.timer-button.paused .timer-icon-play {
  display: block;
}

.timer-button.readonly,
.timer-button:disabled {
  cursor: default;
  opacity: 0.82;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segment {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-width: 70px;
  height: 34px;
}

.segment.active {
  background: var(--ink);
  color: var(--inverse-ink);
}

.top-actions,
.voice-row,
.prompt-row,
.guess-box,
.chat-form,
.reaction-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.top-actions {
  position: relative;
  z-index: 170;
  justify-self: end;
  justify-content: flex-end;
  min-width: 0;
}

.browse-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.nav-link {
  height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(111, 104, 179, 0.12);
  color: var(--violet);
}

.search-box {
  position: relative;
  justify-self: center;
  width: min(560px, 100%);
  min-width: 0;
}

.lobby-search-toggle {
  display: none;
}

.theme-toggle {
  overflow: hidden;
}

.theme-toggle svg {
  position: absolute;
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.theme-toggle .theme-icon-moon {
  opacity: 0;
  transform: translateY(8px) rotate(-12deg);
}

.theme-toggle.active {
  border-color: rgba(241, 184, 75, 0.42);
  background: rgba(241, 184, 75, 0.14);
  color: var(--gold);
}

.theme-toggle.active .theme-icon-sun {
  opacity: 0;
  transform: translateY(-8px) rotate(12deg);
}

.theme-toggle.active .theme-icon-moon {
  opacity: 1;
  transform: translateY(0) rotate(0deg);
}

.search-box input {
  height: 38px;
  padding-right: 42px;
  border-color: rgba(100, 113, 109, 0.45);
}

.search-box svg {
  position: absolute;
  top: 9px;
  right: 12px;
  width: 19px;
  height: 19px;
  color: var(--muted);
  pointer-events: none;
}

.auth-button,
.user-chip {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  font-weight: 900;
}

.account-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 40px;
}

.login-button {
  background: var(--control-hover);
  color: var(--ink);
}

.signup-button {
  background: var(--violet);
  color: #fff;
}

body[data-auth-state="loading"] .login-button,
body[data-auth-state="loading"] .signup-button,
body[data-auth-state="loading"] .user-chip {
  display: none;
}

body[data-auth-state="loading"] .account-controls {
  flex: 0 0 40px;
  width: 40px;
}

.user-chip {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.user-chip .avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
}

.user-menu {
  position: fixed;
  z-index: 420;
  display: grid;
  gap: 6px;
  width: 300px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.user-menu strong {
  padding: 7px 8px 4px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.user-menu button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  font-weight: 800;
}

.user-menu button:hover {
  background: var(--control-hover);
}

.avatar-picker {
  display: grid;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(100, 113, 109, 0.18);
  border-radius: 8px;
  background: var(--surface-muted);
}

.user-menu .avatar-picker-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 4px 8px;
  color: var(--ink);
}

.user-menu .avatar-picker-toggle .avatar {
  width: 28px;
  height: 28px;
}

.user-menu .avatar-picker-toggle svg {
  width: 17px;
  height: 17px;
  transition: transform 140ms ease;
}

.user-menu .avatar-picker-toggle.active svg {
  transform: rotate(180deg);
}

.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.user-menu .avatar-choice {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 62px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: center;
  font-size: 11px;
}

.user-menu .avatar-choice:hover,
.user-menu .avatar-choice.active {
  border-color: rgba(47, 102, 87, 0.24);
  background: var(--control-hover);
}

.user-menu .avatar-choice.active {
  box-shadow: inset 0 0 0 2px rgba(47, 102, 87, 0.18);
}

.avatar-upload-choice {
  color: var(--muted);
}

.avatar-upload-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px dashed color-mix(in srgb, var(--muted) 48%, transparent);
  border-radius: 999px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
}

.name-input {
  width: 112px;
  height: 40px;
}

.primary-button,
.voice-button,
.tool-button,
.icon-button,
.upload-button,
.create-room-button,
.join-request-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.primary-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border-color: transparent;
  background: var(--sage);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.upload-button {
  display: inline-flex;
  justify-content: center;
  gap: 7px;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.join-request-button {
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--sage-2);
  color: var(--sage);
  font-weight: 800;
  white-space: nowrap;
}

.join-request-button[disabled] {
  cursor: default;
  opacity: 0.72;
}

.members-popover .join-request-button {
  width: 100%;
  margin-bottom: 8px;
}

.members-popover .join-request-button.danger {
  border-color: rgba(216, 74, 58, 0.24);
  background: rgba(216, 74, 58, 0.1);
  color: #b83425;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.icon-button,
.tool-button,
.create-room-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.danger-button {
  border-color: rgba(240, 108, 85, 0.35);
  color: #a13f31;
}

.danger-button:hover {
  background: rgba(240, 108, 85, 0.08);
}

.create-room-button {
  border-color: transparent;
  background: var(--sage);
  color: #fff;
}

.create-room-button svg {
  width: 22px;
  height: 22px;
}

.member-alert-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  display: none;
  width: 11px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #e31b23;
  box-shadow: 0 0 0 2px rgba(227, 27, 35, 0.16);
}

#openMembers.has-member-alert .member-alert-dot {
  display: block;
}

.tool-button.active {
  border-color: rgba(47, 102, 87, 0.34);
  background: var(--sage-2);
  color: var(--sage);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

body[data-screen="game"] .workspace {
  justify-self: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.lobby {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 22px;
  min-height: calc(100vh - 74px);
  padding: 8px 0 28px;
}

.lobby.rail-hidden {
  grid-template-columns: minmax(0, 1fr);
}

body[data-screen="game"] .lobby,
body[data-screen="game"] .profile-view,
body[data-screen="game"] .site-footer,
body[data-screen="lobby"] .workspace,
body[data-screen="lobby"] .profile-view,
body[data-screen="profile"] .workspace,
body[data-screen="profile"] .lobby,
body[data-screen="lobby"] #openMembers,
body[data-screen="profile"] #openMembers,
body[data-screen="lobby"] #copyRoom,
body[data-screen="profile"] #copyRoom,
body[data-screen="profile"] #playerName,
body[data-screen="lobby"] #playerName {
  display: none;
}

body[data-screen="game"] .brand-mark,
body[data-screen="game"] .brand-copy,
body[data-screen="game"] .search-box,
body[data-screen="game"] .lobby-search-toggle,
body[data-screen="game"] .lobby-theme-toggle,
body[data-screen="game"] #playerName,
body[data-screen="game"] .status-strip {
  display: none;
}

body[data-screen="game"] .brand {
  pointer-events: none;
  cursor: default;
}

body[data-screen="game"] .room-summary {
  display: flex;
  pointer-events: auto;
}

body[data-screen="game"] .room-name-input {
  pointer-events: auto;
}

body[data-screen="game"] .top-avatar-list {
  display: flex;
}

body[data-screen="game"] .user-chip {
  display: none;
}

body[data-screen="game"] .topbar {
  grid-template-columns: minmax(0, 1fr) auto;
}

.lobby-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
}

.lobby-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
}

.popular-head {
  gap: 14px;
}

.popular-period-tabs {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  border-radius: 999px;
  padding: 3px;
  background: rgba(103, 117, 93, 0.1);
}

.popular-period-tabs button {
  min-width: 34px;
  border: 0;
  border-radius: 999px;
  padding: 6px 11px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.popular-period-tabs button:hover,
.popular-period-tabs button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(24, 35, 29, 0.1);
}

.lobby-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.lobby-rail {
  position: sticky;
  top: 10px;
  display: grid;
  gap: 10px;
  align-self: start;
  justify-items: center;
  max-height: calc(100dvh - 94px);
  overflow-y: auto;
  overscroll-behavior-block: contain;
  padding: 2px 4px 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.lobby-rail::-webkit-scrollbar {
  display: none;
}

.lobby-rail-mobile {
  display: none;
}

.rail-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-bg);
  padding: 0;
}

.rail-avatar {
  background: transparent;
  color: var(--ink);
}

.rail-avatar:hover {
  outline: 2px solid var(--violet);
}

.rail-avatar .avatar {
  width: 34px;
  height: 34px;
  pointer-events: none;
}

.rail-avatar.is-live::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--topbar-bg);
  border-radius: 999px;
  background: #f04438;
  box-shadow: 0 0 0 2px rgba(240, 68, 56, 0.18);
}

.rail-users {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.rail-user-popover {
  position: fixed;
  z-index: 420;
  display: grid;
  gap: 12px;
  width: min(280px, calc(100vw - 20px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.rail-profile-head {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.rail-profile-head .avatar {
  width: 52px;
  height: 52px;
  box-shadow: 0 12px 26px rgba(25, 37, 31, 0.16);
}

.rail-profile-head div,
.rail-profile-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rail-profile-head strong,
.rail-profile-body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-profile-head strong {
  font-size: 16px;
}

.rail-profile-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border-radius: 10px;
  padding: 10px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--sage-2) 70%, transparent)),
    var(--surface);
}

.rail-profile-head span,
.rail-profile-body span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.rail-profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rail-profile-actions button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 950;
}

.featured-channel {
  min-height: clamp(220px, 24vw, 310px);
  display: flex;
  justify-content: center;
}

.profile-view {
  min-height: calc(100vh - 74px);
  padding: 18px clamp(10px, 4vw, 52px) 44px;
}

.profile-main {
  display: grid;
  gap: 26px;
  width: min(1180px, 100%);
  margin: 0 auto;
}

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 10px 12px 24px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--sage);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-shell {
  display: grid;
  gap: 28px;
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 42px;
}

.legal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.legal-brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 950;
}

.legal-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.legal-nav a {
  color: inherit;
  text-decoration: none;
}

.legal-nav a:hover {
  color: var(--sage);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-document {
  display: grid;
  gap: 18px;
  line-height: 1.68;
}

.legal-document h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

.legal-updated {
  margin: -10px 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.legal-document section {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.legal-document h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.3;
}

.legal-document p,
.legal-document ul,
.legal-document ol {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.legal-document ul,
.legal-document ol {
  padding-left: 22px;
}

.legal-document li + li {
  margin-top: 5px;
}

.legal-contact {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 850;
}

.legal-contact a {
  color: var(--sage);
}

.profile-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.profile-avatar-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  min-width: 76px;
}

.profile-back-button {
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--ink);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.profile-avatar-wrap > .avatar {
  width: 72px;
  height: 72px;
}

.profile-avatar-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(47, 102, 87, 0.22);
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(18, 32, 27, 0.14);
}

.profile-avatar-edit svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-avatar-edit:hover,
.profile-avatar-edit.active {
  background: var(--control-hover);
}

.profile-avatar-picker {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 34px);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.profile-avatar-choice {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.profile-avatar-choice .avatar {
  width: 28px;
  height: 28px;
}

.profile-avatar-choice:hover,
.profile-avatar-choice.active {
  border-color: rgba(47, 102, 87, 0.24);
  background: var(--control-hover);
}

.profile-avatar-upload {
  grid-column: 1 / -1;
  min-height: 30px;
  border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.profile-avatar-upload:hover,
.profile-avatar-upload.active {
  border-color: rgba(47, 102, 87, 0.28);
  background: var(--control-hover);
}

.profile-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.profile-copy h2 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(28px, 4.5vw, 44px);
  line-height: 1.08;
}

.profile-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.profile-social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.profile-social-links button {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.profile-social-links strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
}

.profile-social-links span {
  color: var(--muted);
}

.profile-social-links button:hover {
  color: var(--sage);
}

.profile-bio {
  max-width: 720px;
  color: var(--ink) !important;
  font-size: 14px !important;
  font-weight: 720 !important;
  white-space: normal;
}

.profile-bio-editor {
  max-width: 720px;
  margin-top: 2px;
  line-height: 1.45;
}

.profile-bio-editor textarea {
  display: block;
  width: 100%;
  min-height: 26px;
  overflow: hidden;
  resize: none;
  border: 0;
  border-radius: 7px;
  padding: 3px 8px;
  margin-left: -8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 780;
  line-height: 1.45;
  outline: 0;
  cursor: text;
}

.profile-bio-editor textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}

.profile-bio-editor textarea:focus {
  background: color-mix(in srgb, var(--sage-2) 36%, transparent);
}

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

.profile-social-dialog {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(16, 24, 22, 0.22);
}

.profile-social-dialog[hidden] {
  display: none;
}

.profile-social-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(520px, 100%);
  height: min(720px, calc(100vh - 44px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.profile-social-head {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.profile-social-back {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.profile-social-back:hover {
  background: var(--control-hover);
}

.profile-social-tabs {
  display: flex;
  justify-content: center;
  gap: clamp(16px, 5vw, 28px);
  padding-right: 42px;
}

.profile-social-tabs button {
  position: relative;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.profile-social-tabs button.active {
  color: var(--ink);
}

.profile-social-tabs button.active::after {
  position: absolute;
  right: 8px;
  bottom: 1px;
  left: 8px;
  height: 3px;
  border-radius: 999px;
  background: var(--coral);
  content: "";
}

.profile-social-body {
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 22px;
  background: var(--surface);
}

.profile-social-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
}

.profile-reaction-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

.profile-reaction-user:last-child {
  border-bottom: 0;
}

.profile-social-person {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.profile-social-person .avatar {
  width: 48px;
  height: 48px;
}

.profile-social-person span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.profile-social-person strong,
.profile-social-person small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-social-person strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
}

.profile-social-person small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.profile-reaction-person {
  grid-template-columns: 52px minmax(0, 1fr);
}

.profile-reaction-person .avatar {
  width: 52px;
  height: 52px;
}

.profile-reaction-person small {
  font-size: 14px;
}

.profile-reaction-thumb {
  display: grid;
  place-items: center;
  width: 74px;
  height: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.profile-reaction-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-social-follow,
.profile-social-self {
  min-width: 78px;
  min-height: 34px;
  border: 1px solid var(--coral);
  border-radius: 999px;
  background: transparent;
  color: var(--coral);
  text-align: center;
  font-weight: 900;
}

.profile-social-follow.followed {
  border-color: var(--line);
  color: var(--muted);
}

.profile-social-self {
  display: grid;
  place-items: center;
  border-color: transparent;
  color: var(--muted);
}

.profile-social-empty {
  display: grid;
  align-content: center;
  place-items: center;
  gap: 12px;
  min-height: 100%;
  padding: 44px 18px;
  color: var(--muted);
  text-align: center;
}

.profile-social-empty-icon {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 999px;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.72), transparent 28%),
    var(--surface-muted);
  color: var(--muted);
}

.profile-social-empty-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-social-empty strong {
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.profile-section {
  display: grid;
  gap: 12px;
}

.profile-section-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.profile-section-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
}

.profile-section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.profile-puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  min-height: 48px;
}

.profile-section-empty {
  display: grid;
  grid-column: 1 / -1;
  place-items: center;
  min-height: 116px;
  border: 1px dashed rgba(47, 102, 87, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.38);
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

body[data-theme="dark"] .profile-section-empty {
  border-color: rgba(119, 155, 143, 0.24);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(242, 244, 239, 0.58);
}

.profile-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 900;
}

.profile-pending {
  display: inline-grid;
  grid-template-columns: auto minmax(0, max-content);
  gap: 12px;
  align-items: center;
  justify-self: center;
  max-width: min(420px, calc(100vw - 32px));
  min-height: 54px;
  margin-top: clamp(28px, 8vh, 74px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px 8px 10px;
  background: color-mix(in srgb, var(--surface-soft) 92%, transparent);
  color: var(--muted);
  box-shadow: 0 10px 30px rgba(18, 32, 27, 0.08);
}

.profile-pending-mark {
  width: 34px;
  height: 34px;
  border: 3px solid color-mix(in srgb, var(--sage) 18%, transparent);
  border-top-color: var(--sage);
  border-radius: 999px;
  animation: profile-pending-spin 850ms linear infinite;
}

.profile-pending-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.profile-pending-copy strong,
.profile-pending-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-pending-copy strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
}

.profile-pending-copy span {
  font-size: 12px;
  font-weight: 850;
}

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

.featured-card {
  position: relative;
  display: block;
  width: min(920px, 100%);
  max-width: 100%;
  border-radius: 8px;
  background: var(--thumb-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.featured-live {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(220px, 24vw, 310px);
  border: 0;
  border-radius: 0;
  background: var(--thumb-bg);
  color: inherit;
  overflow: hidden;
  box-shadow: none;
  text-align: left;
}

.featured-live::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(90deg, rgba(242, 244, 239, 0.18), rgba(242, 244, 239, 0.06)),
    var(--featured-bg);
  background-size: cover;
  background-position: center;
  filter: blur(18px) saturate(1.05);
  transform: scale(1.06);
  opacity: 0.58;
}

.featured-live img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.featured-overlay {
  position: absolute;
  left: 16px;
  bottom: 14px;
  z-index: 2;
  display: grid;
  gap: 4px;
  max-width: min(460px, calc(100% - 120px));
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--overlay-panel);
  color: #efeff1;
}

.featured-overlay strong,
.featured-overlay span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.featured-overlay strong {
  font-size: 16px;
}

.featured-overlay span {
  color: #adadb8;
  font-size: 12px;
  font-weight: 800;
}

.live-grid,
.daily-recommendation-grid {
  display: grid;
  grid-auto-columns: clamp(220px, 24vw, 260px);
  grid-auto-flow: column;
  grid-template-columns: none;
  grid-template-rows: repeat(var(--visible-rows, 1), auto);
  gap: 16px;
  align-content: start;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding-bottom: 2px;
  scroll-padding-inline: 2px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.live-grid::-webkit-scrollbar,
.daily-recommendation-grid::-webkit-scrollbar {
  display: none;
}

.live-grid > .live-empty,
.daily-recommendation-grid > .live-empty {
  width: min(100%, 560px);
  min-width: min(100%, 560px);
}

.live-grid .daily-card,
.daily-recommendation-grid .daily-card,
.live-grid .popular-card {
  scroll-snap-align: start;
}

.section-control-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.popular-section {
  display: grid;
  gap: 4px;
  margin-top: -8px;
}

.popular-section[hidden],
.daily-recommendation-section[hidden],
.lobby-search-results[hidden] {
  display: none;
}

.popular-more-row {
  display: grid;
  place-items: center;
  margin-top: -4px;
}

.popular-more-row[hidden] {
  display: none;
}

.popular-more-button,
.section-more-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border: 0;
  border-radius: 999px;
  padding: 8px 15px;
  background: transparent;
  color: #8c65d8;
  font-size: 14px;
  font-weight: 950;
}

.section-more-button[hidden] {
  display: none;
}

.popular-more-button:hover,
.section-more-button:hover {
  background: rgba(140, 101, 216, 0.1);
  color: #6e4fc5;
}

.popular-more-button span[aria-hidden="true"],
.section-more-button span[aria-hidden="true"] {
  font-size: 22px;
  line-height: 0.7;
}

.daily-recommendation-section,
.daily-challenge-section,
.daily-theme-section {
  display: grid;
  gap: 4px;
}

.lobby-search-results {
  display: grid;
  gap: 18px;
}

.search-result-section {
  display: grid;
  gap: 10px;
}

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

.search-result-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

.search-result-head span {
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.search-result-grid {
  display: grid;
  grid-auto-columns: clamp(210px, 24vw, 260px);
  grid-auto-flow: column;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.search-result-grid::-webkit-scrollbar {
  display: none;
}

.search-result-grid > * {
  scroll-snap-align: start;
}

.search-user-card {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 24px rgba(25, 37, 31, 0.08);
}

.search-user-card .avatar {
  flex: 0 0 auto;
}

.search-user-card span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.search-user-card strong,
.search-room-open strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-user-card small,
.search-room-open small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.search-room-card {
  min-width: 0;
}

.search-room-open {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.search-room-thumb {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background: var(--thumb-bg);
  color: var(--muted);
  box-shadow: 0 12px 28px rgba(25, 37, 31, 0.12);
}

.search-room-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-room-thumb b {
  position: absolute;
  top: 8px;
  left: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(238, 97, 76, 0.92);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.search-empty {
  min-height: 160px;
}

.daily-head {
  margin-top: 0;
}

.daily-card {
  display: grid;
  grid-template-rows: auto 18px 26px;
  gap: 7px;
  min-width: 0;
  cursor: pointer;
}

.daily-open {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.daily-thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 12px 28px rgba(25, 37, 31, 0.12);
}

.daily-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

.theme-label {
  position: absolute;
  top: 8px;
  left: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(18, 29, 25, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.daily-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 950;
  line-height: 1.25;
}

.daily-subtitle {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.daily-subtitle span {
  display: inline-flex;
  margin-left: 6px;
  margin-right: 6px;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--sage);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  vertical-align: 1px;
}

.daily-loading .daily-thumb {
  display: grid;
  place-items: center;
  background:
    linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.16) 42%, transparent 62%),
    var(--thumb-bg);
  background-size: 220% 100%, auto;
  animation: daily-loading-shine 1.4s linear infinite;
}

@keyframes daily-loading-shine {
  to {
    background-position: -220% 0, 0 0;
  }
}

.popular-card {
  display: grid;
  grid-template-rows: auto 18px 26px;
  gap: 7px;
  min-width: 0;
  background: transparent;
  color: inherit;
}

.popular-loading-card {
  display: grid;
  grid-template-rows: auto 18px 26px;
  gap: 7px;
  width: 100%;
  min-width: 100%;
}

.popular-loading-thumb,
.popular-loading-line {
  border: 1px solid color-mix(in srgb, var(--sage) 14%, transparent);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0)) 0 0 / 220% 100%,
    color-mix(in srgb, var(--surface) 72%, white);
  animation: popular-loading-sheen 1.2s ease-in-out infinite;
}

.popular-loading-thumb {
  aspect-ratio: 16 / 10;
  border-radius: 8px;
}

.popular-loading-line {
  height: 12px;
  border-radius: 999px;
}

.popular-loading-line.title {
  width: 72%;
}

.popular-loading-line.meta {
  width: 46%;
}

@keyframes popular-loading-sheen {
  from {
    background-position: 120% 0, 0 0;
  }

  to {
    background-position: -120% 0, 0 0;
  }
}

.popular-open {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.popular-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: transparent;
  transition: transform 180ms ease;
}

.popular-card:hover .popular-thumb img {
  transform: none;
}

.popular-card strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  line-height: 1.25;
}

.popular-meta-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.popular-meta-row > strong {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}

.card-meta-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 26px;
}

.card-meta-row .daily-subtitle {
  flex: 1 1 auto;
  min-width: 0;
}

.card-actions {
  flex: 0 0 auto;
}

.popular-author {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
  gap: 6px;
  align-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: default;
}

button.popular-author {
  cursor: pointer;
}

button.popular-author:hover {
  color: var(--ink);
}

.popular-author .avatar {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  box-shadow: 0 0 0 2px var(--surface);
}

.popular-author > span:last-child {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popular-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

.popular-actions.compact {
  justify-content: start;
  margin-left: 0;
}

.popular-actions button,
.popular-count {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 22px;
  border: 0;
  border-radius: 999px;
  padding: 0 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.popular-actions button:hover {
  color: var(--ink);
}

.popular-actions button.active {
  background: transparent;
}

.popular-actions button.active[aria-label="点赞"] {
  color: #e44f73;
}

.popular-actions button.active[aria-label="收藏"] {
  color: #6f68d8;
}

.popular-actions svg,
.popular-count svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.4;
}

.popular-actions button.active svg {
  fill: currentColor;
  stroke: currentColor;
}

.live-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.live-thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 102, 87, 0.22), rgba(103, 167, 200, 0.14)),
    var(--thumb-bg);
  box-shadow: 0 12px 28px rgba(25, 37, 31, 0.12);
}

.live-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--thumb-letterbox);
}

.live-empty-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-weight: 800;
}

.live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--coral);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.live-progress {
  display: none;
}

.live-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--sage));
}

.live-progress-number {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(22, 33, 29, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 6px 14px rgba(18, 32, 27, 0.22);
}

.live-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: start;
}

.live-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 15px;
}

.live-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

body[data-screen="lobby"] .topbar,
body[data-screen="profile"] .topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: calc(100% + 20px);
  margin: -10px -10px 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--topbar-border);
  background: var(--topbar-bg);
  box-shadow: 0 2px 14px rgba(25, 37, 31, 0.12);
}

body[data-screen="lobby"] .brand,
body[data-screen="profile"] .brand {
  grid-column: 1;
  order: 1;
}

body[data-screen="lobby"] .top-actions,
body[data-screen="profile"] .top-actions {
  grid-column: 2;
  order: 2;
  justify-self: end;
  justify-content: flex-end;
}

body[data-screen="lobby"] .lobby-search-toggle,
body[data-screen="profile"] .lobby-search-toggle {
  display: inline-grid;
}

body[data-screen="lobby"] .search-box,
body[data-screen="profile"] .search-box {
  display: none;
  grid-column: 1 / -1;
  order: 3;
  justify-self: stretch;
  width: 100%;
}

body[data-screen="lobby"][data-lobby-search="open"] .search-box,
body[data-screen="profile"][data-lobby-search="open"] .search-box {
  display: block;
}

body[data-screen="lobby"] .brand p {
  display: none;
}

body[data-screen="lobby"] .search-box input {
  height: 42px;
  padding-right: 14px;
  border-color: var(--line);
  background: var(--control-bg);
  color: var(--ink);
}

body[data-screen="lobby"] .search-box svg {
  display: none;
}

body[data-screen="lobby"] .brand h1,
body[data-screen="lobby"] .nav-link,
body[data-screen="lobby"] .live-meta strong {
  color: var(--ink);
}

body[data-screen="lobby"] .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

body[data-screen="lobby"] .live-thumb {
  border-color: var(--line);
  background: var(--thumb-bg);
}

body[data-screen="lobby"] .live-meta span {
  color: var(--muted);
}

body[data-screen="lobby"] .eyebrow {
  background: rgba(145, 71, 255, 0.16);
  color: #bf94ff;
}

body[data-screen="lobby"] .live-empty {
  min-height: 220px;
  border-color: var(--line);
  background: var(--thumb-bg);
  color: var(--muted);
}

.live-empty {
  display: grid;
  place-items: center;
  min-height: 48vh;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 800;
}

.members-popover {
  position: fixed;
  z-index: 420;
  width: min(340px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.members-popover[hidden] {
  display: none;
}

.members-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.members-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.game-column,
.side-panel {
  min-width: 0;
}

.game-column {
  display: grid;
  gap: 8px;
  width: 100%;
}

body[data-screen="game"] .game-column {
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  justify-self: stretch;
  min-height: 0;
}

.status-strip,
.prompt-panel,
.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: 0 10px 28px rgba(25, 37, 31, 0.08);
}

.status-strip {
  display: inline-grid;
  grid-template-columns: minmax(150px, 260px) auto;
  justify-self: start;
  width: min(430px, 100%);
  gap: 10px;
  align-items: center;
  padding: 5px 8px;
  box-shadow: none;
}

body[data-screen="game"] .status-strip {
  display: none;
}

.status-strip > div:first-child {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.eyebrow {
  display: inline-grid;
  place-items: center;
  margin: 0;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: #eef4ec;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.status-strip strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.meter {
  display: grid;
  grid-template-columns: minmax(86px, 1fr) auto;
  gap: 7px;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
}

.meter-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e7df;
}

.meter-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--sage));
  transition: width 220ms ease;
}

.prompt-panel {
  display: block;
  margin-top: 0;
  padding: 8px 10px;
}

body[data-screen="game"] .prompt-panel {
  width: 100%;
  min-width: 0;
}

.prompt-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
}

.prompt-input-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 58px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
}

.prompt-input-shell:focus-within {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(47, 102, 87, 0.16);
}

.prompt-input-shell textarea {
  height: 36px;
  border: 0;
  border-radius: 0;
  padding: 0 6px;
  background: transparent;
  box-shadow: none;
  line-height: 36px;
  overflow: hidden;
}

.prompt-input-shell textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.ai-source-segmented {
  flex: 0 0 auto;
  background: #f7faf5;
}

.ai-source-segmented .segment {
  min-width: 104px;
  padding: 0 10px;
  white-space: nowrap;
}

.prompt-run-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.prompt-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.prompt-cancel-button {
  min-width: 92px;
  color: #a13f31;
}

.prompt-run-button.loading {
  cursor: wait;
}

.prompt-hourglass {
  position: relative;
  width: 16px;
  height: 18px;
  display: inline-block;
  animation: hourglass-flip 1050ms ease-in-out infinite;
}

.prompt-hourglass::before,
.prompt-hourglass::after {
  position: absolute;
  left: 4px;
  width: 0;
  height: 7px;
  content: "";
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

.prompt-hourglass::before {
  top: 1px;
  border-top: 7px solid currentColor;
}

.prompt-hourglass::after {
  bottom: 1px;
  border-bottom: 7px solid currentColor;
  opacity: 0.76;
}

@keyframes hourglass-flip {
  0%,
  42% {
    transform: rotate(0deg);
  }
  58%,
  100% {
    transform: rotate(180deg);
  }
}

.settings-tab {
  position: relative;
  z-index: 220;
  align-self: center;
  flex: 0 0 auto;
}

.ai-chat-tab {
  z-index: 230;
}

.settings-button {
  position: relative;
  width: 40px;
  height: 40px;
  min-height: 40px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.settings-tab.is-disabled .settings-button {
  cursor: not-allowed;
  border-color: rgba(100, 113, 109, 0.18);
  background: rgba(100, 113, 109, 0.08);
  color: rgba(100, 113, 109, 0.72);
  opacity: 0.78;
}

.settings-beta {
  position: absolute;
  top: -7px;
  right: -7px;
  padding: 1px 4px;
  border: 1px solid rgba(100, 113, 109, 0.22);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.1;
  text-transform: uppercase;
  pointer-events: none;
}

.settings-button::-webkit-details-marker {
  display: none;
}

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

.settings-tab[open] .settings-button {
  border-color: rgba(47, 102, 87, 0.32);
  background: var(--sage-2);
  color: var(--sage);
}

.settings-menu {
  position: fixed;
  z-index: 420;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: min(520px, calc(100vw - 20px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.ai-chat-menu {
  width: min(560px, calc(100vw - 20px));
}

.settings-menu .primary-button,
.settings-menu .upload-button,
.settings-menu .segmented {
  width: 100%;
  align-self: center;
}

.settings-menu .ai-source-segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-menu .difficulty-segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-menu .theme-segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.share-menu {
  width: min(240px, calc(100vw - 16px));
}

.share-menu .settings-action-button {
  width: 100%;
}

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

.settings-action-button {
  display: inline-flex;
  justify-content: center;
  gap: 7px;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--ink);
  font-weight: 800;
}

.settings-action-button svg {
  width: 18px;
  height: 18px;
}

.settings-action-button.danger {
  border-color: rgba(240, 108, 85, 0.32);
  color: #a13f31;
}

.settings-action-button.danger:hover {
  background: rgba(240, 108, 85, 0.08);
}

.difficulty-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--control-bg);
  color: var(--ink);
  outline: none;
}

textarea {
  width: 100%;
  min-width: 0;
  height: 58px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--control-bg);
  color: var(--ink);
  font: inherit;
  line-height: 1.35;
  outline: none;
}

textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(47, 102, 87, 0.16);
}

input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(47, 102, 87, 0.16);
}

.board-wrap {
  position: relative;
  width: 100%;
  margin-top: 8px;
}

body[data-screen="game"] .board-wrap {
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  justify-self: stretch;
  min-height: 0;
  margin-top: 0;
  overflow: hidden;
}

.board-tools {
  position: absolute;
  z-index: 120;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  display: flex;
  gap: 8px;
}

.image-preview {
  --preview-size: 260px;
  position: absolute;
  z-index: 45;
  top: 60px;
  left: 68px;
  width: min(var(--preview-size), calc(100vw - 36px));
  max-width: calc(100vw - 36px);
  max-height: min(calc(var(--preview-size) + 44px), calc(100vh - 96px));
  overflow: hidden;
  padding: 0 6px 6px;
  border: 1px solid rgba(22, 33, 29, 0.18);
  border-radius: 8px;
  background: var(--surface-muted);
  box-shadow: 0 18px 42px rgba(25, 37, 31, 0.22);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.image-preview[hidden] {
  display: none;
}

.image-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(calc(var(--preview-size) * 0.76), calc(100vh - 148px));
  object-fit: contain;
  border-radius: 6px;
}

.image-preview-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 36px;
  gap: 8px;
  cursor: grab;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.image-preview.dragging .image-preview-bar {
  cursor: grabbing;
}

.image-preview-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.image-preview-action {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.image-preview-action:hover {
  background: var(--control-hover);
}

.image-preview-action:active {
  background: transparent;
  box-shadow: none;
}

.image-preview-action:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.image-preview-action svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

@media (max-width: 740px) {
  .image-preview {
    --preview-size: 210px;
    width: min(var(--preview-size), calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(44vh, calc(var(--preview-size) + 42px));
    padding: 0 5px 5px;
  }

  .image-preview img {
    max-height: min(calc(var(--preview-size) * 0.72), calc(44vh - 42px));
  }

  .image-preview-bar {
    min-height: 34px;
    font-size: 11px;
  }

  .image-preview-action {
    width: 30px;
    height: 30px;
  }
}

.puzzle-board {
  position: relative;
  width: 100%;
  height: calc(100vh - 184px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 86%, var(--sage) 14%);
  border-radius: 8px;
  background: var(--board-bg);
  background-size: var(--board-bg-size);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    inset 0 28px 80px rgba(255, 255, 255, 0.26),
    inset 0 -28px 72px rgba(47, 102, 87, 0.08),
    var(--shadow);
  user-select: none;
  touch-action: none;
}

body[data-screen="game"] .puzzle-board {
  height: 100%;
  min-height: 0;
}

.piece-tray {
  position: absolute;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 30;
  display: block;
  min-height: 0;
  padding: 8px 10px 8px 42px;
  border: 1px solid var(--topbar-border);
  border-radius: 8px;
  background: var(--tray-bg);
  box-shadow: 0 14px 36px rgba(25, 37, 31, 0.16);
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-x;
}

.piece-tray.collapsed {
  right: auto;
  left: 14px;
  width: 54px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--topbar-border);
  background: var(--tray-bg);
  box-shadow: 0 10px 24px rgba(25, 37, 31, 0.12);
}

.piece-tray.collapsed .tray-slots {
  display: none;
}

.tray-toggle-button {
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  z-index: 85;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
}

.tray-toggle-button:hover {
  color: var(--sage);
}

.tray-toggle-button:focus-visible {
  background: transparent;
  outline: 2px solid rgba(47, 102, 87, 0.42);
  outline-offset: 2px;
}

.tray-toggle-button:focus:not(:focus-visible) {
  outline: none;
}

.tray-toggle-button svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.7;
}

.piece-tray.collapsed .tray-toggle-button {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

body[data-screen="game"] .piece-tray {
  max-height: min(112px, 22dvh);
}

body[data-screen="game"][data-collaboration="visitor"] .piece-tray {
  display: none;
}

.tray-slots {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scroll-behavior: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(47, 102, 87, 0.45) transparent;
  margin-inline: 0;
  padding: 0 2px 5px;
}

.tray-slots::-webkit-scrollbar {
  height: 8px;
}

.tray-slots::-webkit-scrollbar-track {
  background: transparent;
}

.tray-slots::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(47, 102, 87, 0.34);
}

.tray-slot {
  display: block;
  --tray-slot-size: clamp(76px, 7.4vw, 98px);
  flex: 0 0 var(--tray-slot-size);
  width: var(--tray-slot-size);
  height: var(--tray-slot-size);
  border: 1px dashed color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius: 8px;
  background: var(--surface-muted);
}

.tray-slots.completion-recommendations {
  gap: 10px;
  align-items: center;
}

.completion-recommendation {
  display: block;
  --completion-thumb-size: clamp(76px, 7.4vw, 98px);
  flex: 0 0 var(--completion-thumb-size);
  width: var(--completion-thumb-size);
  height: var(--completion-thumb-size);
  min-width: var(--completion-thumb-size);
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--sage) 20%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 90%, var(--sage-2) 10%);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(25, 37, 31, 0.1);
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  touch-action: pan-x;
  user-select: none;
}

.completion-recommendation:hover {
  border-color: color-mix(in srgb, var(--sage) 52%, var(--line));
  background: var(--surface);
  transform: translateY(-1px);
}

.completion-recommendation:focus-visible {
  outline: 3px solid rgba(47, 102, 87, 0.28);
  outline-offset: 2px;
}

.completion-recommendation-thumb {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: 7px;
  background: var(--thumb-bg);
}

.completion-recommendation-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-layer,
.slot-layer,
.piece-layer,
.cursor-layer {
  position: absolute;
  inset: 0;
}

.slot-layer,
.cursor-layer {
  pointer-events: none;
}

.preview-layer {
  opacity: 0;
  pointer-events: none;
}

.puzzle-board.completed .preview-layer {
  opacity: 1;
}

.puzzle-board.completed .slot-layer,
.puzzle-board.completed .piece-layer,
.puzzle-board.completed .cursor-layer {
  opacity: 0;
  pointer-events: none;
}

.slot {
  position: absolute;
  border: 1px dashed color-mix(in srgb, var(--sage) 28%, transparent);
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.1)),
    color-mix(in srgb, var(--surface) 26%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 1px 2px rgba(25, 37, 31, 0.04);
}

.slot.hidden {
  opacity: 0;
}

.piece {
  position: absolute;
  border: 0;
  background: transparent;
  filter:
    drop-shadow(0 2px 1px rgba(8, 18, 15, 0.18))
    drop-shadow(0 7px 8px rgba(8, 18, 15, 0.14));
  transform: translate3d(0, 0, 0);
  transform-origin: 0 0;
  cursor: grab;
  transition: filter 120ms ease, opacity 120ms ease;
  will-change: transform, filter;
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.piece.hidden-piece {
  display: none;
}

.piece.tray-piece {
  z-index: 35;
}

body[data-screen="game"][data-collaboration="visitor"] .piece.tray-piece {
  visibility: hidden;
  pointer-events: none;
}

.piece.remote-moving {
  transition: filter 120ms ease, opacity 120ms ease;
}

.piece.dragging,
.piece.tray-piece {
  transition: none;
}

body[data-tray="hidden"] .piece.tray-piece {
  visibility: hidden;
  pointer-events: none;
}

.piece.tray-overflow {
  visibility: hidden;
  pointer-events: none;
}

.piece::after {
  display: none;
}

.piece.dragging {
  z-index: 80;
  cursor: grabbing;
  filter:
    drop-shadow(0 18px 18px rgba(12, 22, 19, 0.26))
    drop-shadow(0 5px 4px rgba(12, 22, 19, 0.24))
    saturate(1.03);
}

.piece.connected {
  filter:
    drop-shadow(0 1px 1px rgba(8, 18, 15, 0.14))
    drop-shadow(0 4px 5px rgba(8, 18, 15, 0.08));
}

body[data-difficulty="hard"] .piece,
body[data-difficulty="expert"] .piece {
  filter: drop-shadow(0 1px 1px rgba(8, 18, 15, 0.1));
}

body[data-difficulty="hard"] .piece.dragging,
body[data-difficulty="expert"] .piece.dragging {
  filter:
    drop-shadow(0 18px 18px rgba(12, 22, 19, 0.26))
    drop-shadow(0 5px 4px rgba(12, 22, 19, 0.24))
    saturate(1.03);
}

.cursor {
  position: absolute;
  display: grid;
  grid-template-columns: 14px auto;
  gap: 5px;
  align-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 900ms ease;
}

.cursor-dot {
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--cursor-color);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.operation-marker {
  position: absolute;
  z-index: 70;
  max-width: min(180px, 44vw);
  padding: 5px 10px 6px;
  border: 0;
  border-radius: 999px;
  background: var(--operator-color);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.88),
    0 8px 18px color-mix(in srgb, var(--operator-color) 36%, transparent);
}

.operation-group-outline {
  position: absolute;
  z-index: 66;
  border: 3px solid var(--operator-color);
  border-radius: 10px;
  pointer-events: none;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.82),
    0 10px 22px color-mix(in srgb, var(--operator-color) 34%, transparent);
}

.fireworks-layer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 244, 196, 0.32), transparent 38%),
    radial-gradient(circle at 20% 25%, rgba(57, 198, 255, 0.16), transparent 28%),
    radial-gradient(circle at 78% 30%, rgba(255, 95, 70, 0.16), transparent 26%),
    rgba(13, 28, 32, 0.18);
}

.fireworks-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
}

.fireworks-flash {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.78), transparent 56%),
    rgba(255, 255, 255, 0.28);
  animation: fireworks-flash 920ms ease-out both;
}

.firework-ring {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 4px solid var(--spark-color);
  border-radius: 999px;
  filter: drop-shadow(0 0 18px var(--spark-color));
  opacity: 0;
  animation: firework-ring 1500ms ease-out both;
}

.fireworks-layer span {
  position: absolute;
  width: var(--spark-size, 12px);
  height: var(--spark-size, 12px);
  border-radius: 999px;
  background: var(--spark-color);
  box-shadow:
    0 0 14px var(--spark-color),
    0 0 34px var(--spark-color),
    0 0 58px var(--spark-color);
  filter: saturate(1.6);
  animation: firework-spark 1600ms cubic-bezier(0.18, 0.8, 0.28, 1) both;
}

@keyframes firework-spark {
  0% {
    transform: translate3d(0, 0, 0) scale(0.35);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  72% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--spark-x), var(--spark-y), 0) scale(0.04);
    opacity: 0;
  }
}

@keyframes firework-ring {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
  15% {
    opacity: 0.95;
  }
  100% {
    transform: translate(-50%, -50%) scale(13);
    opacity: 0;
  }
}

@keyframes fireworks-flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.side-panel {
  display: none;
  gap: 12px;
  align-content: start;
}

.panel-section {
  padding: 14px;
}

.ai-guess-panel {
  display: none;
}

body[data-mode="ai"] .ai-guess-panel {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 16px;
}

.section-heading span,
.live-pill {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.live-pill {
  color: #fff;
  background: var(--coral);
  border-radius: 999px;
  padding: 4px 8px;
}

.player-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.members-list {
  max-height: min(360px, calc(100vh - 120px));
  overflow: auto;
  margin-top: 0;
}

.player-strip {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 0;
  overflow: hidden;
}

body[data-mode="solo"] .player-strip,
body[data-mode="solo"] .name-input {
  display: none;
}

.player {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
}

.player-avatar-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.player-avatar-button:hover .avatar,
.player-avatar-button:focus-visible .avatar {
  transform: translateY(-1px);
  outline: 2px solid rgba(47, 102, 87, 0.32);
}

.kick-button,
.approve-button,
.deny-button {
  min-width: 52px;
  height: 30px;
  border: 1px solid rgba(240, 108, 85, 0.4);
  border-radius: 7px;
  background: rgba(240, 108, 85, 0.08);
  color: #a13f31;
  font-size: 12px;
  font-weight: 800;
}

.approve-button {
  border-color: rgba(47, 102, 87, 0.32);
  background: var(--sage-2);
  color: var(--sage);
}

.join-request-row {
  border-style: dashed;
}

.player-strip .player {
  grid-template-columns: 30px auto;
  gap: 7px;
  max-width: 150px;
  padding: 5px 8px 5px 5px;
  border-radius: 999px;
}

.player-strip .player div {
  min-width: 0;
}

.player-strip .player strong {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-strip .player span:last-child {
  display: none;
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--avatar-color);
  color: #fff;
  font-weight: 900;
}

.avatar::before,
.avatar::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
}

.avatar::before {
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.avatar::after {
  bottom: 7px;
  width: 17px;
  height: 9px;
  border-radius: 999px 999px 5px 5px;
}

.animal-avatar {
  overflow: hidden;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.62), transparent 24%),
    linear-gradient(145deg, color-mix(in srgb, var(--avatar-color) 62%, #fff), var(--avatar-color));
  box-shadow:
    inset 0 -5px 10px rgba(18, 32, 27, 0.12),
    0 5px 12px rgba(18, 32, 27, 0.14);
}

.custom-avatar {
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.38),
    0 5px 12px rgba(18, 32, 27, 0.14);
}

.custom-avatar::before,
.custom-avatar::after {
  display: none;
}

.custom-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.animal-avatar::before,
.animal-avatar::after {
  display: none;
}

.animal-avatar .avatar-emoji {
  display: block;
  font-size: 21px;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(18, 32, 27, 0.16));
  transform-origin: 50% 85%;
  animation: animal-avatar-bob 1850ms ease-in-out infinite;
}

.animal-avatar:hover .avatar-emoji,
.user-chip:hover .animal-avatar .avatar-emoji,
.avatar-choice.active .avatar-emoji {
  animation-duration: 900ms;
}

.top-avatar-list .animal-avatar .avatar-emoji,
.player .animal-avatar .avatar-emoji {
  font-size: 19px;
}

.avatar-choice .animal-avatar {
  width: 34px;
  height: 34px;
}

@keyframes animal-avatar-bob {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg) scale(1);
  }
  45% {
    transform: translateY(-2px) rotate(2deg) scale(1.08);
  }
  70% {
    transform: translateY(1px) rotate(-1deg) scale(0.98);
  }
}

.player-strip .avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
}

.player strong,
.room-card strong {
  display: block;
  font-size: 14px;
}

.player span,
.room-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.voice-row {
  margin-top: 10px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.network-tip {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.solo-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.solo-stats div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
}

.solo-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.solo-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.voice-button {
  flex: 1;
  display: inline-flex;
  justify-content: center;
  gap: 7px;
  align-items: center;
  min-height: 40px;
  border-radius: 8px;
  font-weight: 800;
}

.voice-button.active {
  border-color: rgba(47, 102, 87, 0.35);
  background: var(--sage-2);
  color: var(--sage);
}

.go-live-button {
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.go-live-top-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  color: var(--ink);
}

.go-live-button.active {
  border-color: rgba(238, 97, 76, 0.38);
  background: rgba(238, 97, 76, 0.12);
  color: var(--coral);
}

.go-live-top-button.active {
  border-color: rgba(238, 97, 76, 0.38);
  background: rgba(238, 97, 76, 0.12);
  color: var(--coral);
}

.go-live-button[disabled] {
  opacity: 0.62;
  cursor: wait;
}

.go-live-top-button[disabled] {
  opacity: 0.62;
  cursor: wait;
}

.chat-section {
  min-height: 280px;
}

body[data-mode="solo"] .chat-section {
  display: none;
}

.chat-log {
  display: grid;
  gap: 8px;
  height: 184px;
  overflow: auto;
  padding-right: 4px;
}

.message {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f3f7ef;
}

.message.me {
  background: #eaf2f5;
}

.message strong {
  font-size: 12px;
}

.message span {
  font-size: 13px;
  line-height: 1.35;
}

.chat-form {
  margin-top: 10px;
}

.guess-box {
  align-items: stretch;
}

.guess-result {
  min-height: 38px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.room-card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  text-align: left;
}

.room-card.active {
  border-color: rgba(47, 102, 87, 0.48);
  background: var(--sage-2);
}

.room-thumb {
  width: 54px;
  height: 40px;
  border-radius: 6px;
  background: var(--thumb);
}

.room-card .room-progress {
  min-width: 46px;
  color: var(--sage);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.reaction-row {
  margin-top: 10px;
}

.reaction-row button {
  flex: 1;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--ink);
  font-size: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease both;
}

.auth-modal,
.room-name-modal,
.puzzle-name-modal,
.gallery-modal,
.completion-modal {
  width: min(430px, calc(100vw - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  background: transparent;
}

.auth-modal {
  width: min(500px, calc(100vw - 28px));
}

.auth-modal[data-auth-mode="login"] {
  width: min(420px, calc(100vw - 28px));
}

.gallery-modal {
  width: min(920px, calc(100vw - 32px));
  height: min(760px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  touch-action: pan-y;
}

.auth-modal::backdrop,
.room-name-modal::backdrop,
.puzzle-name-modal::backdrop,
.gallery-modal::backdrop,
.completion-modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.auth-card,
.room-name-card,
.puzzle-name-card,
.gallery-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.auth-card {
  gap: 14px;
  padding: 26px;
}

.room-name-card,
.puzzle-name-card {
  gap: 18px;
  padding: 26px;
}

.small-modal-copy {
  display: grid;
  gap: 6px;
  padding-right: 34px;
}

.small-modal-copy h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.05;
}

.small-modal-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.small-modal-field {
  display: grid;
  gap: 8px;
  font-weight: 900;
}

.small-modal-field span {
  color: var(--muted);
  font-size: 13px;
}

.small-modal-field input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--control-bg);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.completion-dialog-card {
  position: relative;
  display: grid;
  gap: 8px;
  width: 100%;
  max-height: calc(100dvh - 28px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  overflow-y: auto;
}

.completion-dialog-card canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #101412;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

.completion-dialog-card .modal-close {
  z-index: 3;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(245, 255, 249, 0.48);
  background: rgba(10, 21, 18, 0.42);
  color: #f5fff9;
  font-size: 24px;
  line-height: 30px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.completion-dialog-card .modal-close:hover,
.completion-dialog-card .modal-close:focus-visible {
  background: rgba(245, 255, 249, 0.9);
  color: #0f1714;
}

.completion-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.completion-actions .primary-button,
.completion-actions .settings-action-button {
  min-height: 40px;
  border-color: transparent;
  background: var(--sage);
  color: #fff;
  font-weight: 850;
}

.completion-actions .primary-button:hover,
.completion-actions .settings-action-button:hover {
  background: color-mix(in srgb, var(--sage) 86%, #000 14%);
}

.gallery-card {
  height: 100%;
  max-height: calc(100dvh - 32px);
  min-height: 0;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
  touch-action: pan-y;
}

.auth-card h2,
.gallery-card h2 {
  margin: 0;
}

.auth-card h2 {
  order: 1;
  padding-right: 28px;
  font-size: 22px;
  line-height: 1.25;
}

.auth-modal[data-auth-mode="login"] .auth-card h2 {
  padding-right: 0;
  font-size: 21px;
  text-align: center;
}

.auth-social {
  order: 2;
  display: grid;
  gap: 8px;
}

.auth-divider {
  order: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.auth-fields {
  order: 4;
  display: grid;
  gap: 8px;
}

.auth-fields label {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 800;
}

.auth-field-hint {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.auth-field-hint.invalid {
  color: #d1242f;
  font-weight: 800;
}

#authSubmit {
  order: 5;
}

.auth-switch {
  order: 6;
}

#authMessage {
  order: 7;
  min-height: 18px;
}

.social-auth-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 0 14px;
  background: #f6f8fa;
  color: #24292f;
  font-weight: 700;
}

.social-auth-button:hover {
  background: #eef2f6;
}

.social-auth-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.google-icon {
  width: 19px;
  height: 19px;
}

.auth-modal[data-auth-mode="login"] .auth-fields {
  order: 2;
}

.auth-modal[data-auth-mode="login"] #authSubmit {
  order: 3;
  background: #2da44e;
}

.auth-modal[data-auth-mode="login"] .auth-divider {
  order: 4;
}

.auth-modal[data-auth-mode="login"] .auth-social {
  order: 5;
}

.auth-modal[data-auth-mode="login"] .auth-switch {
  order: 6;
}

.auth-modal[data-auth-mode="login"] #authMessage {
  order: 7;
}

.auth-card input,
.gallery-card input,
.gallery-card select {
  border-color: var(--line);
  background: var(--control-bg);
  color: var(--ink);
}

.auth-modal[data-auth-mode="login"] .auth-card input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(47, 102, 87, 0.18);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
}

.auth-card p,
.gallery-card p {
  color: var(--muted);
  font-size: 13px;
}

.auth-switch {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-switch button {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--violet);
  font-weight: 900;
}

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

.gallery-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
}

.gallery-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
}

.gallery-tabs button {
  min-width: 0;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.gallery-tabs button.active {
  background: var(--ink);
  color: var(--inverse-ink);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  min-height: 0;
  max-height: min(520px, 62vh);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.gallery-item {
  display: grid;
  gap: 7px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  align-content: start;
}

.gallery-popular-item {
  align-content: start;
}

.gallery-popular-item .popular-open {
  display: grid;
  gap: 7px;
  padding: 0;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  object-fit: contain;
  background: var(--thumb-letterbox);
}

.gallery-popular-item .popular-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.gallery-popular-item .popular-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  object-fit: cover;
  background: transparent;
}

.profile-view .my-puzzle-open img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: transparent;
}

.gallery-card-label {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.gallery-upload-tile {
  align-content: center;
  align-items: center;
  justify-content: center;
  justify-items: center;
  min-height: 156px;
  border: 1.5px dashed #6b43c9;
  border-radius: 8px;
  background: var(--surface-muted);
}

body[data-theme="dark"] .gallery-upload-tile {
  border-color: rgba(145, 71, 255, 0.58);
  background: rgba(255, 255, 255, 0.025);
}

.gallery-upload-tile:hover {
  border-color: #9147ff;
  background: var(--control-hover);
}

body[data-theme="dark"] .gallery-upload-tile:hover {
  background: rgba(145, 71, 255, 0.12);
}

.gallery-upload-tile[disabled] {
  cursor: wait;
  opacity: 0.72;
}

.gallery-plus {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 72px;
  font-weight: 950;
  line-height: 1;
}

.gallery-upload-tile.is-busy .gallery-plus::before {
  content: "";
  width: 30px;
  height: 30px;
  border: 3px solid rgba(47, 102, 87, 0.18);
  border-top-color: var(--sage);
  border-radius: 999px;
  animation: action-spin 0.75s linear infinite;
}

.my-puzzle-card {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 0;
}

.my-puzzle-open {
  display: grid;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.my-puzzle-open:hover img {
  outline: 2px solid #9147ff;
}

.gallery-card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 28px;
}

.gallery-card-row strong {
  min-width: 0;
  align-self: center;
}

.gallery-card-progress {
  min-width: 34px;
  color: var(--ink);
  font-weight: 900;
  text-align: right;
}

.gallery-inline-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  min-height: 26px;
}

.gallery-icon-action {
  position: relative;
  display: inline-flex;
  place-items: center;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(47, 102, 87, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

body[data-theme="dark"] .gallery-icon-action {
  border-color: rgba(242, 244, 239, 0.12);
  background: rgba(242, 244, 239, 0.06);
  color: rgba(242, 244, 239, 0.72);
}

.gallery-icon-action[disabled] {
  cursor: wait;
  opacity: 0.7;
}

.gallery-icon-action svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-icon-action.is-busy svg {
  opacity: 0;
}

.gallery-icon-action.is-busy::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(47, 102, 87, 0.18);
  border-top-color: currentColor;
  border-radius: 999px;
  animation: action-spin 0.75s linear infinite;
}

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

.gallery-icon-action:hover {
  background: rgba(47, 102, 87, 0.12);
  color: var(--ink);
}

body[data-theme="dark"] .gallery-icon-action:hover {
  background: rgba(242, 244, 239, 0.12);
  color: var(--ink);
}

.gallery-icon-action.visibility-public {
  color: var(--sage);
}

body[data-theme="dark"] .gallery-icon-action.visibility-public {
  color: #8ed5bd;
}

.gallery-icon-action.visibility-private {
  color: var(--muted);
}

body[data-theme="dark"] .gallery-icon-action.visibility-private {
  color: rgba(242, 244, 239, 0.72);
}

.gallery-icon-action.danger {
  width: 26px;
  min-width: 26px;
  padding: 0;
  border-color: rgba(216, 74, 58, 0.14);
  color: var(--muted);
}

body[data-theme="dark"] .gallery-icon-action.danger {
  border-color: rgba(240, 108, 85, 0.2);
  color: rgba(242, 244, 239, 0.72);
}

.gallery-icon-action.danger:hover {
  background: rgba(216, 74, 58, 0.14);
  color: #b83425;
}

body[data-theme="dark"] .gallery-icon-action.danger:hover {
  background: rgba(240, 108, 85, 0.16);
  color: #ff9d8d;
}

.gallery-source-private {
  cursor: default;
  opacity: 0.72;
  pointer-events: none;
}

body[data-theme="dark"] .gallery-source-private {
  border-color: rgba(242, 244, 239, 0.1);
  background: rgba(242, 244, 239, 0.045);
  color: rgba(242, 244, 239, 0.56);
}

.gallery-inline-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.gallery-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.editable-puzzle-title {
  cursor: text;
}

.editable-puzzle-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gallery-item span {
  color: var(--muted);
  font-size: 12px;
}

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

@media (max-width: 1080px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  body[data-screen="lobby"] .topbar,
  body[data-screen="profile"] .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  body[data-screen="lobby"] .browse-nav,
  body[data-screen="lobby"] .search-box,
  body[data-screen="profile"] .search-box {
    grid-column: 1 / -1;
  }

  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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

  .chat-section {
    grid-column: 1 / -1;
  }

  body[data-screen="game"] .topbar {
    gap: 8px;
    margin-bottom: 8px;
  }

  body[data-screen="game"] .prompt-panel {
    padding: 6px 8px;
  }

  body[data-screen="game"] textarea {
    height: 46px;
    padding-block: 7px;
  }

  body[data-screen="game"] .prompt-input-shell textarea {
    height: 36px;
    padding-block: 0;
    line-height: 36px;
  }

  body[data-screen="game"] .prompt-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  body[data-screen="game"] .piece-tray {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    min-height: 0;
    padding: 8px 8px 8px 38px;
  }

  body[data-screen="game"] .tray-slot {
    --tray-slot-size: clamp(70px, 12dvh, 88px);
  }

  body[data-screen="game"] .completion-recommendation {
    --completion-thumb-size: clamp(70px, 12dvh, 88px);
  }
}

@media (max-width: 740px) {
  .app-shell {
    padding: 10px;
  }

  .popular-head {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .popular-head > div:first-child {
    min-width: 0;
  }

  .popular-head h2 {
    white-space: nowrap;
    font-size: 20px;
  }

  .popular-head .section-control-row {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .popular-period-tabs {
    width: auto;
  }

  .popular-period-tabs button {
    min-width: 32px;
    padding: 6px 10px;
  }

  .daily-recommendation-grid,
  .daily-challenge-grid,
  .daily-theme-grid,
  .live-grid {
    grid-auto-columns: minmax(210px, 78vw);
    grid-template-columns: none;
  }

  .profile-view {
    padding: 12px 0 32px;
  }

  .profile-hero {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .profile-back-button {
    grid-column: 1;
  }

  .profile-avatar-wrap {
    grid-column: 1;
    width: 62px;
    min-width: 62px;
  }

  .profile-avatar-wrap > .avatar {
    width: 58px;
    height: 58px;
  }

  .profile-avatar-edit {
    width: 24px;
    height: 24px;
  }

  .profile-avatar-picker {
    grid-template-columns: repeat(4, 32px);
  }

  .profile-copy {
    grid-column: 2;
    grid-row: 1;
  }

  .profile-social-links {
    gap: 10px 14px;
  }

  .profile-social-links button {
    font-size: 13px;
  }

  .profile-social-links strong {
    font-size: 14px;
  }

  .profile-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .profile-actions > button {
    width: 100%;
  }

  .profile-social-dialog {
    align-items: stretch;
    padding: 0;
    background: var(--surface);
  }

  .profile-social-panel {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .profile-social-head {
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .profile-social-tabs {
    gap: 18px;
    padding-right: 34px;
  }

  .profile-social-tabs button {
    font-size: 16px;
  }

  .profile-social-body {
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  .profile-puzzle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .legal-shell {
    width: min(100%, calc(100% - 24px));
    gap: 22px;
    padding-top: 20px;
  }

  .legal-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .legal-nav {
    justify-content: flex-start;
  }

  .topbar {
    gap: 10px;
  }

  body[data-screen="lobby"] .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    width: calc(100% + 20px);
    padding: 10px;
  }

  body[data-screen="lobby"] .brand,
  body[data-screen="profile"] .brand {
    grid-column: 1;
    order: 1;
    min-width: 0;
  }

  body[data-screen="lobby"] .brand-mark,
  body[data-screen="profile"] .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }

  body[data-screen="lobby"] .brand h1,
  body[data-screen="profile"] .brand h1 {
    overflow: hidden;
    font-size: 19px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-screen="lobby"] .top-actions,
  body[data-screen="profile"] .top-actions {
    grid-column: 2;
    order: 2;
    justify-self: end;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 8px;
  }

  body[data-screen="lobby"] .lobby-search-toggle,
  body[data-screen="profile"] .lobby-search-toggle {
    display: inline-grid;
  }

  body[data-screen="lobby"] .search-box,
  body[data-screen="profile"] .search-box {
    display: none;
    grid-column: 1 / -1;
    order: 3;
    width: 100%;
  }

  body[data-screen="lobby"][data-lobby-search="open"] .search-box,
  body[data-screen="profile"][data-lobby-search="open"] .search-box {
    display: block;
  }

  body[data-screen="lobby"] .search-box input,
  body[data-screen="profile"] .search-box input {
    height: 44px;
    padding-right: 14px;
    font-size: 16px;
  }

  body[data-screen="lobby"] .search-box svg {
    display: none;
  }

  body[data-screen="lobby"] .login-button,
  body[data-screen="lobby"] .signup-button {
    min-height: 38px;
    padding: 0 12px;
  }

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

  .lobby-main {
    align-content: start;
    grid-auto-rows: max-content;
  }

  .featured-channel:empty,
  .featured-channel[hidden] {
    min-height: 0;
  }

  .lobby-rail {
    display: none;
  }

  .lobby-rail.lobby-rail-mobile {
    position: static;
    display: grid;
    width: 100%;
    max-height: none;
    margin: -2px 0 6px;
    overflow: hidden;
    padding: 0;
    align-self: start;
    justify-items: stretch;
  }

  .lobby-rail-mobile .rail-users {
    grid-auto-columns: 36px;
    grid-auto-flow: column;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 2px 0 8px;
    scroll-padding-inline: 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .lobby-rail-mobile .rail-users::-webkit-scrollbar {
    display: none;
  }

  .lobby-rail-mobile .rail-avatar {
    scroll-snap-align: start;
  }

  .gallery-head,
  .gallery-controls {
    grid-template-columns: 1fr;
  }

  .gallery-modal {
    width: calc(100vw - 20px);
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .gallery-card {
    max-height: calc(100dvh - 24px);
    padding: 18px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .prompt-panel {
    grid-template-columns: 1fr;
  }

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

  .prompt-input-shell {
    grid-template-columns: 1fr;
  }

  .ai-source-segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .ai-source-segmented .segment {
    min-width: 0;
  }

  .prompt-row,
  .voice-row,
  .guess-box {
    flex-direction: column;
    align-items: stretch;
  }

  .status-strip {
    display: grid;
  }

  body[data-screen="game"] .status-strip {
    display: none;
  }

  .meter {
    grid-template-columns: 1fr auto;
  }

  .puzzle-board {
    height: calc(100vh - 260px);
    min-height: 420px;
  }

  body[data-screen="game"] .puzzle-board {
    height: 100%;
    min-height: 0;
  }

  body[data-screen="game"] .piece-tray {
    min-height: 0;
    padding-top: 8px;
  }

  body[data-screen="game"] .tray-slot {
    --tray-slot-size: clamp(66px, 13dvh, 82px);
  }

  body[data-screen="game"] .completion-recommendation {
    --completion-thumb-size: clamp(66px, 13dvh, 82px);
  }

  .side-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body[data-screen="game"] .app-shell {
    padding: 6px;
    padding-bottom: 0;
  }

  body[data-screen="game"] .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    align-items: stretch;
    margin-bottom: 6px;
  }

  body[data-screen="game"] .brand,
  body[data-screen="game"] .room-summary,
  body[data-screen="game"] .room-summary-main {
    width: 100%;
    min-width: 0;
  }

  body[data-screen="game"] .room-name-input {
    width: 100%;
    height: 26px;
    padding: 0;
    font-size: 16px;
  }

  body[data-screen="game"] .room-progress {
    grid-template-columns: minmax(72px, 1fr) auto auto;
    gap: 6px;
  }

  body[data-screen="game"] .room-progress strong,
  body[data-screen="game"] .room-online-count {
    font-size: 12px;
  }

  body[data-screen="game"] .board-timer {
    min-width: 108px;
    height: 38px;
    padding: 0 10px;
    font-size: 12px;
  }

  body[data-screen="game"] .top-actions {
    justify-self: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
    overflow: visible;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body[data-screen="game"] .top-actions::-webkit-scrollbar {
    display: none;
  }

  body[data-screen="game"] .auth-button,
  body[data-screen="game"] .join-request-button {
    flex: 0 0 auto;
    min-height: 36px;
    height: 36px;
    padding: 0 11px;
    border-radius: 8px;
    font-size: 14px;
  }

  body[data-screen="game"] .icon-button,
  body[data-screen="game"] .create-room-button,
  body[data-screen="game"] .user-chip {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
  }

  body[data-screen="game"] .prompt-panel {
    padding: 6px;
  }

  body[data-screen="game"] .prompt-row {
    grid-template-columns: minmax(0, 1fr) auto 48px;
    gap: 6px;
  }

  body[data-screen="game"] .prompt-input-shell {
    min-height: 50px;
    gap: 5px;
    padding: 5px;
  }

  body[data-screen="game"] .prompt-input-shell textarea {
    height: 30px;
    line-height: 30px;
    font-size: 14px;
  }

  body[data-screen="game"] .ai-source-segmented .segment {
    min-height: 30px;
    padding: 0 8px;
    font-size: 12px;
  }

  body[data-screen="game"] .prompt-run-button {
    min-height: 50px;
    padding: 0 12px;
    font-size: 15px;
  }

  body[data-screen="game"] .settings-menu {
    position: fixed;
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body[data-screen="game"] .settings-actions {
    grid-template-columns: 1fr;
  }
}

body[data-screen="game"][data-room-chrome="hidden"] .topbar,
body[data-screen="game"][data-room-chrome="hidden"] .prompt-panel {
  display: none !important;
}

body[data-screen="game"][data-room-chrome="hidden"] .app-shell {
  grid-template-rows: minmax(0, 1fr);
  padding-top: max(14px, env(safe-area-inset-top));
  padding-bottom: 0;
}

body[data-screen="game"][data-room-chrome="hidden"] .board-tools {
  top: max(16px, calc(env(safe-area-inset-top) + 10px));
}

body[data-screen="game"][data-room-chrome="hidden"] .workspace {
  height: 100%;
  min-height: 0;
}

body[data-screen="game"][data-room-chrome="hidden"] .game-column {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

body[data-screen="game"][data-room-chrome="hidden"] .board-wrap {
  grid-row: 1;
  height: 100%;
}

@media (max-width: 740px) {
  body[data-screen="game"][data-room-chrome="hidden"] .app-shell {
    padding-top: max(28px, env(safe-area-inset-top));
  }

  body[data-screen="game"][data-room-chrome="hidden"] .board-tools {
    top: 14px;
  }
}

body[data-screen="game"] .piece-tray.collapsed {
  right: auto;
  width: 54px;
  min-height: 54px;
  max-height: 54px;
  padding: 10px;
}

@media (max-width: 740px) {
  body[data-screen="game"] .piece-tray.collapsed {
    left: 10px;
    width: 50px;
    min-height: 50px;
    max-height: 50px;
    padding: 8px;
  }
}
