/* TSM visual language v1 — website-wide shared presentation contract.
 * Reference pages: Media, Luminaries, Notifications.
 * Owners: ordinary website shell/panel geometry, empty/loading states,
 * guest Profile and auth-page alignment. Does not style game canvases,
 * modal Sazan Cards, admin editing tools or interactive game controls.
 * Keep the established vertical spacing and page-specific accent palettes. */
body:not(.tsm-game-page) {
  --tsm-visual-width: var(--tsm-sazan-card-width, var(--sv2-canvas-width, min(760px, calc(100vw - 36px))));
  --tsm-visual-gap: var(--tsm-panel-gap, 16px);
  --tsm-visual-radius: var(--tsm-panel-radius, 18px);
}
/* Site-wide consistency for root website panels and standalone status boxes.
   Preserve nested grid tiles, media galleries, overlays and tabs. */
body:not(.tsm-game-page) main > :is(
  .tsm-section-heading, .tsm-panel-title, .tsm-content-host, .tsm-gallery-host,
  .ns-empty, .tsm-loading-panel, .tsm-loading-state, .tsm-empty-state,
  [data-gallery-status], [data-content-status], [data-loading-status]
) {
  box-sizing: border-box !important;
  width: min(100%, var(--tsm-visual-width)) !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
/* Other page-owned panels use the same width token without forcing a different
   aspect ratio or changing page-specific vertical spacing. */
body:not(.tsm-game-page) main > :is(
  .tsm-cms-panels, .tsm-media-queue, .tsm-auth-stack,
  .tsm-notification-toolbar, .tsm-notification-list
) {
  box-sizing: border-box !important;
  width: min(100%, var(--tsm-visual-width)) !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-inline: auto !important;
}
/* A state explicitly hidden by Auth or the CMS must not reappear through old
   flex/grid !important rules. */
body:not(.tsm-game-page) :is([data-auth-guest],[data-auth-user],.tsm-content-host,.tsm-gallery-host)[hidden] {
  display: none !important;
}
body:not(.tsm-game-page).tsm-signed-in [data-auth-guest] {
  display: none !important;
}
body:not(.tsm-game-page):not(.tsm-auth-resolved) [data-auth-guest] {
  display: none !important;
}
/* The Shell belongs to the stable website chrome, not a page-entry animation.
   Its position may change on scroll, but it must not slide into view on load. */
body:not(.tsm-game-page).tsm-page-profile > header.tsm-canonical-shell {
  transition: none !important;
}
/* Profile: logged-out page is only heading, supporting copy and a sign-in
   action. Eliminate the old full-height, padded guest placeholder. */
body.tsm-page-profile main.profile-page {
  min-height: 0 !important;
}
body.tsm-page-profile main.profile-page > .profile-guest:not([hidden]) {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: center !important;
  box-sizing: border-box !important;
  position: static !important;
  flex: 0 0 auto !important;
  width: min(100%, var(--tsm-visual-width)) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  margin: 0 auto !important;
  padding: 0 !important;
  gap: var(--tsm-visual-gap) !important;
  transform: none !important;
}
body.tsm-page-profile main.profile-page > .profile-guest:not([hidden]) > p {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
}
body.tsm-page-profile main.profile-page > .profile-guest:not([hidden]) > a {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}
/* Sign In: repair horizontal dimensions and colour ONLY. The label/input
   grouping and vertical rhythm are deliberately unchanged. */
body.tsm-page-signin {
  --tsm-auth-accent: #f6c933;
  --tsm-auth-accent-rgb: 246,201,51;
}
body.tsm-page-signin main.tsm-auth-main,
body.tsm-page-signin main.tsm-auth-main > .tsm-auth-stack,
body.tsm-page-signin .tsm-auth-stack > .tsm-auth-form,
body.tsm-page-signin .tsm-auth-form > .tsm-auth-field-group,
body.tsm-page-signin .tsm-auth-stack > .tsm-panel,
body.tsm-page-signin .tsm-auth-form > .tsm-panel,
body.tsm-page-signin .tsm-auth-field-group > .tsm-panel {
  box-sizing: border-box !important;
  width: min(100%, var(--tsm-visual-width)) !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
body.tsm-page-signin main.tsm-auth-main > .tsm-section-heading,
body.tsm-page-signin main.tsm-auth-main .tsm-panel {
  border-color: #f6c933 !important;
}
body.tsm-page-signin .tsm-auth-title-panel label,
body.tsm-page-signin .tsm-auth-link-panel a { color: #f6c933 !important; }
body.tsm-page-signin .tsm-auth-input-panel:focus-within {
  border-color: #f6c933 !important;
}

/* Signed-in users never see the guest sign-in form. Their destination remains
   the existing Profile page; no change to credentials or redirect logic. */
body.tsm-page-signin.tsm-signed-in .tsm-auth-stack {
  display: none !important;
}
body.tsm-page-signin .tsm-auth-already-signed-in {
  box-sizing: border-box;
  width: min(100%, var(--tsm-visual-width));
  margin: var(--tsm-visual-gap) auto 0;
  padding: 16px;
  text-align: center;
  border: 3px solid #f6c933;
  border-radius: var(--tsm-visual-radius);
  background: #101018;
  color: #f6c933;
}
body.tsm-page-signin .tsm-auth-already-signed-in[hidden] {
  display: none !important;
}
body.tsm-page-signin .tsm-auth-already-signed-in a {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 14px;
  margin-top: var(--tsm-visual-gap);
  border: 2px solid #f6c933;
  border-radius: var(--tsm-visual-radius);
  color: #f6c933;
  text-decoration: none;
  font-weight: 900;
}
