:root {
  --green: #00e05a;
  --green-bright: #c8ffdb;
  --green-dim: #0a8a3e;
  --green-dark: #06401d;
  --red: #ff3b4e;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: #000;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #000;
  color: var(--green);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

[hidden] {
  display: none !important;
}

#rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  opacity: 0.35;
}

main {
  position: relative;
  z-index: 1;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 40px;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  animation: appear 0.6s ease-out;
}

.screen.top {
  justify-content: flex-start;
}

@keyframes appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* No frame: a soft black halo keeps text readable over the rain. */
.panel {
  background: rgba(0, 0, 0, 0.85);
  box-shadow: 0 0 28px 28px rgba(0, 0, 0, 0.85);
}

.panel.center {
  text-align: center;
}

p {
  margin: 0 0 10px;
}

.dim {
  color: var(--green-dim);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-weight: 400;
  text-transform: uppercase;
}

.title {
  font-size: clamp(18px, 5.5vw, 24px);
  line-height: 1.6;
  letter-spacing: 0.22em;
}

.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 36px;
  padding: 12px;
  border: 1px solid var(--green);
  border-radius: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

.btn:active {
  background: var(--green);
  color: #000;
}

.btn:disabled {
  opacity: 0.5;
}

.question {
  display: block;
  min-height: 3em;
  margin: 8px 0 20px;
  font-size: 18px;
  color: var(--green-bright);
}

.prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--green-dim);
}

.prompt:focus-within {
  border-color: var(--green);
}

.prompt input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--green-bright);
  caret-color: var(--green);
  font: inherit;
  /* 16px+ keeps iOS Safari from zooming the page on focus */
  font-size: 18px;
  -webkit-appearance: none;
  appearance: none;
}

.prompt input::placeholder {
  color: var(--green-dim);
  opacity: 1;
}

.custom-form {
  margin-top: 20px;
}

.key-form {
  margin-top: 28px;
  text-align: left;
}

.send {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 44px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

.send:active {
  color: var(--green-bright);
}

.plane {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hint {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--green-dim);
}

.msg {
  min-height: 1.5em;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--green-dim);
}

.msg.error {
  color: var(--red);
}

.shake {
  animation: shake 0.4s;
}

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

.city {
  margin: 2px 0 4px;
  font-size: clamp(36px, 13vw, 56px);
  line-height: 1.15;
  letter-spacing: 0.18em;
  color: var(--green-bright);
}

.coords {
  white-space: pre-wrap;
  text-transform: none;
}

.map {
  flex: none;
  display: block;
  width: 36%;
  aspect-ratio: 48 / 30;
  background: #000;
}

.term {
  margin-top: 20px;
  border: 1px solid var(--green-dark);
  background: #010402;
  font-size: 12px;
  line-height: 1.5;
}

.term-bar {
  position: relative;
  padding: 4px 10px;
  border-bottom: 1px solid var(--green-dark);
  color: var(--green-dim);
  font-size: 10px;
  text-align: center;
}

.term-dots {
  position: absolute;
  left: 10px;
  top: 50%;
  display: flex;
  gap: 5px;
  transform: translateY(-50%);
}

.term-dots i {
  width: 7px;
  height: 7px;
  border: 1px solid var(--green-dim);
  border-radius: 50%;
}

.term-body {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
}

/* faint scanlines over the whole screen area */
.term-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.28) 2px 3px);
  pointer-events: none;
}

.typed {
  flex: 1;
  min-width: 0;
  min-height: 10.5em;
  padding-right: 10px;
  border-right: 1px solid var(--green-dark);
}

.typed-line {
  min-height: 1.5em;
  margin: 0;
  font-size: 12px;
  color: var(--green-bright);
  overflow-wrap: anywhere;
}

.typed-line em {
  font-style: italic;
  color: var(--green);
}

.prompt-sign {
  color: var(--green);
}

.term-status {
  display: flex;
  justify-content: space-between;
  padding: 1px 8px;
  background: var(--green-dim);
  color: #000;
  font-size: 10px;
}

.typed-line.current::after {
  content: "█";
  margin-left: 1px;
  color: var(--green);
  animation: blink 1s steps(1) infinite;
}

.bull {
  width: 24px;
  height: 18px;
  margin-left: 4px;
  vertical-align: middle;
  fill: none;
  stroke: var(--red);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes blink {
  50% { opacity: 0; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 16px;
}

.act {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 84px;
  padding: 12px 2px 8px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--green-dim);
  font: inherit;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  transition: color 0.15s, border-color 0.15s;
}

.act svg {
  flex: none;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.act span {
  max-width: 100%;
  overflow-wrap: break-word;
}

.act[aria-pressed="true"] {
  border-color: var(--green);
  color: var(--green-bright);
}

.act[data-id="red_pill"][aria-pressed="true"] {
  border-color: var(--red);
  color: var(--red);
}

.act:active {
  opacity: 0.6;
}

:focus-visible {
  outline: 1px solid var(--green-bright);
  outline-offset: 2px;
}

/* 320px phones: narrower gutters so the longest label words fit a tile */
@media (max-width: 359px) {
  .screen {
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
  }

  .grid {
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .shake,
  .typed-line.current::after {
    animation: none;
  }
}
