:root {
  --page-overlay: rgba(4, 8, 8, 0.6);
  --chrome: #111613;
  --chrome-line: #5e5546;
  --chrome-ink: #ece5d1;
  --screen: #0b1813;
  --screen-raised: #10231b;
  --screen-ink: #e4e0ce;
  --screen-muted: #91a398;
  --accent: #d69a52;
  --accent-2: #78a47d;
  --danger: #bf5949;
  --focus: #f2bc72;
  --shadow: rgba(0, 0, 0, 0.65);
  color-scheme: dark;
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

html[data-theme="light"] {
  --page-overlay: rgba(231, 233, 224, 0.28);
  --chrome: #d8d3c5;
  --chrome-line: #776f60;
  --chrome-ink: #232922;
  --screen: #eeeee7;
  --screen-raised: #e4e6dc;
  --screen-ink: #1b3026;
  --screen-muted: #53665b;
  --accent: #9f5b25;
  --accent-2: #3f7550;
  --danger: #a63e35;
  --focus: #b86b2d;
  --shadow: rgba(0, 0, 0, 0.32);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #070b0d;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 18px 22px 24px;
  background-color: #070b0d;
  background-image: linear-gradient(var(--page-overlay), var(--page-overlay)), url("assets/spookyhouse-manor.webp");
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  color: var(--chrome-ink);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
.screen:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.house-shell {
  width: min(100%, 1240px);
  min-height: calc(100vh - 42px);
  margin-inline: auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.game-masthead {
  min-height: 56px;
  padding: 9px 12px 9px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(236, 229, 209, 0.2);
  border-radius: 6px;
  background: rgba(10, 14, 12, 0.8);
  color: #ece5d1;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.masthead-brand {
  min-width: 0;
  display: grid;
  gap: 2px;
  color: inherit;
  text-decoration: none;
}

.masthead-brand span {
  color: rgba(236, 229, 209, 0.64);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.masthead-brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.32rem;
  letter-spacing: 0.04em;
}

.masthead-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.signal-status {
  margin-right: 5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(236, 229, 209, 0.68);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signal-status span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8fc98d;
  box-shadow: 0 0 9px rgba(143, 201, 141, 0.75);
}

.masthead-actions button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(236, 229, 209, 0.28);
  border-radius: 4px;
  background: rgba(236, 229, 209, 0.06);
  color: #ece5d1;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.masthead-actions button:hover {
  border-color: rgba(236, 229, 209, 0.58);
  background: rgba(236, 229, 209, 0.12);
}

.terminal {
  min-height: 0;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--chrome-line);
  border-radius: 8px;
  background: var(--chrome);
  box-shadow: 0 28px 78px var(--shadow), inset 0 0 0 3px color-mix(in srgb, var(--chrome-line) 28%, transparent);
}

.terminal:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 12px;
  border: 0;
  border-radius: 0;
}

.terminal-bar {
  height: 26px;
  padding: 0 7px 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: color-mix(in srgb, var(--chrome-ink) 62%, transparent);
  font-size: 0.58rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.terminal-rule {
  height: 1px;
  flex: 1;
  background: color-mix(in srgb, var(--chrome-line) 62%, transparent);
}

.screen {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "dialogue hud"
    "dialogue controls";
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent-2) 48%, var(--chrome-line));
  border-radius: 4px;
  background: var(--screen);
  color: var(--screen-ink);
  box-shadow: inset 0 0 46px color-mix(in srgb, var(--accent-2) 7%, transparent);
  font-size: 15px;
  line-height: 1.55;
}

.screen__dialogue {
  grid-area: dialogue;
  min-height: 0;
  padding: 28px 30px 34px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  scroll-behavior: smooth;
  background-image: repeating-linear-gradient(to bottom, transparent 0 28px, color-mix(in srgb, var(--screen-ink) 3%, transparent) 28px 29px);
  scrollbar-color: var(--screen-muted) transparent;
  scrollbar-width: thin;
}

.screen__dialogue:empty::before {
  content: "The house is listening.";
  margin: auto;
  color: color-mix(in srgb, var(--screen-muted) 62%, transparent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-style: italic;
}

.screen__hud {
  grid-area: hud;
  min-height: 0;
  padding: 25px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  border-left: 1px solid color-mix(in srgb, var(--screen-ink) 14%, transparent);
  background: var(--screen-raised);
}

.line--location {
  min-height: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--screen-ink) 15%, transparent);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.line--location:empty {
  display: none;
}

