:root {
  color-scheme: dark;
  --page: #080b09;
  --paper: #171c19;
  --panel: #0f1411;
  --ink: #f7edcf;
  --muted: #a7ae95;
  --red: #df6870;
  --gold: #d7a84f;
  --green: #718c61;
  --line: #424b41;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: auto;
  padding: 0 48px 64px;
  background: var(--paper);
  box-shadow: 0 0 80px #000;
}

nav {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

nav a {
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
  text-transform: uppercase;
}

nav .brand {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: none;
}

.nav-links {
  display: flex;
  gap: 22px;
}

main {
  padding-top: 36px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 430px);
  align-items: end;
  gap: 30px;
  margin-bottom: 28px;
}

.eyebrow,
.card-label,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 5.3rem);
  letter-spacing: -.08em;
  line-height: .75;
}

.intro {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

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

.console,
.character-card,
.wardrobe-card,
.objective-card,
.chat-card {
  border: 1px solid var(--line);
  background: var(--panel);
}

.console {
  padding: 12px;
}

.console-head,
.chat-title,
.growth-row,
.keys {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.console-head {
  min-height: 30px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}

.connection,
#chat-status {
  color: var(--muted);
}

.connection.online,
#chat-status.online {
  color: #99c679;
}

.screen-wrap {
  position: relative;
  overflow: hidden;
  border: 8px solid #313833;
  background: #31493b;
  box-shadow: inset 0 0 0 2px #090b0a;
}

#game {
  display: block;
  width: 100%;
  aspect-ratio: 10 / 7;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.screen-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  color: #17201b;
  background: #d8ddb7ee;
  text-align: center;
}

.screen-panel[hidden],
.toast[hidden] {
  display: none;
}

.screen-panel strong {
  font-size: clamp(16px, 3vw, 26px);
  text-transform: uppercase;
}

.screen-panel span {
  max-width: 380px;
  font-size: 10px;
  line-height: 1.5;
}

.panel-action,
.species-grid button {
  padding: 9px 12px;
  border: 2px solid #17201b;
  color: #17201b;
  background: #fff1c7;
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  width: min(300px, 100%);
}

.breed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  width: min(300px, 100%);
}

.species-grid button {
  cursor: pointer;
}

.species-grid button:hover,
.species-grid button:focus-visible,
.species-grid button.selected,
.breed-grid button:hover,
.breed-grid button:focus-visible,
.breed-grid button.selected,
.panel-action:hover,
.panel-action:focus-visible {
  color: #fff1c7;
  background: #17201b;
}

.species-panel {
  gap: 6px;
  padding: 10px;
}

.species-panel .panel-kicker {
  margin-bottom: 1px;
}

#creator-preview {
  width: 58px;
  height: 58px;
  border: 2px solid #17201b;
  image-rendering: pixelated;
}

.species-panel .species-grid button {
  padding-block: 6px;
}

.breed-grid button {
  padding: 5px 3px;
  border: 1px solid #17201b;
  color: #17201b;
  background: #fff1c7;
  cursor: pointer;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(8, 26px);
  gap: 5px;
}

.color-grid button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid #17201b;
  cursor: pointer;
}

.color-grid button.selected {
  outline: 3px solid #fff1c7;
  outline-offset: -6px;
}

.species-grid button:disabled:not(.selected) {
  opacity: .38;
}

.confirm-actions {
  display: flex;
  gap: 8px;
}

.panel-action.danger {
  color: #fff1c7;
  border-color: #7b252d;
  background: #7b252d;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  color: #17201b;
  background: #fff1c7;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
}

.touch-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 18px 10px 6px;
  user-select: none;
}

.dpad {
  display: grid;
  grid-template: repeat(3, 40px) / repeat(3, 40px);
}

.dpad button,
.action-buttons button {
  border: 1px solid #5b665a;
  color: var(--ink);
  background: #292f2b;
  touch-action: none;
}

.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }

.action-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.action-buttons button {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: var(--red);
  font-weight: 900;
}

