:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #1e1e1e;
  color: #f3f1ea;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
}

a {
  color: inherit;
}

.site-shell {
  position: relative;
  min-height: 100vh;
  padding: 0;
  isolation: isolate;
  background: #1e1e1e;
}

.terminal-surface {
  height: 100vh;
  display: flex;
  align-items: stretch;
  cursor: text;
}

:root {
  --terminal-mono:
    ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", "Fira Code",
    Menlo, Consolas, "Liberation Mono", monospace;
}

.terminal-window {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 20px;
  border: 0;
  background: #1e1e1e;
  box-shadow: none;
  color: #ffffff;
  font-family: var(--terminal-mono);
  font-size: 1rem;
  line-height: 1.45;
  overflow: auto;
}

.terminal-entry {
  margin: 0 0 1rem;
}

.terminal-prompt,
.terminal-input-label {
  color: #f0a31a;
}

/* Preserve indentation when echoing multiline REPL input (`...` lines). */
.terminal-prompt {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.terminal-output {
  display: grid;
  gap: 0.65rem;
}

.terminal-text,
.terminal-file pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.terminal-error {
  color: #ffb0a3;
}

.terminal-panel,
.terminal-file,
.terminal-game-placeholder,
.terminal-game,
.nano-panel {
  max-height: min(34rem, 78vh);
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 0.85rem;
  border: 1px solid rgba(180, 210, 185, 0.18);
  background: rgba(255, 255, 255, 0.035);
}

.terminal-panel h2,
.terminal-game-placeholder h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  color: #e9d18e;
}

.terminal-game {
  width: min(100%, 48rem);
  max-height: none;
  overflow: hidden;
  padding: 0.65rem;
  background:
    linear-gradient(180deg, rgba(84, 168, 242, 0.08), transparent 26%),
    rgba(255, 255, 255, 0.035);
}

.terminal-game-canvas {
  width: 100%;
  height: clamp(29rem, 72vh, 42rem);
  display: block;
  border: 1px solid rgba(180, 210, 185, 0.14);
  background: #08100d;
  outline: none;
  touch-action: none;
  cursor: crosshair;
}

.terminal-game-canvas:focus-visible {
  border-color: rgba(156, 199, 255, 0.82);
  outline: 2px solid rgba(156, 199, 255, 0.28);
  outline-offset: 2px;
}

.terminal-game-header {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  color: #e9d18e;
}

.terminal-game-fallback {
  min-height: 16rem;
  display: grid;
  place-items: center;
  color: rgba(199, 223, 201, 0.72);
}

.textropolis-game {
  width: min(100%, 58rem);
  min-height: clamp(32rem, 74vh, 46rem);
  gap: 0.85rem;
  overflow: hidden;
}

.textropolis-game:focus-visible {
  outline: 2px solid rgba(156, 199, 255, 0.28);
  outline-offset: 2px;
}

.textropolis-loading,
.textropolis-error {
  min-height: 24rem;
  display: grid;
  place-items: center;
  color: rgba(243, 241, 234, 0.82);
}

.textropolis-error {
  color: #ffb8a8;
}

.textropolis-city-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 0.45rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.2rem;
}

