:root {
  --bg: #0b0c1d;
  --bg-2: #14163a;
  --grid: rgba(255, 255, 255, 0.05);
  --ink: #f3f3ee;
  --ink-dim: #8b8fa6;
  --ink-dimmer: #5b5f78;
  --accent: #6ee7b7;
  --chomp: #ffd166;

  /* NIST CSF 5-category palette — one color per function */
  --nist-id: #7dd3fc;
  /* Identify   — sky blue   */
  --nist-pr: #6ee7b7;
  /* Protect    — mint green */
  --nist-de: #ffd166;
  /* Detect     — amber      */
  --nist-rs: #f87171;
  /* Respond    — coral      */
  --nist-rc: #c084fc;
  /* Recover    — violet     */
  --piece-stroke: rgba(0, 0, 0, 0.35);
  --piece-shine: rgba(255, 255, 255, 0.18);

  /* Proportional cell sizing — scales with viewport height instead of
     hardcoded per-breakpoint values. 250px accounts for stage chrome
     (padding, gaps, eyebrow, footer, level-up-spark, board-wrap). */
  --cell: clamp(28px, calc((100vh - 250px) / 8), 60px);
  --cols: 6;
  --rows: 8;

  --duration: 16s;
  --piece-fall: 0.7s;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(ellipse at 50% 30%, #1c1f4d 0%, var(--bg) 55%, #06061a 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 80px 80px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 35%, transparent 80%);
}

.stage {
  position: relative;
  width: min(96vw, 1640px);
  max-height: 96vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* Proportional padding & gap — scales with viewport */
  padding: clamp(12px, 3vh, 36px) clamp(16px, 4vw, 56px);
  gap: clamp(8px, 1.5vh, 22px);
}

/* ── eyebrow + footer ──────────────────────────────────── */
.eyebrow {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.9;
}

.eyebrow::before {
  content: "// ";
  opacity: 0.5;
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dimmer);
}

.footer .brand {
  color: var(--accent);
  opacity: 0.7;
}

.footer .meta {
  color: var(--ink-dimmer);
}

/* ── main layout ─────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: auto auto;
  /* Proportional gap between board and copy */
  gap: clamp(24px, 6vw, 96px);
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2vh, 22px);
}

/* ── tetris board ────────────────────────────────────── */
.board-wrap {
  position: relative;
  padding: 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.board {
  position: relative;
  width: calc(var(--cell) * var(--cols));
  height: calc(var(--cell) * var(--rows));
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / var(--cell) var(--cell),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / var(--cell) var(--cell),
    rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    inset 0 -40px 80px rgba(110, 231, 183, 0.04);
  overflow: hidden;
}

/* board chrome — score / level above */
.board-meta {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dimmer);
}

.board-meta .lbl {
  color: var(--ink-dimmer);
}

.board-meta .val {
  color: var(--accent);
  font-weight: 500;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* completion flash — runs once when board fills */
.complete-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  animation: flashSweep var(--duration) linear infinite;
}

@keyframes flashSweep {

  0%,
  78% {
    opacity: 0;
    transform: translateY(-100%);
  }

  80% {
    opacity: 1;
    transform: translateY(-100%);
  }

  88% {
    opacity: 0.9;
    transform: translateY(100%);
  }

  90%,
  100% {
    opacity: 0;
    transform: translateY(100%);
  }
}

.complete-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-weight: 700;
  font-size: clamp(15px, calc(var(--cell) * 0.6), 36px);
  letter-spacing: 0.12em;
  color: #0b0c1d;
  background: rgba(110, 231, 183, 0.92);
  mix-blend-mode: normal;
  opacity: 0;
  animation: completeText var(--duration) linear infinite;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

@keyframes completeText {

  0%,
  84% {
    opacity: 0;
    transform: scale(0.92);
  }

  86% {
    opacity: 1;
    transform: scale(1);
  }

  94% {
    opacity: 1;
    transform: scale(1);
  }

  96%,
  100% {
    opacity: 0;
    transform: scale(1.04);
  }
}

