:root {
  color-scheme: dark;
  --bg: #060606;
  --panel: #10100e;
  --panel-soft: #171711;
  --text: #ebe7d6;
  --muted: #9c9987;
  --line: #3b382b;
  --accent: #c7ff68;
  --accent-dim: #6f8e43;
  --warning: #d9b36a;
  --danger: #ff6d5f;
  --shadow: 0 22px 90px rgba(0, 0, 0, 0.72);
  font-family: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(199, 255, 104, 0.1), transparent 30rem),
    radial-gradient(circle at 80% 84%, rgba(217, 179, 106, 0.08), transparent 26rem),
    #060606;
  background-size: 100% 3px, 46px 46px, auto, auto, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.04),
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 5px
    );
  mix-blend-mode: overlay;
  opacity: 0.28;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 18px;
  display: grid;
  align-items: center;
}

.beta-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 1;
  margin: 0;
  padding: 3px 7px;
  border: 1px solid rgba(199, 255, 104, 0.28);
  color: var(--muted);
  background: rgba(6, 6, 6, 0.52);
  font-size: 0.72rem;
}

.intro-screen,
.complete-screen,
.finale-screen,
.game-screen {
  width: 100%;
}

.intro-screen,
.complete-screen,
.finale-screen,
.room-panel,
.notes-panel,
.progress-panel {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 54px),
    rgba(16, 16, 14, 0.92);
  box-shadow: var(--shadow);
}

.intro-screen::after,
.complete-screen::after,
.finale-screen::after,
.room-panel::after,
.notes-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(199, 255, 104, 0.08);
  transform: translate(4px, 4px);
}

.intro-screen,
.complete-screen,
.finale-screen {
  overflow: hidden;
  padding: clamp(28px, 7vw, 76px);
}

.dead-link-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: -28px -28px 34px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #080806;
  font-size: 0.76rem;
}

.intro-copy {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
  font-weight: 800;
}

h1 {
  max-width: 9ch;
  color: #f8f3df;
  font-size: clamp(3.4rem, 12vw, 8.6rem);
}

h2 {
  max-width: 16ch;
  font-size: clamp(1.7rem, 4.8vw, 3.3rem);
}

h3 {
  font-size: 1.15rem;
}

.glitch-title {
  position: relative;
  text-shadow: 2px 0 rgba(255, 109, 95, 0.62), -2px 0 rgba(199, 255, 104, 0.44);
}

.glitch-title::before,
.glitch-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.62;
}

.glitch-title::before {
  color: var(--danger);
  transform: translate(2px, -1px);
  clip-path: inset(12% 0 64% 0);
}

.glitch-title::after {
  color: var(--accent);
  transform: translate(-2px, 1px);
  clip-path: inset(58% 0 18% 0);
}

.is-glitching .glitch-title,
.is-glitching .room-panel,
.is-glitching .progress-fill,
.is-glitching .finale-screen {
  animation: glitch-shift 180ms steps(2, end);
}

.intro-text,
.complete-screen p,
.finale-line {
  max-width: 68ch;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.72;
}

.intro-actions,
.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 28px;
}

.button,
.icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 18px;
  color: var(--text);
  background: #171711;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.button:hover,
.icon-button:hover {
  border-color: var(--accent-dim);
  background: #1f2116;
  transform: translateY(-1px);
}

.button-primary {
  color: #111408;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}

.button-primary:hover {
  color: #090b04;
  background: #e2ff9f;
}

.button-ghost {
  background: transparent;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.game-screen {
  display: grid;
  gap: 18px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.progress-panel {
  padding: 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

#progress-nodes {
  color: var(--accent);
  letter-spacing: 0;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #090907;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      var(--accent),
      var(--accent) 10px,
      #95c14e 10px,
      #95c14e 15px
    );
  transition: width 250ms ease;
}

.inventory-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.inventory-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid rgba(199, 255, 104, 0.28);
  padding: 0 7px;
  color: var(--accent);
  background: rgba(199, 255, 104, 0.06);
  font-size: 0.76rem;
}

.inventory-chip.is-empty {
  color: var(--muted);
  border-color: var(--line);
}

.is-finale {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 109, 95, 0.08),
      rgba(255, 109, 95, 0.08) 1px,
      transparent 1px,
      transparent 6px
    ),
    radial-gradient(circle at 50% 30%, rgba(199, 255, 104, 0.18), transparent 24rem),
    #050504;
}

.is-blackout {
  background: #000;
}

.is-blackout::before {
  opacity: 0;
}

.is-blackout .app-shell {
  opacity: 0;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
  align-items: start;
}

.room-panel,
.notes-panel {
  padding: clamp(18px, 3vw, 32px);
}