.action-buttons #return-button {
  width: 44px;
  height: 44px;
  color: var(--gold);
}

.keys {
  margin: 11px 1px 0;
  color: #778076;
  font-size: 9px;
}

.sidebar {
  display: grid;
  gap: 12px;
}

.character-card,
.wardrobe-card,
.objective-card,
.chat-card {
  padding: 13px;
}

.wardrobe-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.wardrobe-title span {
  color: var(--gold);
  font-size: 8px;
}

.wardrobe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.wardrobe-grid label {
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
}

.wardrobe-grid select {
  width: 100%;
  height: 28px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #090c0a;
  font-size: 8px;
}

.wardrobe-grid select:disabled {
  color: #737a70;
  opacity: .65;
}

.set-copy {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.45;
}

.character-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
}

.portrait-frame {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border: 1px solid var(--line);
  background: #31493b;
}

#portrait {
  width: 88px;
  height: 88px;
  image-rendering: pixelated;
}

.character-copy h2 {
  overflow: hidden;
  margin: 0 0 5px;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-copy > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.stats div {
  padding: 8px;
  background: var(--panel);
}

.stats dt {
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
}

.stats dd {
  margin: 3px 0 0;
  color: var(--gold);
  font-size: 12px;
}

.growth {
  grid-column: 1 / -1;
}

.growth-row {
  color: var(--muted);
  font-size: 8px;
}

.growth-track {
  height: 5px;
  margin-top: 6px;
  background: #283029;
}

.growth-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width .25s steps(5);
}

#objective {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.objective-card .carried {
  margin: 9px 0 0;
  color: var(--gold);
  font-size: 8px;
  line-height: 1.45;
}

.chat-card {
  min-height: 220px;
}

.chat-title {
  color: var(--red);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
}

.chat-log {
  display: grid;
  align-content: end;
  min-height: 130px;
  max-height: 190px;
  gap: 5px;
  overflow: auto;
  margin: 10px 0;
  padding: 8px;
  border: 1px solid var(--line);
  background: #090c0a;
}

.chat-log p {
  margin: 0;
  font-size: 9px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chat-log strong {
  color: var(--red);
}

.chat-empty {
  color: #778076;
}

#chat-form {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 5px;
}

#chat-form input,
#chat-form button {
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #090c0a;
  font-size: 9px;
}

#chat-form input {
  padding: 7px;
}

#chat-form button {
  color: var(--red);
  cursor: pointer;
  font-weight: 900;
}

.footnote {
  margin: 16px 0 0;
  color: #778076;
  font-size: 9px;
  line-height: 1.5;
  text-transform: uppercase;
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls {
    display: flex;
  }
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: 1fr 1fr;
  }

  .chat-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 650px) {
  .page-shell {
    width: 100%;
    padding: 0 14px 44px;
  }

  nav {
    min-height: 64px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  h1 {
    line-height: .82;
  }

  .game-layout {
    margin-inline: -14px;
  }

  .console,
  .character-card,
  .wardrobe-card,
  .objective-card,
  .chat-card {
    border-right: 0;
    border-left: 0;
  }

  .console {
    padding-inline: 8px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .chat-card {
    grid-column: auto;
  }

  .keys {
    display: none;
  }
}

@media (max-width: 430px) {
  .species-panel {
    gap: 3px;
    padding: 5px;
  }

  .species-panel .panel-kicker {
    display: none;
  }

  .species-panel strong {
    font-size: 14px;
  }

  #creator-preview {
    width: 44px;
    height: 44px;
  }

  .color-grid {
    grid-template-columns: repeat(8, 22px);
    gap: 3px;
  }

  .color-grid button {
    width: 22px;
    height: 22px;
  }

  .species-panel .panel-action {
    padding-block: 6px;
  }

  .species-panel .species-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }

  .species-panel .species-grid button {
    padding: 5px 2px;
    font-size: 8px;
  }

  .species-panel .breed-grid button {
    padding: 4px 1px;
    font-size: 7px;
  }

  .species-panel > span {
    font-size: 8px;
  }
}
