:root {
  --bg: #000000;
  --fg: #c8c4cc;
  --fg-bright: #f0eef2;
  --accent: #a3162e;
  --accent-dim: #5c0f1c;
  --dim: #4a4650;
  --mono: "Courier New", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  overflow-x: hidden;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.22;
}

/* ---------- Gate / archive board ---------- */
.gate-screen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: #000;
  color: var(--fg);
  overflow-y: auto;
  padding: 2rem 1.2rem 4rem;
  transition: opacity 0.5s ease;
}

.gate-screen--exit {
  opacity: 0;
  pointer-events: none;
}

.gate-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.ascii-sigil {
  color: var(--accent);
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.15;
  margin: 0 0 1.5rem;
  opacity: 0.85;
}

.redacted {
  background: #1a1a1a;
  color: transparent;
  padding: 0.1em 0.35em;
  cursor: text;
  user-select: all;
  border-radius: 1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.redacted::selection {
  color: var(--fg-bright);
  background: var(--accent);
}

.redacted::-moz-selection {
  color: var(--fg-bright);
  background: var(--accent);
}

.gate-banner {
  border: 1px solid var(--accent-dim);
  padding: 0.8rem 1rem;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  margin-bottom: 2rem;
}

.board-post {
  border-top: 1px solid #1c1a1e;
  padding: 1.1rem 0;
  transition: transform 0.2s;
}

.board-post:first-of-type {
  border-top: none;
}

.board-post:nth-of-type(odd) {
  transform: rotate(-0.5deg);
}

.board-post:nth-of-type(even) {
  transform: rotate(0.4deg);
  margin-left: 1.4rem;
}

.board-post:nth-of-type(3n) {
  font-size: 1.05em;
  margin-left: 2.4rem;
}

.board-post:nth-of-type(4n) {
  border-left: 2px solid var(--accent-dim);
  padding-left: 0.9rem;
  margin-left: 0;
}

.board-post:hover {
  transform: rotate(0deg);
}

.board-post--mirror {
  transform: scaleX(-1);
  transition: transform 0.35s;
}

.board-post--mirror:hover {
  transform: scaleX(1);
}

.board-post--flip {
  transform: rotate(180deg);
  transition: transform 0.35s;
  margin: 2.2rem 0;
}

.board-post--flip:hover {
  transform: rotate(0deg);
}

.board-post--sideways {
  transform: rotate(-90deg);
  transition: transform 0.35s;
  margin: 3rem 0 3rem 1rem;
}

.board-post--sideways:hover {
  transform: rotate(0deg);
}

.board-meta {
  color: var(--dim);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.board-text {
  color: var(--fg-bright);
  font-size: 1.02rem;
  line-height: 1.7;
  margin: 0;
  white-space: pre-wrap;
}

.board-text.lang-en { color: var(--fg); }

.gate-access {
  margin-top: 2.5rem;
  border-top: 1px solid var(--accent-dim);
  padding-top: 1.5rem;
}

.gate-access p {
  color: var(--fg);
  font-size: 0.9rem;
  line-height: 1.6;
}

.gate-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

#gate-input {
  background: #000;
  border: 1px solid var(--accent);
  color: var(--fg-bright);
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.15em;
  padding: 0.55rem 0.8rem;
  outline: none;
  width: 200px;
}

#gate-input.shake {
  animation: shake 0.4s;
  border-color: #ff2b4d;
}

#gate-submit {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--fg-bright);
  padding: 0.55rem 1.3rem;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  cursor: pointer;
}

#gate-submit:hover { background: var(--accent); }

.gate-feedback {
  color: #ff2b4d;
  min-height: 1.4em;
  margin-top: 0.7rem;
  font-size: 0.85rem;
}

/* ---------- Main archive ---------- */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
  position: relative;
}

.title {
  text-align: center;
  font-size: clamp(2.2rem, 7vw, 4rem);
  letter-spacing: 0.35em;
  margin: 0;
  color: var(--fg-bright);
  font-weight: normal;
}

.subtitle {
  text-align: center;
  color: var(--dim);
  margin-top: 0.6rem;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.lore {
  margin: 2.5rem 0;
  line-height: 1.8;
  color: var(--fg);
  border-left: 2px solid var(--accent-dim);
  padding-left: 1.2rem;
}

.lore strong { color: var(--fg-bright); }

.lore--second {
  border-left-color: var(--accent);
  color: #9a94a8;
  font-size: 0.95rem;
}

.isopsephy-wrap {
  margin-top: 1.5rem;
  border-top: 1px solid var(--dim);
  padding-top: 1rem;
}

.isopsephy {
  border-collapse: collapse;
  margin: 1rem auto;
  font-size: 0.85rem;
}

.isopsephy td {
  border: 1px solid var(--dim);
  padding: 0.35rem 0.6rem;
  text-align: center;
  color: var(--fg);
}

.lock-feedback {
  min-height: 1.4em;
  margin-top: 1rem;
  color: #ff2b4d;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.grid-wrap {
  margin: 2.5rem 0;
  border: 1px solid #1c1a1e;
  background: #050505;
  padding: 1rem;
  overflow-x: auto;
}

.cryptogram {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.3;
  letter-spacing: 0.12em;
  color: #6a6670;
  white-space: pre;
  user-select: text;
}

.reference {
  margin: 2rem 0;
  border: 1px solid #1c1a1e;
  padding: 0.8rem 1rem;
  background: #050505;
}

.reference summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: bold;
}