.room-story {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.72;
}

.puzzle-box {
  min-height: 150px;
  margin-bottom: 22px;
  padding: 18px;
  border: 1px dashed #57523d;
  background:
    linear-gradient(90deg, rgba(199, 255, 104, 0.045), transparent 38%),
    #090907;
  color: #f0ecd9;
  line-height: 1.7;
  white-space: pre-wrap;
}

.artifact-letter {
  color: #f7f3dc;
  text-shadow: 0 0 5px rgba(199, 255, 104, 0.22);
}

.answer-form {
  display: grid;
  gap: 8px;
}

.answer-form label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  background: #090907;
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(199, 255, 104, 0.13);
}

.hint-text {
  flex: 1 1 240px;
  margin: 0;
  color: var(--warning);
  line-height: 1.55;
}

.status-message {
  min-height: 28px;
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.status-message.is-error {
  color: var(--danger);
}

.status-message.is-success {
  color: var(--accent);
}

.notes-header {
  margin-bottom: 14px;
}

.notes-toggle {
  display: none;
}

.notes-body {
  display: block;
}

.notes-footnote {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.finale-screen {
  min-height: min(680px, calc(100vh - 64px));
  display: grid;
  align-content: center;
  gap: 22px;
  border-color: rgba(199, 255, 104, 0.55);
  background:
    linear-gradient(180deg, rgba(199, 255, 104, 0.12), transparent 32%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 28px),
    #090907;
}

.finale-screen h2 {
  max-width: 12ch;
  font-size: clamp(2.4rem, 8vw, 6rem);
}

.finale-fragments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 58px;
}

.finale-fragments span {
  display: inline-grid;
  min-width: 54px;
  min-height: 54px;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: rgba(199, 255, 104, 0.08);
  font-weight: 800;
  animation: fragment-arrive 360ms steps(3, end);
}

.finale-line {
  min-height: 48px;
  margin: 0;
  color: var(--accent);
}

.stats-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  gap: 12px;
  margin: 26px 0 0;
}

.stats-list div {
  padding: 14px;
  border: 1px solid var(--line);
  background: #090907;
}

.stats-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.stats-list dd {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 800;
}

.recovered-site {
  padding: 0;
  overflow: auto;
  color: #000;
  background: #c0c0c0;
  border: 0;
  box-shadow: none;
  font-family: "Times New Roman", Times, serif;
  animation: slow-recover 4.8s ease-out both;
}

.recovered-site::after {
  display: none;
}

.old-site-frame {
  width: min(100%, 860px);
  margin: 0 auto;
  border: 2px ridge #fff;
  background: #c0c0c0;
}

.old-site-header {
  padding: 18px 12px;
  border-bottom: 2px ridge #808080;
  text-align: center;
  background: #d6d6d6;
}

.old-site-header h2 {
  max-width: none;
  color: #000080;
  font-size: clamp(1.7rem, 5vw, 3rem);
  font-family: "Times New Roman", Times, serif;
  text-transform: uppercase;
}

.old-site-subtitle {
  margin: 8px 0 0;
  color: #000;
  font-size: 1rem;
}

.old-site-sidebar,
.old-site-content {
  vertical-align: top;
  padding: 12px;
}

.old-site-sidebar {
  width: 178px;
  border-right: 2px ridge #808080;
  text-align: center;
  background: #b8b8b8;
}

.old-site-content {
  background: #c0c0c0;
  font-size: 1rem;
  line-height: 1.35;
}

.old-site-content h3 {
  margin-top: 18px;
  color: #000080;
  font-family: "Times New Roman", Times, serif;
}

.old-site-content a {
  color: #0000ee;
  text-decoration: underline;
}

.old-site-content a:visited {
  color: #551a8b;
}

.gif-placeholder {
  margin: 0 auto 14px;
  padding: 8px 4px;
  border: 2px outset #fff;
  color: #ffff00;
  background:
    repeating-linear-gradient(
      -45deg,
      #000 0,
      #000 8px,
      #cc0000 8px,
      #cc0000 16px
    );
  font: bold 0.78rem Arial, sans-serif;
}

.counter-label,
.tiny-note {
  margin: 10px 0 4px;
  font-size: 0.82rem;
}

.visitor-counter {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 6px;
  border: 2px inset #fff;
  color: #00ff00;
  background: #000;
  font: bold 1rem "Courier New", monospace;
}

.blinkless-banner {
  display: inline-block;
  margin: 0 0 10px;
  padding: 2px 6px;
  color: #000;
  background: #ffffcc;
  border: 1px solid #808080;
  font-weight: bold;
}

