:root {
  --ink: #102028;
  --ink-soft: #334155;
  --paper: #fffaf3;
  --sky-top: #8ecdf2;
  --sky-mid: #d7f3fb;
  --line: #1f2937;
  --working: #15803d;
  --working-bg: #dcfce7;
  --waiting: #c2410c;
  --waiting-bg: #ffedd5;
  --idle: #475569;
  --idle-bg: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 50, 70, 0.12);
  font-family: "Segoe UI", "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top), var(--sky-mid) 42%, #c6ebc0);
  min-height: 100%;
}

.sky { position: relative; z-index: 1; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  z-index: 50;
  border-radius: 8px;
}
.skip:focus { top: 12px; }

.sun-blob {
  position: fixed;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff4c2 0%, #ffe08a 55%, rgba(255, 224, 138, 0) 70%);
  top: 18px;
  right: 8%;
  z-index: 0;
  pointer-events: none;
}

.html-cloud {
  position: fixed;
  background: #fff;
  border-radius: 40px;
  opacity: 0.9;
  z-index: 0;
  pointer-events: none;
  animation: drift 46s ease-in-out infinite alternate;
}
.html-cloud::before,
.html-cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.c1 { width: 90px; height: 28px; top: 46px; left: 6%; }
.c1::before { width: 36px; height: 36px; top: -18px; left: 12px; }
.c1::after { width: 28px; height: 28px; top: -12px; left: 40px; }
.c2 { width: 70px; height: 22px; top: 90px; left: 28%; animation-duration: 60s; }
.c2::before { width: 26px; height: 26px; top: -14px; left: 10px; }
.c2::after { width: 22px; height: 22px; top: -10px; left: 32px; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(36px); }
}

.top, .layout, .foot, .error, .demo-banner { position: relative; z-index: 1; }

.top {
  max-width: 1180px;
  margin: 16px auto 0;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: #fffaf3;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.logo { width: 48px; height: 48px; flex: none; }

h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tagline {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e11d48;
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  border-radius: 999px;
  padding: 4px 8px 4px 7px;
  vertical-align: middle;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.75); }
}

.top-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.updated { margin: 0; color: var(--ink-soft); font-size: 0.9rem; font-weight: 650; }

.demo-btn, .zoom button, .close, .who {
  font: inherit;
  font-weight: 750;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  cursor: pointer;
}

.demo-btn {
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
}
.demo-btn[aria-pressed="true"] {
  background: #ffedd5;
  border-color: var(--waiting);
  color: #9a3412;
}

