/* Dạo Phố: the town full screen, the sky behind it (world.js paints this
   box's background by the hour), a few frosted cards over it. Be Vietnam Pro
   (bundled: fonts/, fonts.css), made for Vietnamese. */
:root {
  --ink: #15283a;
  --muted: #4c6276;
  --sea: #2f74c6;
  --sun: #ffc23d;
  --card: rgba(255, 255, 255, 0.86);
  --edge: rgba(255, 255, 255, 0.7);
  --text: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-family: var(--text);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
html { touch-action: manipulation; }
body {
  background: #9cc4e6;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  line-height: 1.4; /* (Vietnamese accents need the room) */
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--sea); }

/* ---------- the town ---------- */
.stage { position: fixed; inset: 0; overflow: hidden; background: linear-gradient(#3f7fd0, #d5e6f0 78%); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 9px 3px;
  border-radius: 999px;
  background: rgba(20, 40, 60, 0.62);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  will-change: transform;
}
.label::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom: 0;
  border-top-color: rgba(20, 40, 60, 0.62);
}

/* ---------- what's on screen ---------- */
.hud-left { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.hud-left > * { pointer-events: auto; }
.title-card { display: flex; flex-direction: column; padding: 7px 12px 8px; border-radius: 14px; background: var(--card); box-shadow: 0 4px 14px rgba(0, 30, 60, 0.18); backdrop-filter: blur(6px); }
.title-card b { font-size: 18px; line-height: 1.35; color: var(--sea); }
.title-card span { font-size: 12px; line-height: 1.45; color: var(--muted); }
.hud-right { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); display: flex; align-items: center; gap: 6px; }
.hud-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(0, 30, 60, 0.18);
  font-size: 22px;
}
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 12px 5px;
  max-width: calc(100% - 200px);
  border-radius: 999px;
  background: rgba(20, 40, 60, 0.55);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}
