/* Jogo */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
#ui > *, .screen > * { pointer-events: auto; }
.screen { position: absolute; inset: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); pointer-events: none; }
[hidden] { display: none !important; }
.btn.big { padding: 14px 26px; font-size: 17px; }
.ico { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; font-size: 17px; }
.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font: 600 12px var(--mono); white-space: nowrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.scroll-y { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* HUD */
#hud { position: absolute; z-index: 5; top: calc(8px + var(--safe-t)); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; pointer-events: none; }
#hud > * { pointer-events: auto; }
.res { display: flex; gap: 6px; flex-wrap: wrap; }
.r { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 5px 9px 6px; min-width: 76px; }
.r span { display: block; font: 700 9px var(--mono); letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.r b { font: 700 15px var(--mono); }
.r i { display: block; height: 3px; border-radius: 2px; background: var(--grid); margin-top: 3px; overflow: hidden; }
.r i s { display: block; height: 100%; text-decoration: none; transition: width .4s; }
.r.low { border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(255, 106, 90, .25); } }
.hud-r { display: flex; gap: 6px; align-items: center; }

/* abertura */
#s-title { display: flex; align-items: center; padding: 0 6vw; }
.title-box { max-width: 560px; }
.title-box h1 { font: 800 clamp(40px, 8vw, 86px)/.92 var(--font); letter-spacing: .02em; margin: 10px 0 16px; text-shadow: 0 4px 30px rgba(0, 0, 0, .6); }
.title-box h1 span { color: var(--cyan); }
.title-box .sub { font-size: clamp(15px, 2vw, 19px); line-height: 1.5; color: #d2e2e8; text-shadow: 0 2px 10px #000; }
.title-box .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.title-box .row.small { margin-top: 10px; }
.title-box .hint { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* projeto da missão */
#s-design { display: flex; align-items: stretch; justify-content: flex-start; padding: 10px; }
.design { width: min(760px, 100%); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; backdrop-filter: blur(8px); }
.d-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.steps { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.steps button { background: none; border: 1px solid var(--grid); border-radius: 999px; padding: 5px 11px; font-size: 13px; color: var(--muted); }
.steps button.on { border-color: var(--cyan); color: var(--ink); background: rgba(127, 224, 255, .1); }
.steps button.done { color: var(--teal); }
.d-body { flex: 1; overflow-y: auto; padding: 16px 18px; min-height: 0; }
.d-body h2 { font-size: 22px; margin: 0 0 4px; }
.d-body .intro { color: var(--muted); margin: 0 0 14px; font-size: 14px; line-height: 1.5; }
.d-foot { border-top: 1px solid var(--line); padding: 10px 18px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.d-meters { display: flex; gap: 14px; flex: 1; min-width: 240px; }
.meter { flex: 1; font-size: 12px; }
.meter b { font: 700 14px var(--mono); }
.meter i { display: block; height: 6px; border-radius: 3px; background: var(--grid); margin-top: 4px; overflow: hidden; }
.meter i s { display: block; height: 100%; text-decoration: none; transition: width .3s; }
.meter.bad b { color: var(--red); }
.d-nav { display: flex; gap: 8px; }
.d-why { color: var(--amber); font-size: 12px; width: 100%; margin: 0; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who button { background: rgba(255, 255, 255, .03); border: 2px solid var(--grid); border-radius: 16px; padding: 10px; text-align: center; }
.who button.on { border-color: var(--cyan); background: rgba(127, 224, 255, .08); }
.who img { width: 100%; max-width: 180px; aspect-ratio: 3 / 4; object-fit: cover; object-position: top; border-radius: 12px; display: block; margin: 0 auto 8px; }
.mapwrap { position: relative; }
#surf { width: 100%; aspect-ratio: 2 / 1; border-radius: 12px; display: block; cursor: pointer; touch-action: manipulation; }
.mcard { margin-top: 12px; background: rgba(255, 255, 255, .03); border: 1px solid var(--grid); border-left: 4px solid var(--c, var(--cyan)); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.mcard h3 { margin: 0 0 4px; font-size: 18px; }
.mcard .q { color: var(--amber); font-weight: 600; }
.mcard .f { color: var(--muted); font-size: 13px; }
.mtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.opt { text-align: left; background: rgba(255, 255, 255, .03); border: 2px solid var(--grid); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.opt b { color: var(--ink); font-size: 15px; }
.opt .nums { font: 600 12px var(--mono); color: var(--teal); }
.opt.on { border-color: var(--amber); background: rgba(255, 196, 106, .07); }
.opt .fact { font-size: 12px; color: var(--dim); }
.crew { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cm { position: relative; text-align: left; background: rgba(255, 255, 255, .03); border: 2px solid var(--grid); border-radius: 14px; padding: 8px; font-size: 12px; line-height: 1.4; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.cm img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: top; border-radius: 10px; }
.cm b { color: var(--ink); font-size: 13px; }
.cm .perk { color: var(--teal); }
.cm .cost { font: 700 11px var(--mono); color: var(--amber); }
.cm.on { border-color: var(--teal); background: rgba(95, 224, 208, .08); }
.cm.fixed { border-style: dashed; }
.cm .badge { position: absolute; top: 12px; left: 12px; background: var(--teal); color: #02121a; font: 800 10px var(--mono); padding: 3px 6px; border-radius: 6px; }

/* planejamento */
#s-plan { display: grid; grid-template-columns: minmax(300px, 420px) 1fr minmax(240px, 320px); grid-template-rows: 1fr auto; gap: 10px; padding: 64px 10px 10px; }
.plan-panel { grid-row: 1 / 3; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; flex-shrink: 0; }
.tabs button { background: none; border: 0; border-radius: 8px; padding: 7px 10px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button.on { background: rgba(127, 224, 255, .12); color: var(--ink); }
.tab-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.tab-body .intro { font-size: 12px; color: var(--muted); margin: 0 0 2px; line-height: 1.45; }
.item { background: rgba(255, 255, 255, .03); border: 1px solid var(--grid); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.45; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.item b { font-size: 14px; }
.item .eff { color: var(--teal); font-size: 12px; grid-column: 1; }
.item .desc { color: var(--muted); font-size: 12px; grid-column: 1 / 3; }
.item .btn { grid-row: 1 / 3; grid-column: 2; }
.item.owned { border-color: rgba(95, 224, 208, .35); }
.item .lv { font: 700 11px var(--mono); color: var(--amber); margin-left: 6px; }
.power { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; font-size: 13px; }
.power .cells { display: flex; gap: 3px; }
.power .cells i { width: 14px; height: 18px; border-radius: 3px; background: var(--grid); }
.power .cells i.on { background: var(--amber); }
.plan-side { grid-column: 3; grid-row: 1; padding: 12px 14px; overflow-y: auto; font-size: 13px; line-height: 1.5; min-height: 0; }
.plan-side h3 { font-size: 14px; margin: 12px 0 6px; }
.plan-side h3:first-child { margin-top: 0; }
.plan-side .goal { color: var(--amber); }
.zonechk { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.zonechk span { font: 600 11px var(--mono); padding: 3px 7px; border-radius: 6px; background: var(--grid); color: var(--muted); }
.zonechk span.ok { background: rgba(95, 224, 208, .2); color: var(--teal); }
.plan-go { grid-column: 3; grid-row: 2; display: flex; justify-content: flex-end; }
.plan-go .btn { width: 100%; }
.crewrow { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; }
.crewrow img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; object-position: top; }

/* mergulho */
.zone-box { position: absolute; top: 64px; right: 10px; width: min(300px, 40vw); padding: 10px 12px; font-size: 12px; line-height: 1.45; }
.zone-box b { font-size: 15px; display: block; }
.zone-box .depth { font: 700 20px var(--mono); color: var(--cyan); white-space: nowrap; }
.zone-box .kicker { margin-right: 10px; }
.log { position: absolute; left: 10px; top: 64px; bottom: 100px; width: min(420px, 46vw); display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; overflow: hidden; pointer-events: none !important; mask-image: linear-gradient(transparent, #000 30%); -webkit-mask-image: linear-gradient(transparent, #000 30%); }
.log p { margin: 0; font-size: 13px; line-height: 1.45; background: rgba(4, 12, 18, .72); padding: 6px 10px; border-radius: 8px; border-left: 3px solid var(--grid); }
.log p.sys { color: var(--muted); }
.log p.good { border-left-color: var(--green); }
.log p.warn { border-left-color: var(--amber); color: #ffe2b0; }
.log p.crit { border-left-color: var(--red); color: #ffc4bc; }
.log p.disc { border-left-color: var(--violet); font-weight: 700; color: #e4dbff; }
.log p.fact { border-left-color: var(--cyan); color: #c4eefc; }
.log p.strange { border-left-color: var(--teal); }
.actions { position: absolute; left: 10px; right: 10px; bottom: 10px; display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; }
.act { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; justify-content: center; text-align: center; touch-action: manipulation; }
.act .k { font: 700 10px var(--mono); color: var(--dim); }
.act b { font-size: 12.5px; line-height: 1.15; }
.act small { font: 600 10.5px var(--mono); color: var(--amber); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act:disabled { opacity: .38; }
.act.hot { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset; }
.act.end { background: linear-gradient(135deg, #ffc46a33, #ff8a4a33); border-color: var(--amber); }

/* EVA */
.eva-top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; }
.suit { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px 12px; display: flex; gap: 10px; align-items: center; font: 700 11px var(--mono); }
.suit i { width: 160px; height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; display: block; }
.suit s { display: block; height: 100%; background: var(--cyan); text-decoration: none; }
.eva-help { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--muted); background: rgba(4, 12, 18, .6); padding: 5px 10px; border-radius: 8px; white-space: nowrap; }
.stick { position: absolute; left: 24px; bottom: 24px; width: 130px; height: 130px; border-radius: 50%; background: rgba(127, 224, 255, .08); border: 2px solid var(--line); touch-action: none; display: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px; border-radius: 50%; background: rgba(127, 224, 255, .35); }
.eva-btns { position: absolute; right: 16px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.eva-btns .btn.small { min-width: 96px; }
body.touch .stick { display: block; }
body.touch .eva-help { display: none; }

/* diálogo */
#dlg { position: absolute; z-index: 30; left: 0; right: 0; bottom: 0; padding: 10px calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l)); display: flex; justify-content: center; background: linear-gradient(transparent, rgba(2, 6, 10, .7)); }
.dlg-box { width: min(880px, 100%); display: grid; grid-template-columns: 150px 1fr; gap: 16px; background: var(--panel2); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
#dlg-img { width: 150px; height: 180px; object-fit: cover; object-position: top; border-radius: 12px; border: 2px solid var(--c, var(--line)); background: #0a1822; }
.dlg-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dlg-who b { font-size: 17px; color: var(--c, var(--ink)); }
.dlg-who span { display: block; font-size: 12px; color: var(--muted); }
#dlg-text { margin: 0; font-size: 16px; line-height: 1.55; min-height: 3em; }
#dlg-choices { display: grid; gap: 6px; }
#dlg-choices button { text-align: left; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 14px; font-weight: 600; }
#dlg-choices button small { display: block; font: 500 11.5px var(--mono); color: var(--teal); margin-top: 2px; }
#dlg-choices button:disabled { opacity: .45; }
#dlg-choices button:disabled small { color: var(--red); }
#dlg-choices button:hover:not(:disabled) { border-color: var(--cyan); }
#dlg-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
#dlg-note:empty { display: none; }
#dlg-next { align-self: flex-end; }

/* cartões, folhas e avisos */
#card { position: absolute; z-index: 20; top: 64px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 20px)); background: var(--panel2); border: 1px solid var(--violet); border-radius: 16px; padding: 14px 16px; font-size: 14px; line-height: 1.5; animation: up .3s; }
#card .kicker { color: var(--violet); }
#card h3 { margin: 4px 0 6px; font-size: 20px; }
#card .fact { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--grid); color: #c4eefc; font-size: 13px; }
#card .src { color: var(--dim); font: 600 11px var(--mono); }
#sheet { position: absolute; z-index: 40; inset: 0; background: rgba(2, 6, 10, .7); display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--safe-t)) 10px calc(10px + var(--safe-b)); }
.sheet-box { position: relative; width: min(820px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 18px; padding: 20px; font-size: 14px; line-height: 1.55; }
.sheet-box h2 { margin: 0 0 8px; font-size: 22px; }
.sheet-box h3 { margin: 18px 0 6px; font-size: 15px; color: var(--amber); }
.close { position: sticky; float: right; top: 0; }
#section { width: 100%; height: min(52vh, 420px); border-radius: 12px; display: block; }
#toast { position: absolute; z-index: 35; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--cyan); border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.45; max-width: min(560px, 92vw); text-align: center; }
#fade { position: absolute; z-index: 50; inset: 0; background: #02060a; opacity: 0; pointer-events: none; display: grid; place-items: center; transition: opacity .5s; }
#fade.on { opacity: 1; pointer-events: auto; }
#fade span { font: 700 14px var(--mono); letter-spacing: .2em; color: var(--cyan); }
#rotate { position: absolute; z-index: 60; inset: 0; background: rgba(2, 6, 10, .94); display: grid; place-items: center; text-align: center; font-size: 16px; }
#rotate p:first-child { font-size: 46px; margin: 0; }

/* fim */
#s-end { overflow-y: auto; pointer-events: auto; background: rgba(2, 6, 10, .55); }
.end { width: min(900px, calc(100% - 20px)); margin: 20px auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.end .grade { float: right; font: 800 72px/1 var(--font); color: var(--amber); margin-left: 16px; }
.end h2 { font-size: 30px; margin: 4px 0 10px; }
.end p { line-height: 1.6; }
.end .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; clear: both; }
.end .stats div { background: rgba(255, 255, 255, .04); border-radius: 12px; padding: 10px; }
.end .stats b { display: block; font: 700 20px var(--mono); }
.end .stats span { font-size: 12px; color: var(--muted); }
.end ul { padding-left: 18px; line-height: 1.55; }
.end ul.dim li { color: var(--muted); font-size: 13px; }
.end .interp { display: grid; gap: 8px; margin: 12px 0; }
.end .interp div { background: rgba(255, 255, 255, .03); border: 1px solid var(--grid); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.5; }
.end .interp .tag { margin-right: 8px; }
.end .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* telas menores e celular deitado */
@media (max-width: 1100px) {
  #s-plan { grid-template-columns: minmax(280px, 380px) 1fr; }
  .plan-side { grid-column: 2; grid-row: 1; justify-self: end; width: min(300px, 100%); align-self: start; max-height: 60%; }
  .plan-go { grid-column: 2; }
  .actions { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .log { bottom: 170px; }
}
@media (max-height: 520px), (max-width: 700px) {
  .r { min-width: 0; padding: 3px 7px; }
  .r b { font-size: 12px; }
  .r span { font-size: 8px; }
  .ico { width: 32px; height: 32px; font-size: 14px; }
  .pill { padding: 5px 9px; font-size: 11px; }
  #s-plan { padding-top: 50px; grid-template-columns: minmax(250px, 46%) 1fr; }
  .plan-side { display: none; }
  .zone-box { top: 50px; font-size: 11px; width: 220px; }
  .zone-box .depth { font-size: 15px; }
  .log { top: 50px; bottom: 140px; }
  .log p { font-size: 11.5px; padding: 4px 8px; }
  .act { min-height: 0; padding: 4px 2px; border-radius: 9px; }
  .act b { font-size: 11px; }
  .act .k { display: none; }
  .dlg-box { grid-template-columns: 84px 1fr; gap: 10px; padding: 10px; }
  #dlg-img { width: 84px; height: 104px; }
  #dlg-text { font-size: 14px; }
  #dlg-choices button { padding: 6px 10px; font-size: 13px; }
  .opts { grid-template-columns: 1fr; }
  .end .stats { grid-template-columns: repeat(2, 1fr); }
  .title-box h1 { font-size: 44px; }
}
@media (max-height: 520px) {
  .actions { grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
  .log { bottom: 66px; width: 40vw; }
  .d-body { padding: 10px 14px; }
  #dlg { padding-top: 4px; }
  .dlg-box { max-height: 70vh; overflow-y: auto; }
}
@media (max-width: 700px) and (min-height: 521px) {
  .actions { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .log { bottom: 210px; width: auto; right: 10px; top: 150px; }
  .zone-box { left: 10px; right: auto; top: 90px; width: auto; }
  #s-plan { grid-template-columns: 1fr; grid-template-rows: 1fr auto; padding-top: 96px; }
  .plan-panel { grid-row: 1; max-height: 58vh; align-self: end; }
  .plan-go { grid-column: 1; grid-row: 2; }
  .who { gap: 8px; }
}
.suit span { white-space: nowrap; }
@media (max-height: 520px) {
  #s-design { padding: 6px; }
  .d-head { padding: 8px 14px 6px; }
  .d-head .kicker { display: none; }
  .steps { margin-top: 0; }
  .d-body h2 { font-size: 18px; }
  .d-body .intro { font-size: 12px; margin-bottom: 8px; }
  .d-foot { padding: 6px 12px; gap: 8px; }
  .d-foot .btn { padding: 7px 12px; }
  .log { bottom: 92px; }
  .plan-go .btn { padding: 10px 16px; font-size: 15px; }
  .plan-go { justify-content: flex-end; }
  .plan-go .btn { width: auto; }
  .suit i { width: 100px; }
  .eva-top { top: 6px; }
}
