:root {
  --bg: #f4f1ee;
  --track: #e2dadb;
  --track-dim: #474647;
  --ink: #01161e;
  --font: "Inter", system-ui, sans-serif;
  --wheel-size: max(270px, min(80vw, calc(64vh - 140px), 760px));
  --wheel-size: max(270px, min(80vw, calc(64dvh - 140px), 760px));
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  background: var(--bg);
  font-family: var(--font);
  color: var(--ink);
}

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

html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.page-title {
  width: 100%;
  margin: auto 0;
  padding: 12px 16px 2px;
  text-align: center;
  font-weight: 600;
}

.page-title__eyebrow,
.grid-wrap__color-name {
  font-size: clamp(13px, 3.5vw, 15px);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.page-title__eyebrow {
  display: block;
  height: 20px;
  line-height: 20px;
  position: relative;
  z-index: 2;
}

.page-title__line {
  font-size: clamp(30px, 9vw, 39px);
  display: flex;
  justify-content: center;
  height: 1.3em;
  margin-top: -0.2em;
}

.page-title__emotion {
  display: flex;
  height: 100%;
  text-transform: lowercase;
  visibility: hidden;
}

.page-title__emotion--ready {
  visibility: visible;
}

.page-title__letter {
  display: flex;
  width: clamp(36px, 9vw, 48px);
  height: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
}

.page-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 16px;
  margin-bottom: auto;
}

.page-content.cvd-deuteranomaly {
  filter: url(#deuteranomaly-filter);
}

.topline__buttons {
  display: flex;
  gap: 8px;
  align-self: flex-end;
  padding: 10px 12px 0;
}

@media (min-width: 600px) {
  .topline__buttons {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 40;
    flex-direction: column;
    align-items: center;
    padding: 0;
  }
}

.topline__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.topline__icon {
  display: block;
  width: 28px;
  height: 28px;
  background-color: currentColor;
  transition: background-color 0.15s ease;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.topline__icon--cvd { --icon: url("images/colorblind.svg"); }
.topline__icon--random { --icon: url("images/random.svg"); }
.topline__icon--info { --icon: url("images/info.svg"); }
.topline__icon--share { --icon: url("images/share.svg"); }

@media (hover: hover) {
  .topline__button:hover {
    opacity: 0.7;
  }
}

.topline__button[aria-pressed="true"] {
  opacity: 0.5;
}

.credits-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.credits-overlay[hidden] {
  display: none;
}

.credits-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 22, 30, 0.55);
}

.credits-overlay__panel {
  position: relative;
  max-width: min(480px, 88vw);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(1, 22, 30, 0.3);
}

.credits-overlay__panel h2 {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  row-gap: 6px;
  margin: 0 0 16px;
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 600;
}

.credits-overlay__title-word {
  display: inline-flex;
  align-items: baseline;
}

.credits-overlay__title-word + .credits-overlay__title-word {
  margin-left: 0.3em;
}

.credits-overlay__title-letter {
  display: inline-block;
}

.credits-overlay__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 16px;
}

.credits-overlay__panel p {
  font-size: 14px;
  line-height: 1.6;
}

.credits-overlay__panel p.credits-overlay__intro {
  font-size: 18px;
}

.credits-overlay__panel a {
  color: var(--ink);
}

.credits-overlay__icon-credit {
  display: inline-flex;
  transition: opacity 0.15s ease;
}

.credits-overlay__icon {
  display: block;
  width: 10px;
  height: 10px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

@media (hover: hover) {
  .credits-overlay__icon-credit:hover {
    opacity: 0.6;
  }
}

.credits-overlay__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(1, 22, 30, 0.08);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

@media (hover: hover) {
  .credits-overlay__close:hover {
    background: rgba(1, 22, 30, 0.16);
  }
}

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.intro-overlay[hidden] {
  display: none;
}

.intro-overlay__phrase {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  row-gap: 8px;
  font-size: clamp(30px, 9vw, 39px);
  font-weight: 600;
  text-align: center;
  visibility: hidden;
}

.intro-overlay__phrase--ready {
  visibility: visible;
}

.intro-overlay__word {
  display: inline-flex;
  align-items: baseline;
}

.intro-overlay__word + .intro-overlay__word {
  margin-left: 0.35em;
}

.intro-overlay__letter {
  display: inline-block;
  opacity: 0;
}

.share-overlay__label {
  display: block;
  margin: 18px 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.7;
}

.share-overlay__select-row {
  display: flex;
  gap: 10px;
}

.share-overlay__select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid rgba(1, 22, 30, 0.25);
  border-radius: 8px;
  cursor: pointer;
}