.polybius-wrap { margin-top: 1rem; }

.polybius {
  border-collapse: collapse;
  margin: 1rem auto;
}

.polybius th, .polybius td {
  border: 1px solid var(--dim);
  padding: 0.4rem 0.7rem;
  text-align: center;
  color: var(--fg);
}

.polybius th { color: var(--accent); }

.hint-text {
  color: var(--dim);
  font-size: 0.85rem;
}

.hint-text--center {
  text-align: center;
  margin-top: -1.5rem;
  margin-bottom: 2rem;
}

.answer-section {
  margin: 3rem 0 1rem;
  text-align: center;
}

.answer-section label {
  display: block;
  margin-bottom: 0.8rem;
  color: var(--fg);
  letter-spacing: 0.05em;
}

.answer-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

#answer-input {
  background: #050505;
  border: 1px solid var(--accent);
  color: var(--fg-bright);
  padding: 0.7rem 1rem;
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  width: 260px;
  outline: none;
}

#answer-input:focus {
  border-color: var(--fg-bright);
}

#answer-input.shake {
  animation: shake 0.4s;
  border-color: #ff2b4d;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

#submit-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--fg-bright);
  padding: 0.7rem 1.6rem;
  font-family: var(--mono);
  font-weight: bold;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: background 0.2s;
}

#submit-btn:hover { background: var(--accent); }

.feedback {
  min-height: 1.4em;
  margin-top: 0.8rem;
  color: var(--accent);
  font-size: 0.9rem;
}

.sky-section {
  margin: 3rem 0;
  text-align: center;
  border-top: 1px solid var(--accent-dim);
  padding-top: 2rem;
}

.sky-label {
  color: var(--fg);
  font-size: 0.9rem;
  margin: 0 auto 1.2rem;
  max-width: 560px;
  letter-spacing: 0.03em;
}

#sky-canvas {
  width: 100%;
  max-width: 700px;
  height: 220px;
  border: 1px solid #1c1a1e;
  background: #050508;
  cursor: crosshair;
}

footer {
  text-align: center;
  color: var(--dim);
  margin-top: 4rem;
  font-size: 0.8rem;
}

/* ---------- Jumpscare ---------- */
body.global-shake {
  animation: jumpscare-shake 0.06s infinite;
}

.jumpscare-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

#jumpscare-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.jumpscare-text {
  position: relative;
  font-size: clamp(3rem, 20vw, 14rem);
  font-weight: bold;
  color: #ff1a3d;
  letter-spacing: 0.2em;
  text-shadow: 0 0 30px #ff1a3d, 0 0 90px #ff1a3d;
  animation: jumpscare-pulse 0.15s infinite alternate, jumpscare-shake 0.08s infinite;
}

@keyframes jumpscare-pulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.15); opacity: 0.85; }
}

@keyframes jumpscare-shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-10px, 6px); }
  50% { transform: translate(8px, -8px); }
  75% { transform: translate(-6px, -4px); }
  100% { transform: translate(10px, 4px); }
}

.success-panel {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.success-panel[hidden] {
  display: none;
}

/* Fake crash (hostile-interaction punishment) */
#fake-crash {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #050505;
  color: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  font-family: var(--mono);
  animation: crash-flicker 0.3s steps(2) infinite;
}

.fake-crash-inner {
  max-width: 420px;
}

.fake-crash-face {
  font-size: 2.4rem;
  letter-spacing: 0.1em;
  color: #666;
  margin-bottom: 1rem;
}

.fake-crash-title {
  font-size: 1.3rem;
  color: #ccc;
}

.fake-crash-sub {
  font-size: 0.85rem;
  color: #777;
  margin-top: 0.6rem;
}

@keyframes crash-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.92; }
}

.success-panel h2 {
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  color: #ff1a3d;
  font-weight: normal;
  letter-spacing: 0.1em;
}

.success-badge {
  color: var(--fg);
  margin-top: 1.5rem;
  font-size: 0.9rem;
  max-width: 420px;
}

.success-badge a {
  color: #ff1a3d;
}

.success-sub {
  color: var(--dim);
  margin-top: 2rem;
  letter-spacing: 0.2em;
}
