/* MrTerm-style chrome: bright blue who/map header, red identity bar,
   black ANSI text, bright blue vitals. VT323 is the bundled terminal face. */

@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/vt323-latin-400-normal.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #000000;
  --fg: #55ffff;
  --bright: #ffffff;
  --black: #000000;
  --red: #aa0000;
  --green: #00aa00;
  --yellow: #aa5500;
  --blue: #0000aa;
  --magenta: #aa00aa;
  --cyan: #00aaaa;
  --white: #aaaaaa;
  --bred: #ff5555;
  --bgreen: #55ff55;
  --byellow: #ffff55;
  --bblue: #5555ff;
  --bmagenta: #ff55ff;
  --bcyan: #55ffff;
  --bwhite: #ffffff;
  --bar: #0000ff;
  --identity: #ff0000;
  --font: "VT323", "IBM VGA", "More Perfect DOS VGA", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
}

body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.15;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overflow: hidden;
}

#chrome {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bar);
  color: var(--bwhite);
  min-height: 2.45em;
  padding: 3px 8px 4px;
  line-height: 1.1;
}

#who {
  flex: 1 1 38%;
  min-width: 0;
  max-height: 2.3em;
  overflow: hidden;
  line-height: 1.15;
}

.who-name {
  display: inline-block;
  margin-right: 0.8em;
  white-space: nowrap;
  color: var(--bwhite);
}

.who-name.you { font-weight: 700; }

#map {
  flex: 1 1 62%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  overflow: hidden;
  gap: 1px;
}

.map-row {
  display: flex;
  background: var(--black);
  color: var(--bwhite);
  width: max-content;
  max-width: 100%;
  line-height: 1.05;
}

.map-cell { white-space: pre; }

.map-tile.here {
  outline: 1px solid var(--bwhite);
  outline-offset: -1px;
}

#identity {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  background: var(--identity);
  color: var(--black);
  font-weight: 700;
  padding: 1px 8px 2px;
  line-height: 1.15;
  white-space: nowrap;
}

#identity-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#identity-meta { flex: 0 0 auto; }

#log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 8px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--black);
  color: var(--bcyan);
  font-size: 20px;
}

#log div.room-name { color: var(--bwhite); }
#log div.room,
#log div.info,
#log div.system,
#log div.item,
#log div.emote,
#log div.combat { color: var(--bcyan); }
#log div.exits,
#log div.npc { color: var(--bmagenta); }
#log div.say,
#log div.tell,
#log div.shout { color: var(--byellow); }
#log div.combat-hard { color: var(--bwhite); font-weight: 700; }
#log div.error { color: var(--bred); }

body.nocolour #log div { color: var(--bwhite); font-weight: 400; }

#dock {
  flex: 0 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--black);
}

#vitals {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  background: var(--bar);
  color: var(--bwhite);
  padding: 1px 8px 2px;
  line-height: 1.15;
  white-space: nowrap;
}

#vitals-stats {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#clock { flex: 0 0 auto; }

#quick-row {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px 0;
}

#quick {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

#quick.collapsed { display: none; }

#quick button, #quick-toggle {
  font-family: inherit;
  font-size: 16px;
  color: var(--bwhite);
  background: var(--black);
  border: 1px solid var(--bblue);
  padding: 2px 8px;
}

#form {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 8px 8px;
  position: relative;
  min-height: 36px;
}

#prompt { color: var(--bwhite); flex: 0 0 auto; }

#echo {
  color: var(--bwhite);
  white-space: pre;
  overflow: hidden;
}

#cursor {
  color: var(--bwhite);
  background: var(--bwhite);
  width: 0.6em;
  display: inline-block;
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  50% { background: transparent; color: transparent; }
}

#input {
  position: absolute;
  inset: 4px 8px 8px;
  width: calc(100% - 16px);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.2;
  color: transparent;
  caret-color: transparent;
  background: transparent;
  border: 0;
  padding: 0;
}

#input:focus { outline: none; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  #chrome, #identity, #vitals { font-size: 15px; }
  #log { font-size: 16px; }
  #who { max-height: 2.4em; }
  #identity { gap: 6px; padding-left: 6px; padding-right: 6px; }
  #vitals { gap: 6px; padding-left: 6px; padding-right: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  #cursor { animation: none; }
}

#gate-screens, #play {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

#gate-screens[hidden], #play[hidden], .step[hidden], .screen[hidden] { display: none; }

#gate-screens { overflow: auto; }

.screen { display: flex; flex-direction: column; min-height: 100%; }

.gate-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--bar);
  color: var(--bwhite);
  padding: 8px 12px;
  font-size: 22px;
}

.gate-red {
  background: var(--identity);
  color: var(--black);
  font-weight: 700;
  padding: 4px 12px;
}

.gate-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 12px 28px;
  max-width: 42rem;
}

.gate-body label, .step-label { color: var(--bwhite); }

.gate-body input {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-family: inherit;
  font-size: 18px;
  color: var(--bwhite);
  background: var(--black);
  border: 1px solid var(--bblue);
  padding: 8px;
}

.gate-actions, .choice-list, #roster-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.gate-actions { flex-direction: row; flex-wrap: wrap; }

.gate-body button, .pick, .char-row, #sign-out {
  font-family: inherit;
  font-size: 18px;
  color: var(--bwhite);
  background: var(--black);
  border: 1px solid var(--bblue);
  padding: 8px 12px;
}

.char-row, .pick { width: 100%; text-align: left; }

#auth-error, #roster-error, #create-error { color: var(--bred); min-height: 1.2em; margin: 0; }

#local-note, #roster-empty { color: var(--bcyan); margin: 0; }

#sheet-text {
  margin: 0;
  white-space: pre-wrap;
  color: var(--bcyan);
  font-family: inherit;
  font-size: 20px;
}

#step-sheet:focus { outline: none; }
