:root {
  color-scheme: dark;
  --background: #0a0a0a;
  --text: #dedede;
  --muted: #9b9b9b;
  --accent: #e8b66d;
  --prompt: #64d9ce;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.65;
  background: var(--background);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip { position: fixed; top: -60px; left: 16px; color: var(--accent); background: var(--background); z-index: 2; }
.skip:focus { top: 8px; }
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 24px;
}
#output {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: #555 var(--background);
  overscroll-behavior: contain;
}
#terminal-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
#output { min-width: 0; }
#command-guide { flex-shrink: 0; border-top: 1px solid #393939; font-size: 12px; }
#command-guide summary { cursor: pointer; color: var(--prompt); padding: 5px 0; width: fit-content; }
#command-guide summary:focus-visible { outline: 1px solid var(--prompt); outline-offset: 2px; }
.guide-body { max-height: min(170px, 26dvh); overflow: auto; scrollbar-width: thin; overflow-wrap: anywhere; }
.guide-body dl { display: grid; grid-template-columns: max-content 1fr; gap: 1px 14px; margin: 4px 0 12px; }
.guide-body dt, .guide-body dd { margin: 0; }
.guide-body dd, .guide-body p { color: var(--muted); }
.guide-body p { margin: 0 0 10px; }
.guide-body code { font: inherit; color: var(--text); }
@media (min-width: 1050px) {
  #terminal-workspace { flex-direction: row; gap: 24px; }
  #command-guide { width: 292px; border-top: 0; border-left: 1px solid #393939; padding-left: 16px; }
  #command-guide:not([open]) { width: auto; }
  .guide-body { max-height: calc(100dvh - 155px); }
  .guide-body dl { grid-template-columns: 1fr; gap: 0; }
  .guide-body dd { margin: 0 0 7px; }
}
.line { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.line.command { margin-top: 20px; margin-bottom: 5px; }
.line.system, .line.task, .line.hint, .line.success, .line.archive, .line.error, .line.ending { color: var(--accent); }
.line.file { color: var(--muted); margin-bottom: 3px; }
#command-form { display: flex; align-items: center; gap: 8px; padding-top: 12px; flex-shrink: 0; }
.prompt { flex-shrink: 1; min-width: 0; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#command {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--text);
}
.prompt, #command-form:focus-within .prompt, .command-prompt { color: var(--prompt); }
button { padding: 5px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
button:hover { color: var(--text); }
button:focus-visible, a:focus-visible, #output:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
#send { flex-shrink: 0; width: 36px; height: 40px; }
#tik {
  position: absolute;
  bottom: 85px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(360px, calc(100% - 48px));
  padding: 12px 0 12px 12px;
  background: var(--background);
  color: var(--accent);
}
.pumpkin { flex-shrink: 0; width: 40px; height: 40px; }
#tik p { margin: 0; font-size: 12px; line-height: 1.7; }
#tik-hint { padding: 0; color: inherit; text-decoration: underline; }
#dismiss-tik { align-self: flex-start; color: inherit; min-width: 28px; }
body.embed #app { padding: 16px; }
@media (max-width: 600px) {
  :root { font-size: 13px; }
  #app { padding: 16px 12px; }
  #command-form { gap: 6px; flex-wrap: wrap; padding-top: 8px; }
  .prompt { flex-basis: 100%; max-width: 100%; font-size: 12px; }
  #command { font-size: 16px; }
  #send { width: 40px; height: 44px; }
  #tik { bottom: 112px; right: 12px; max-width: calc(100% - 24px); }
  body.embed #app { padding: 12px; }
}
/* Each role has its own readable accent on the black terminal. */
.line.system { color: #c0c0b9; }
.line.task { color: #f2f2e9; }
.line.archive, .dialogue { color: #85ceff; }
.line.success { color: #7fe09b; }
.line.error { color: #f398a3; }
.line.hint { color: #ffc36f; }
.line.ending { color: #e5e5de; margin: 24px 0; }
.ending-choice { margin: 20px 0 28px; }
.ending-options { border-collapse: collapse; table-layout: fixed; width: min(100%, 620px); font: inherit; }
.ending-options caption { text-align: left; color: var(--muted); margin-bottom: 10px; }
.ending-options th, .ending-options td { width: 50%; border-left: 1px solid #424242; border-right: 1px solid #424242; text-align: center; padding: 10px 16px; overflow-wrap: anywhere; }
.ending-options th { border-top: 1px solid #424242; border-bottom: 1px solid #424242; font-weight: normal; }
.ending-options tr:last-child td { border-bottom: 1px solid #424242; padding-bottom: 16px; }
.ending-options code { font: inherit; color: var(--accent); }
.choice-tik { display: block; width: 96px; height: 96px; margin: 4px auto; image-rendering: pixelated; }
.ending-choice > p { color: var(--muted); margin: 10px 0 0; }
#tik { right: 0; bottom: 78px; width: min(410px, calc(100% - 16px)); max-width: none; padding: 0; gap: 4px; background: none; align-items: flex-end; color: var(--text); }
.tik-bubble { flex: 1; position: relative; border: 1px solid #555; background: #151515; padding: 12px 28px 12px 14px; margin-bottom: 24px; }
.tik-bubble::after { content: ''; position: absolute; right: -5px; bottom: 15px; width: 8px; height: 8px; border-right: 1px solid #555; border-top: 1px solid #555; background: #151515; transform: rotate(45deg); }
#tik p { font-size: 12px; }
#tik-hint { color: var(--accent); }
#dismiss-tik { position: absolute; right: 2px; top: 1px; color: var(--muted); }
.tik-peek { position: relative; width: 88px; height: 100px; overflow: hidden; flex-shrink: 0; }
.tik-peek img { position: absolute; width: 112px; height: 112px; right: -14px; top: 3px; image-rendering: pixelated; }
.tik-corner { position: absolute; bottom: 0; right: 0; height: 14px; width: 100%; border-top: 1px solid #444; background: var(--background); }
.terminal-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; padding-top: 4px; font-size: 11px; }
.terminal-tools button { padding: 2px 0; }
#skip-typing { position: absolute; right: 24px; bottom: 108px; z-index: 4; font-size: 11px; padding: 4px 8px; border: 1px solid #555; background: var(--background); color: #ddd; }
.awaiting-text { display: none; }
#fortune { position: absolute; display: flex; align-items: flex-end; width: min(370px, calc(100% - 24px)); z-index: 5; gap: 8px; }
#fortune img { width: 72px; height: 72px; flex-shrink: 0; image-rendering: pixelated; }
.fortune-bubble { flex: 1; min-width: 0; position: relative; padding: 12px 26px 12px 12px; background: #141414; border: 1px solid #9a7546; overflow-wrap: anywhere; }
.fortune-bubble p { margin: 0; font-size: 12px; }
.fortune-bubble .fortune-label { color: #ffc36f; font-size: 10px; margin-bottom: 6px; }
#dismiss-fortune { position: absolute; right: 2px; top: 0; min-width: 24px; }
#completion { flex: 1; min-height: 0; overflow: auto; outline: none; }
.completion-inner { width: min(100%, 600px); margin: auto; padding: clamp(16px, 5vh, 60px) 0 24px; }
.completion-label { color: #a0a09a; letter-spacing: .06em; font-size: 11px; }
#completion-tik { display: block; image-rendering: pixelated; margin: 24px 0; }
#completion-title { font-size: clamp(22px, 4vw, 32px); line-height: 1.35; font-weight: 500; margin: 0 0 24px; color: #f2f2e9; }
#completion-choice { color: #ffc36f; font-size: 17px; }
#completion-story { max-width: 54ch; min-height: 3.3em; }
#completion-status { font-size: 12px; color: #85ceff; border-top: 1px solid #3c3c3c; padding-top: 20px; margin-top: 28px; }
.completion-solved { color: #7fe09b; font-size: 12px; }
.completion-actions { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 30px; }
.completion-actions button { padding: 8px 0; color: #dedede; text-decoration: underline; text-underline-offset: 5px; }
body.completed #output, body.completed #command-form, body.completed .terminal-tools { display: none; }
body.completed #terminal-workspace { display: none; }
body.completed #skip-typing { bottom: 12px; }
@media (max-width: 600px) {
  #tik { right: 0; bottom: 112px; width: calc(100% - 12px); max-width: none; }
  .tik-bubble { padding: 10px 24px 10px 10px; }
  .tik-peek { width: 76px; }
  .ending-options th, .ending-options td { padding-left: 10px; padding-right: 10px; }
  .choice-tik { width: 80px; height: 80px; }
  #skip-typing { bottom: 148px; right: 12px; }
  #fortune img { width: 60px; height: 60px; }
  .completion-inner { padding-top: 8px; }
  #completion-tik { width: 112px; height: 112px; margin: 16px 0; }
}
