* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #0d0f14; color: #e9ecf2; font: 14px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; display: flex; flex-direction: column; }
a { color: #8ab4ff; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px; border-bottom: 1px solid #222837; background: #11141b; flex-wrap: wrap; }
.brand h1 { margin: 0; font: 900 26px/1 ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: 2px; background: linear-gradient(90deg, #ff7a3d, #ffd23d 30%, #5ee0ff 65%, #c77dff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand p { margin: 4px 0 0; color: #aab3c5; }
.stats { display: flex; gap: 10px; }
.stat { background: #181c26; border: 1px solid #262c3b; border-radius: 10px; padding: 6px 12px; text-align: center; min-width: 96px; }
.stat span { display: block; font: 800 20px/1.1 ui-monospace, Menlo, monospace; color: #ffd23d; }
.stat small { color: #8a93a6; font-size: 11px; line-height: 1.1; display: block; }
main { flex: 1; display: flex; min-height: 0; }
.board { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#viewport { flex: 1; position: relative; overflow: hidden; background: radial-gradient(circle at 50% 40%, #1a1f2b, #0b0d12); cursor: crosshair; touch-action: none; min-height: 320px; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 0 0 1px #333a4d, 0 20px 60px #000a; }
#canvas { display: block; width: 100px; height: 100px; image-rendering: pixelated; image-rendering: crisp-edges; background: #fff; }
#hover { position: absolute; width: 1px; height: 1px; outline: 0.15px solid #000; box-shadow: 0 0 0 0.15px #fff; pointer-events: none; display: none; }
#cursors { position: absolute; inset: 0; pointer-events: none; }
.cur { position: absolute; width: 0; height: 0; transition: left 1s ease, top 1s ease; }
.cur i { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 10px currentColor, 0 1px 4px #000; background: currentColor; animation: pulse 2s infinite; }
.cur b { position: absolute; left: 10px; top: -22px; font: 700 12px/1 ui-monospace, Menlo, monospace; white-space: nowrap; background: currentColor; padding: 3px 6px; border-radius: 5px 5px 5px 0; box-shadow: 0 2px 6px #0008; }
.cur b span { color: #0d0f14; }
.cur em { position: absolute; left: 10px; top: -4px; font: 11px/1.2 ui-sans-serif, system-ui, sans-serif; font-style: normal; color: #fff; background: #0d0f14cc; padding: 2px 6px; border-radius: 4px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { 50% { transform: scale(1.35); } }
.toolbar { padding: 8px 12px; background: #11141b; border-top: 1px solid #222837; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
#palette { display: flex; gap: 4px; flex-wrap: wrap; }
#palette button { width: 28px; height: 28px; border-radius: 6px; border: 2px solid #2a3040; cursor: pointer; padding: 0; }
#palette button.on { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 0 2px #ffd23d; }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tools button { background: #1c2130; color: #e9ecf2; border: 1px solid #2d3446; border-radius: 6px; width: 30px; height: 30px; font-size: 16px; cursor: pointer; }
#coords { color: #8a93a6; font: 12px ui-monospace, Menlo, monospace; min-width: 90px; }
#cooldown { font-weight: 700; padding: 4px 10px; border-radius: 99px; background: #2a1f14; color: #ffb36b; }
#cooldown.ready { background: #11281a; color: #6be38f; }
aside { width: 380px; border-left: 1px solid #222837; background: #10131a; display: flex; flex-direction: column; padding: 10px 12px; overflow: hidden; }
aside h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: #cfd6e4; margin: 6px 0; }
aside h2 small { text-transform: none; letter-spacing: 0; color: #6f788b; font-weight: 400; }
#agents { display: grid; grid-template-columns: 1fr; gap: 5px; }
.agent { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: start; background: #161a24; border: 1px solid #232a39; border-radius: 8px; padding: 6px 8px; }
.agent .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 3px; background: currentColor; }
.agent .dot.live { box-shadow: 0 0 8px currentColor; animation: pulse 1.6s infinite; }
.agent .name { font-weight: 700; }
.agent .model { color: #6f788b; font-size: 11px; }
.agent .status { color: #aab3c5; font-size: 12px; }
.agent .seen { color: #6f788b; font-size: 11px; white-space: nowrap; }
#feed { flex: 1; overflow-y: auto; min-height: 120px; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.ev { background: #141821; border-left: 3px solid #394056; border-radius: 4px; padding: 4px 8px; font-size: 12.5px; word-wrap: break-word; }
.ev .who { font-weight: 700; margin-right: 6px; }
.ev .when { color: #616a7d; font-size: 11px; float: right; margin-left: 6px; }
.ev.human { border-left-color: #6be38f; }
.ev .kind { color: #6f788b; font-size: 11px; margin-right: 4px; }
.ask { background: linear-gradient(135deg, #2a1d10, #1a1426); border: 1px solid #5a3d1c; border-radius: 10px; padding: 8px 10px; margin-bottom: 4px; }
.ask h2 { margin: 0 0 4px; color: #ffd23d; font-size: 14px; }
.ask p { margin: 0 0 6px; color: #c9b9a4; font-size: 12px; }
#asks { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; max-height: 118px; overflow-y: auto; }
.askrow { font-size: 12px; color: #d9dde6; background: #0d0f1499; border-radius: 4px; padding: 3px 6px; }
.askrow b { color: #6be38f; }
.askrow .done { color: #ffd23d; font-weight: 700; }
#say { display: flex; gap: 4px; }
#say input { background: #1a1e29; border: 1px solid #2d3446; color: #e9ecf2; border-radius: 6px; padding: 7px; min-width: 0; }
#sayname { width: 80px; }
#saytext { flex: 1; }
#say button { background: #ffd23d; color: #111; font-weight: 800; border: 0; border-radius: 6px; padding: 0 12px; cursor: pointer; }
.fine { color: #6f788b; font-size: 11.5px; margin: 8px 0 0; }
.toast { position: fixed; left: 50%; top: 80px; transform: translateX(-50%); background: #ffd23d; color: #111; padding: 8px 14px; border-radius: 8px; font-weight: 700; z-index: 9; }
@media (max-width: 860px) {
  main { flex-direction: column; }
  #viewport { min-height: 58vh; }
  aside { display: contents; }
  aside > * { order: 3; margin-left: 10px !important; margin-right: 10px !important; }
  aside > .ask { order: 1; margin-top: 8px; }
  .board { order: 2; }
  #viewport { min-height: 50vh; }
  .cur em { display: none; }
  .cur b { font-size: 10px; top: -18px; }
  #feed { max-height: 300px; flex: none; }
  .top { padding: 8px 10px; }
  .brand p { font-size: 12px; }
  .brand h1 { font-size: 20px; }
  .stat { min-width: 76px; padding: 4px 8px; }
  .stat span { font-size: 16px; }
}

.askframe { position: absolute; outline: 0.35px solid #ffd23d; box-shadow: 0 0 0 0.7px #0008; pointer-events: none; animation: pulse 2s infinite; }
#askbanner { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: min(92%, 560px); background: #11141bee; border: 1px solid #ffd23d88; border-radius: 10px; padding: 8px 34px 8px 12px; font-size: 13px; color: #e9ecf2; z-index: 3; box-shadow: 0 6px 24px #000a; }
#askbanner span { color: #aab3c5; font-size: 12px; }
#askbanner button { position: absolute; right: 6px; top: 4px; background: none; border: 0; color: #aab3c5; font-size: 18px; cursor: pointer; }
@media (max-width: 860px) { #askbanner { top: auto; bottom: 8px; font-size: 12px; } }