/* ── pieces ──────────────────────────────────────────── */
.piece {
  position: absolute;
  left: calc(var(--cell) * var(--col));
  top: calc(var(--cell) * var(--row));
  width: calc(var(--cell) * var(--w));
  height: calc(var(--cell) * var(--h));
  display: grid;
  grid-template-columns: repeat(var(--w), 1fr);
  grid-template-rows: repeat(var(--h), 1fr);
  animation: drop var(--duration) cubic-bezier(.55, .05, .7, .55) infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0;
  will-change: transform, opacity;
}

.piece .cell {
  background: var(--color, #6ee7b7);
  box-shadow:
    inset 0 0 0 2px var(--piece-stroke),
    inset 6px 6px 0 -2px var(--piece-shine),
    inset -6px -6px 0 -2px rgba(0, 0, 0, 0.25);
  border-radius: 3px;
}

/* drop keyframe: piece starts above board, falls to target row.
   --row+--h is how far above the board to start (so bottom of piece = top of board).
   Stagger via --delay. After landing, holds until end of cycle. */
@keyframes drop {
  0% {
    transform: translateY(calc(var(--cell) * -1 * (var(--row) + var(--h) + 1)));
    opacity: 0;
  }

  0.5% {
    opacity: 1;
  }

  var-fall-end {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── labels ──────────────────────────────────────────── */
.copy {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: clamp(18px, 2.5vh, 28px);
  width: 640px;
  max-width: 100%;
  align-self: stretch;
  padding-top: 8px;
  justify-items: start;
}

.tagline {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: clamp(24px, 3.4vw, 52px);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

.tagline .dim {
  color: var(--ink-dim);
}

.tagline .hl {
  color: var(--chomp);
  position: relative;
}

.tagline .hl::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: -3px;
  height: 3px;
  background: var(--chomp);
  transform: scaleX(0);
  transform-origin: left center;
  animation: underline var(--duration) linear infinite;
}

@keyframes underline {

  0%,
  80% {
    transform: scaleX(0);
  }

  88% {
    transform: scaleX(1);
  }

  100% {
    transform: scaleX(1);
  }
}

.sub {
  font-size: clamp(13px, 1.1vw, 16px);
  color: var(--ink-dim);
  letter-spacing: 0.02em;
  margin: 0;
  max-width: 44ch;
  text-align: justify;
}

.sub .accent {
  color: var(--accent);
}

/* level-up spark — sits centered under the board, persistent,
   sparks pulse subtly when the board completes */
.level-up-spark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 8px 18px;
  border-radius: 6px;
  background: rgba(110, 231, 183, 0.06);
  box-shadow: inset 0 0 0 1px rgba(110, 231, 183, 0.25);
}

.level-up-spark .spark {
  color: var(--accent);
  font-size: 12px;
  display: inline-block;
  transform-origin: center;
  animation: sparkPulse var(--duration) ease-in-out infinite;
}

.level-up-spark .spark.s2 {
  animation-delay: 0.18s;
}

/* ── text effects: gaps & overlaps ──────────────────── */
.tagline .gaps-effect {
  position: relative;
  display: inline-block;
  width: 4.5ch;
  text-align: center;
  white-space: nowrap;
  animation: gapsEffect var(--duration) linear infinite;
  will-change: letter-spacing, opacity;
}

@keyframes gapsEffect {

  0%,
  20% {
    letter-spacing: 0.05em;
    opacity: 1;
  }

  40%,
  60% {
    letter-spacing: 0.2em;
    opacity: 0.6;
  }

  80%,
  100% {
    letter-spacing: 0.05em;
    opacity: 1;
  }
}

.tagline .overlaps-effect {
  position: relative;
  display: inline-block;
  animation: overlapsEffect var(--duration) linear infinite;
  will-change: letter-spacing, transform, opacity;
}

@keyframes overlapsEffect {

  0%,
  20% {
    letter-spacing: normal;
    transform: scaleX(1);
    opacity: 1;
  }

  40%,
  60% {
    letter-spacing: -0.15em;
    transform: scaleX(0.92);
    opacity: 1;
  }

  80%,
  100% {
    letter-spacing: normal;
    transform: scaleX(1);
    opacity: 1;
  }
}

@keyframes sparkPulse {

  0%,
  78% {
    opacity: 0.45;
    transform: scale(1) rotate(0deg);
  }

  84% {
    opacity: 1;
    transform: scale(1.5) rotate(180deg);
  }

  90% {
    opacity: 0.95;
    transform: scale(1.15) rotate(260deg);
  }

  96% {
    opacity: 0.6;
    transform: scale(1) rotate(360deg);
  }

  100% {
    opacity: 0.45;
    transform: scale(1) rotate(360deg);
  }
}

/* learn-more cta — always visible, no flashing.
   Centered horizontally within the .copy column. */
.learn-more {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(110, 231, 183, 0.06);
  box-shadow: inset 0 0 0 1px rgba(110, 231, 183, 0.15);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.learn-more::after {
  content: "→";
  font-weight: 700;
  transition: transform 0.15s ease;
}

.learn-more:hover {
  transform: translateY(-1px);
  color: var(--ink);
  font-weight: 800;
}

.learn-more:hover::after {
  transform: translateX(3px);
}

.learn-more:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 0 #c89849, 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ── hover-to-pause on the board column ──────────────── */
.board-col:hover {
  cursor: pause;
}

.board-col:hover .piece,
.board-col:hover .complete-flash,
.board-col:hover .complete-text,
.board-col:hover .level-up-spark .spark {
  animation-play-state: paused;
}

/* labels list — grouped into NIST categories, 3 left / 2 right */
.labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 36px;
  align-items: stretch;
  margin-top: 4px;
}

.labels-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  min-height: 100%;
}

.cat-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-header {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: clamp(9px, 0.85vw, 10.5px);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cat-color, var(--ink-dim));
}

