@font-face { font-family: "Departure Mono"; src: url("/fonts/DepartureMono-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Jacquarda"; src: url("/fonts/JacquardaBastarda9-latin.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #0d0b09;
  --ink: #e8e0cf;
  --dim: #9a9080;
  --yellow: #f0d050;
  --green: #6fd36f;
  --cyan: #59c8e0;
  --purple: #c08cf0;
  --blue: #7ea6ff;
  --orange: #e8a03a;
  --red: #e2554a;
  --gold: #c49234;
  --herb: #7fb069;
  --carn: #e06a50;
  --scav: #a993e0;
  --omni: #e0ae4a;
  --fs: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: var(--fs)/1.35 "Departure Mono", ui-monospace, monospace; -webkit-font-smoothing: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { image-rendering: pixelated; }
a { color: var(--cyan); }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.px16 { width: 32px; height: 32px; }
[hidden] { display: none !important; }

/* ---------- the screen ---------- */
.screen { display: grid; grid-template-rows: auto auto auto minmax(240px, 1fr); height: 100dvh; gap: 6px; padding: 8px; }

.bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 18px; min-height: max-content; padding: 4px 14px;
  border: 12px solid transparent; border-image: url("/art/ui/frame.png") 6 fill / 12px stretch; image-rendering: pixelated; }
.mark { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: normal; }
.word { font: 36px/1 "Jacquarda", serif; color: var(--yellow); letter-spacing: 1px; text-shadow: 2px 2px 0 #3a250c; }
.clock { display: flex; flex-direction: column; line-height: 1.2; }
.when { color: var(--ink); }
.next { color: var(--green); }
.speed { display: flex; gap: 6px; }
.key { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; cursor: pointer; background: none;
  border: 8px solid transparent; border-image: url("/art/ui/btn_dark.png") 4 fill / 8px stretch; }
.key img { width: 24px; height: 24px; }
.key.on { border-image-source: url("/art/ui/btn_hot.png"); }
.key.on img { filter: brightness(0.25); }
.mode { margin: 0 0 0 auto; color: var(--orange); max-width: 46ch; text-align: right; font-size: 14px; }
.mode.live { color: var(--green); }

.tabs { min-height: max-content; display: flex; align-items: flex-end; gap: 2px; padding: 0 4px; flex-wrap: wrap; }
.tab { position: relative; height: 36px; padding: 0 26px 0 14px; cursor: pointer; color: #2a1a08; background: none;
  border: 8px solid transparent; border-width: 8px 24px 8px 8px; border-image: url("/art/ui/tab.png") 4 12 4 4 fill / 8px 24px 8px 8px stretch;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.tab u { text-decoration-color: #6a3c0c; }
.tab.on { border-image-source: url("/art/ui/tab_on.png"); color: #1a0f04; transform: translateY(-2px); }
.tab:hover { filter: brightness(1.12); }
.names { margin-left: auto; color: var(--dim); display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; padding-bottom: 6px; }
.names input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.names .box { width: 18px; height: 18px; background: #0f0c0a; border: 2px solid var(--gold); box-shadow: inset 2px 2px 0 #000; display: inline-grid; place-items: center; }
.names input:checked + .box::after { content: ""; width: 8px; height: 8px; background: var(--yellow); }
.names input:focus-visible + .box { outline: 2px solid var(--yellow); outline-offset: 2px; }
.names { position: relative; }

.map { position: relative; overflow-x: auto; overflow-y: hidden; height: 400px; background: #2a1d10;
  border: 12px solid transparent; border-image: url("/art/ui/frame.png") 6 / 12px stretch; scrollbar-color: var(--gold) #1b1714; }
.map canvas { display: block; touch-action: pan-x; cursor: grab; }
.wake { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; color: var(--yellow); background: #1b1410; }

/* ---------- sheets ---------- */
.dock { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(360px, 1.35fr) minmax(320px, 1.15fr); gap: 6px; min-height: 240px; }
.sheet { container-type: inline-size; min-height: 0; overflow: auto; padding: 6px 10px; border: 12px solid transparent;
  border-image: url("/art/ui/frame_sheet.png") 6 fill / 12px stretch; scrollbar-color: var(--gold) #1b1714; }
.head { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; }
.portrait { width: 108px; height: 72px; background: #3a3128; image-rendering: pixelated; border: 2px solid #0a0806; outline: 2px solid #5a4a38; }
.who { min-width: 0; }
.name { margin: 0; font-size: var(--fs); font-weight: normal; color: var(--yellow); overflow-wrap: anywhere; }
.nick { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.status { margin: 0; color: var(--green); }
.status.warn { color: var(--orange); }
.status.bad { color: var(--red); }
.icons { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 150px; }
.ibtn { display: grid; justify-items: center; align-content: center; gap: 0; width: 64px; height: 56px; padding: 0; text-decoration: none; color: #2a1a08; cursor: pointer;
  border: 8px solid transparent; border-image: url("/art/ui/btn.png") 4 fill / 8px stretch; font-size: 13px; line-height: 1.1; }
.ibtn img { width: 24px; height: 24px; image-rendering: auto; }
.ibtn:hover { border-image-source: url("/art/ui/btn_hot.png"); }
.ibtn:active { transform: translateY(1px); }
.ibtn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.ibtn .txt { font-size: 13px; }
.ibtn.wide { width: auto; padding: 0 8px; grid-auto-flow: column; gap: 6px; height: 44px; }

.ca { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin: 10px 0 6px; }
.ca .lbl { color: var(--dim); font-size: 14px; }
.addr { padding: 6px 10px; border: 6px solid transparent; border-image: url("/art/ui/well.png") 3 fill / 6px stretch; color: var(--cyan);
  font: 14px/1.3 "Departure Mono", monospace; overflow-wrap: anywhere; user-select: all; min-width: 0; }
.addr.none { color: var(--dim); user-select: none; }
.copy { display: flex; gap: 6px; align-items: center; height: 40px; padding: 0 8px; cursor: pointer; color: #2a1a08;
  border: 8px solid transparent; border-image: url("/art/ui/btn.png") 4 fill / 8px stretch; background: none; }
.copy img { width: 16px; height: 16px; }
.copy:disabled { opacity: 0.45; cursor: not-allowed; }

.facts { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 8px 0 0; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; text-align: right; color: var(--ink); }
.facts dt.feeds { color: var(--yellow); margin-top: 8px; }

@container (max-width: 470px) {
  .head { grid-template-columns: auto 1fr; }
  .water .nick { display: none; }
  .water .portrait { width: 81px; height: 54px; }
  .water .ibtn { height: 48px; }
  .water .ca { grid-template-columns: 1fr auto; margin-top: 6px; }
  .water .ca .lbl { display: none; }
  .water .addr { font-size: 13px; padding: 4px 8px; }
  .icons { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}
@container (max-width: 380px) {
  .grid2 { grid-template-columns: 1fr; }
  .grid2 > div:nth-child(odd) { border-right: 0; }
  .grid2 > div:nth-child(n+2) { border-top: 2px solid var(--gold); }
}

/* creature sheet, in the reference's own grammar */
.stabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 10px 0 0; }
.stab { height: 30px; padding: 0 20px 0 8px; font-size: 14px; color: #2a1a08; cursor: pointer; background: none;
  border: 6px solid transparent; border-width: 6px 18px 6px 6px; border-image: url("/art/ui/tab.png") 4 12 4 4 fill / 6px 18px 6px 6px stretch; }
.stab.on { border-image-source: url("/art/ui/tab_on.png"); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; border-top: 2px solid var(--gold); }
.grid2 > div { padding: 6px 8px; min-height: 40px; }
.grid2 > div:nth-child(odd) { border-right: 2px solid var(--gold); }
.grid2 > div:nth-child(n+3) { border-top: 2px solid var(--gold); }
.grid2 p, .thoughts p { margin: 0; overflow-wrap: anywhere; }
.thoughts { border-top: 2px solid var(--gold); padding: 6px 2px; }
.thoughts .q { color: var(--ink); text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 4px; margin-bottom: 6px; }
.c-g { color: var(--green); } .c-c { color: var(--cyan); } .c-p { color: var(--purple); } .c-y { color: var(--yellow); }
.c-o { color: var(--orange); } .c-r { color: var(--red); } .c-b { color: var(--blue); } .c-d { color: var(--dim); }
.t-herbivore { color: var(--herb); } .t-carnivore { color: var(--carn); } .t-scavenger { color: var(--scav); } .t-omnivore { color: var(--omni); }
.link { color: var(--cyan); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: #2c6a78; text-underline-offset: 3px; }
.empty { color: var(--dim); }
.spark { width: 100%; height: 120px; image-rendering: pixelated; background: #120f0c; display: block; margin-top: 6px; }

.chead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chead h2 { margin: 0; font-size: var(--fs); font-weight: normal; color: var(--yellow); }
.filter { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 13px; padding: 2px 8px; background: #241e18; border: 2px solid #4a3c2c; cursor: pointer; color: var(--dim); }
.chip.on { color: var(--yellow); border-color: var(--gold); }
.log { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.log li { overflow-wrap: anywhere; padding-left: 9ch; text-indent: -9ch; }
.log time { color: var(--dim); display: inline-block; width: 9ch; text-indent: 0; }

/* ---------- windows ---------- */
.veil { position: fixed; inset: 0; background: rgba(8, 6, 4, 0.55); z-index: 10; }
.win { position: fixed; z-index: 11; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(1180px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  display: grid; grid-template-rows: auto minmax(0, 1fr); border: 12px solid transparent; border-image: url("/art/ui/frame_sheet.png") 6 fill / 12px stretch; }
.wbar { display: flex; align-items: center; gap: 10px; padding: 4px 6px 8px; border-bottom: 2px solid var(--gold); }
.wbar h2 { margin: 0; font-weight: normal; font-size: 20px; color: var(--yellow); flex: 1; }
.close { width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; background: none; border: 8px solid transparent; border-image: url("/art/ui/btn.png") 4 fill / 8px stretch; padding: 0; }
.close img { width: 20px; height: 20px; filter: brightness(0.15); }
.wbody { overflow: auto; padding: 10px 6px; min-height: 0; scrollbar-color: var(--gold) #1b1714; }
.lead { margin: 0 0 12px; color: var(--ink); max-width: 80ch; }

/* birth */
.species { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.sp { display: grid; grid-template-columns: 96px 1fr; gap: 8px; align-items: center; text-align: left; padding: 6px 8px; cursor: pointer; background: #1d1915;
  border: 2px solid #3d3226; color: var(--ink); }
.sp canvas { width: 96px; height: 64px; image-rendering: pixelated; background: #3a3128; }
.sp .t { display: grid; gap: 1px; align-content: center; }
.sp:hover { border-color: var(--gold); }
.sp.on { border-color: var(--yellow); background: #2a2116; }
.sp:disabled { opacity: 0.45; cursor: not-allowed; }
.sp b { font-weight: normal; color: var(--yellow); }
.sp p { margin: 0; font-size: 14px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 14px 0; }
.form label { display: grid; gap: 4px; color: var(--dim); font-size: 14px; }
.form input, .form textarea { color: var(--ink); background: #0f0c0a; padding: 8px 10px; border: 6px solid transparent; border-image: url("/art/ui/well.png") 3 fill / 6px stretch; min-width: 0; }
.form .full { grid-column: 1 / -1; }
.form input:disabled { opacity: 0.5; cursor: not-allowed; }
.form input[type="file"]::file-selector-button { font: inherit; color: #2a1a08; background: #d6b67a; border: 2px solid #14100b; box-shadow: inset -2px -2px 0 #a8844e, inset 2px 2px 0 #eed6a0; padding: 4px 10px; margin-right: 10px; cursor: pointer; }
.steps { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; }
.steps li::before { counter-increment: s; content: counter(s); display: grid; place-items: center; width: 34px; height: 34px; background: var(--gold); color: #1a0f04; }
.steps p { margin: 0; }
.go { height: 46px; padding: 0 14px; cursor: pointer; color: #0e1a0c; background: none; border: 8px solid transparent; border-image: url("/art/ui/btn_go.png") 4 fill / 8px stretch; white-space: nowrap; }
.go.plain { color: #2a1a08; border-image-source: url("/art/ui/btn.png"); }
.go:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.7); }
.note { color: var(--orange); margin: 6px 0; }
.ok { color: var(--green); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-weight: normal; color: var(--dim); padding: 4px 8px; border-bottom: 2px solid var(--gold); white-space: nowrap; }
.tbl td { padding: 4px 8px; border-bottom: 1px solid #2c241b; vertical-align: top; }
.tbl td.n, .tbl th.n { text-align: right; white-space: nowrap; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover td { background: #241d15; }
.scroll-x { overflow-x: auto; }
.cols2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
h3 { margin: 16px 0 6px; font-weight: normal; color: var(--yellow); font-size: 17px; }

/* guide */
.diets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.diet { padding: 8px; background: #1d1915; border-top: 4px solid; }
.diet canvas { width: 144px; height: 96px; image-rendering: pixelated; display: block; margin: 0 auto 6px; }
.diet h4 { margin: 0 0 4px; font-weight: normal; }
.diet p { margin: 0; font-size: 14px; }
.split { display: flex; height: 34px; margin: 8px 0 2px; }
.split span { display: grid; place-items: center; color: #140f0b; font-size: 14px; white-space: nowrap; overflow: hidden; }
.rules { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; max-width: 92ch; }
.rules li::before { content: "> "; color: var(--gold); }
.risk { margin-top: 18px; color: var(--dim); font-size: 13px; }

.noscript { padding: 20px; }

/* ---------- narrower screens ---------- */
@media (max-width: 1180px) {
  .dock { grid-template-columns: 1fr 1fr; height: auto; }
  .chronicle { grid-column: 1 / -1; max-height: 340px; }
  .screen { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto auto; }
  .water, .creature { max-height: 460px; }
  .diets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --fs: 15px; }
  .screen { padding: 4px; gap: 4px; }
  .bar { flex-wrap: wrap; gap: 8px 12px; border-width: 10px; padding: 2px 6px; }
  .word { font-size: 27px; }
  .mode { margin: 0; text-align: left; max-width: none; flex-basis: 100%; font-size: 13px; }
  .tabs { gap: 0; }
  .tab { padding: 0 18px 0 6px; font-size: 14px; height: 34px; }
  .names { margin-left: 0; width: 100%; padding: 4px 4px 2px; }
  .map { border-width: 8px; }
  .dock { grid-template-columns: 1fr; }
  .water, .creature { max-height: none; }
  .chronicle { max-height: 420px; }
  .head { grid-template-columns: auto 1fr; }
  .icons { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
  .portrait { width: 108px; height: 72px; }
  .ca { grid-template-columns: 1fr auto; }
  .ca .lbl { grid-column: 1 / -1; }
  .form { grid-template-columns: 1fr; }
  .steps li { grid-template-columns: 34px 1fr; }
  .steps li .go { grid-column: 2; justify-self: start; }
  .diets { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .grid2 > div:nth-child(odd) { border-right: 0; }
  .grid2 > div:nth-child(n+2) { border-top: 2px solid var(--gold); }
  .win { width: calc(100vw - 8px); max-height: calc(100dvh - 8px); border-width: 10px; }
  .species { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .tbl.cards thead { display: none; }
  .tbl.cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 8px 2px; border-bottom: 1px solid #2c241b; }
  .tbl.cards td { border: 0; padding: 0; text-align: left; white-space: normal; }
  .tbl.cards td.n { text-align: left; }
  .tbl.cards td[data-label]::before { content: attr(data-label) " "; color: var(--dim); }
  .tbl.cards td:empty { display: none; }
  .scroll-x { overflow-x: visible; }
}
@media (prefers-reduced-motion: reduce) { .tab.on { transform: none; } }