.gif-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.gif-row span {
  display: inline-block;
  min-width: 58px;
  padding: 3px 5px;
  border: 2px outset #fff;
  color: #000080;
  background: #e6e6e6;
  font: bold 0.75rem Arial, sans-serif;
  text-align: center;
}

.old-link-list {
  columns: 2;
  padding-left: 22px;
}

.old-link-list li {
  margin-bottom: 5px;
}

.archive-message {
  min-height: 24px;
  margin: 16px 0;
  padding: 6px;
  border: 1px inset #fff;
  color: #000;
  background: #dcdcdc;
  font-family: "Courier New", monospace;
}

.old-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 14px 0;
  font-size: 0.9rem;
}

.old-stats div {
  padding: 4px 8px;
  border: 1px solid #808080;
  background: #d0d0d0;
}

.old-stats dt,
.old-stats dd {
  display: inline;
  margin: 0;
}

.old-stats dt::after {
  content: ": ";
}

.old-button {
  border: 2px outset #fff;
  border-radius: 0;
  padding: 3px 9px;
  color: #000;
  background: #d6d6d6;
  font: 0.86rem Arial, sans-serif;
}

.old-button:active {
  border-style: inset;
}

.stay-button {
  margin-top: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

@keyframes glitch-shift {
  0% {
    transform: translate(0, 0);
    filter: none;
  }

  40% {
    transform: translate(2px, -1px);
    filter: contrast(1.4);
  }

  70% {
    transform: translate(-2px, 1px);
  }

  100% {
    transform: translate(0, 0);
    filter: none;
  }
}

@keyframes fragment-arrive {
  0% {
    opacity: 0;
    transform: translateY(10px) skewX(12deg);
  }

  55% {
    opacity: 1;
    transform: translateY(-3px) skewX(-8deg);
  }

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

@keyframes slow-recover {
  0% {
    opacity: 0;
    filter: brightness(0.2) contrast(1.8);
    transform: translateY(8px);
  }

  45% {
    opacity: 0.2;
  }

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

@media (min-width: 768px) and (max-width: 1024px) {
  .app-shell {
    padding: 24px 16px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) minmax(230px, 300px);
    gap: 16px;
  }

  .intro-screen,
  .complete-screen,
  .finale-screen {
    padding: clamp(26px, 5vw, 52px);
  }
}

@media (max-width: 767px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app-shell {
    width: 100%;
    min-height: auto;
    padding: 8px;
    align-items: start;
  }

  .intro-screen,
  .complete-screen,
  .finale-screen,
  .room-panel,
    .notes-panel {
    padding: 10px;
  }

  .dead-link-strip {
    gap: 5px 10px;
    margin: -14px -14px 16px;
    padding: 5px 8px;
    font-size: 0.6rem;
  }

  .beta-badge {
    top: 8px;
    right: 9px;
    padding: 1px 4px;
    font-size: 0.58rem;
  }

  .eyebrow {
    margin-bottom: 7px;
    font-size: 0.62rem;
  }

  h1 {
    font-size: clamp(1.85rem, 11vw, 3rem);
  }

  h2 {
    max-width: none;
    font-size: clamp(1.02rem, 5.8vw, 1.48rem);
  }

  h3 {
    font-size: 0.98rem;
  }

  .intro-text,
  .room-story,
  .hint-text,
    .status-message,
    .finale-line {
    font-size: clamp(0.78rem, 3.5vw, 0.9rem);
    line-height: 1.38;
  }

  .intro-actions,
  .room-actions {
    gap: 6px;
    margin-top: 10px;
  }

  .game-screen {
    gap: 6px;
  }

  .game-header,
  .answer-row,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-header,
  .progress-meta {
    display: grid;
  }

  .game-header {
    gap: 5px;
  }

  .progress-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 6px;
    row-gap: 3px;
    padding: 5px;
  }

  .progress-meta {
    grid-column: 1;
    display: flex;
    gap: 6px;
    margin-bottom: 0;
    font-size: 0.58rem;
  }

  .progress-track {
    grid-column: 1;
    height: 4px;
  }

  .inventory-strip {
    grid-column: 2;
    grid-row: 1 / span 2;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 0;
    overflow: hidden;
  }

  .inventory-chip {
    min-height: 17px;
    padding: 0 5px;
    font-size: 0.58rem;
    white-space: nowrap;
  }

  .room-panel,
  .notes-panel {
    padding: 8px;
  }

  .room-story {
    margin-bottom: 7px;
  }

  .puzzle-box {
    min-height: 72px;
    margin-bottom: 8px;
    padding: 8px;
    font-size: clamp(0.74rem, 3.45vw, 0.86rem);
    line-height: 1.34;
  }

  .answer-form {
    gap: 6px;
  }

  .answer-form label {
    font-size: 0.78rem;
  }

  input {
    min-height: 34px;
    padding: 0 9px;
    font-size: 0.84rem;
  }

  .button,
  .icon-button {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .hint-text {
    flex-basis: 100%;
  }

  .status-message {
    min-height: 22px;
    margin-top: 6px;
  }

  .notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 0;
  }

  .notes-header .eyebrow,
  .notes-header h3 {
    display: none;
  }

  .notes-toggle {
    display: flex;
    width: 100%;
    min-height: 30px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 0 9px;
    color: var(--text);
    background: #12120d;
    font-size: 0.78rem;
  }

  .notes-toggle::after {
    content: "+";
    color: var(--accent);
  }

  .notes-panel.is-open .notes-toggle::after {
    content: "-";
  }

  .notes-body {
    display: none;
    margin-top: 7px;
  }

  .notes-panel.is-open .notes-body {
    display: block;
  }

  textarea {
    height: 90px;
    max-height: 90px;
    min-height: 90px;
    padding: 9px;
    font-size: 0.78rem;
    line-height: 1.34;
  }

  .notes-footnote {
    margin-top: 5px;
    font-size: 0.62rem;
  }

  .finale-screen {
    min-height: calc(100vh - 24px);
    gap: 14px;
  }

  .finale-screen h2 {
    max-width: none;
    font-size: clamp(1.7rem, 10vw, 3rem);
  }

  .finale-fragments {
    gap: 6px;
    min-height: 38px;
  }

  .finale-fragments span {
    min-width: 38px;
    min-height: 38px;
    font-size: 0.82rem;
  }

  .old-site-frame,
  .old-site-frame tbody,
  .old-site-frame tr,
  .old-site-frame td {
    display: block;
    width: 100%;
  }

  .old-site-sidebar {
    border-right: 0;
    border-bottom: 2px ridge #808080;
  }

  .old-site-header {
    padding: 12px 8px;
  }

  .old-site-header h2 {
    font-size: clamp(1.25rem, 7vw, 2rem);
  }

  .old-site-subtitle,
  .old-site-content {
    font-size: clamp(0.9rem, 3.6vw, 1rem);
  }

  .old-site-sidebar,
  .old-site-content {
    padding: 9px;
  }

  .old-link-list {
    columns: 1;
    padding-left: 18px;
  }

  .gif-placeholder {
    max-width: 150px;
    margin-bottom: 9px;
    padding: 6px 4px;
    font-size: 0.7rem;
  }

  .gif-row {
    gap: 4px;
    margin: 10px 0;
  }

  .gif-row span {
    min-width: 50px;
    padding: 2px 4px;
    font-size: 0.68rem;
  }

  .visitor-counter {
    font-size: 0.88rem;
  }

  .tiny-note,
  .counter-label,
  .old-stats,
  .old-button,
  .archive-message {
    font-size: 0.78rem;
  }

  .old-stats {
    gap: 6px;
  }
}

@media (max-width: 479px) {
  .app-shell {
    padding: 6px;
  }

  .intro-screen,
  .complete-screen,
  .finale-screen,
  .room-panel,
    .notes-panel {
    padding: 7px;
  }

  .dead-link-strip {
    margin: -7px -7px 8px;
    padding: 4px 6px;
    font-size: 0.56rem;
  }

  h1 {
    font-size: clamp(1.65rem, 10vw, 2.6rem);
  }

  h2 {
    font-size: clamp(0.98rem, 5.8vw, 1.34rem);
  }

  .intro-text,
  .room-story,
  .hint-text,
    .status-message,
    .finale-line {
    font-size: clamp(0.74rem, 3.6vw, 0.84rem);
  }

  .game-screen {
    gap: 5px;
  }

  .progress-panel {
    padding: 4px;
  }

  .progress-track {
    height: 6px;
  }

  .room-panel,
  .notes-panel {
    padding: 7px;
  }

  .puzzle-box {
    min-height: 64px;
    margin-bottom: 7px;
    padding: 7px;
    font-size: clamp(0.72rem, 3.55vw, 0.8rem);
  }

  input {
    min-height: 32px;
  }

  .button,
  .icon-button {
    min-height: 32px;
    font-size: 0.74rem;
  }

  textarea {
    height: 90px;
    max-height: 90px;
    min-height: 90px;
    font-size: 0.74rem;
  }

  .finale-fragments span {
    min-width: 32px;
    min-height: 32px;
  }

  .old-site-header,
  .old-site-sidebar,
  .old-site-content {
    padding: 7px;
  }

  .old-link-list li {
    margin-bottom: 3px;
  }
}