.share-overlay__swatch {
  flex: 0 0 auto;
  width: 42px;
  border-radius: 8px;
  border: 1px solid rgba(1, 22, 30, 0.15);
  transition: background-color 0.2s ease;
}

.share-overlay__link-wrap {
  position: relative;
}

.share-overlay__link {
  width: 100%;
  padding: 10px 74px 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  background: rgba(1, 22, 30, 0.06);
  border: 1px dashed rgba(1, 22, 30, 0.35);
  border-radius: 8px;
  cursor: pointer;
  text-overflow: ellipsis;
  user-select: text;
  -webkit-user-select: text;
}

.share-overlay__copied {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.share-overlay__copied.visible {
  opacity: 1;
}

.marquee-panel {
  text-align: center;
  width: 100%;
}

.marquee {
  position: relative;
  width: min(720px, 92vw);
  margin: 0 auto;
}

.marquee__viewport {
  font-size: clamp(25.5px, 7.5vw, 36px);
  --fade: clamp(24px, 8vw, 56px);
  overflow: hidden;
  height: 2.6em;
  display: flex;
  align-items: center;
  -webkit-mask-image: linear-gradient(to right, transparent 0, black var(--fade), black calc(100% - var(--fade)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, black var(--fade), black calc(100% - var(--fade)), transparent 100%);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.marquee__viewport.dragging {
  cursor: grabbing;
}

.marquee__track {
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  will-change: transform;
  opacity: 0;
}

.marquee__word {
  font-weight: 500;
  color: var(--ink);
  opacity: 0.32;
  padding: 0 0.75em;
  cursor: pointer;
  transition: opacity 0.2s ease, color 0.2s ease;
  outline: none;
}

.marquee__word--active {
  opacity: 1;
}

body.kbd-nav .marquee__word:focus {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.chart-wrap {
  width: calc(var(--wheel-size) * 460 / 400);
}

#chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.slice-bg {
  fill: var(--track);
  pointer-events: none;
  transition: fill 0.4s ease;
}

#chart.bg-dimmed .slice-bg {
  fill: var(--track-dim);
}

.slice-fg {
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.slice-fg.hovered {
  opacity: 0.75;
}

.slice-hit {
  fill: transparent;
  stroke: var(--bg);
  stroke-width: 1.5px;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
}

body.kbd-nav .slice-hit:focus {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.slice-outer-highlight {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.slice-outer-highlight.selected {
  opacity: 1;
}

.slice-outer-highlight circle {
  fill: var(--ink);
  stroke: var(--ink);
  stroke-width: 2px;
}

.slice-outer-highlight .dot-symbol {
  stroke: var(--bg);
  stroke-width: 3px;
  stroke-linecap: round;
}

.slice-outer-highlight.negative .dot-symbol--v {
  display: none;
}

.valence-divider {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.35;
}

.grid-wrap {
  width: var(--wheel-size);
  margin-top: 0;
}

.grid-wrap__color-name {
  text-align: center;
  margin-bottom: 10px;
}

#color-grid {
  width: 100%;
  height: auto;
  display: block;
}

.color-cell {
  cursor: pointer;
  outline: none;
}

body.kbd-nav .color-cell:focus {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.color-cell rect {
  stroke: rgba(1, 22, 30, 0.15);
  stroke-width: 1;
  transition: stroke-width 0.12s ease, stroke 0.12s ease;
}

@media (hover: hover) {
  .color-cell:hover rect {
    stroke: #01161e;
    stroke-width: 2;
  }
}

.color-cell .selector-dot {
  pointer-events: none;
}

.load-error {
  max-width: 480px;
  margin: 24px auto;
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid rgba(1, 22, 30, 0.15);
  background: #fff3f2;
  color: #8a1f1a;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
}

.noscript-message {
  max-width: 480px;
  margin: 15vh auto 0;
  padding: 0 24px;
  text-align: center;
  font-family: var(--font);
  color: var(--ink);
}

.noscript-message p {
  font-size: 16px;
  line-height: 1.6;
}