.error, .demo-banner {
  max-width: 1180px;
  margin: 10px auto 0;
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 650;
}
.error { background: #fee2e2; color: #7f1d1d; }
.demo-banner { background: #ffedd5; color: #9a3412; }

.layout {
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.stage-wrap, .side, .roster-wrap, .panel { min-width: 0; max-width: 100%; }
.side { display: flex; flex-direction: column; gap: 12px; }

.roster-wrap, .panel {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.roster-wrap h2, .panel h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.roster {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.who {
  border-radius: 14px;
  padding: 4px 2px 6px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  position: relative;
}
.who .mochi { height: 54px; width: auto; display: block; }
.who .who-name { font-size: 11px; font-weight: 750; color: var(--ink); }
.who .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  box-shadow: 0 0 0 2px #fff;
}

.stage {
  position: relative;
  height: min(78vh, 820px);
  min-height: 560px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 0 3px rgba(255, 255, 255, 0.7);
  background: #b9e4f8;
}

.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(#9ed4f6, #e8f7ff 62%, #d7f3ea);
  touch-action: pan-y;
  cursor: grab;
}
.map-cloud {
  position: absolute;
  z-index: 0;
  opacity: 0.92;
}
.world { z-index: 1; }
.demo-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff7ed;
  color: #9a3412;
  border: 2px solid #c2410c;
  border-radius: 999px;
  padding: 3px 4px 3px 12px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 3px 0 rgba(194, 65, 12, 0.16);
}
.demo-badge button {
  border-radius: 999px;
  background: #c2410c;
  color: #fff;
  min-height: 32px;
  padding: 4px 10px;
  font-weight: 800;
}
.scene {
  position: absolute;
  left: 0;
  top: 0;
  width: 1600px;
  height: 900px;
}
.scene .island {
  position: absolute;
  left: 0;
  top: 0;
  width: 1600px;
  height: 900px;
  z-index: 1;
  pointer-events: none;
  user-select: none;
}
.prop {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.prop img {
  position: absolute;
  left: 0;
  bottom: 0;
  height: auto;
  transform: translateX(-50%);
  display: block;
  pointer-events: none;
  user-select: none;
}
.prop img.w200 { width: 200px; }
.prop img.w214 { width: 214px; }
.prop img.w250 { width: 250px; }
.prop img.w108 { width: 108px; }
.prop img.w78 { width: 78px; }
.prop img.w56 { width: 56px; }
.prop img.w96 { width: 96px; }
.prop img.w54 { width: 54px; }
.prop img.w50 { width: 50px; }
.prop .sprout { transform-origin: center bottom; animation: sprout 0.7s ease-out both; }
@keyframes sprout {
  0% { transform: translateX(-50%) scale(0.08); }
  62% { transform: translateX(-50%) scale(1.08); }
  100% { transform: translateX(-50%) scale(1); }
}
.bit {
  position: absolute;
  width: 7px;
  height: 7px;
  z-index: 980;
  pointer-events: none;
}
.viewport.is-zoomed { touch-action: none; }
.viewport.is-zoomed:active { cursor: grabbing; }

.world { position: relative; transform-origin: 0 0; will-change: transform; }

.actors {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 2;
  pointer-events: none;
}
.actor {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.actor .shadow {
  position: absolute;
  left: 0;
  top: 2px;
  width: 42px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 48, 28, 0.34);
  filter: blur(1.4px);
}
.actor .flip,
.actor .motion {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}
.actor .sprite {
  position: absolute;
  left: 0;
  bottom: 2px;
  height: 100px;
  width: auto;
  transform: translateX(-50%);
  display: block;
  pointer-events: none;
  user-select: none;
}
.actor .ring {
  position: absolute;
  left: 0;
  top: 2px;
  width: 50px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid #f97316;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.labels, .hits, #leaders { position: absolute; inset: 0; pointer-events: none; }
.hits { z-index: 3; }
.labels { z-index: 2; }
#leaders { z-index: 1; width: 100%; height: 100%; overflow: visible; }

.callout-name { display: none; }
.bubble.is-docked .callout-name,
.chip.is-docked .callout-name {
  display: block;
  margin-bottom: 1px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #334155;
}
.bubble.is-docked,
.chip.is-docked {
  max-width: 148px;
  padding: 4px 6px 5px;
  font-size: 11px;
  text-align: left;
  transform: none;
  box-shadow: 0 3px 0 rgba(15, 23, 42, 0.14);
}
.bubble.is-docked::after { display: none; }
.trophy-label.is-docked { transform: none; }

.hit-btn {
  position: absolute;
  width: 64px;
  height: 86px;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
}
.hit-btn:focus-visible { outline: 3px solid var(--line); outline-offset: 2px; }

.zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zoom button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: 0 4px 0 rgba(15, 23, 42, 0.12);
}
#zoom-fit { font-size: 0.78rem; }

.loading {
  position: absolute;
  left: 14px;
  bottom: 14px;
  margin: 0;
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 750;
  z-index: 4;
}

.pill, .bubble, .chip, .namepill, .trophy-label {
  position: absolute;
  color: var(--ink);
  font-weight: 750;
  line-height: 1.25;
  pointer-events: none;
}

.trophy-label, .namepill {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 2px 0 rgba(15, 23, 42, 0.12);
  white-space: nowrap;
}
.sign-anchor {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 860;
  pointer-events: none;
}
.project-sign {
  position: absolute;
  left: 0;
  bottom: 6px;
  transform: translateX(-50%);
  transform-origin: center bottom;
  white-space: nowrap;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: #4a2a12;
  background: linear-gradient(180deg, #fff6e4 0%, #f6d7a2 58%, #e8b56a 100%);
  border: 2px solid #7a4b28;
  border-radius: 9px;
  padding: 3px 9px 4px;
  box-shadow: 0 3px 0 #c4894a, inset 0 1px 0 rgba(255, 255, 255, 0.75);
}
.project-sign::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 5px;
  height: 8px;
  transform: translateX(-50%);
  background: #c4894a;
  border-radius: 0 0 2px 2px;
}
.trophy-label {
  font-size: 11px;
  padding: 2px 7px;
  transform: translate(-50%, 2px);
  color: #14532d;
  border-color: #166534;
}
.namepill {
  font-size: 12px;
  padding: 2px 7px 2px 6px;
  transform: translate(-50%, 6px);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bubble {
  width: max-content;
  max-width: 168px;
  background: #fff;
  color: #9a3412;
  border: 2px solid #c2410c;
  border-radius: 14px;
  padding: 6px 8px;
  font-size: 12px;
  text-align: center;
  transform: translate(-50%, -118%);
  box-shadow: 0 6px 0 rgba(194, 65, 12, 0.12);
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-right: 2px solid #c2410c;
  border-bottom: 2px solid #c2410c;
  transform: translateX(-50%) rotate(45deg);
}

.chip {
  width: max-content;
  max-width: 160px;
  background: #fff;
  color: #14532d;
  border: 2px solid #15803d;
  border-radius: 14px;
  padding: 5px 8px 6px;
  font-size: 12px;
  text-align: center;
  transform: translate(-50%, -120%);
  box-shadow: 0 6px 0 rgba(21, 128, 61, 0.12);
}
.chip .bar { margin-top: 4px; }

.bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: #16a34a;
  border-radius: 99px;
  transition: width 0.45s ease;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.dot.working { background: #16a34a; }
.dot.waiting { background: #ea580c; }
.dot.idle { background: #94a3b8; }

#news { list-style: none; margin: 0; padding: 0; }
#news li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-top: 1px solid #e2e8f0;
}
#news li:first-child { border-top: 0; padding-top: 2px; }
.news-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  flex: none;
  display: grid;
  place-items: center;
}
.news-mark svg { width: 16px; height: 16px; display: block; }
.news-copy { min-width: 0; }
.news-copy p { margin: 0; color: #1e293b; font-size: 0.92rem; font-weight: 650; }
.news-copy time { color: #475569; font-size: 0.78rem; font-weight: 650; }

.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
}
.legend-icon { width: 16px; height: 16px; flex: none; }

.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px 22px;
  color: #1e293b;
  font-size: 0.85rem;
}
.foot code, .demo-banner code {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.84em;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 40, 50, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.sheet {
  width: min(440px, 100%);
  background: #fff;
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  padding: 18px 18px 22px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
  max-height: min(88vh, 640px);
  overflow: auto;
}
.sheet h2 { margin: 0; font-size: 1.5rem; }
.role { margin: 2px 0 8px; color: var(--ink-soft); font-weight: 700; }
.state-pill {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.85rem;
}
.state-pill.working { background: var(--working-bg); color: #14532d; }
.state-pill.waiting { background: var(--waiting-bg); color: #9a3412; }
.state-pill.idle { background: var(--idle-bg); color: #1e293b; }
.meta { margin: 0 0 6px; font-weight: 750; }
.detail { margin: 0 0 8px; font-size: 1.02rem; }
.card-avatar .mochi { height: 132px; width: auto; display: block; }
.card-bar-wrap { margin-top: 8px; }
.progress-label { margin: 6px 0 0; font-weight: 750; color: #14532d; }
.close {
  float: right;
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 14px;
}

button:focus-visible, a:focus-visible {
  outline: 3px solid #0f172a;
  outline-offset: 2px;
}

/* Mochi pose motion. Walking wins over work/wait/rest while a bot is en route. */
.actor.at-work .motion { animation: work-tap 0.48s ease-in-out infinite; }
.actor.is-waiting .motion { animation: little-hop 3.5s ease-in-out infinite; }
.actor.is-idle .motion { animation: breathe 3.2s ease-in-out infinite; }
.actor.is-walking .motion { animation: walk-bob 0.36s ease-in-out infinite; }
@keyframes walk-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
@keyframes work-tap {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  38% { transform: translateY(3px) scale(1.06, 0.9); }
  70% { transform: translateY(-8px) scale(0.96, 1.07); }
}
@keyframes little-hop {
  0%, 72%, 100% { transform: translateY(0); }
  80% { transform: translateY(-12px); }
  88% { transform: translateY(0); }
  93% { transform: translateY(-4px); }
  97% { transform: translateY(0); }
}
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.04, 0.96); }
}
.actor.is-waiting .ring { animation: ping 1.3s ease-out infinite; }
@keyframes ping {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.62); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.7); }
}
.zzz, .steam { display: none; }
.actor.is-idle .zzz { display: block; }
.actor.sips.is-idle .zzz { display: none; }
.actor.sips.is-idle .steam { display: block; }
.zzz {
  position: absolute;
  left: 18px;
  bottom: 78px;
  width: 28px;
  height: 36px;
  pointer-events: none;
}
.zzz i {
  position: absolute;
  font-style: normal;
  font-weight: 800;
  color: #334155;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
  opacity: 0;
  animation: zfloat 2.4s ease-in-out infinite;
}
.zzz i:nth-child(1) { left: 0; bottom: 0; font-size: 13px; }
.zzz i:nth-child(2) { left: 10px; bottom: 12px; font-size: 15px; animation-delay: 0.35s; }
.zzz i:nth-child(3) { left: 20px; bottom: 24px; font-size: 18px; animation-delay: 0.7s; }
@keyframes zfloat {
  0% { opacity: 0; transform: translateY(4px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}
.steam {
  position: absolute;
  left: 20px;
  bottom: 58px;
  width: 10px;
  height: 18px;
}
.steam::before,
.steam::after {
  content: "";
  position: absolute;
  left: 0;
  width: 8px;
  height: 8px;
  border: 2px solid transparent;
  border-top-color: #64748b;
  border-radius: 50%;
  animation: steam 1.6s ease-in-out infinite;
}
.steam::after { left: 6px; animation-delay: 0.45s; }
@keyframes steam {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(-6px); }
}
.flag {
  transform-box: fill-box;
  transform-origin: left center;
  animation: wave 1.15s ease-in-out infinite;
}
@keyframes wave {
  0%, 100% { transform: skewX(0deg); }
  50% { transform: skewX(-14deg); }
}
.cloud-bit { animation: cloudDrift 28s ease-in-out infinite alternate; }
@keyframes cloudDrift {
  to { transform: translate(40px, 4px); }
}
.butter { animation: flutter 8s ease-in-out infinite; }
@keyframes flutter {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(36px, -16px); }
}
.wing { transform-box: fill-box; transform-origin: center; animation: flap 0.35s ease-in-out infinite; }
@keyframes flap {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(0.35); }
}
#scenery polygon { vector-effect: non-scaling-stroke; }

@media (min-width: 861px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; }
}

.world svg { display: block; font-family: inherit; }
.labels.is-compact .namepill { font-size: 10px; padding: 1px 5px; }

@media (max-width: 860px) {
  .top { margin: 10px 10px 0; flex-direction: column; align-items: stretch; }
  .top-meta { flex-direction: row; justify-content: space-between; align-items: center; }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 10px;
  }
  .stage { height: 68vh; min-height: 420px; border-radius: 22px; }
  .roster {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 2px;
    width: 100%;
    min-width: 0;
  }
  .who { flex: 0 0 76px; }
  .trophy-label, .namepill { font-size: 11px; }
  .bubble, .chip { max-width: 136px; font-size: 11px; }
  h1 { font-size: 1.3rem; }
  .tagline { font-size: 0.88rem; }
}

@media (prefers-reduced-motion: reduce) {
  .motion, .ring, .zzz i, .steam::before, .steam::after, .flag, .sprout, .bit,
  .live-dot, .html-cloud, .cloud-bit, .butter, .wing {
    animation: none !important;
  }
  .actor.is-waiting .ring { opacity: 1; }
  .actor.is-idle .zzz i:first-child { opacity: 1; }
}
