:root {
  --sky: #3e5466;
  --sky-deep: #34495a;
  --panel: rgba(28, 38, 48, .9);
  --line: rgba(255, 255, 255, .08);
  --text: #e9eef2;
  --muted: #8fa3b3;
  --accent: #ffd25a;
  --alert: #ff6b6b;
  --work: #f2b04c;
  --think: #6fb6ff;
  --ok: #62d394;
  --pixel: 'Press Start 2P', monospace;
  --ui: 'Pixelify Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, var(--sky) 0%, var(--sky-deep) 100%);
  color: var(--text);
  font: 15px/1.35 var(--ui);
}

#office {
  position: fixed;
  inset: 0;
}

.world { overflow: hidden; }

.stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  z-index: 1;
}

.stage > * { position: absolute; left: 0; top: 0; }
.stage canvas { image-rendering: pixelated; }
.stage .bg { z-index: 0; }

/* ---------- Pokémon ---------- */
.actor { width: 0; height: 0; will-change: transform; }

.actor .inner {
  position: absolute;
  bottom: 0;
  left: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.actor .shadow {
  position: absolute;
  left: -16px;
  top: -5px;
  width: 32px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .2);
}

.sprite { display: block; image-rendering: pixelated; min-width: 20px; }

.tag {
  position: absolute;
  top: 6px;
  left: 0;
  transform: translateX(-50%);
  font: 9px var(--ui);
  color: #fff;
  background: rgba(28, 38, 48, .85);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
}

.bubble {
  position: relative;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 13px/1.2 var(--ui);
  color: #1e2833;
  background: #fff;
  border: 2px solid #1e2833;
  border-radius: 4px;
  padding: 3px 8px;
  margin-bottom: 7px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 8px;
  height: 8px;
  background: #fff;
  border-right: 2px solid #1e2833;
  border-bottom: 2px solid #1e2833;
  transform: translateX(-50%) rotate(45deg);
}
.bubble[hidden] { display: none; }

.actor[data-state='waiting'] .bubble { background: #ffe27a; animation: nudge 1.2s steps(2) infinite; }
.actor[data-state='waiting'] .bubble::after { background: #ffe27a; }
.actor.offline .tag { opacity: .7; }

.helper .bubble { font-size: 11px; max-width: 130px; }
.helper .tag { font-size: 8px; }
.nurse .bubble, .nurse .tag { display: none; }

.poof-in { animation: poof-in .45s steps(5); }
.poof-out { animation: poof-out .45s steps(5) forwards; }

@keyframes poof-in { from { opacity: 0; filter: brightness(3); } }
@keyframes poof-out { to { opacity: 0; filter: brightness(3); } }
@keyframes nudge { 50% { transform: translateY(-3px); } }

/* ---------- panels ---------- */
.panel {
  position: fixed;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  display: flex;
  flex-direction: column;
  max-height: 40vh;
}

.panel h2 {
  margin: 0;
  padding: 10px 12px 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font: 600 12px var(--ui);
  letter-spacing: 1.5px;
  color: var(--muted);
  text-transform: uppercase;
}
.panel h2 span { text-transform: none; letter-spacing: 0; font-weight: 400; }

.panel ul { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; }

#team-panel { left: 16px; bottom: 16px; width: 300px; }
#feed-panel { right: 16px; bottom: 16px; width: 340px; }
#feed:empty::after { content: 'Belum ada aktiviti.'; display: block; padding: 4px; color: var(--muted); font-size: 13px; }

#team li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 5px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .04);
}
#team li.offline { opacity: .6; }
#team img { width: 34px; height: 34px; image-rendering: pixelated; object-fit: contain; }
#team .row { display: flex; align-items: center; gap: 6px; }
#team b { font-weight: 600; font-size: 14px; }
#team .chip { font-size: 11px; color: var(--muted); background: rgba(255, 255, 255, .08); padding: 0 5px; border-radius: 2px; }
#team .lv, #team .ago { margin-left: auto; color: var(--muted); font-size: 12px; }
#team .pill { font-size: 11px; padding: 0 6px; border-radius: 2px; margin-top: 2px; background: rgba(255, 255, 255, .1); color: var(--muted); }
#team li[data-state='waiting'] .pill { background: rgba(255, 107, 107, .2); color: var(--alert); }
#team li[data-state='thinking'] .pill { background: rgba(111, 182, 255, .18); color: var(--think); }
#team li:is([data-state='reading'], [data-state='editing'], [data-state='running'], [data-state='web'], [data-state='delegating']) .pill { background: rgba(242, 176, 76, .18); color: var(--work); }
#team li[data-state='done'] .pill { background: rgba(98, 211, 148, .16); color: var(--ok); }
#team p { margin: 1px 0 0; font-size: 12px; color: #c9d4dc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#feed li { padding: 4px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
#feed time { color: var(--muted); margin-right: 6px; font-size: 12px; }
#feed b { color: var(--accent); font-weight: 600; }
#feed .where { color: var(--muted); }
#feed li[data-state='waiting'] .what { color: var(--alert); }
#feed li[data-state='done'] .what { color: var(--ok); }

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  top: 14px;
  right: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar h1 { margin: 0 auto 0 0; font: 12px var(--pixel); color: var(--accent); text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

button, select, .btn {
  font: 14px var(--ui);
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.on { background: #5a4d2a; border-color: var(--accent); }
button.rec-on { border-color: var(--alert); color: var(--alert); }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  body { overflow: auto; }
  #office { position: relative; height: 62vh; }
  .panel { position: static; width: auto !important; margin: 12px; max-height: none; }
  .topbar h1 { display: none; }
  .topbar { flex-wrap: wrap; justify-content: flex-end; }
}
