/* Bremen City Quest — retro pixel theme, accessible text */
:root {
  --bg: #0b0f14;
  --bg-2: #101722;
  --panel: #131b27;
  --panel-2: #1a2434;
  --line: #34425a;
  --text: #f1f5fa;
  --muted: #b3c0d2;
  --sky: #b9cbdc;
  --red: #c9160f;
  --red-dark: #7d0d08;
  --gold: #ffd166;
  --green: #8fe0b0;
  --ghost-bg: #15212f;
  --ghost-line: #8ea6c4;
  --focus: #ffd166;
  --pixel: 3px;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --fs: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.hidden { display: none !important; }
.px { display: inline-block; line-height: 0; }
.px svg { display: block; image-rendering: pixelated; }

/* visible keyboard focus everywhere */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* 8-bit box: hard corners, stepped border via box-shadow */
.pxbox {
  border-radius: 0;
  box-shadow:
    0 calc(-1 * var(--pixel)) 0 0 var(--box, var(--line)),
    0 var(--pixel) 0 0 var(--box, var(--line)),
    calc(-1 * var(--pixel)) 0 0 0 var(--box, var(--line)),
    var(--pixel) 0 0 0 var(--box, var(--line));
}

/* header / status bar */
.status {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px; padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: var(--pixel) solid var(--line);
  flex: 0 0 auto;
}
.app-icon { width: 32px; height: 32px; flex: 0 0 auto; image-rendering: pixelated; box-shadow: 0 0 0 2px #000; }
.btn-icon { background: transparent; border: 0; font-size: 28px; line-height: 1; color: var(--text); padding: 8px 10px; min-width: 44px; min-height: 44px; cursor: pointer; flex: 0 0 auto; }
.status-left { flex: 1 1 auto; min-width: 0; }
.status-room { font-weight: 700; font-size: .85em; color: var(--sky); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { display: flex; gap: 4px; margin-top: 6px; }
.progress i { display: block; width: 11px; height: 11px; background: var(--bg-2); box-shadow: inset 0 0 0 2px var(--line); }
.progress i.done { background: var(--green); box-shadow: none; }
.progress i.now { background: #ff4d45; box-shadow: none; animation: blink 1s steps(2, start) infinite; }
.status-items { display: flex; gap: 4px; align-items: center; }
.status-items .px { animation: pop .35s steps(3) both; }
.badge { font-family: var(--font-pixel); font-size: 9px; background: var(--gold); color: #1a1a1a; padding: 5px 6px; }
.companion, .cat { width: 36px; height: 39px; flex: 0 0 auto; background: transparent; border: 0; padding: 0; cursor: pointer; line-height: 0; }
.companion { animation: float 2.4s ease-in-out infinite; }
.companion:disabled, .cat:disabled { cursor: default; opacity: .55; }
.cat { width: 36px; height: 36px; animation: peek 4s steps(2) infinite; }
.companion.angry { animation: shake .4s steps(4) 3; }
.companion.happy { animation: bounce .5s steps(4) 2; }

/* travel */
.travel { background: var(--panel-2); border-bottom: var(--pixel) solid var(--line); padding: 12px 14px; flex: 0 0 auto; }
.travel-row { display: flex; align-items: center; gap: 14px; }
.compass {
  width: 72px; height: 72px; flex: 0 0 auto; background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 var(--pixel) var(--sky), 0 0 0 calc(var(--pixel) * 2) #000;
}
.arrow { width: 48px; height: 48px; line-height: 0; transition: transform .3s steps(6); filter: drop-shadow(2px 2px 0 #000); }
.arrow svg { width: 100%; height: 100%; display: block; }
.travel-label { font-size: .75em; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.travel-target { font-weight: 700; color: #fff; }
.travel-distance { color: var(--gold); }
.travel-note { font-size: .9em; color: var(--muted); }
.travel-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* log */
.log {
  flex: 1 1 auto; overflow-y: auto; padding: 16px 14px 10px;
  display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch;
}
.row { display: flex; align-items: flex-end; gap: 8px; max-width: 92%; }
.row-ghost { align-self: flex-start; }
.row-player { align-self: flex-end; flex-direction: row-reverse; }
.avatar { flex: 0 0 auto; width: 30px; height: 32px; margin-bottom: 4px; }
.msg { padding: 12px 14px; white-space: pre-wrap; word-wrap: break-word; position: relative; }
.msg-ghost { --box: var(--ghost-line); background: var(--ghost-bg); color: var(--text); margin-left: var(--pixel); }
.msg-ghost .tag { font-size: .72em; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sky); display: block; margin-bottom: 6px; }
.untyped { visibility: hidden; }
.cursor { color: var(--sky); animation: blink .7s steps(2, start) infinite; }
.dots { display: inline-flex; gap: 5px; padding: 6px 2px; }
.dots i { width: 8px; height: 8px; background: var(--sky); animation: dot 1s steps(2, start) infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
.msg-hint { --box: var(--gold); }
.msg-hint .tag { color: var(--gold); }
.msg-player { --box: var(--red-dark); background: var(--red); color: #fff; font-weight: 700; margin-right: var(--pixel); }
.msg-text { align-self: center; max-width: 94%; color: #d5deea; text-align: center; padding: 2px 10px; font-style: italic; }
.msg-system { align-self: center; font-size: .85em; font-weight: 700; color: var(--green); text-align: center; padding: 0 10px; letter-spacing: .04em; }
.msg-item {
  align-self: center; --box: var(--gold); background: #2a2410; color: var(--gold); font-weight: 700;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; margin: var(--pixel) 0;
}
.msg-item.lost { --box: var(--muted); background: #1a1f28; color: var(--muted); }
.msg-end {
  align-self: center; width: 100%; max-width: 360px; --box: var(--red); background: #1c0e0d; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; margin: var(--pixel) 0 8px;
}
.msg-end.win { --box: var(--gold); background: #2a2410; }
.msg-end .end-title { font-family: var(--font-pixel); font-size: 14px; color: #fff; line-height: 1.6; }
.msg-end .end-sub { color: var(--muted); font-size: .9em; }
.msg-item .px { filter: drop-shadow(1px 1px 0 #000); }

/* footer */
.footer { flex: 0 0 auto; background: var(--panel); border-top: var(--pixel) solid var(--line); padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); min-height: 20px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices:empty { display: none; }
.choices.waiting { visibility: hidden; }
.choice {
  min-height: 48px; padding: 8px 12px; font: inherit; font-weight: 700; color: var(--text); cursor: pointer;
  background: #1f2d3f; border: 0; box-shadow: 0 0 0 2px var(--sky); text-align: center; line-height: 1.25;
}
.choice:active { background: var(--sky); color: #000; }
.choice.tried { color: var(--muted); background: var(--bg-2); box-shadow: 0 0 0 2px var(--line); text-decoration: line-through; cursor: default; }
.choice.single { grid-column: 1 / -1; }
.choices.ok .choice { box-shadow: 0 0 0 3px var(--green); }
.choices.bad { animation: shake .3s steps(4) 2; }
.select { font: inherit; padding: 8px; background: var(--bg-2); color: var(--text); border: 2px solid var(--line); min-height: 44px; flex: 1 1 auto; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 0;
  min-height: 44px; padding: 8px 18px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; color: #fff;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .35), inset 3px 3px 0 rgba(255, 255, 255, .15);
}
.btn:active { box-shadow: inset 3px 3px 0 rgba(0, 0, 0, .35); transform: translate(1px, 1px); }
.btn-primary { background: var(--red); }
.btn-secondary { background: var(--panel-2); color: var(--text); }
.btn-dev { background: var(--gold); color: #1a1a1a; }

/* menu */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .78); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; overflow-y: auto; }
.overlay.hidden { display: none; }
.menu {
  width: 100%; max-width: 420px; background: var(--panel); padding: 18px; margin: auto;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 0 0 var(--pixel) var(--sky), 0 0 0 calc(var(--pixel) * 2) #000;
}
.menu-logo { width: 100%; background: var(--sky); }
.menu-title { display: flex; align-items: center; gap: 12px; }
.menu-ghost { width: 40px; height: 43px; animation: float 2.4s ease-in-out infinite; }
.menu-heading { font-family: var(--font-pixel); font-size: 13px; color: #fff; line-height: 1.6; }
.menu-sub { color: var(--muted); font-size: .9em; }
.menu-section { font-size: .75em; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 -4px; }
.menu-help { margin: 0; font-size: .9em; color: var(--muted); }
.menu-credits { margin: 0; font-size: .8em; color: var(--muted); text-align: center; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--red); flex: 0 0 auto; }
.toggle code { font-family: var(--font-pixel); font-size: 9px; background: var(--bg-2); padding: 3px 5px; white-space: nowrap; }

/* animations */
@keyframes blink { to { visibility: hidden; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes dot { 50% { transform: translateY(-4px); } }
@keyframes peek { 0%, 100% { transform: translateY(2px); } 50% { transform: translateY(-2px); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.row, .msg-text, .msg-system, .msg-item { animation: rise .18s steps(3) both; }
.log.restoring .row, .log.restoring .msg-text, .log.restoring .msg-system, .log.restoring .msg-item { animation: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 720px) {
  body { max-width: 640px; margin: 0 auto; box-shadow: 0 0 0 var(--pixel) var(--line); }
}