.textropolis-city-card {
  --progress: 0%;
  position: relative;
  min-height: 2.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 0.75rem;
  align-items: center;
  padding: 0.4rem 0.65rem;
  border: 1px solid rgba(180, 210, 185, 0.18);
  border-radius: 0;
  background:
    linear-gradient(
      90deg,
      rgba(233, 209, 142, 0.2) 0 var(--progress),
      rgba(0, 0, 0, 0.22) var(--progress) 100%
    );
  color: #f3f1ea;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.textropolis-city-card:hover,
.textropolis-city-card:focus-visible {
  border-color: rgba(156, 199, 255, 0.82);
  outline: none;
}

.textropolis-city-card.locked {
  color: rgba(199, 223, 201, 0.44);
  cursor: default;
}

.textropolis-city-card small {
  grid-column: 1 / -1;
  color: rgba(199, 223, 201, 0.58);
}

.textropolis-word-ticker {
  min-height: 2rem;
  position: relative;
  overflow: hidden;
  border-block: 1px solid rgba(180, 210, 185, 0.14);
  background: rgba(0, 0, 0, 0.18);
}

.textropolis-ticker-track {
  display: inline-block;
  min-width: max-content;
  box-sizing: content-box;
  padding: 0.32rem 0 0.32rem 100%;
  color: rgba(243, 241, 234, 0.84);
  white-space: nowrap;
  animation: textropolis-ticker var(--ticker-duration, 58s) linear infinite;
  will-change: transform;
}

.textropolis-ticker-word {
  margin: 0 0.7rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.textropolis-ticker-word:not(:last-child)::after {
  content: " //";
  color: rgba(199, 223, 201, 0.42);
}

.textropolis-ticker-word:hover,
.textropolis-ticker-word:focus-visible {
  color: #ffffff;
  outline: none;
}

.textropolis-ticker-track:empty {
  animation: none;
}

.textropolis-definition-sky {
  --lane-gap: 3.35rem;
  min-height: 20.8rem;
  position: relative;
  overflow: hidden;
}

.textropolis-definition-sky .textropolis-banner {
  position: absolute;
  inset: calc(var(--lane) * var(--lane-gap)) 0 auto 0;
}

.textropolis-banner-flight {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  box-sizing: content-box;
  padding-left: 100%;
  animation: textropolis-fly var(--duration, 12000ms) linear var(--delay, 0ms) both;
  will-change: transform;
}

.textropolis-plane {
  width: 2.25rem;
  height: 1.05rem;
  position: relative;
  display: inline-block;
  border-radius: 999px 50% 50% 999px;
  background: #e9d18e;
  box-shadow: inset -0.58rem 0 0 rgba(0, 0, 0, 0.22);
}

.textropolis-plane::before,
.textropolis-plane::after {
  content: "";
  position: absolute;
  left: 0.62rem;
  border-left: 0.72rem solid transparent;
  border-right: 0.24rem solid transparent;
}

.textropolis-plane::before {
  top: -0.56rem;
  border-bottom: 0.64rem solid #c7dfc9;
}

.textropolis-plane::after {
  bottom: -0.5rem;
  border-top: 0.58rem solid #c7dfc9;
}

.textropolis-rope {
  width: 1.4rem;
  height: 1px;
  display: inline-block;
  transform: translateY(-0.23rem) rotate(5deg);
  background: rgba(199, 223, 201, 0.55);
}

.textropolis-rope.lower {
  margin-left: -1.75rem;
  transform: translateY(0.28rem) rotate(-5deg);
}

.textropolis-ad {
  display: inline-block;
  width: max-content;
  max-width: min(72vw, 54rem);
  min-width: 18rem;
  padding: 0.22rem 0.65rem;
  border: 1px solid rgba(233, 209, 142, 0.56);
  background: rgba(233, 209, 142, 0.12);
  color: rgba(243, 241, 234, 0.92);
  font-size: 0.88rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.textropolis-current-word {
  min-height: 4.25rem;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: clamp(2.25rem, 7vw, 5rem);
  line-height: 1;
  text-transform: uppercase;
}

.textropolis-feedback {
  min-height: 1.4rem;
  color: rgba(243, 241, 234, 0.72);
  text-align: center;
}

.textropolis-keyboard {
  margin-top: auto;
  border: 1px solid rgba(180, 210, 185, 0.2);
  background: rgba(0, 0, 0, 0.28);
}

.textropolis-letters {
  display: grid;
  grid-template-columns: repeat(var(--letter-cols, 4), minmax(0, 1fr));
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.textropolis-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(180, 210, 185, 0.2);
}

.textropolis-letters button,
.textropolis-controls button {
  min-height: 3.2rem;
  border: 0;
  border-right: 1px solid rgba(180, 210, 185, 0.14);
  border-bottom: 1px solid rgba(180, 210, 185, 0.14);
  border-radius: 0;
  background: transparent;
  color: #f3f1ea;
  font: inherit;
  cursor: pointer;
  user-select: none;
}

.textropolis-letters button {
  touch-action: none;
  -webkit-touch-callout: none;
}

.textropolis-controls button {
  touch-action: manipulation;
}

.textropolis-letters button:focus-visible,
.textropolis-controls button:focus-visible {
  background: rgba(156, 199, 255, 0.12);
  outline: none;
}

.textropolis-letters button.selected {
  color: rgba(199, 223, 201, 0.38);
  cursor: default;
}

@media (hover: hover) {
  .textropolis-letters button:hover,
  .textropolis-controls button:hover {
    background: rgba(156, 199, 255, 0.12);
  }
}

@media (hover: none) {
  .textropolis-letters button:focus,
  .textropolis-controls button:focus {
    background: transparent;
    outline: none;
  }
}

@keyframes textropolis-fly {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

@keyframes textropolis-ticker {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

.terminal-file-title,
.nano-panel-header {
  margin-bottom: 0.55rem;
  color: #e9d18e;
}

.terminal-input-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin-top: 0;
}

.terminal-input {
  min-width: 0;
  min-height: 0;
  line-height: 1.45rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  font-family: var(--terminal-mono);
  font-size: inherit;
  font-weight: inherit;
  -webkit-appearance: none;
  appearance: none;
  cursor: text;
  /* Multiline command editor: grows by rows, no manual resize or scrollbar. */
  resize: none;
  overflow: hidden;
  white-space: pre;
}

.terminal-input:focus {
  border-color: rgba(156, 199, 255, 0.82);
  outline: none;
}

.terminal-submit,
.nano-actions button {
  min-height: 2.35rem;
  padding: 0 0.85rem;
  border: 1px solid rgba(180, 210, 185, 0.24);
  border-radius: 0;
  background: rgba(172, 215, 178, 0.13);
  color: #f3f1ea;
  font: inherit;
  cursor: pointer;
}

.terminal-submit {
  display: none;
}

.terminal-submit:hover,
.terminal-submit:focus-visible,
.nano-actions button:hover,
.nano-actions button:focus-visible {
  border-color: rgba(156, 199, 255, 0.82);
  outline: none;
}

.nano-panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

.nano-panel-state {
  color: rgba(199, 223, 201, 0.68);
}

.nano-editor {
  width: 100%;
  min-height: 16rem;
  max-height: 52vh;
  resize: vertical;
  padding: 0.75rem;
  border: 1px solid rgba(180, 210, 185, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.28);
  color: #f3f1ea;
  font: inherit;
}

.nano-editor:focus-visible {
  border-color: rgba(156, 199, 255, 0.82);
  outline: 2px solid rgba(156, 199, 255, 0.28);
  outline-offset: 2px;
}

.nano-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.7rem;
}

.nano-editor-hidden,
.nano-actions-hidden {
  display: none;
}

.profile-overlay {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 340px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 2.6rem 1.7rem 2.45rem;
  border: 0;
  border-top: 0.55rem double #7f3dff;
  border-bottom: 0.55rem double #7f3dff;
  background: transparent;
  box-shadow: none;
  color: #a9a9a9;
  font-family: Georgia, "Times New Roman", Times, serif;
  text-align: center;
  transform: translate(-50%, -50%);
  transition:
    opacity 160ms ease,
    visibility 160ms ease;
}

.profile-overlay-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.profile-overlay h1 {
  margin: 0;
  color: inherit;
  font-size: 2.15rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0;
}

.profile-role {
  margin: 1.25rem 0 0;
  color: inherit;
  font-size: 2rem;
  line-height: 1.2;
}

.contact-links {
  display: flex;
  justify-content: center;
  gap: 1.45rem;
  margin-top: 2rem;
}

.contact-links a {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  color: inherit;
  line-height: 1;
  text-decoration: none;
}

.contact-icon {
  width: 100%;
  height: 100%;
  display: block;
}

.contact-icon-expanded {
  width: 118%;
  height: 118%;
}

.contact-links a:hover,
.contact-links a:focus-visible {
  color: #ffffff;
  outline: 0;
}

.contact-links a:focus-visible .contact-icon {
  filter: drop-shadow(0 0 0.35rem rgba(255, 255, 255, 0.8));
}

@media (max-width: 640px) {
  .site-shell {
    padding: 0;
  }

  .profile-overlay {
    max-height: calc(100vh - 1.5rem);
    width: min(340px, calc(100vw - 1.5rem));
    padding: 2rem 1rem;
  }

  .profile-overlay h1 {
    font-size: 2rem;
  }

  .profile-role {
    font-size: 1.65rem;
  }

  .contact-links {
    gap: 1.1rem;
    margin-top: 1.6rem;
  }

  .contact-links a {
    width: 2.45rem;
    height: 2.45rem;
  }

  .terminal-input-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .nano-panel {
    max-height: 70vh;
  }

  .terminal-game {
    padding: 0.35rem;
  }

  .terminal-game-canvas {
    height: clamp(28rem, 72vh, 36rem);
  }

  .textropolis-game {
    height: min(40rem, calc(100svh - 0.8rem));
    min-height: min(30rem, calc(100svh - 0.8rem));
    gap: clamp(0.32rem, 1.2svh, 0.6rem);
  }

  .textropolis-word-ticker {
    min-height: 1.55rem;
  }

  .textropolis-ticker-track {
    padding-block: 0.2rem;
  }

  .terminal-game-header {
    font-size: 0.86rem;
    line-height: 1.15;
  }

  .textropolis-banner-flight {
    gap: 0.25rem;
  }

  .textropolis-ad {
    min-width: 14rem;
    max-width: 76vw;
    padding: 0.16rem 0.45rem;
    font-size: 0.62rem;
    line-height: 1.15;
  }

  .textropolis-definition-sky {
    --lane-gap: 2.35rem;
    flex: 0 1 14rem;
    min-height: 14rem;
  }

  .textropolis-current-word {
    min-height: clamp(2.2rem, 8svh, 3.2rem);
    font-size: clamp(1.8rem, 10vw, 3.2rem);
  }

  .textropolis-feedback {
    min-height: 1rem;
    font-size: 0.82rem;
    line-height: 1.15;
  }

  .textropolis-city-list {
    min-height: 0;
    gap: 0.5rem;
  }

  .textropolis-city-card {
    min-height: 3.05rem;
  }

  .textropolis-letters button,
  .textropolis-controls button {
    min-height: clamp(2.4rem, 7.5svh, 3rem);
  }

  .textropolis-city-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .nano-editor {
    min-height: 12rem;
    max-height: 44vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