.credit {
  position: fixed;
  left: calc(8px + env(safe-area-inset-left));
  bottom: calc(8px + env(safe-area-inset-bottom));
  padding: 1px 7px 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.5;
  text-decoration: none;
}
.loading {
  position: fixed;
  top: calc(66px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 7px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(0, 30, 60, 0.18);
  font-size: 13px;
  line-height: 1.5;
}
.loading.failed { flex-wrap: wrap; justify-content: center; max-width: calc(100% - 32px); border-radius: 16px; text-align: center; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--sea); border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stats { position: fixed; left: 8px; top: calc(80px + env(safe-area-inset-top)); margin: 0; padding: 4px 8px; max-width: calc(100% - 16px); border-radius: 8px; background: rgba(0, 0, 0, 0.6); color: #cfe; font: 11px/1.4 ui-monospace, monospace; white-space: pre-wrap; pointer-events: none; }

/* The map: bottom right on a computer, under the menu button on a phone. */
.map-box { position: fixed; right: calc(12px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#minimap { width: 148px; height: 148px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0, 30, 60, 0.25); background: #e9e5d6; }
.map-box .credit { position: static; pointer-events: auto; }

/* The thumb's joystick, fixed bottom left; hop and sit (or up and down) on the right. Phones only. */
.stick, .pads { display: none; }
.stick {
  position: fixed;
  left: calc(26px + env(safe-area-inset-left));
  bottom: calc(30px + env(safe-area-inset-bottom));
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.6);
  touch-action: none;
}
.stick.on { background: rgba(255, 255, 255, 0.3); }
.stick .knob { position: absolute; left: 37px; top: 37px; width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); pointer-events: none; }
.pads { position: fixed; right: calc(18px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); align-items: flex-end; gap: 12px; }
.pads button { width: 56px; height: 56px; border: 0; border-radius: 50%; background: var(--card); box-shadow: 0 4px 14px rgba(0, 30, 60, 0.22); font-size: 20px; line-height: 1; touch-action: none; }
.pads button.big { width: 76px; height: 76px; font-size: 30px; background: var(--sea); color: #fff; }
@media (pointer: coarse) {
  .stick { display: block; }
  body[data-mode='walk'] .pads.walk-only, body[data-mode='fly'] .pads.fly-only { display: flex; }
  .pads.fly-only { flex-direction: column; }
  .map-box { top: calc(58px + env(safe-area-inset-top)); bottom: auto; }
  #minimap { width: 112px; height: 112px; }
  .hint { bottom: calc(170px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); }
}
.hint.gone { opacity: 0; transition: opacity 0.6s; }

/* Rain: two layers of streaks sliding down, on their own layers. */
.rain { position: fixed; inset: -20% 0 0 0; pointer-events: none; overflow: hidden; }
.rain::before, .rain::after {
  content: '';
  position: absolute;
  inset: -100% 0 0 0;
  background-image: repeating-linear-gradient(100deg, transparent 0 22px, rgba(220, 235, 255, 0.35) 22px 23px, transparent 23px 47px);
  background-size: 47px 140px;
  will-change: transform;
  animation: rain 0.7s linear infinite;
}
.rain::after { background-size: 31px 90px; opacity: 0.6; animation-duration: 0.5s; }
@keyframes rain { to { transform: translateY(50%); } }

/* Choosing the animal. */
.animals { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.animal { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border: 2px solid transparent; border-radius: 14px; background: #eef3f8; font-size: 12px; line-height: 1.45; }
.animal[aria-checked='true'] { border-color: var(--sea); background: #fff; color: var(--sea); font-weight: 700; }
.face { width: 40px; height: 40px; border-radius: 50%; position: relative; }
.face::before, .face::after { content: ''; position: absolute; top: 15px; width: 5px; height: 5px; border-radius: 50%; background: #1d1d22; }
.face::before { left: 12px; }
.face::after { right: 12px; }
.face.cat { background: #f2a65a; }
.face.rabbit { background: #f4efe9; box-shadow: inset 0 0 0 2px #e6ddd2; }
.face.bear { background: #9a6a45; }
.face.duck { background: #ffe066; }
.face.dog { background: #e8d2b0; }
.shirts { display: flex; gap: 10px; justify-content: center; }
.shirt { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #c8d4df; }
.shirt[aria-checked='true'] { box-shadow: 0 0 0 3px var(--sea); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- the menu ---------- */
.menu-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 25, 40, 0.35); }
.menu {
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 34px rgba(0, 30, 60, 0.3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.4; }
.menu h3 { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.note { margin: 4px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.btn { padding: 9px 14px; border: 1px solid #d3dfe9; border-radius: 12px; background: #fff; font-weight: 700; line-height: 1.4; }
.btn.primary { border-color: var(--sea); background: var(--sea); color: #fff; }
.btn.big { padding: 12px; font-size: 16px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.link { padding: 0; border: 0; background: none; color: var(--sea); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 3px; border-radius: 12px; background: #e8eff5; }
.seg button { padding: 7px 2px; border: 0; border-radius: 9px; background: none; font-size: 13px; line-height: 1.4; }
.seg button[aria-checked='true'] { background: #fff; color: var(--sea); font-weight: 700; box-shadow: 0 1px 4px rgba(0, 30, 60, 0.15); }
.menu-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(60px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 12px; background: rgba(20, 35, 50, 0.9); color: #fff; font-size: 14px; line-height: 1.45; }
.update { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-radius: 14px; background: #fff; box-shadow: 0 6px 18px rgba(0, 30, 60, 0.25); font-size: 14px; white-space: nowrap; }

@media (max-width: 520px) {
  .hint { max-width: calc(100% - 150px); font-size: 11px; }
  .title-card b { font-size: 16px; }
}

/* ---------- quests, coins, what E does, talking, the wardrobe ---------- */
.quest-card { display: flex; flex-direction: column; max-width: 250px; padding: 6px 12px 7px; border-radius: 14px; background: rgba(255, 249, 230, 0.92); box-shadow: 0 4px 14px rgba(0, 30, 60, 0.15); font-size: 13px; line-height: 1.45; }
.quest-card small { color: #a0761b; font-weight: 700; font-size: 11px; }
.coins { display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border-radius: 999px; background: var(--card); box-shadow: 0 4px 14px rgba(0, 30, 60, 0.15); font-weight: 700; font-size: 14px; line-height: 1.4; }
.prompt { position: fixed; left: 50%; bottom: calc(52px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: rgba(20, 40, 60, 0.75); color: #fff; font-weight: 700; font-size: 14px; line-height: 1.45; pointer-events: none; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
.prompt kbd { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: #fff; color: var(--ink); font: 700 13px var(--text); }
body:not([data-screen='world']) .prompt { display: none; }
.fade { position: fixed; inset: 0; background: #000; opacity: 0; transition: opacity 0.22s; pointer-events: none; z-index: 4; }
.fade.on { opacity: 1; }
.talk { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(440px, calc(100% - 24px)); padding: 14px; border-radius: 18px; background: rgba(255, 255, 255, 0.97); box-shadow: 0 10px 30px rgba(0, 30, 60, 0.3); z-index: 3; }
.talk p { margin: 0 0 10px; font-size: 15px; line-height: 1.55; }
.talk-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.talk-buttons .btn { flex: 1 1 auto; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border: 2px solid transparent; border-radius: 12px; background: #eef3f8; font-size: 12px; line-height: 1.45; }
.item.on { border-color: var(--sea); background: #fff; color: var(--sea); font-weight: 700; }
.item small { color: #a0761b; font-weight: 700; }
.item-icon { font-size: 22px; line-height: 1.2; }
.menu h2 .coins { margin-left: 8px; height: 28px; font-size: 13px; box-shadow: none; background: #fff6dc; }
@media (pointer: coarse) {
  .prompt { bottom: calc(176px + env(safe-area-inset-bottom)); }
  .hud-btn { width: 40px; height: 40px; font-size: 18px; }
  .coins { height: 32px; padding: 0 9px; font-size: 13px; }
  .quest-card { max-width: 200px; font-size: 12px; }
  .title-card { display: none; }
}
