*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;background:#040c12;color:#d8f0ea;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;overflow:hidden;-webkit-tap-highlight-color:transparent;user-select:none}
#app{display:grid;grid-template-rows:auto 1fr auto;grid-template-columns:1fr 280px;height:100%;max-height:100dvh}
#top{grid-column:1/-1;display:flex;align-items:center;gap:8px;padding:6px 10px;background:linear-gradient(180deg,#0a2430,#061820);border-bottom:2px solid #1a6a6e;flex-wrap:wrap}
.brand{display:flex;flex-direction:column;line-height:1.05;min-width:110px}
.brand b{font-size:13px;letter-spacing:.08em;color:#7ef0d8}
.brand span{font-size:10px;color:#f0a040;letter-spacing:.04em}
#hud{display:flex;flex-wrap:wrap;gap:6px;flex:1}
.h{background:#0c2a34;border:1px solid #1e5a62;border-radius:6px;padding:3px 8px;font-size:12px;color:#9ec}
.h b{color:#fff;font-size:13px}.h i{font-style:normal;color:#7a9}
.tr{display:flex;gap:4px}
.hb{background:#123843;color:#dff;border:1px solid #2a7a82;border-radius:6px;padding:5px 9px;cursor:pointer;font-size:13px;text-decoration:none}
.hb:hover,.hb:active{background:#1a5560}
#stageWrap{position:relative;overflow:hidden;background:#02080c;min-height:0}
#cv{display:block;width:100%;height:100%;touch-action:none;cursor:grab}
#cv.drag{cursor:grabbing}
#bubbles{pointer-events:none;position:absolute;inset:0;overflow:hidden}
.bubble{position:absolute;background:rgba(6,30,40,.92);border:1px solid #3ad;color:#dff;font-size:11px;padding:4px 8px;border-radius:10px;max-width:160px;transform:translate(-50%,-120%);animation:pop 3.2s forwards;z-index:5}
@keyframes pop{0%{opacity:0;transform:translate(-50%,-80%)}10%{opacity:1}80%{opacity:1}100%{opacity:0;transform:translate(-50%,-160%)}}
#toast{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);background:rgba(10,40,50,.95);border:1px solid #f0a040;color:#ffe8c0;padding:6px 14px;border-radius:8px;font-size:12px;opacity:0;pointer-events:none;transition:opacity .2s;z-index:6;max-width:90%;text-align:center}
#toast.on{opacity:1}
#side{background:#071820;border-left:2px solid #1a6a6e;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.tabs{display:flex;border-bottom:1px solid #1a4a52}
.tab{flex:1;background:transparent;border:0;color:#8ab;padding:8px 4px;font-size:11px;font-weight:700;letter-spacing:.04em;cursor:pointer}
.tab.on{color:#7ef0d8;box-shadow:inset 0 -2px 0 #7ef0d8;background:#0a2430}
.panel{flex:1;overflow:auto;padding:8px;font-size:12px;-webkit-overflow-scrolling:touch}
.cardb{background:#0c2430;border:1px solid #1e5a62;border-radius:8px;padding:8px;margin-bottom:8px}
.cardb h4{color:#7ef0d8;font-size:12px;margin-bottom:4px}
.cardb .meta{color:#8ab;font-size:10px;margin-bottom:6px}
.cardb .row{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.btn{background:#174850;color:#dff;border:1px solid #2a8;border-radius:6px;padding:6px 10px;cursor:pointer;font-size:12px}
.btn:hover{background:#1f6070}
.btn.good{background:#1a5a38;border-color:#3a8}.btn.warn{background:#5a3810;border-color:#c80}.btn.bad{background:#5a1820;border-color:#c44}
.btn:disabled{opacity:.4;cursor:default}
.crewchip{display:flex;gap:8px;align-items:center;padding:6px;border-radius:8px;background:#0a2030;border:1px solid #1a4a52;margin-bottom:6px;cursor:pointer}
.crewchip.sel{border-color:#7ef0d8;box-shadow:0 0 0 1px #7ef0d8}
.crewchip img{width:40px;height:40px;border-radius:50%;object-fit:cover;background:#123;border:2px solid #2a6}
.crewchip .nm{font-weight:700;color:#dff;font-size:12px}
.crewchip .st{font-size:10px;color:#8ab}
.bar{height:6px;background:#123;border-radius:3px;overflow:hidden;margin-top:3px}
.bar>i{display:block;height:100%;background:linear-gradient(90deg,#2a8,#7ef0d8)}
.bar.hp>i{background:linear-gradient(90deg,#a32,#f64)}
.bar.ha>i{background:linear-gradient(90deg,#468,#9cf)}
#foot{grid-column:1/-1;display:flex;justify-content:space-between;gap:10px;align-items:center;padding:4px 10px;background:#041018;border-top:1px solid #1a4a52;font-size:11px;color:#8ab;flex-wrap:wrap}
#logLine{color:#cde;flex:1}
.fine{opacity:.7;font-size:10px}
#start{position:fixed;inset:0;background:rgba(2,8,12,.92);display:flex;align-items:center;justify-content:center;z-index:20;padding:16px}
#start .card{background:linear-gradient(180deg,#0c2834,#061820);border:2px solid #1a8a8e;border-radius:14px;padding:18px;max-width:420px;width:100%;text-align:center;box-shadow:0 0 40px #0a405088}
#start .hero{width:100%;max-height:160px;object-fit:cover;border-radius:8px;margin-bottom:10px;border:1px solid #1a5}
#start h1{font-size:22px;letter-spacing:.12em;color:#7ef0d8;line-height:1.1}
#start h1 span{display:block;font-size:28px;color:#f0a040;letter-spacing:.18em}
#start .sub{color:#8ab;font-size:12px;margin:6px 0 10px}
#start .blurb{font-size:13px;color:#cde;margin-bottom:14px;line-height:1.35}
#start .go{background:linear-gradient(180deg,#2a9,#176);color:#021;border:0;border-radius:10px;padding:12px 22px;font-weight:800;font-size:15px;letter-spacing:.06em;cursor:pointer;width:100%}
#start .go.blink{animation:blink 1.4s infinite}
@keyframes blink{0%,100%{filter:brightness(1)}50%{filter:brightness(1.25)}}
#start .hint{margin-top:10px;font-size:11px;color:#6a8}
#modal{position:fixed;inset:0;background:rgba(0,0,0,.72);display:flex;align-items:center;justify-content:center;z-index:30;padding:14px}
#modal[hidden]{display:none}
.mbox{background:#0c2430;border:2px solid #2a8;border-radius:12px;padding:16px;max-width:440px;width:100%;max-height:90vh;overflow:auto;color:#dff}
.mbox h2{color:#7ef0d8;font-size:16px;margin-bottom:8px}
.mbox p{font-size:13px;line-height:1.4;margin-bottom:8px;color:#cde}
.mbox .btns{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.mbox img.av{width:72px;height:72px;border-radius:50%;float:right;margin:0 0 8px 8px;border:2px solid #3ad;object-fit:cover}
.incident{border-color:#c44!important;animation:pulse 1s infinite}
@keyframes pulse{0%,100%{box-shadow:0 0 0 0 #c440}50%{box-shadow:0 0 12px 2px #c488}}

/* Mobile / embed */
@media (max-width:820px){
  #app{grid-template-columns:1fr;grid-template-rows:auto 1fr 200px auto}
  #side{border-left:0;border-top:2px solid #1a6a6e}
  .brand span{display:none}
  #hud .h i{display:none}
}
body.embed #app{grid-template-columns:1fr;grid-template-rows:auto 1fr 150px auto;font-size:12px}
body.embed #side{max-height:150px}
body.embed .brand span,.body.embed .fine{display:none}
body.embed #start .hero,#start .blurb{display:none}
body.embed #top{padding:4px 6px}
body.embed .h{padding:2px 5px;font-size:11px}
@media (max-width:400px){
  #hud .h:nth-child(n+5){display:none}
  .tab{font-size:10px;padding:6px 2px}
}
