@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap");

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

* {
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

:root {
  color-scheme: dark;
  /* Side insets match the corner logos' outer margins, not their widths.
     JS copies the live offsets; these match the logo CSS before that runs. */
  --table-gutter-left: max(0.7rem, env(safe-area-inset-left, 0px));
  --table-gutter-right: calc(clamp(0.5rem, 1.5vw, 2rem) + 0.75rem);
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  margin: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

body {
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
  color: #f0f0f0;
  background-color: #0b0b0b;
  background-image:
    linear-gradient(
      175deg,
      rgba(255, 255, 255, 0.04) 0%,
      transparent 28%,
      transparent 72%,
      rgba(0, 0, 0, 0.35) 100%
    ),
    repeating-linear-gradient(
      45deg,
      #141414 0px,
      #141414 2px,
      #0e0e0e 2px,
      #0e0e0e 4px
    ),
    repeating-linear-gradient(
      -45deg,
      #181818 0px,
      #181818 2px,
      #101010 2px,
      #101010 4px
    ),
    linear-gradient(#121212, #0a0a0a);
  background-attachment: fixed;
}

.app-main {
  height: 100svh;
  max-height: 100svh;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  padding-top: clamp(0.85rem, 1.6vw, 1.5rem);
  padding-bottom: clamp(0.65rem, 1.4vw, 1.25rem);
  padding-left: max(var(--table-gutter-left), env(safe-area-inset-left, 0px));
  padding-right: max(var(--table-gutter-right), env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}

.periodic-table {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Auto-hiding top navigation ── */
.top-nav-hotzone {
  --top-nav-hotzone-h: 1.35rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: var(--top-nav-hotzone-h);
  pointer-events: auto;
}

.top-nav {
  --top-nav-pullbar-h: 1.15rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 clamp(0.5rem, 1.5vw, 2rem);
  pointer-events: none;
  transform: translateY(0);
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.top-nav.is-hidden {
  transform: translateY(calc(-100% + var(--top-nav-pullbar-h)));
}

.top-nav-panel,
.top-nav-pullbar {
  pointer-events: auto;
}

.top-nav-panel {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: clamp(0.45rem, 1vw, 0.75rem) clamp(0.85rem, 1.8vw, 1.5rem)
    clamp(0.35rem, 0.8vw, 0.55rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background:
    linear-gradient(
      180deg,
      rgba(28, 28, 28, 0.96) 0%,
      rgba(14, 14, 14, 0.92) 100%
    );
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.top-nav-pullbar {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: min(7.5rem, 42vw);
  height: var(--top-nav-pullbar-h);
  margin-top: -1px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: rgba(22, 22, 22, 0.94);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  color: inherit;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    width 220ms ease;
}

.top-nav-pullbar:hover,
.top-nav-pullbar:focus-visible {
  background: rgba(40, 40, 40, 0.98);
  border-color: rgba(255, 255, 255, 0.22);
  outline: none;
}

.top-nav-pullbar:focus-visible {
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 0 2px rgba(255, 255, 255, 0.35);
}

.top-nav-pullbar-handle {
  display: block;
  width: 2.35rem;
  height: 0.28rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.top-nav.is-hidden .top-nav-pullbar {
  width: min(9rem, 48vw);
}

.top-nav.is-hidden .top-nav-pullbar-handle {
  background: rgba(255, 255, 255, 0.62);
}

/* Type-to-search overlay — slides in from the top-right as the user types */
.type-search {
  position: fixed;
  z-index: 70;
  top: max(0.7rem, env(safe-area-inset-top, 0px));
  right: max(0.7rem, env(safe-area-inset-right, 0px));
  left: auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 9.5rem;
  max-width: min(28rem, calc(100vw - 1.4rem));
  padding: 0.5rem 0.45rem 0.5rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(
      180deg,
      rgba(32, 32, 34, 0.98) 0%,
      rgba(14, 14, 16, 0.96) 100%
    );
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(22%, -120%, 0);
  transition:
    opacity 280ms ease,
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 320ms ease;
}

.type-search.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
}

.type-search.is-demo-front {
  z-index: 1100;
}

.type-search-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.62);
}

.type-search-body {
  min-width: 0;
  flex: 1 1 auto;
}

.type-search-kicker {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
}

.type-search-line {
  display: flex;
  align-items: center;
  margin: 0.08rem 0 0;
  min-height: 1.35em;
  font-size: clamp(1.05rem, 0.4vw + 0.95rem, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.type-search-query {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-search.is-caption .type-search-caret {
  display: none;
}

.type-search-caret {
  display: inline-block;
  width: 0.12em;
  height: 1.05em;
  margin-left: 0.12em;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.88);
  animation: type-search-caret 1.05s steps(1) infinite;
}

.type-search-key {
  margin: 0 0 0 0.55rem;
  padding: 0.18rem 0.42rem 0.14rem;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: 700 0.68rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.06em;
  text-transform: none;
}

.type-search-key.is-pressed {
  transform: translateY(2px);
  border-bottom-width: 1px;
}

.type-search-clear {
  flex-shrink: 0;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.type-search-clear:hover,
.type-search-clear:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

@keyframes type-search-caret {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .type-search {
    transition: opacity 160ms ease, visibility 160ms ease;
    transform: none;
  }

  .type-search-caret {
    animation: none;
  }
}

/* ── Auto-hiding bottom navigation ── */
.bottom-nav-hotzone {
  --bottom-nav-hotzone-h: 1.35rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: var(--bottom-nav-hotzone-h);
  pointer-events: auto;
}

.bottom-nav {
  --bottom-nav-pullbar-h: 1.15rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 clamp(0.5rem, 1.5vw, 2rem);
  pointer-events: none;
  transform: translateY(0);
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.bottom-nav.is-hidden {
  transform: translateY(calc(100% - var(--bottom-nav-pullbar-h)));
}

.bottom-nav-panel,
.bottom-nav-pullbar {
  pointer-events: auto;
}

.bottom-nav-panel {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: clamp(0.7rem, 1.2vw, 1rem) clamp(0.85rem, 1.8vw, 1.5rem)
    clamp(0.65rem, 1.4vw, 1.15rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background:
    linear-gradient(
      0deg,
      rgba(28, 28, 28, 0.96) 0%,
      rgba(14, 14, 14, 0.92) 100%
    );
  box-shadow:
    0 -10px 36px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.bottom-nav-pullbar {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: min(7.5rem, 42vw);
  height: var(--bottom-nav-pullbar-h);
  margin-bottom: -1px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: rgba(22, 22, 22, 0.94);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  color: inherit;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    width 220ms ease;
}

.bottom-nav-pullbar:hover,
.bottom-nav-pullbar:focus-visible {
  background: rgba(40, 40, 40, 0.98);
  border-color: rgba(255, 255, 255, 0.22);
  outline: none;
}

.bottom-nav-pullbar:focus-visible {
  box-shadow:
    0 -6px 18px rgba(0, 0, 0, 0.35),
    0 0 0 2px rgba(255, 255, 255, 0.35);
}

.bottom-nav-pullbar-handle {
  display: block;
  width: 2.35rem;
  height: 0.28rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.bottom-nav.is-hidden .bottom-nav-pullbar {
  width: min(9rem, 48vw);
}

.bottom-nav.is-hidden .bottom-nav-pullbar-handle {
  background: rgba(255, 255, 255, 0.62);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  flex-wrap: nowrap;
  margin: 0;
  animation: title-in 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.table-header-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  flex: 1 1 auto;
}

.table-header-text {
  min-width: 0;
  flex: 1 1 auto;
}

.app-logo-lockup {
  position: fixed;
  z-index: 50;
  left: max(0.7rem, env(safe-area-inset-left));
  top: max(0.55rem, env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.18rem, 0.55vmin, 0.38rem);
  margin: 0;
  pointer-events: none;
  transform-origin: top left;
  transition: top 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-logo {
  width: clamp(2.585rem, 2.64vw, 3.465rem);
  height: auto;
  object-fit: contain;
  object-position: center;
}

.app-logo-lockup .app-logo {
  width: clamp(2.15rem, min(8.2vmin, 4.6vw), 5.75rem);
}

.app-logo-lockup .app-logo-name {
  font-size: clamp(0.68rem, min(2.3vmin, 1.35vw), 1.45rem);
}

.app-logo-name {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
}

/* The learning card is translucent. Hide the corner mark while it is
   open so the logo stays behind the card and does not show through. */
body.modal-open .app-logo-lockup {
  visibility: hidden;
}

.brand-mark {
  font-size: 0.55em;
  font-weight: 650;
  margin-left: 0.04em;
  letter-spacing: 0;
}

.app-logo-phase {
  margin: clamp(0.04rem, 0.28vmin, 0.12rem) 0 0;
  font-size: clamp(0.4rem, min(1.15vmin, 0.65vw), 0.52rem);
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1;
  color: rgba(255, 255, 255, 0.42);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
}

.search-hint {
  position: absolute;
  z-index: 2;
  left: calc(100% + 0.55rem);
  top: 0;
  margin: 0;
  pointer-events: auto;
}

.search-hint-mark {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  box-shadow: none;
}

.search-hint-mark svg {
  width: 1.85rem;
  height: 1.85rem;
  stroke: currentColor;
}

.search-hint-mark:hover,
.search-hint-mark:focus-visible,
.search-hint-mark.is-running {
  color: rgba(255, 255, 255, 0.72);
  outline: none;
}

body.is-type-search .search-hint,
body.modal-open .search-hint,
body.is-screensaver-on .search-hint {
  display: none;
}

/* Handwritten notes after the table loads, before the teachers card. */
.table-coach-type,
.table-coach-demo {
  position: fixed;
  z-index: 52;
  margin: 0;
  pointer-events: none;
  user-select: none;
}

.table-coach-type {
  font-family: 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;
  font-size: clamp(1.85rem, 2.8vw, 2.75rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: #fff;
  text-align: center;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 0 2px rgba(0, 0, 0, 0.9),
    0 0 14px rgba(0, 0, 0, 0.85);
  max-width: calc(100vw - 2rem);
  opacity: 0;
  transform: translateX(-50%) translateY(10px) rotate(-1.6deg);
  transition:
    opacity 420ms ease,
    transform 420ms ease;
}

.table-coach-type.is-in {
  opacity: 1;
  transform: translateX(-50%) translateY(0) rotate(-1.6deg);
}

#table-coach-searchable,
#table-coach-saver-out,
#search-demo-step {
  width: max-content;
  white-space: nowrap;
}

#table-coach-ask {
  width: max-content;
  max-width: min(40rem, calc(100vw - 2rem));
  white-space: normal;
}

#table-coach-saver {
  width: max-content;
  max-width: min(36rem, calc(100vw - 2rem));
  white-space: normal;
}

.table-coach-chalk {
  position: relative;
  display: inline-block;
}

.table-coach-chalk-ring {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 186%;
  height: 2.85em;
  overflow: visible;
  transform: translate(-50%, -50%) rotate(-6deg);
  pointer-events: none;
}

.table-coach-chalk-ring path {
  stroke: color-mix(in srgb, #ec407a 74%, #f4e4ea);
  stroke-width: 3.4;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  opacity: 0.9;
  filter:
    drop-shadow(0 0 0.6px rgba(255, 214, 226, 0.8))
    drop-shadow(0 1px 0 rgba(120, 36, 68, 0.35));
}

.table-coach-saver-point .table-coach-arrow {
  transform: scaleX(-1);
}

.table-coach-saver-point .table-coach-demo-text {
  left: 0;
  top: 124px;
  width: 188px;
  text-align: right;
  transform-origin: right top;
}

#search-demo-step {
  z-index: 80;
  max-width: min(34rem, calc(100vw - 2rem));
  white-space: normal;
}

.table-coach-search-line {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
  white-space: nowrap;
}

.table-coach-search {
  width: 0.92em;
  height: 0.92em;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter:
    drop-shadow(0 2px 0 rgba(0, 0, 0, 0.4))
    drop-shadow(0 0 6px rgba(0, 0, 0, 0.85));
}

.table-coach-cursor {
  display: block;
  width: 0.12em;
  height: 0.82em;
  flex: 0 0 auto;
  background: #00ff00;
  box-shadow: 0 0 2px rgba(0, 255, 0, 0.65);
  opacity: 0;
}

.table-coach-cursor.is-on {
  opacity: 1;
}

.table-coach-demo {
  width: 420px;
  height: 230px;
  overflow: visible;
  opacity: 0;
  transition: opacity 420ms ease;
}

.table-coach-demo.is-in {
  opacity: 1;
  transition: opacity 180ms ease;
}

.table-coach-arrow {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter:
    drop-shadow(0 1px 1px rgba(0, 0, 0, 0.9))
    drop-shadow(0 0 6px rgba(0, 0, 0, 0.55));
}

.table-coach-shaft,
.table-coach-head {
  stroke: #fff;
  stroke-width: 3.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.table-coach-demo-text span {
  display: block;
}

.table-coach-demo-text {
  position: absolute;
  left: 198px;
  top: 142px;
  margin: 0;
  width: max-content;
  font-family: 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;
  font-size: 34px;
  font-weight: 600;
  line-height: 0.98;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 0 2px rgba(0, 0, 0, 0.9),
    0 0 14px rgba(0, 0, 0, 0.85);
  transform: rotate(-3.5deg);
  transform-origin: left top;
  opacity: 0;
  transition: opacity 320ms ease;
}

.table-coach-demo.is-in .table-coach-demo-text {
  opacity: 1;
}

body.modal-open .table-coach,
body.is-screensaver-on .table-coach,
body.intro-tour-active .table-coach,
body.is-type-search .table-coach {
  visibility: hidden;
}

/* Same mark on the screensaver and blackboard, without the fixed header lockup. */
.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  margin: 0;
  pointer-events: none;
  user-select: none;
}

.table-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.built-by {
  position: fixed;
  right: calc(clamp(0.5rem, 1.5vw, 2rem) + 0.75rem);
  bottom: max(0.55rem, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.1rem, 0.35vmin, 0.22rem);
  width: max-content;
  max-width: calc(100vw - 1.5rem);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  pointer-events: auto;
  transform-origin: bottom right;
  transition: bottom 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.built-by:hover,
.built-by:focus-visible {
  color: #fff;
  outline: none;
}

.built-by-kicker {
  font-size: clamp(0.42rem, min(1.15vmin, 0.7vw), 0.58rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.46);
  line-height: 1;
}

.built-by-logo {
  width: clamp(1.35rem, min(4.4vmin, 2.5vw), 2.55rem);
  height: clamp(1.35rem, min(4.4vmin, 2.5vw), 2.55rem);
  object-fit: contain;
  border-radius: 50%;
  flex-shrink: 0;
}

.built-by-name {
  font-size: clamp(0.5rem, min(1.5vmin, 0.85vw), 0.72rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
}

.header-feedback {
  position: relative;
}

.header-feedback-btn,
.header-screensaver-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: clamp(0.72rem, 0.3vw + 0.62rem, 0.86rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.header-feedback-btn:hover,
.header-feedback-btn:focus-visible,
.header-screensaver-btn:hover,
.header-screensaver-btn:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  outline: none;
}

.header-feedback-btn:focus-visible,
.header-screensaver-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.header-feedback-icon,
.header-screensaver-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.header-feedback-label,
.header-screensaver-label {
  line-height: 1;
}

.feedback-panel {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: min(22rem, calc(100vw - 1.5rem));
  margin: 0;
  padding: 0.9rem 0.95rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      rgba(32, 32, 34, 0.98) 0%,
      rgba(14, 14, 16, 0.96) 100%
    );
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #f2f2f2;
  pointer-events: auto;
}

.feedback-panel[hidden] {
  display: none !important;
}

.feedback-trap {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.feedback-panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.feedback-panel-lede {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.72);
}

.feedback-email {
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
}

.feedback-email:focus {
  border-color: rgba(255, 255, 255, 0.38);
  outline: none;
}

.feedback-email[readonly] {
  cursor: default;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.feedback-email[readonly]:focus {
  border-color: rgba(255, 255, 255, 0.1);
}

.recruit-banner {
  --recruit-unit: 16px;
  position: fixed;
  z-index: 1050;
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100vw - 20px);
  margin: 0;
  padding: 0.62em 1.45em 0.68em 0.9em;
  border: 1px solid rgba(243, 212, 138, 0.4);
  border-radius: 0.7em;
  background:
    linear-gradient(
      180deg,
      rgba(48, 40, 24, 0.97) 0%,
      rgba(16, 16, 18, 0.96) 100%
    );
  box-shadow:
    0 0.7em 1.8em rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: var(--recruit-unit);
  transform-origin: top left;
  pointer-events: auto;
}

.recruit-banner[hidden] {
  display: none !important;
}

.recruit-banner-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.15em 0.55em;
  min-width: 0;
}

.recruit-banner-kicker {
  margin: 0;
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(243, 212, 138, 0.86);
}

.recruit-banner-title {
  margin: 0;
  font-size: 1.15em;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.recruit-banner-copy {
  margin: 0.28em 0 0;
  font-size: 0.82em;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.86);
}

.recruit-banner-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35em 0.75em;
  margin-top: 0.42em;
}

.recruit-banner-cta {
  margin: 0;
  padding: 0.32em 0.75em;
  border: 0;
  border-radius: 999px;
  background: #f3d48a;
  color: #1c1508;
  font: inherit;
  font-size: 0.78em;
  font-weight: 700;
  cursor: pointer;
}

.recruit-banner-esc {
  margin: 0;
  font-size: 0.68em;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.72);
}

.recruit-banner-key {
  display: inline-block;
  margin: 0 0.15em;
  padding: 0.08em 0.32em 0.04em;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-bottom-width: 0.18em;
  border-radius: 0.28em;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: 700 0.92em/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.04em;
  vertical-align: 0.04em;
}

.recruit-banner-cta:hover,
.recruit-banner-cta:focus-visible {
  background: #ffe3a6;
  outline: none;
}

.recruit-banner-close {
  position: absolute;
  top: 0.28em;
  right: 0.28em;
  width: 1.35em;
  height: 1.35em;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 1em;
  line-height: 1;
  cursor: pointer;
}

.recruit-banner-close:hover,
.recruit-banner-close:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

body:has(.feedback-panel:not([hidden])) .recruit-banner,
body:has(.feedback-sent:not([hidden])) .recruit-banner,
body.intro-tour-active .recruit-banner,
body.table-coach-active .recruit-banner {
  display: none;
}

.feedback-field {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.feedback-suggestion {
  width: 100%;
  min-height: 6.5rem;
  margin: 0;
  padding: 0.65rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
  resize: vertical;
}

.feedback-suggestion:focus {
  border-color: rgba(255, 255, 255, 0.38);
  outline: none;
}

.feedback-remaining {
  margin: -0.15rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: right;
  color: rgba(255, 255, 255, 0.48);
}

.feedback-remaining.is-low {
  color: #ffab91;
}

.feedback-status {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.86);
}

.feedback-status[hidden] {
  display: none !important;
}

.feedback-status.is-error {
  color: #ffab91;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.feedback-cancel {
  order: 1;
}

.feedback-send {
  order: 2;
}

.feedback-cancel,
.feedback-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.feedback-cancel svg,
.feedback-send svg {
  width: 1.05rem;
  height: 1.05rem;
}

.feedback-cancel {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
}

.feedback-send {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}

.feedback-cancel:hover,
.feedback-cancel:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.feedback-send:hover,
.feedback-send:focus,
.feedback-send:focus-visible,
.feedback-send.is-keyed {
  background: #2f81f7;
  border-color: #2f81f7;
  color: #fff;
  outline: none;
}

.feedback-send:active {
  background: #1a5fd0;
  border-color: #1a5fd0;
  transform: translateY(1px) scale(0.92);
}

.feedback-send:disabled,
.feedback-cancel:disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.feedback-send.is-working svg {
  opacity: 0;
}

.feedback-send.is-working::after {
  content: "";
  position: absolute;
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: feedback-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .feedback-send {
    transition: none;
  }

  .feedback-send:active {
    transform: none;
  }

  .feedback-send.is-working::after {
    animation: none;
    border-top-color: rgba(255, 255, 255, 0.55);
  }
}

.feedback-sent {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.6rem;
  width: min(22rem, calc(100vw - 1.5rem));
  margin: 0;
  padding: 0.9rem 0.75rem 0.9rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      rgba(32, 32, 34, 0.98) 0%,
      rgba(14, 14, 16, 0.96) 100%
    );
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #f2f2f2;
}

.feedback-sent[hidden] {
  display: none !important;
}

.feedback-sent-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.feedback-sent-body {
  grid-column: 1;
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
}

.feedback-sent-close {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.feedback-sent-close svg {
  width: 1.05rem;
  height: 1.05rem;
}

.feedback-sent-close:hover,
.feedback-sent-close:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

/* ── Screensaver picker + overlay ── */
.screensaver-picker {
  position: fixed;
  z-index: 80;
  width: min(19.5rem, calc(100vw - 1.5rem));
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      rgba(32, 32, 34, 0.98) 0%,
      rgba(14, 14, 16, 0.96) 100%
    );
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.screensaver-picker-kicker {
  margin: 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
}

.screensaver-pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.screensaver-pick:hover,
.screensaver-pick:focus-visible,
.screensaver-pick.is-default:hover,
.screensaver-pick.is-default:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
  outline: none;
}

.screensaver-pick.is-default {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
}

.screensaver-pick-title {
  font-size: 0.92rem;
  font-weight: 650;
}

body.is-screensaver-on .top-nav,
body.is-screensaver-on .top-nav-hotzone,
body.is-screensaver-on .bottom-nav,
body.is-screensaver-on .bottom-nav-hotzone,
body.is-screensaver-on .app-main,
body.is-screensaver-on .app-logo-lockup {
  visibility: hidden;
  pointer-events: none;
}

body.is-screensaver-idle,
body.is-screensaver-idle * {
  cursor: none !important;
}

.screensaver-root {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: grid;
  background:
    radial-gradient(ellipse at 50% 38%, #151a24 0%, #07080c 72%);
  color: #f4f4f4;
}

.screensaver-root[data-mode='molecular'] {
  background:
    radial-gradient(ellipse at 50% 40%, #1c2433 0%, #0b0f16 68%, #05070b 100%);
}

.screensaver-root[data-mode='molecular']:fullscreen,
.screensaver-root[data-mode='molecular']:-webkit-full-screen {
  background:
    radial-gradient(ellipse at 50% 40%, #1c2433 0%, #0b0f16 68%, #05070b 100%);
}

.screensaver-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.screensaver-table {
  width: 100%;
  height: 100%;
  padding: 6.4rem 1.25rem 7.5rem;
  pointer-events: none;
  user-select: none;
}

.screensaver-table .grid-cell.is-ss-dim .element-square,
.screensaver-table .grid-cell.is-ss-dim .series-placeholder {
  filter: brightness(0.5) saturate(0.78);
  transition: filter 1500ms ease, transform 1500ms ease, box-shadow 1500ms ease;
}

.screensaver-table .grid-cell.is-ss-lit {
  z-index: 2;
}

.screensaver-table .grid-cell.is-ss-lit .element-square {
  filter: brightness(1.12) saturate(1.18);
  transform: scale(1.08);
  box-shadow: 0 0 28px color-mix(in srgb, var(--el-bg) 60%, transparent);
  transition: filter 1500ms ease, transform 1500ms ease, box-shadow 1500ms ease;
}

.screensaver-viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
}

.screensaver-root .hub-structure-viewport,
.screensaver-root .atom-shells-viewport {
  --structure-box: min(100vw, 100vh);
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 0;
}

.screensaver-root .hub-structure-fs-btn,
.screensaver-root .hub-structure-angle-switch {
  display: none !important;
}

.screensaver-root[data-mode='molecular'] .screensaver-stage,
.screensaver-root[data-mode='atomic'] .screensaver-stage {
  touch-action: none;
}

.screensaver-root[data-mode='molecular'] .hub-structure-canvas,
.screensaver-root[data-mode='atomic'] .atom-shells-canvas {
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.screensaver-root .hub-structure-canvas.is-spin-dragging,
.screensaver-root .atom-shells-canvas.is-shell-dragging {
  cursor: grabbing;
}

.screensaver-root[data-mode='molecular'] .screensaver-viewport {
  position: absolute;
  inset: clamp(7.4rem, 18vh, 10rem) 0 clamp(6.8rem, 17vh, 9.25rem);
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
}

.screensaver-root[data-mode='molecular'] .screensaver-mode {
  display: none;
}

.screensaver-mol {
  position: absolute;
  z-index: 5;
  top: max(0.7rem, env(safe-area-inset-top));
  left: max(7.4rem, 16vw);
  right: max(6.2rem, 12vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08rem;
  margin: 0;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.screensaver-mol[hidden] {
  display: none;
}

.screensaver-mol-name {
  margin: 0;
  font-size: clamp(1.35rem, 2.5vw, 2.15rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  color: #fff;
  text-wrap: balance;
}

.screensaver-mol-formula {
  margin: 0;
  font-size: clamp(1.12rem, 2vw, 1.65rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.1;
  color: rgba(255, 255, 255, 0.9);
}

.screensaver-mol-formula sub {
  font-size: 0.62em;
}

.screensaver-mol-geom {
  margin: 0.12rem 0 0;
  font-size: clamp(0.92rem, 1.4vw, 1.12rem);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.62);
}

.screensaver-mol-geom[hidden] {
  display: none;
}

.screensaver-root > .brand-lockup {
  position: absolute;
  z-index: 6;
  top: max(0.65rem, env(safe-area-inset-top));
  left: max(0.85rem, env(safe-area-inset-left));
}

.screensaver-key {
  position: absolute;
  top: max(0.85rem, env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: 5;
  margin: 0;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}

.screensaver-key[hidden] {
  display: none;
}

.screensaver-key-lesson {
  margin: 0;
}

/* Active element sits in the hole between Be and B. */
.screensaver-table .category-gap.is-ss-spot {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.screensaver-table .category-gap.is-ss-spot .screensaver-spot[hidden] {
  display: none;
}

.screensaver-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22em;
  width: 100%;
  min-width: 0;
  padding: 0.35rem 0.7rem;
  text-align: center;
}

.screensaver-spot-line,
.screensaver-spot-shells {
  margin: 0;
  max-width: 100%;
  font-weight: 700;
  line-height: 1;
}

.screensaver-spot-line {
  letter-spacing: 0.03em;
  color: var(--ss-spot, #fff);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.65);
}

.screensaver-spot-shells {
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.72);
}

.screensaver-key-lesson {
  margin-bottom: 0.28rem;
  font-size: clamp(1.2rem, 2.3vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
}

.screensaver-key-line {
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.92);
}

.screensaver-key-shells {
  margin-top: 0.2rem;
  font-size: clamp(0.85rem, 1.35vw, 1.05rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.62);
}

.screensaver-id {
  position: absolute;
  top: 0.8rem;
  left: 6.4rem;
  z-index: 4;
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.screensaver-id[hidden] {
  display: none;
}

.screensaver-symbol {
  font-size: clamp(2.43rem, 5.4vw, 4.185rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ss-accent, #90caf9);
  line-height: 1;
}

.screensaver-z {
  font-size: clamp(1.05rem, 1.8vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.5);
}

.screensaver-z[hidden] {
  display: none;
}

.screensaver-name {
  font-size: clamp(1.14rem, 1.92vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.screensaver-root .screensaver-ms {
  display: none;
}

.screensaver-clock-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(0, auto) minmax(10rem, 1fr);
  align-items: end;
  column-gap: 0.85rem;
  padding: 3.4rem max(1.15rem, env(safe-area-inset-right)) 0.7rem max(1.15rem, env(safe-area-inset-left));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72) 58%);
  text-align: center;
  pointer-events: none;
}

.screensaver-clock-cluster {
  grid-column: 2;
  min-width: 0;
}

.screensaver-root .built-by,
html.is-phone .screensaver-root .built-by {
  position: relative;
  grid-column: 3;
  justify-self: end;
  align-self: end;
  right: auto;
  bottom: auto;
  z-index: 6;
  pointer-events: auto;
}

.screensaver-mode {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.screensaver-root[data-mode='atomic'] .screensaver-mode {
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
}

.screensaver-root[data-mode='table'] .screensaver-mode {
  display: none;
}

.screensaver-clock {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.4rem, 7.2vw, 5.4rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.55);
}

.screensaver-ms {
  font-size: 0.42em;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.62);
  vertical-align: 0.18em;
  margin-left: 0.06em;
}

.screensaver-hint {
  position: absolute;
  top: 1.45rem;
  right: 6.4rem;
  z-index: 5;
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  pointer-events: none;
  transition: opacity 600ms ease;
}

.screensaver-hint.is-faded {
  opacity: 0;
}

.screensaver-exit {
  position: absolute;
  top: 1.15rem;
  right: 1.25rem;
  z-index: 6;
  margin: 0;
  padding: 0.42rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.screensaver-exit:hover,
.screensaver-exit:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}

.screensaver-fallback {
  margin: auto;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.7);
}

@media (prefers-reduced-motion: reduce) {
  .screensaver-table .grid-cell.is-ss-dim .element-square,
  .screensaver-table .grid-cell.is-ss-lit .element-square {
    transition: none;
    transform: none;
  }
}

@media (max-width: 720px) {
  .screensaver-mol {
    top: 5.7rem;
    left: 0.75rem;
    right: 4.6rem;
  }

  .screensaver-root[data-mode='molecular'] .screensaver-viewport {
    position: absolute;
    inset: 12.25rem 0 7.15rem;
  }

  .app-logo {
    width: 2.31rem;
  }

  .header-feedback-label,
  .header-feedback-label,
  .header-screensaver-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .header-feedback-btn,
  .header-screensaver-btn {
    padding: 0.45rem;
    border-radius: 50%;
  }
}

.depth-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.4rem;
  flex: 1 1 18rem;
  justify-content: center;
}

.depth-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  margin: 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #f2f2f2;
  font: inherit;
  cursor: pointer;
  min-width: 6.5rem;
  text-align: left;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.depth-chip-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.depth-chip-hint {
  font-size: 0.68rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.2;
}

.depth-chip:hover,
.depth-chip:focus-visible {
  transform: translateY(-1px);
  outline: none;
  border-color: rgba(255, 255, 255, 0.32);
}

.depth-chip.is-active {
  background: rgba(255, 255, 255, 0.06);
  border-color: #64b5f6;
  box-shadow: none;
}

.depth-chip.is-active .depth-chip-label {
  color: #f2f2f2;
}

.aspect-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.aspect-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
  margin: 0;
  padding: 0.38rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.88);
  font: inherit;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.aspect-chip-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.aspect-chip-hint {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.48);
}

.aspect-chip:hover,
.aspect-chip:focus-visible {
  transform: translateY(-1px);
  outline: none;
  border-color: rgba(255, 255, 255, 0.28);
}

.aspect-chip.is-active {
  background: rgba(255, 255, 255, 0.06);
  border-color: #64b5f6;
  color: #fff;
}

.table-title {
  margin: 0;
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-size: clamp(1.05rem, 1.1vw + 0.8rem, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f2f2f2;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.table-shell {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  container-name: table-shell;
}

.table-fit-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}

.table-scale {
  container-type: inline-size;
  container-name: periodic;
  width: 100%;
  max-width: 100%;
  margin: 0;
  transform-origin: center center;
}

.main-grid {
  position: relative;
  display: grid;
  /*
    Col 1 = "Period" (narrow, hug content)
    Col 2 = Roman numerals (narrow)
    Cols 3–20 = groups 1–18 (flexible squares)
  */
  grid-template-columns:
    max-content
    max-content
    repeat(18, minmax(0, 1fr));
  /* Row 1 = "Group"; row 2 = group nos; rows 3–9 = periods 1–7; 10–11 = f-block */
  grid-template-rows: auto auto repeat(7, auto) auto auto;
  font-size: clamp(1.15rem, 3.35cqi, 10rem);
  gap: clamp(2px, 0.22cqi, 10px);
  column-gap: clamp(2px, 0.22cqi, 10px);
}

.axis-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  font-size: 0.32em;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.5);
  user-select: none;
}

/*
 * Reset button chrome only — do NOT set font-size/color here
 * (higher specificity would override .axis-label / .group-label).
 */
button.axis-label--interactive {
  appearance: none;
  margin: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition: color 140ms ease;
}

button.axis-label--interactive:hover,
button.axis-label--interactive:focus-visible {
  color: rgba(255, 255, 255, 0.92);
  outline: none;
}

.axis-title {
  font-size: 0.22em;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}

.axis-title-group {
  align-items: flex-end;
  padding-bottom: 0.2em;
}

.axis-title-period {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.18em;
  justify-self: end;
  align-self: center;
  padding-block: 0.35em;
  margin-inline-end: 0.15em;
  /* Same ink gap to the numerals as "Group" has above the group numbers.
     The numeral column is wider than IV, which is where this word sits. */
  margin-right: -1.72em;
}

.group-label,
button.axis-label--interactive.group-label {
  /* Quiet by default; blue rounded box only when selected */
  --group-badge: #1877f2;
  box-sizing: border-box;
  min-width: 1.15em;
  margin: 0 auto;
  /* Bottom padding is shorter than the side padding so the digit, which
     sits above the font's descender, lands the same distance from the
     tiles as the period numerals. */
  padding: 0.1em 0.14em 0.061em;
  align-items: center;
  justify-content: center;
  justify-self: center;
  align-self: end;
  font-size: 0.48em;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  border-radius: 0.35em;
  box-shadow: none;
  transition:
    color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

button.axis-label--interactive.group-label:hover,
button.axis-label--interactive.group-label:focus-visible {
  color: rgba(255, 255, 255, 0.92);
  background: transparent;
  filter: none;
}

button.axis-label--interactive.group-label.is-active {
  color: #fff;
  background: var(--group-badge);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.period-label,
button.axis-label--interactive.period-label {
  /* Same quiet → blue badge treatment as group labels when selected */
  --period-badge: #1877f2;
  box-sizing: border-box;
  justify-content: flex-end;
  justify-self: end;
  width: max-content;
  align-self: center;
  min-width: 1.15em;
  margin-block: 0.04em;
  padding: 0.1em 0.14em;
  font-size: 0.48em;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  border-radius: 0.35em;
  box-shadow: none;
  transition:
    color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

button.axis-label--interactive.period-label:hover,
button.axis-label--interactive.period-label:focus-visible {
  color: rgba(255, 255, 255, 0.92);
  background: transparent;
  filter: none;
}

button.axis-label--interactive.period-label.is-active {
  color: #fff;
  background: var(--period-badge);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.f-period-label {
  font-size: 0.48em;
  align-self: center;
}

/* Extra breathing room before the f-block annex rows */
.f-block-lanthanoid-row {
  margin-top: clamp(0.35rem, 0.55cqi, 0.85rem);
}

/* Be (group 2) to B (group 13) gap — periods II–III.
   Element cards also cover period I, up to the group numbers.
   Absolute so content never grows the grid rows / pushes elements. */
.category-gap {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  margin: clamp(2px, 0.35cqi, 8px);
  overflow: hidden;
  border-radius: clamp(6px, 0.55cqi, 12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 240ms ease,
    transform 240ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 240ms ease;
}

.category-gap.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

/* Stay inside the empty gap. A taller card would cover the tiles underneath. */
.category-gap.is-visible:not(.is-element) {
  overflow: hidden;
}

/* Expand upward inside the gap. The box itself never leaves the empty rows. */
.category-gap.has-clamp-open {
  overflow: hidden;
  z-index: 40;
  background: rgba(12, 12, 14, 0.97);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

.category-gap-accent {
  flex-shrink: 0;
  width: clamp(6px, 0.55cqi, 12px);
  background: var(--gap-accent, #9ccc65);
  border-top-left-radius: inherit;
  border-bottom-left-radius: inherit;
}

.category-gap-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* em is the table's type size, so spacing tracks the site with the copy */
  gap: clamp(0.28rem, 0.14em, 0.6rem);
  padding: clamp(0.4rem, 0.2em, 0.95rem) clamp(0.65rem, 0.28em, 1.25rem);
  overflow: hidden;
}

/* Collapsed: ~2 lines; " more…" sits inline at the end of the truncated copy */
.category-gap-copy {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(1.45em * 2);
  overflow: hidden;
  /* Floor stays readable; the middle term follows the table, which fills the site. */
  font-size: clamp(1rem, 0.48em, 1.85rem);
  font-weight: 400;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
}

.category-gap-text {
  margin: 0;
  font: inherit;
  color: inherit;
}

.category-gap-body .clamp-more {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  white-space: nowrap;
  vertical-align: baseline;
}

.category-gap-body .clamp-more[hidden],
.category-gap-body.is-expanded .clamp-more {
  display: none !important;
}

.category-gap-body .clamp-more:hover,
.category-gap-body .clamp-more:focus-visible {
  color: #fff;
  outline: none;
}

.category-gap-body.is-expanded {
  height: auto;
  max-height: none;
  overflow: visible;
  justify-content: flex-start;
  gap: clamp(0.35rem, 0.18em, 0.75rem);
}

.category-gap-body.is-expanded .category-gap-copy {
  flex: 0 1 auto;
  max-height: none;
  overflow: visible;
}

/* One extra line fits — show it without "more…" */
.category-gap-body.is-near-fit .category-gap-copy {
  max-height: calc(1.45em * 3);
  overflow: hidden;
}

.category-gap-title {
  margin: 0;
  flex-shrink: 0;
  font-size: clamp(1.1rem, 0.62em, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--gap-title, var(--gap-accent, #9ccc65));
}

/* Symbol · number · family. Facts, not a sentence. */
.category-gap-identity {
  margin: 0;
  flex-shrink: 0;
  font-size: clamp(0.95rem, 0.42em, 1.45rem);
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.92);
}

.category-gap-identity[hidden] {
  display: none !important;
}

.category-gap-open {
  align-self: flex-start;
  width: fit-content;
  margin: 0.22rem 0 0;
  padding: 0.32em 0.72em 0.36em;
  flex-shrink: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gap-title, #fff) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gap-title, #fff) 55%, transparent);
  font-size: clamp(0.92rem, 0.4em, 1.4rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--gap-title, #fff);
  text-decoration: none;
}

.category-gap-open[hidden] {
  display: none !important;
}

.category-gap.is-element {
  cursor: pointer;
}

.category-gap.is-element:hover .category-gap-open,
.category-gap.is-element:focus-visible .category-gap-open {
  background: color-mix(in srgb, var(--gap-title, #fff) 32%, transparent);
  box-shadow: inset 0 0 0 1px var(--gap-title, #fff);
  text-decoration: none;
}

.category-gap.is-element:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

/* Bohr atom sits in the single-element card; hidden for family/group copy */
.category-gap-bohr {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
  height: 100%;
  aspect-ratio: 5 / 6;
  max-width: 34%;
  min-width: 0;
  min-height: 0;
  margin: 0 clamp(4px, 0.45cqi, 10px) 0 0;
  padding: clamp(2px, 0.25cqi, 6px) 0 clamp(2px, 0.2cqi, 4px);
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  pointer-events: none;
}

.category-gap.is-tall .category-gap-copy {
  max-height: calc(1.45em * 4);
}

.category-gap.is-tall .category-gap-title {
  font-size: clamp(1.2rem, 0.72em, 2.5rem);
}

.category-gap.is-element .category-gap-title {
  font-size: clamp(1.35rem, 0.86em, 3.15rem);
  line-height: 1.05;
}

.category-gap.is-element .category-gap-identity {
  line-height: 1.15;
}

.category-gap.is-element .category-gap-copy {
  line-height: 1.32;
}

.category-gap.is-element .category-gap-body {
  gap: clamp(0.16rem, 0.07em, 0.4rem);
  padding-block: clamp(0.3rem, 0.12em, 0.65rem);
}

.category-gap.is-element .category-gap-open {
  margin-top: 0.12rem;
  padding: 0.22em 0.68em 0.24em;
}

.category-gap.is-element.is-tall .category-gap-copy {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
}

.category-gap.is-tall .category-gap-bohr {
  max-width: 38%;
}

.category-gap-bohr[hidden] {
  display: none !important;
}

.category-gap-bohr .category-gap-bohr-svg {
  flex: 1 1 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  aspect-ratio: 1;
}

.category-gap-bohr-caption {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35em 0.4em;
  margin: 0;
  max-width: 100%;
  overflow: visible;
  text-align: center;
  white-space: normal;
  font-size: clamp(0.78rem, 0.32em, 1.15rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: rgba(255, 255, 255, 0.9);
  font-variant-numeric: tabular-nums;
}

.category-gap-shells-label {
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.55);
}

.category-gap.has-clamp-open .category-gap-bohr {
  align-self: flex-start;
  height: clamp(5.25rem, 16cqi, 8.25rem);
  margin-top: clamp(0.35rem, 0.7cqi, 0.7rem);
}

.grid-cell {
  min-width: 0;
  aspect-ratio: 1 / 1;
  /* Text square is a size container so type tracks cell width (cqw) */
  container-type: inline-size;
  container-name: element-cell;
  transition:
    opacity 220ms ease,
    filter 220ms ease;
}

.grid-cell.is-dimmed {
  opacity: 0.22;
  filter: grayscale(0.35);
  pointer-events: none;
}

.series-placeholder {
  aspect-ratio: 1 / 1;
  width: 100%;
  height: auto;
  box-sizing: border-box;
  background: #ffffff;
  border: max(3px, 7cqw) solid var(--series-border, #f8bbd0);
  border-radius: max(1px, 1cqw);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: 8% 5%;
  color: #1a1a1a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.series-placeholder:hover,
.grid-cell.is-series-hover .series-placeholder {
  border-color: var(--series-hover, var(--series-border));
  box-shadow:
    0 0 0 1px var(--series-hover, var(--series-border)),
    0 4px 12px rgba(0, 0, 0, 0.35);
}

/* Keep vertical rhythm of element squares without drawing symbol/name */
.series-symbol-gap,
.series-name-gap {
  visibility: hidden;
  width: 100%;
}

.element-square {
  --press-scale: 1;
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 8% 5%;
  border: max(1px, 1.2cqw) solid rgba(0, 0, 0, 0.35);
  border-radius: max(1px, 1cqw);
  background: var(--el-bg);
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 0;
  cursor: pointer;
  font-family: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 1px 2px rgba(0, 0, 0, 0.35);
  /* scale = hover enlarge; translate = piano press only */
  opacity: 1;
  scale: 1;
  translate: 0 0;
  transform: none;
  animation: element-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--el-delay, 0ms);
  transition:
    scale 180ms ease,
    translate 80ms ease-out,
    box-shadow 120ms ease,
    filter 120ms ease,
    background-color 160ms ease;
}

/* Graphite non-metal tiles sit on a near-black page — light edge and labels. */
.element-square[data-category="nonmetal"] {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.28);
}

.grid-cell:has(.element-square:hover),
.grid-cell:has(.element-square:focus-visible),
.grid-cell:has(.element-square.is-piano-press),
.grid-cell:has(.element-square:active) {
  z-index: 6;
  position: relative;
}

/* Enlarge on hover only — suppressed during / after a press until pointer leaves */
.element-square:hover:not(:active):not(.is-piano-press):not(.is-key-held),
.element-square:focus-visible:not(:active):not(.is-piano-press):not(.is-key-held) {
  scale: 2.8;
  z-index: 6;
  background: var(--el-hover-bg, var(--el-bg));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 12px 32px rgba(0, 0, 0, 0.55),
    0 4px 12px rgba(0, 0, 0, 0.35);
  filter: brightness(1.08);
  outline: none;
}

/* While a key gesture is in progress, freeze size so hover cannot enlarge it */
.element-square.is-key-held {
  scale: var(--press-scale, 1) !important;
  transition-property: translate, box-shadow, filter, background-color;
}

/* Piano-key press: lock size, only move down */
.element-square:active,
.element-square.is-piano-press {
  scale: var(--press-scale, 1) !important;
  translate: 0 0.65em;
  z-index: 6;
  box-shadow:
    inset 0 6px 14px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 4px rgba(0, 0, 0, 0.25);
  filter: brightness(0.9);
  transition:
    scale 0ms,
    translate 70ms ease-out,
    box-shadow 70ms ease-out,
    filter 70ms ease-out;
}

.element-square.is-piano-press {
  animation: piano-key-press 240ms cubic-bezier(0.15, 0.85, 0.25, 1);
}

@keyframes piano-key-press {
  0% {
    translate: 0 0;
  }
  35% {
    translate: 0 0.7em;
  }
  100% {
    translate: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .element-square.is-piano-press {
    animation: none;
  }

  .element-square:active,
  .element-square.is-piano-press {
    translate: 0 0.2em;
    transition-duration: 0ms;
  }
}

.element-square.has-hover-color:hover,
.element-square.has-hover-color:focus-visible,
.grid-cell.is-series-hover .element-square.has-hover-color {
  filter: none;
}

.grid-cell.is-series-hover .element-square {
  background: var(--el-hover-bg, var(--el-bg));
  filter: brightness(1.04);
  z-index: 1;
}

/* cqw = % of square width — keeps proportions as cells grow on large screens */
.element-number {
  position: static;
  font-size: clamp(0.55rem, 20cqw, 14rem);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  opacity: 0.95;
  letter-spacing: normal;
  white-space: nowrap;
}

.element-symbol {
  font-size: clamp(0.95rem, 42cqw, 28rem);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  letter-spacing: normal;
}

/* In-our-body filter: small symbol on top, large % in the centre */
.element-square.is-body-pct .element-symbol {
  order: -1;
  font-size: clamp(0.48rem, 18cqw, 12rem);
  font-weight: 700;
  opacity: 0.95;
}

.element-square.is-body-pct .element-number {
  font-size: clamp(0.85rem, 36cqw, 22rem);
  letter-spacing: -0.03em;
}

.element-square.is-body-pct-long .element-number {
  font-size: clamp(0.62rem, 26cqw, 16rem);
  letter-spacing: -0.04em;
}

.element-name {
  font-size: clamp(0.45rem, 16cqw, 11rem);
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.95;
  padding: 0 2%;
  letter-spacing: normal;
}

.legend {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: 0;
  max-height: min(24vh, 11rem);
  overflow: visible;
}

.legend-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.55rem;
}

.legend-tab {
  margin: 0;
  padding: 0.2rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
  font: inherit;
  font-size: clamp(0.62rem, 0.4vw + 0.5rem, 0.9rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.legend-tab:hover,
.legend-tab:focus-visible {
  color: rgba(255, 255, 255, 0.88);
  border-color: rgba(255, 255, 255, 0.22);
  outline: none;
}

.legend-tab.is-active {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

.legend-title {
  margin: 0 0 0.45rem;
  font-size: clamp(0.62rem, 0.4vw + 0.5rem, 0.9rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.55);
}

.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(0.2rem, 0.55vw, 0.45rem) clamp(0.55rem, 1.2vw, 1rem);
  overflow: visible;
}

/* display:flex above would otherwise beat the UA [hidden] { display:none } */
.legend-list[hidden] {
  display: none !important;
}

.bottom-nav .legend-list {
  gap: 0.35rem 0.45rem;
  padding: 0.2rem 0 0.15rem;
}

.bottom-nav .legend-list > li {
  display: flex;
  padding: 3px 0 4px;
  overflow: visible;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.25rem 0.35rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  font: inherit;
  font-size: clamp(0.75rem, 0.45vw + 0.65rem, 1.15rem);
  font-weight: 500;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.bottom-nav .legend-item {
  gap: 0.4rem;
  padding: 0.32rem 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(0.68rem, 0.38vw + 0.58rem, 0.92rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.18);
}

.legend-item:hover,
.legend-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.bottom-nav .legend-item:hover,
.bottom-nav .legend-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--tag-color, #888);
  transform: none;
}

.legend-item.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.bottom-nav .legend-item.is-active,
.bottom-nav .legend-item.is-active:hover,
.bottom-nav .legend-item.is-active:focus-visible {
  background: var(--tag-color, #888);
  color: var(--tag-text, #1a1a1a);
  border-color: color-mix(in srgb, var(--tag-color, #888) 82%, white);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 4px 14px color-mix(in srgb, var(--tag-color, #888) 34%, transparent);
  transform: none;
}

.legend-item[data-category="nonmetal"] .legend-swatch {
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.12);
}

.legend-swatch {
  width: clamp(0.75rem, 0.6vw + 0.55rem, 1.15rem);
  height: clamp(0.75rem, 0.6vw + 0.55rem, 1.15rem);
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.bottom-nav .legend-swatch {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.bottom-nav .legend-item[data-category="nonmetal"] .legend-swatch {
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.18);
}

.bottom-nav .legend-item.is-active .legend-swatch {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.08);
}

@keyframes element-in {
  from {
    opacity: 0;
    scale: 0.92;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes title-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (hover: none) {
  .element-square:hover {
    scale: 1;
    filter: none;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.28),
      0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

/* ── First-visit intro tour (Three.js circles) ── */
/* Block all page hover/clicks until the tour is finished or skipped */
body.intro-tour-active {
  overflow: hidden;
  cursor: default;
}

body.intro-tour-active .app-main,
body.intro-tour-active .top-nav,
body.intro-tour-active .bottom-nav,
body.intro-tour-active .top-nav-hotzone,
body.intro-tour-active .bottom-nav-hotzone,
body.intro-tour-active .top-nav-pullbar,
body.intro-tour-active .bottom-nav-pullbar,
body.intro-tour-active .top-nav-panel,
body.intro-tour-active .bottom-nav-panel {
  pointer-events: none !important;
}

/* While waiting for a guided click, let hits reach only .is-intro-clickable targets */
body.intro-tour-active.is-intro-awaiting-click .intro-tour-dim {
  pointer-events: none;
}

body.intro-tour-active .is-intro-clickable {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Empty-table clear: shell receives clicks, but tiles never open */
body.intro-tour-active .table-shell.is-intro-clickable .element-square,
body.intro-tour-active .table-shell.is-intro-clickable .grid-cell,
body.intro-tour-active .app-main.is-intro-clickable .element-square,
body.intro-tour-active .app-main.is-intro-clickable .grid-cell {
  pointer-events: none !important;
  cursor: default !important;
}

/* Kill hover affordances even if a pointer slips through */
body.intro-tour-active .element-square:hover,
body.intro-tour-active .element-square:focus-visible,
body.intro-tour-active .legend-item:hover,
body.intro-tour-active .legend-item:focus-visible,
body.intro-tour-active .series-placeholder:hover,
body.intro-tour-active .group-label:hover,
body.intro-tour-active .period-label:hover {
  scale: 1 !important;
  translate: 0 0 !important;
  transform: none !important;
  filter: none !important;
}

/* Keep drawers open when the tour asks for them — but allow .is-hidden to slide away */
body.intro-tour-active .top-nav:not(.is-hidden),
body.intro-tour-active .bottom-nav:not(.is-hidden) {
  transform: translateY(0) !important;
}

/* Focus mode: table starts fully grey; only .is-intro-lit tiles show family colour */
body.intro-tour-active.intro-focus-table .grid-cell .element-square {
  background: #4e4e4e !important;
  color: #b0b0b0 !important;
  border-color: rgba(0, 0, 0, 0.35) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
  filter: none !important;
}

body.intro-tour-active.intro-focus-table .grid-cell .series-placeholder {
  background: #4e4e4e !important;
  color: #b0b0b0 !important;
  border-color: #6a6a6a !important;
  box-shadow: none !important;
  filter: none !important;
}

/* Real family-filter dimming would double-fade grey tiles — keep an even grey field */
body.intro-tour-active.intro-focus-table .grid-cell.is-dimmed {
  opacity: 1;
  filter: none;
}

body.intro-tour-active.intro-focus-table .legend-item:not(.is-intro-lit) {
  filter: none;
  opacity: 0.42;
  color: #9a9a9a !important;
  border-color: #5a5a5a !important;
  background: rgba(255, 255, 255, 0.05) !important;
  box-shadow: none !important;
}

body.intro-tour-active.intro-focus-table .legend-item:not(.is-intro-lit) .legend-swatch {
  background: #6a6a6a !important;
}

body.intro-tour-active.intro-focus-table .grid-cell.is-intro-lit .element-square {
  background: var(--el-bg) !important;
  color: #1a1a1a !important;
  border-color: rgba(0, 0, 0, 0.35) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 0 0 1px color-mix(in srgb, var(--el-bg) 55%, transparent),
    0 0 18px color-mix(in srgb, var(--el-bg) 35%, transparent) !important;
  filter: none !important;
  z-index: 1;
}

body.intro-tour-active.intro-focus-table .grid-cell.is-intro-lit .element-square[data-category="nonmetal"] {
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
}

body.intro-tour-active.intro-focus-table .grid-cell.is-intro-lit .series-placeholder {
  background: #ffffff !important;
  color: #1a1a1a !important;
  border-color: var(--series-border, #f8bbd0) !important;
  box-shadow:
    0 0 0 1px var(--series-border, #f8bbd0),
    0 4px 14px rgba(0, 0, 0, 0.35) !important;
  filter: none !important;
}

body.intro-tour-active.intro-focus-table .legend-item.is-intro-lit {
  filter: none;
  opacity: 1;
  color: rgba(255, 255, 255, 0.95) !important;
  border-color: var(--tag-color, #888) !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

body.intro-tour-active.intro-focus-table .legend-item.is-intro-lit.is-active {
  background: var(--tag-color, #888) !important;
  color: var(--tag-text, #1a1a1a) !important;
  border-color: color-mix(in srgb, var(--tag-color, #888) 82%, white) !important;
}

body.intro-tour-active.intro-focus-table .legend-item.is-intro-lit .legend-swatch {
  filter: none;
  background: var(--tag-color, #888) !important;
}

.intro-tour {
  --intro-accent: #64b5f6;
  --intro-card-opacity: 1;
  --intro-dim: 0.38;
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.intro-tour[data-dim='light'] {
  --intro-dim: 0.16;
}

.intro-tour[data-dim='glass'] {
  --intro-dim: 0.55;
}

/* Tour copy stays top-right so chalk rings (Group / Period labels) stay clear */
.intro-tour-card,
.intro-tour[data-card='top'] .intro-tour-card {
  bottom: auto;
  top: max(0.55rem, env(safe-area-inset-top, 0px));
  left: auto;
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  transform: rotate(-1.1deg);
}

/* When the header drawer is open, sit just under it so the card does not cover it */
.intro-tour[data-card='below-top'] .intro-tour-card {
  top: var(--intro-card-top, 5.25rem);
  transform: rotate(-0.8deg);
}

.intro-tour-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, var(--intro-dim));
  /* Capture all clicks/hovers so the table underneath cannot be used */
  pointer-events: auto;
  cursor: default;
  transition:
    background 320ms ease,
    backdrop-filter 320ms ease,
    -webkit-backdrop-filter 320ms ease;
  z-index: 1;
}

/* Thick frosted glass during Gold demo — hide the table; only demo tile + tour card stay clear */
.intro-tour.has-gold-demo .intro-tour-dim,
.intro-tour[data-dim='glass'] .intro-tour-dim {
  background:
    linear-gradient(
      160deg,
      rgba(18, 20, 28, 0.78) 0%,
      rgba(8, 10, 16, 0.88) 100%
    );
  backdrop-filter: blur(36px) saturate(1.35);
  -webkit-backdrop-filter: blur(36px) saturate(1.35);
  box-shadow:
    inset 0 0 120px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.intro-tour.has-gold-demo .intro-tour-canvas-host {
  opacity: 0;
  pointer-events: none;
}

.intro-tour.has-gold-demo .intro-tour-card {
  z-index: 8;
}

/* Enlarged Gold tile anatomy during the intro tour — centered on the page */
.intro-gold-demo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  pointer-events: none;
}

.intro-tour.has-gold-demo .intro-gold-demo {
  display: block;
}

.intro-gold-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(
      165deg,
      rgba(40, 42, 52, 0.55) 0%,
      rgba(16, 18, 24, 0.72) 100%
    );
  box-shadow:
    0 20px 56px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Match modal .modal-header-id square (--header-square) */
.intro-gold-tile {
  --header-square: clamp(5.5rem, 12vw, 8.5rem);
  --focus-purple: #e040fb;
  container-type: inline-size;
  container-name: intro-gold-tile;
  position: relative;
  flex: 0 0 auto;
  align-self: center;
  width: var(--header-square);
  height: var(--header-square);
  max-width: var(--header-square);
  max-height: var(--header-square);
  aspect-ratio: 1;
  padding: 6% 4%;
  border: 0;
  border-radius: 0;
  background: var(--el-bg, #ffb300);
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 8px 22px rgba(0, 0, 0, 0.4);
  transition: box-shadow 220ms ease;
}

.intro-gold-number,
.intro-gold-symbol,
.intro-gold-mass {
  transition:
    color 220ms ease,
    opacity 220ms ease,
    filter 220ms ease,
    text-shadow 220ms ease,
    transform 220ms ease;
}

.intro-gold-number {
  font-size: clamp(0.55rem, 22cqw, 14rem);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  width: 100%;
}

.intro-gold-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12em;
  min-height: 0;
  padding-bottom: 4%;
  transition: opacity 220ms ease, filter 220ms ease;
}

.intro-gold-symbol {
  font-size: clamp(0.95rem, 46cqw, 28rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
}

.intro-gold-mass {
  font-size: clamp(0.42rem, 16cqw, 1.05rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  text-align: center;
  opacity: 0.88;
}

/* Focus a data point: purple accent; grey out the rest of the square */
.intro-gold-tile[data-focus='atom'] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 0 0 2px var(--focus-purple),
    0 0 10px rgba(224, 64, 251, 0.22),
    0 8px 22px rgba(0, 0, 0, 0.4);
}

.intro-gold-tile[data-focus='number'] .intro-gold-number {
  color: var(--focus-purple);
  text-shadow: 0 0 4px rgba(224, 64, 251, 0.28);
  transform: scale(1.06);
}

.intro-gold-tile[data-focus='number'] .intro-gold-center {
  opacity: 0.2;
  filter: grayscale(1) brightness(0.75);
}

.intro-gold-tile[data-focus='symbol'] .intro-gold-number,
.intro-gold-tile[data-focus='symbol'] .intro-gold-mass {
  opacity: 0.2;
  filter: grayscale(1) brightness(0.75);
  color: #3a3a3a;
}

.intro-gold-tile[data-focus='symbol'] .intro-gold-symbol {
  color: var(--focus-purple);
  text-shadow: 0 0 4px rgba(224, 64, 251, 0.28);
  transform: scale(1.03);
}

.intro-gold-tile[data-focus='mass'] .intro-gold-number,
.intro-gold-tile[data-focus='mass'] .intro-gold-symbol {
  opacity: 0.2;
  filter: grayscale(1) brightness(0.75);
  color: #3a3a3a;
}

.intro-gold-tile[data-focus='mass'] .intro-gold-mass {
  color: var(--focus-purple);
  opacity: 1;
  text-shadow: 0 0 4px rgba(224, 64, 251, 0.28);
  transform: scale(1.08);
}

@media (max-width: 720px) {
  .intro-gold-tile {
    --header-square: clamp(4.5rem, 28vw, 6.5rem);
  }
}

/* Game-style “tap here” cue — same mouse-pointer icon as the tour cursor */
.intro-tour-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  margin: 0;
  pointer-events: none;
  z-index: 6;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
  will-change: transform;
}

.intro-tour-pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #f2eef8;
  background: rgba(194, 107, 217, 0.35);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.intro-tour-pointer::after {
  content: '';
  position: absolute;
  left: 14px;
  top: 14px;
  width: 14px;
  height: 18px;
  border-radius: 1px 8px 8px 8px;
  background: #f2eef8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transform: rotate(25deg);
  transform-origin: 0 0;
}

.intro-tour-tap-ripple {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(194, 107, 217, 0.45);
  box-shadow: 0 0 0 0 rgba(194, 107, 217, 0.35);
  opacity: 0;
}

.intro-tour-cursor.is-tapping .intro-tour-pointer {
  animation: intro-pointer-tap 900ms cubic-bezier(0.33, 0.9, 0.4, 1) infinite;
}

.intro-tour-cursor.is-tapping .intro-tour-tap-ripple {
  animation: intro-hand-ripple 900ms ease-out infinite;
}

@keyframes intro-pointer-tap {
  0%,
  55%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  30% {
    transform: translate(1px, 5px) scale(0.88);
  }
  40% {
    transform: translate(0, 2px) scale(0.96);
  }
}

@keyframes intro-hand-ripple {
  0%,
  22% {
    opacity: 0;
    transform: scale(0.4);
    box-shadow: 0 0 0 0 rgba(194, 107, 217, 0.45);
  }
  30% {
    opacity: 0.9;
    transform: scale(0.85);
  }
  55% {
    opacity: 0;
    transform: scale(2.4);
    box-shadow: 0 0 0 10px rgba(194, 107, 217, 0);
  }
  100% {
    opacity: 0;
    transform: scale(2.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro-tour-cursor.is-tapping .intro-tour-pointer,
  .intro-tour-cursor.is-tapping .intro-tour-tap-ripple {
    animation: none;
  }

  .intro-tour-cursor.is-tapping .intro-tour-tap-ripple {
    opacity: 0.55;
    transform: scale(1.1);
  }
}

.intro-tour-canvas-host,
.intro-tour-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.intro-tour-card {
  --intro-hand: 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;
  position: absolute;
  left: auto;
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  bottom: auto;
  top: max(0.55rem, env(safe-area-inset-top, 0px));
  transform: rotate(-1.1deg);
  width: min(28rem, calc(100vw - 1.35rem));
  padding: 1.05rem 1.2rem 1.1rem;
  border-radius: 1.15rem 1.35rem 1.05rem 1.4rem;
  z-index: 5;
  border: 2.5px solid color-mix(in srgb, var(--intro-accent) 70%, #fff);
  background:
    radial-gradient(
      120% 90% at 12% 0%,
      color-mix(in srgb, var(--intro-accent) 22%, transparent) 0%,
      transparent 46%
    ),
    linear-gradient(
      168deg,
      #2a2434 0%,
      #17141f 55%,
      #120f18 100%
    );
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.48),
    0 0 0 3px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -10px 28px rgba(0, 0, 0, 0.28);
  opacity: var(--intro-card-opacity);
  pointer-events: auto;
  z-index: 4;
  transition:
    top 320ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 280ms ease,
    opacity 280ms ease,
    transform 280ms ease;
}

.intro-tour-card::before {
  content: '';
  position: absolute;
  inset: 0.45rem;
  border-radius: 0.85rem 1rem 0.8rem 1.05rem;
  border: 1.5px dashed color-mix(in srgb, var(--intro-accent) 42%, rgba(255, 255, 255, 0.18));
  pointer-events: none;
  opacity: 0.85;
}

.intro-tour-kicker {
  position: relative;
  margin: 0 0 0.15rem;
  font-family: var(--intro-hand);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: color-mix(in srgb, var(--intro-accent) 78%, #fff);
}

.intro-tour-title {
  position: relative;
  margin: 0 0 0.4rem;
  font-family: var(--intro-hand);
  font-size: clamp(1.85rem, 2.4vw + 1.2rem, 2.55rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.05;
  color: #fff8ff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.intro-tour-body {
  position: relative;
  margin: 0;
  font-family: var(--intro-hand);
  font-size: clamp(1.35rem, 1.2vw + 1.05rem, 1.7rem);
  font-weight: 500;
  line-height: 1.28;
  color: #f0d4ff;
}

.intro-tour[data-step='groups-word'] .intro-tour-title,
.intro-tour[data-step='groups-example'] .intro-tour-title {
  color: #ffe4ff;
}

.intro-tour-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 0.95rem;
}

.intro-tour-progress {
  flex: 1;
  text-align: center;
  font-family: var(--intro-hand);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 236, 255, 0.62);
}

.intro-tour-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.intro-tour-back,
.intro-tour-next,
.intro-tour-skip {
  appearance: none;
  border-radius: 999px;
  font-family: var(--intro-hand);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.28rem 1.05rem 0.38rem;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 120ms ease,
    opacity 160ms ease,
    box-shadow 160ms ease;
}

.intro-tour-back {
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 245, 255, 0.88);
}

.intro-tour-next {
  border: 2px solid color-mix(in srgb, var(--intro-accent) 65%, #fff);
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--intro-accent) 92%, #fff) 0%,
      color-mix(in srgb, var(--intro-accent) 72%, #5a2080) 100%
    );
  color: #1a1020;
  box-shadow:
    0 3px 0 color-mix(in srgb, var(--intro-accent) 45%, #000),
    0 6px 16px color-mix(in srgb, var(--intro-accent) 35%, transparent);
}

.intro-tour-skip {
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: rgba(255, 240, 255, 0.72);
  padding-inline: 0.8rem;
}

.intro-tour-back:hover:not(:disabled),
.intro-tour-back:focus-visible:not(:disabled),
.intro-tour-skip:hover,
.intro-tour-skip:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.34);
  color: #fff;
  outline: none;
}

.intro-tour-next:hover:not(:disabled),
.intro-tour-next:focus-visible:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-2px);
  outline: none;
}

.intro-tour-next:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--intro-accent) 45%, #000),
    0 3px 10px color-mix(in srgb, var(--intro-accent) 28%, transparent);
}

.intro-tour-back:disabled,
.intro-tour-next:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
  filter: none;
  box-shadow: none;
}

.intro-tour-back:focus-visible,
.intro-tour-next:focus-visible,
.intro-tour-skip:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--intro-accent) 70%, transparent);
}

@media (max-height: 640px) {
  .intro-tour-card {
    top: max(0.4rem, env(safe-area-inset-top, 0px));
    padding: 0.85rem 1rem 0.9rem;
    transform: rotate(-0.7deg);
  }

  .intro-tour-title {
    font-size: clamp(1.55rem, 4.5vw, 2.1rem);
  }

  .intro-tour-body {
    font-size: clamp(1.15rem, 3.4vw, 1.45rem);
  }

  .intro-tour-back,
  .intro-tour-next,
  .intro-tour-skip {
    font-size: 1.1rem;
  }
}

.peak-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.peak-dim {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: rgba(8, 10, 16, 0.55);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.peak-card {
  position: absolute;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(26rem, calc(100% - 2rem));
  padding: 1.1rem 1.25rem 1.2rem;
  border-radius: 1.35rem;
  color: #f4f4f5;
  background: linear-gradient(160deg, rgba(28, 30, 38, 0.72), rgba(12, 14, 20, 0.78));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(28px) saturate(1.45);
  -webkit-backdrop-filter: blur(28px) saturate(1.45);
  pointer-events: auto;
}

.peak-card-queue {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  text-align: center;
  width: min(28rem, calc(100% - 2rem));
  padding: 1.6rem 1.4rem 1.5rem;
}

.peak-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 244, 245, 0.62);
}

.peak-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.peak-clock,
.peak-line {
  margin: 0.35rem 0 0.15rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.peak-clock { font-size: 2.6rem; }

.peak-line { font-size: 3.4rem; }

.peak-copy {
  margin: 0.35rem 0 0;
  color: rgba(244, 244, 245, 0.82);
  font-size: 0.95rem;
  line-height: 1.4;
}