.cat-header .num {
  opacity: 0.55;
  color: var(--ink-dim);
}

.cat-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--cat-color);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset;
}

.cat-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 17px;
}

.label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(11px, 0.95vw, 13.5px);
  color: var(--ink);
  opacity: 0;
  transform: translateY(-10px);
  animation-delay: var(--delay, 0s);
  letter-spacing: 0.005em;
}

.label .swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 2px;
  background: var(--color, var(--accent));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 3px 3px 0 -1px rgba(255, 255, 255, 0.25);
}

.label .text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes chipIn {
  0% {
    opacity: 0;
    transform: translateY(-12px);
  }

  0.4% {
    opacity: 0;
    transform: translateY(-12px);
  }

  4% {
    opacity: 1;
    transform: translateY(0);
  }

  78% {
    opacity: 1;
    transform: translateY(0);
  }

  82% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* keep chips visible after landing — overrides the chipIn cycle to maintain post-land */
@keyframes chipPersist {

  0%,
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── responsive ─────────────────────────────────────── */

/* Short viewports (landscape tablets, small laptops): collapse board
   and shrink chrome so everything fits without scroll.  Use the same
   flex-column approach as mobile but keep side-by-side labels. */
@media (max-height: 600px) and (min-width: 641px) {
  :root {
    --cell: clamp(22px, calc((100vh - 180px) / 8), 40px);
  }

  .stage {
    padding: 8px 28px;
    gap: 4px;
    max-height: none;
    min-height: 100%;
  }

  .main {
    gap: clamp(16px, 4vw, 40px);
  }

  .board-col {
    gap: 6px;
  }

  .board-wrap {
    padding: 8px;
  }

  .complete-text {
    font-size: clamp(12px, calc(var(--cell) * 0.5), 18px);
    letter-spacing: 0.06em;
  }

  .level-up-spark {
    font-size: 9.5px;
    padding: 4px 10px;
    gap: 6px;
    letter-spacing: 0.2em;
  }

  .level-up-spark .spark {
    font-size: 9.5px;
  }

  .copy {
    gap: clamp(8px, 1.5vh, 14px);
    padding-top: 0;
  }

  .tagline {
    font-size: clamp(18px, 2.5vw, 28px);
    line-height: 1.05;
  }

  .sub {
    font-size: 11px;
  }

  .labels {
    gap: 2px 18px;
  }

  .labels-col {
    gap: 6px;
  }

  .cat-items {
    gap: 2px;
    padding-left: 14px;
  }

  .label {
    font-size: 10px;
    gap: 6px;
  }

  .label .swatch {
    width: 7px;
    height: 7px;
    flex-basis: 7px;
  }

  .cat-header {
    font-size: 8.5px;
    letter-spacing: 0.15em;
    gap: 6px;
  }

  .cat-header .dot {
    width: 6px;
    height: 6px;
  }

  .eyebrow {
    font-size: 10px;
    letter-spacing: 0.2em;
  }

  .footer {
    font-size: 9px;
    letter-spacing: 0.16em;
  }
}

/* Stack vertically on narrow viewports */
@media (max-width: 820px) {
  .stage {
    padding: clamp(14px, 3vh, 22px) clamp(12px, 3vw, 22px);
    max-height: none;
    min-height: 100%;
    gap: clamp(10px, 2vh, 14px);
  }

  .main {
    grid-template-columns: 1fr;
    gap: clamp(14px, 3vh, 22px);
    justify-items: center;
    align-content: center;
  }

  .copy {
    max-width: 540px;
    text-align: center;
    padding-top: 0;
    gap: 18px;
  }

  .sub {
    margin-left: auto;
    margin-right: auto;
  }

  .labels {
    gap: 12px 22px;
  }

  .labels-col {
    gap: 12px;
  }

  .cat-items {
    gap: 4px;
    padding-left: 17px;
  }

  .label {
    font-size: clamp(10.5px, 2.5vw, 12px);
    gap: 8px;
  }

  .label .swatch {
    width: 9px;
    height: 9px;
    flex-basis: 9px;
  }

  .label .text {
    white-space: normal;
    line-height: 1.2;
  }

  .cat-header {
    font-size: clamp(9px, 2vw, 10.5px);
    letter-spacing: 0.22em;
  }

  .tagline {
    font-size: clamp(22px, 5vw, 32px);
  }

  .sub {
    font-size: 13.5px;
  }
}

/* iPad portrait: bigger board, taller viewport */
@media (max-width: 820px) and (min-height: 900px) {
  :root {
    --cell: clamp(40px, calc((100vh - 250px) / 8), 60px);
  }

  .tagline {
    font-size: 32px;
  }
}

/* mobile */
@media (max-width: 640px) {
  :root {
    --cell: clamp(16px, calc((100dvh - 520px) / 8), 24px);
  }

  body {
    overflow-y: auto;
    overflow-x: hidden;
    align-items: flex-start;
  }

  .stage {
    width: 100%;
    min-height: 100dvh;
    padding: 10px 10px 14px;
    gap: 8px;
  }

  .main {
    width: 100%;
    gap: 12px;
    align-content: start;
    justify-items: center;
  }

  .board-col {
    width: 100%;
    align-items: center;
  }

  .board-wrap {
    padding: 8px;
  }

  .copy {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }

  .tagline {
    font-size: 22px;
  }

  .sub {
    font-size: 12.5px;
  }

  .complete-text {
    font-size: 15px;
    letter-spacing: 0.06em;
  }

  .labels {
    order: 4;
    width: 100%;
    max-width: 330px;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .labels-col {
    gap: 10px;
  }

  .label {
    font-size: 10.5px;
    gap: 7px;
  }

  .label .swatch {
    width: 8px;
    height: 8px;
    flex-basis: 8px;
  }

  .cat-header {
    justify-content: center;
    font-size: 9px;
    letter-spacing: 0.18em;
  }

  .cat-items {
    align-items: center;
    padding-left: 0;
  }

  .label {
    justify-content: center;
    text-align: center;
  }

  .footer {
    font-size: 9.5px;
    letter-spacing: 0.18em;
  }

  .footer .meta {
    display: none;
  }

  .level-up-spark {
    font-size: 10px;
    padding: 6px 12px;
    gap: 8px;
    letter-spacing: 0.28em;
  }

  .learn-more {
    order: 3;
    font-size: 14px;
    padding: 11px 22px;
  }

  .eyebrow {
    font-size: 10.5px;
    letter-spacing: 0.24em;
  }
}

@media (prefers-reduced-motion: reduce) {

  .piece,
  .label,
  .complete-flash,
  .complete-text,
  .level-up-spark .spark,
  .tagline .hl::after,
  .cat-header {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
