.drift-page {
  --drift-held: #4ade80;
  --drift-warn: #f5a623;
  --drift-gone: #e24b4a;
  overflow-x: hidden;
}

.drift-stage {
  width: 100%;
  min-height: calc(100vh - var(--global-nav-h));
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2rem) 0;
  isolation: isolate;
}

/* Everything the field carries is positioned against the field itself. */
.drift-field {
  position: relative;
  width: 100%;
  max-width: 1400px;
}

#drift-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  background: #07070b;
  cursor: none;
  touch-action: none;
}

#drift-canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.drift-page[data-pointer="off"] #drift-canvas { cursor: crosshair; }

/* Title plate, sitting over the top left of the field. */
.drift-title::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -7rem -26rem -9rem -7rem;
  background: radial-gradient(
    52% 62% at 19% 46%,
    rgba(7, 7, 11, .97) 0%,
    rgba(7, 7, 11, .94) 42%,
    rgba(7, 7, 11, .62) 68%,
    rgba(7, 7, 11, 0) 100%
  );
}

.drift-title {
  position: absolute;
  isolation: isolate;
  top: clamp(1.6rem, 4vw, 3rem);
  left: clamp(1.6rem, 4vw, 3.4rem);
  z-index: 2;
  max-width: min(30rem, 62vw);
  pointer-events: none;
}

.drift-index {
  margin: 0 0 .55rem;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.drift-title h1 {
  margin: 0 0 .5rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: .95;
  letter-spacing: -.02em;
}

.drift-title h1 span { color: var(--accent); }

.drift-title p {
  margin: 0;
  max-width: 26rem;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.75;
}

/* Readout rail along the bottom of the field. */
.drift-rail {
  position: absolute;
  right: clamp(1.6rem, 4vw, 3.4rem);
  bottom: clamp(1.6rem, 4vw, 3rem);
  left: clamp(1.6rem, 4vw, 3.4rem);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  border: 1px solid var(--border);
  background: var(--border);
  pointer-events: none;
}

.drift-cell {
  flex: 1 1 8rem;
  min-width: 0;
  padding: .6rem .85rem;
  background: rgba(10, 10, 15, .88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.drift-cell dt {
  margin-bottom: .25rem;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.drift-cell dd {
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.drift-cell dd[data-state="held"] { color: var(--drift-held); }
.drift-cell dd[data-state="drifting"] { color: var(--drift-warn); }
.drift-cell dd[data-state="breached"] { color: var(--drift-gone); }

/* Mode switch, top right. */
.drift-controls {
  position: absolute;
  top: clamp(1.6rem, 4vw, 3rem);
  right: clamp(1.6rem, 4vw, 3.4rem);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
}

.drift-switch {
  display: flex;
  gap: 1px;
  border: 1px solid var(--border-hi);
  background: var(--border-hi);
}

.drift-switch button {
  min-height: 34px;
  padding: 0 .95rem;
  border: 0;
  background: rgba(10, 10, 15, .9);
  color: var(--text-faint);
  font: 11px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}

.drift-switch button:hover { color: var(--text); }
.drift-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: #0a0a0f;
  font-weight: 500;
}

.drift-reset {
  min-height: 30px;
  padding: 0 .8rem;
  border: 1px solid var(--border);
  background: rgba(10, 10, 15, .9);
  color: var(--text-faint);
  font: 10px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}

.drift-reset:hover { color: var(--accent); border-color: var(--accent); }

/* The verdict, which arrives when the estate is past saving by hand. */
.drift-verdict {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: min(34rem, calc(100% - 4rem));
  padding: 1.6rem 1.7rem;
  transform: translate(-50%, -50%);
  border: 1px solid var(--accent);
  background: rgba(10, 10, 15, .95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 0 80px rgba(245, 166, 35, .12);
}

.drift-verdict[hidden] { display: none; }

.drift-verdict h2 {
  margin: 0 0 .7rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.1;
}

.drift-verdict p {
  margin: 0 0 .8rem;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.8;
}

.drift-verdict p:last-of-type { margin-bottom: 1.1rem; }
.drift-verdict strong { color: var(--accent); font-weight: 500; }

.drift-verdict-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

.drift-verdict-actions button {
  min-height: 36px;
  padding: 0 1rem;
  border: 1px solid var(--border-hi);
  background: transparent;
  color: var(--text-dim);
  font: 11px var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}

.drift-verdict-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #0a0a0f;
  font-weight: 500;
}

/* Standing text below the field. */
.drift-note {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 5rem;
  border-top: 1px solid var(--border);
}

.drift-note h2 {
  margin: 0 0 .9rem;
  max-width: 40rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.4vw, 2.2rem);
  line-height: 1.1;
}

.drift-note p {
  margin: 0 0 1rem;
  max-width: 46rem;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.9;
}

.drift-note a { color: var(--accent); }

.drift-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin: 1.6rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
  color: var(--text-faint);
}

.drift-legend li { display: flex; align-items: center; gap: .5rem; }

.drift-legend i {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 1px;
}

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

@media (max-width: 860px) {
  #drift-canvas { aspect-ratio: 16 / 9; }
  .drift-title { position: static; max-width: none; margin-bottom: 1rem; }
  .drift-stage { display: block; min-height: 0; padding-top: 1.5rem; }
  .drift-controls { position: static; align-items: flex-start; margin: 1rem 0; flex-direction: row; }
  .drift-rail { position: static; margin-top: 1rem; }
  .drift-verdict { position: fixed; }
}