.hud__menu {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
}

.line--menu-title {
  color: var(--screen-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.12;
}

.hud__details {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--screen-muted);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}

.hud__options {
  display: grid;
  gap: 6px;
}

.menu-option {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--screen-ink) 18%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--screen) 70%, transparent);
  color: var(--screen-ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 130ms ease, background 130ms ease, transform 130ms ease;
}

.menu-option:hover,
.menu-option:focus-visible {
  transform: translateX(3px);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--screen));
}

.menu-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.line--prompt {
  margin-top: auto;
  padding-top: 10px;
  color: var(--screen-muted);
  font-size: 0.72rem;
  font-style: italic;
}

.line--log {
  max-width: 68ch;
  color: var(--screen-muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.65;
}

.line--log:last-child {
  color: var(--screen-ink);
}

.line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.screen__controls {
  grid-area: controls;
  padding: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid color-mix(in srgb, var(--screen-ink) 14%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--screen-ink) 14%, transparent);
  background: var(--screen-raised);
}

.control-button,
.control-select select,
.menu-submit {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--screen-ink) 23%, transparent);
  border-radius: 4px;
  background: var(--screen);
  color: var(--screen-ink);
  font-size: 0.67rem;
  font-weight: 700;
}

.control-button,
.menu-submit {
  cursor: pointer;
}

.control-button:hover,
.control-button:focus-visible,
.menu-submit:hover,
.menu-submit:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--screen));
}

.control-select {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--screen-muted);
  font-size: 0.64rem;
  font-weight: 750;
  text-transform: uppercase;
}

.control-select select {
  text-transform: none;
}

.control-volume {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.control-label {
  color: var(--screen-muted);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.control-slider {
  width: min(110px, 16vw);
  height: 5px;
  appearance: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--screen-ink) 18%, transparent);
  accent-color: var(--accent-2);
  cursor: pointer;
}

.control-slider::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  appearance: none;
  border: 2px solid var(--screen);
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2);
}

.control-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--screen);
  border-radius: 50%;
  background: var(--accent-2);
}

#volume-output {
  width: 2.3ch;
  color: var(--screen-muted);
  font-size: 0.62rem;
  text-align: right;
}

.menu-form {
  display: grid;
  gap: 9px;
}

.menu-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--screen-ink) 25%, transparent);
  border-radius: 4px;
  background: var(--screen);
  color: var(--screen-ink);
}

.menu-submit {
  justify-self: start;
}

@media (max-width: 900px) {
  body {
    padding: 10px;
  }

  .house-shell {
    min-height: calc(100vh - 20px);
  }

  .signal-status {
    display: none;
  }

  .screen {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(240px, 0.8fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "dialogue"
      "hud"
      "controls";
    overflow-y: auto;
  }

  .screen__dialogue {
    min-height: 240px;
    border-bottom: 1px solid color-mix(in srgb, var(--screen-ink) 14%, transparent);
  }

  .screen__hud,
  .screen__controls {
    border-left: 0;
  }
}

@media (max-width: 600px) {
  body {
    padding: 0;
    background-attachment: scroll;
  }

  .house-shell {
    min-height: 100vh;
    gap: 0;
  }

  .game-masthead {
    min-height: 58px;
    border: 0;
    border-radius: 0;
  }

  .masthead-brand span {
    display: none;
  }

  .masthead-brand strong {
    font-size: 1.05rem;
  }

  .masthead-actions button {
    padding-inline: 8px;
    font-size: 0.62rem;
  }

  .terminal {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .terminal-bar {
    display: none;
  }

  .screen {
    min-height: calc(100vh - 58px);
    border: 0;
    border-radius: 0;
    font-size: 14px;
  }

  .screen__dialogue,
  .screen__hud {
    padding: 20px 16px;
  }

  .screen__controls {
    padding: 10px;
  }

  .control-volume {
    width: 100%;
    margin-left: 0;
  }

  .control-slider {
    width: auto;
    flex: 1;
  }
}

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