/* CLT Survival - interface */
:root {
  --ink: #14110f;
  --paper: #f6ecd6;
  --paper-2: #e9dcbd;
  --gold: #ffb52e;
  --fry: #d9822b;
  --hot: #ff4d3a;
  --ok: #58c26a;
  --blue: #2f6fd6;
  --line: #2b241d;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  display: block; outline: none; touch-action: none;
}

#ui { position: fixed; inset: 0; pointer-events: none; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- carregamento */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #3a2a1a 0%, #14110f 70%);
  z-index: 50; transition: opacity .35s ease;
}
.boot.hide { opacity: 0; pointer-events: none; }
.boot-card { width: min(420px, 82vw); text-align: center; }
.boot-title {
  font-weight: 900; font-size: clamp(34px, 8vw, 58px); letter-spacing: .04em; color: var(--gold);
  text-shadow: 0 4px 0 #7a3b0c, 0 10px 24px rgba(0, 0, 0, .6);
}
.boot-bar { margin: 22px auto 10px; height: 14px; border-radius: 8px; background: #2a211a; border: 2px solid #4a3828; overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--fry), var(--gold)); transition: width .2s ease; }
.boot-msg { font-size: 14px; opacity: .8; }

/* ---------------------------------------------------------------- HUD */
.hud { position: absolute; inset: 0; pointer-events: none; font-weight: 800; }
.hud-top { position: absolute; top: calc(6px + var(--safe-t)); left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r)); }
.xpbar {
  position: relative; height: 18px; border-radius: 9px; background: rgba(20, 16, 12, .75);
  border: 2px solid #1b130c; box-shadow: 0 2px 0 rgba(0,0,0,.4); overflow: hidden;
}
.xpbar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #2d6fd6, #5fb4ff); transition: width .15s; }
.xplvl { position: absolute; right: 10px; top: 0; line-height: 15px; font-size: 12px; text-shadow: 0 1px 2px #000; }

.hud-left { position: absolute; top: calc(32px + var(--safe-t)); left: calc(10px + var(--safe-l)); }
.hpbox { display: flex; align-items: center; gap: 6px; }
.hpicon { width: 28px; height: 28px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.5)); }
.hpbox.low .hpicon { animation: beat .5s infinite; }
@keyframes beat { 50% { transform: scale(1.25); } }
.hpbar { position: relative; width: 190px; height: 20px; border-radius: 10px; background: rgba(20, 16, 12, .75); border: 2px solid #1b130c; overflow: hidden; }
.hpbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #d8262a, #ff6b4a); transition: width .12s; }
.hptext { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 16px; text-shadow: 0 1px 2px #000; }
.slots { margin-top: 6px; }
.slot-row { display: flex; gap: 4px; margin-bottom: 4px; }
.slot {
  position: relative; width: 38px; height: 38px; border-radius: 8px; background: rgba(246, 236, 214, .92);
  border: 2px solid #1b130c; box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.slot img { width: 100%; height: 100%; }
.slot b { position: absolute; right: -3px; bottom: -5px; font-size: 11px; background: #1b130c; color: var(--gold); border-radius: 6px; padding: 0 4px; }
.slot.empty { background: rgba(20, 16, 12, .35); border-style: dashed; border-color: rgba(246,236,214,.25); box-shadow: none; }
.slot.empty img, .slot.empty b { display: none; }
.slot.evo { background: linear-gradient(#ffe08a, #ffb52e); }
.slot-row.small .slot { width: 28px; height: 28px; border-radius: 6px; }
.slot-row.small .slot b { font-size: 10px; }

.hud-center { position: absolute; top: calc(28px + var(--safe-t)); left: 50%; transform: translateX(-50%); text-align: center; }
.clock {
  font-size: 34px; letter-spacing: .04em; color: #fff;
  text-shadow: 0 3px 0 #1b130c, 0 0 18px rgba(0,0,0,.5);
  font-variant-numeric: tabular-nums;
}
.clock.extra { color: var(--hot); }
.clock-sub { font-size: 12px; opacity: .85; text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; }
.bossbar { margin-top: 8px; width: min(520px, 70vw); }
.bossname { font-size: 15px; color: #ffd2c4; text-shadow: 0 2px 0 #000; margin-bottom: 3px; }
.bossfill { position: relative; height: 16px; border-radius: 8px; background: rgba(20, 10, 10, .8); border: 2px solid #1b130c; overflow: hidden; }
.bossfill i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #8f1218, #ff3b3b); transition: width .15s; }

.hud-right { position: absolute; top: calc(32px + var(--safe-t)); right: calc(10px + var(--safe-r)); text-align: right; }
.kills { font-size: 20px; text-shadow: 0 2px 0 #000; }
.kills::before { content: '🍗 '; }
.fps { font-size: 11px; opacity: .85; margin-top: 4px; text-shadow: 0 1px 2px #000; font-weight: 600; }
.pausebtn {
  pointer-events: auto; margin-top: 8px; width: 40px; height: 40px; border-radius: 10px; font-weight: 900;
  background: rgba(246,236,214,.9); border: 2px solid #1b130c; color: #1b130c; cursor: pointer;
}

.banner {
  position: absolute; top: 24%; left: 50%; transform: translateX(-50%); text-align: center; width: 92vw;
}
.banner.show { animation: bannerIn 3.2s ease forwards; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateX(-50%) scale(1.6); }
  8% { opacity: 1; transform: translateX(-50%) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}
.b-title { font-size: clamp(26px, 5vw, 48px); font-weight: 900; color: var(--gold); text-shadow: 0 4px 0 #6b2c06, 0 0 30px rgba(0,0,0,.6); letter-spacing: .02em; }
.b-sub { font-size: clamp(14px, 2.2vw, 20px); margin-top: 6px; text-shadow: 0 2px 0 #000; }

.toast {
  position: absolute; bottom: calc(18% + var(--safe-b)); left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 12px; background: rgba(20, 16, 12, .85); border: 2px solid var(--gold);
  color: var(--gold); font-size: 18px; white-space: nowrap;
}
.toast.show { animation: toastIn 2.6s ease forwards; }
@keyframes toastIn { 0% { opacity: 0; transform: translate(-50%, 20px); } 10% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; } 100% { opacity: 0; } }

.bubble {
  position: absolute; left: 0; top: 0; padding: 7px 12px; border-radius: 14px; background: #fff; color: #1b130c;
  border: 3px solid #1b130c; font-size: 15px; white-space: nowrap; box-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -11px; margin-left: -7px; border: 7px solid transparent; border-top-color: #1b130c;
}
.bubble.pop { animation: pop .25s ease; }
@keyframes pop { 0% { scale: .3; } 70% { scale: 1.15; } 100% { scale: 1; } }

.vignette {
  position: absolute; inset: 0; opacity: 0; transition: opacity .08s;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(200,10,10,.75) 100%);
}
.freeze { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(120,200,255,0) 50%, rgba(120,200,255,.45) 100%); }

.crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.crosshair i { position: absolute; background: #6cff6c; box-shadow: 0 0 2px #000; }
.crosshair i:nth-child(1) { left: -1px; top: -14px; width: 2px; height: 8px; }
.crosshair i:nth-child(2) { left: -1px; top: 6px; width: 2px; height: 8px; }
.crosshair i:nth-child(3) { left: -14px; top: -1px; width: 8px; height: 2px; }
.crosshair i:nth-child(4) { left: 6px; top: -1px; width: 8px; height: 2px; }
.speedo { position: absolute; bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%); font-size: 16px; color: #ffd85a; text-shadow: 0 2px 0 #000; font-variant-numeric: tabular-nums; }
.radar { position: absolute; left: calc(10px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); width: 150px; height: 150px; }

/* ---------------------------------------------------------------- toque */
.touch { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
.joy-base {
  position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35); background: rgba(0,0,0,.18); opacity: 0; transition: opacity .1s;
}
.joy-base.on { opacity: 1; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 181, 46, .85); border: 3px solid #1b130c; transform: translate(-50%, -50%); }
.tbtns { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(20px + var(--safe-b)); display: grid; grid-template-columns: repeat(2, auto); gap: 12px; }
.tbtn {
  width: 86px; height: 86px; border-radius: 50%; border: 3px solid #1b130c; font-weight: 900; font-size: 12px;
  background: rgba(246, 236, 214, .85); color: #1b130c; touch-action: none;
}
.tbtn.on { background: var(--gold); transform: scale(.94); }
.t-dash { background: rgba(255, 140, 60, .9); }

/* ---------------------------------------------------------------- telas */
.screens { position: absolute; inset: 0; display: none; pointer-events: auto; }
.screens.open { display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(20,14,8,.35), rgba(10,8,6,.75)); }
.screen {
  width: min(880px, 94vw); max-height: calc(100dvh - 24px); overflow: auto; padding: 22px 24px;
  background: var(--paper); color: var(--ink); border: 4px solid #1b130c; border-radius: 18px;
  box-shadow: 0 10px 0 rgba(0,0,0,.35), 0 30px 60px rgba(0,0,0,.45);
  animation: screenIn .22s ease;
}
@keyframes screenIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.screen h1 { margin: 0 0 12px; font-size: clamp(24px, 4.5vw, 38px); font-weight: 900; letter-spacing: .02em; }
.screen h1 small { font-size: .55em; opacity: .7; }
.screen-menu { background: transparent; border: 0; box-shadow: none; width: auto; }
.menu-col { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(420px, 88vw); }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .9; margin-bottom: 4px; }
.logo span { font-size: clamp(54px, 12vw, 92px); font-weight: 900; color: var(--gold); letter-spacing: .03em; text-shadow: 0 6px 0 #7a3b0c, 0 0 40px rgba(0,0,0,.6); -webkit-text-stroke: 3px #1b130c; }
.logo span + span { font-size: clamp(34px, 7.5vw, 58px); color: #fff; }
.tagline { color: #fff; text-shadow: 0 2px 0 #000; font-weight: 700; text-align: center; margin-bottom: 6px; }
.sustanca { display: flex; align-items: center; gap: 6px; font-weight: 800; color: #fff; text-shadow: 0 2px 0 #000; }
.screen:not(.screen-menu) .sustanca { color: var(--ink); text-shadow: none; margin-bottom: 8px; }
.sustanca img { width: 28px; height: 28px; }
.tip { margin-top: 8px; max-width: 420px; text-align: center; font-size: 13px; color: #fff; opacity: .9; text-shadow: 0 1px 2px #000; font-weight: 600; }

.btn {
  font: inherit; font-weight: 900; font-size: 17px; letter-spacing: .02em; cursor: pointer;
  padding: 12px 20px; min-width: 260px; border-radius: 12px; border: 3px solid #1b130c;
  background: #fff7e6; color: #1b130c; box-shadow: 0 4px 0 #1b130c; transition: transform .06s, box-shadow .06s, background .1s;
}
.btn:hover, .btn:focus-visible { background: #ffe3a6; outline: none; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1b130c; }
.btn.big { font-size: 21px; padding: 15px 22px; background: var(--gold); }
.btn.big:hover, .btn.big:focus-visible { background: #ffc85a; }
.btn.small { min-width: 0; padding: 7px 12px; font-size: 14px; }
.btn.danger { background: #ffd2c4; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.go { background: var(--ok); color: #0b1d0e; }
.btn.tog.on, .btn.qbtn.on { background: var(--gold); }

.cards { display: grid; gap: 10px; margin-bottom: 10px; }
.cards.two { grid-template-columns: 1fr 1fr; }
.card {
  font: inherit; text-align: left; cursor: pointer; padding: 12px 14px; border-radius: 14px; border: 3px solid #1b130c;
  background: #fff; color: var(--ink); box-shadow: 0 4px 0 #1b130c;
}
.card.on { background: #ffe3a6; outline: 3px solid var(--fry); }
.card.elite.on { background: #ffc9c0; outline-color: var(--hot); }
.card:focus-visible { outline: 3px solid var(--blue); }
.card-title { font-weight: 900; font-size: 19px; }
.card-text { font-size: 13px; margin-top: 4px; opacity: .85; font-weight: 600; }
.row-label { font-weight: 900; margin: 6px 0; }
.weapon-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.wpick {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 10px; border: 2px solid #1b130c;
  background: #fff; cursor: pointer; font: inherit; font-weight: 800; font-size: 13px;
}
.wpick img { width: 34px; height: 34px; }
.wpick.on { background: #ffe3a6; outline: 3px solid var(--fry); }
.record { font-size: 13px; font-weight: 700; opacity: .85; margin: 6px 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.actions .btn { min-width: 200px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: #fff; border: 2px solid #1b130c; }
.li-main { flex: 1; }
.li-desc { font-size: 13px; opacity: .8; font-weight: 600; margin-top: 2px; }
.li.locked { opacity: .6; }
.li.ok { background: #fff3cf; }
.pips { color: var(--fry); letter-spacing: 2px; }
.unlock { font-size: 12px; color: var(--blue); font-weight: 800; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.opt > span { flex: 1; }
.opt input[type=range] { width: min(300px, 40vw); accent-color: var(--fry); }
.opt em { width: 48px; text-align: right; font-style: normal; }
.seg { display: flex; gap: 6px; flex: none !important; }
.note { font-size: 12px; opacity: .7; margin-top: 10px; font-weight: 600; }

.pause-info { font-weight: 800; margin-bottom: 10px; }
.pause-build { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.bitem { display: flex; align-items: center; gap: 6px; background: #fff; border: 2px solid #1b130c; border-radius: 10px; padding: 3px 10px 3px 3px; font-size: 13px; font-weight: 700; }
.bitem img { width: 34px; height: 34px; }
.bitem.small img { width: 26px; height: 26px; }
.screen-pause { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }

.screen-levelup { width: min(980px, 96vw); background: #fff8e8; }
.lv-title { color: #1b130c; }
.lv-sub { font-weight: 700; margin: -6px 0 12px; }
.offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.offer {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; cursor: pointer;
  padding: 16px 12px 14px; border-radius: 16px; border: 3px solid #1b130c; background: #fff; color: var(--ink);
  box-shadow: 0 5px 0 #1b130c; font: inherit; transition: transform .08s;
  animation: offerIn .35s ease backwards;
}
.offer:nth-child(2) { animation-delay: .06s; } .offer:nth-child(3) { animation-delay: .12s; } .offer:nth-child(4) { animation-delay: .18s; }
@keyframes offerIn { from { opacity: 0; transform: translateY(24px) rotate(-2deg); } }
.offer:hover, .offer:focus-visible { transform: translateY(-4px); background: #fff1cc; outline: none; }
.offer.new { background: linear-gradient(#fffdf6, #fff3cf); }
.offer.passive { background: linear-gradient(#fbfffb, #e9f8ea); }
.offer img { width: 72px; height: 72px; }
.o-key { position: absolute; left: 10px; top: 8px; font-size: 13px; font-weight: 900; opacity: .5; }
.o-name { font-weight: 900; font-size: 17px; }
.o-text { font-size: 13px; font-weight: 600; opacity: .85; margin-top: 4px; }
.o-hint { font-size: 12px; font-weight: 800; color: var(--blue); margin-top: 6px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--hot); color: #fff; vertical-align: middle; }
.tag.lv { background: #1b130c; color: var(--gold); }

.screen-chest { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.marmita-box img { width: 120px; height: 120px; animation: shake .5s ease 2; }
@keyframes shake { 25% { transform: rotate(-8deg) scale(1.05); } 75% { transform: rotate(8deg) scale(1.05); } }
.chest-items { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.citem { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 12px; border-radius: 12px; background: #fff; border: 2px solid #1b130c; animation: offerIn .4s ease backwards; }
.citem img { width: 48px; height: 48px; }
.citem.evolve { background: linear-gradient(90deg, #ffe08a, #fff3cf); border-color: var(--fry); }

.res-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.res-grid div { background: #fff; border: 2px solid #1b130c; border-radius: 10px; padding: 6px 8px; text-align: center; }
.res-grid span { display: block; font-size: 11px; font-weight: 700; opacity: .7; }
.res-grid b { font-size: 20px; }
h1.win { color: #1d7a2c; }
h1.lose { color: #b4161b; }
.dmg { width: 100%; border-collapse: collapse; font-size: 14px; font-weight: 700; }
.dmg th { text-align: left; font-size: 12px; opacity: .7; padding: 4px; }
.dmg td { padding: 4px; border-top: 1px solid rgba(0,0,0,.12); }
.dmg td img { width: 24px; height: 24px; vertical-align: middle; }
.newrec { margin-top: 10px; font-weight: 900; color: var(--fry); font-size: 18px; text-align: center; }
.new-ach { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; font-weight: 700; }

@media (max-width: 640px) {
  .cards.two { grid-template-columns: 1fr; }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
  .hpbar { width: 130px; }
  .clock { font-size: 26px; }
  .btn { min-width: 0; width: 100%; }
  .slot { width: 32px; height: 32px; }
  .radar { width: 110px; height: 110px; }
}

/* ---------------------------------------------------------------- laboratorio */
.lab-panel {
  position: fixed; top: 10px; left: 10px; max-width: 340px; max-height: calc(100dvh - 20px); overflow: auto;
  padding: 10px 12px; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(10, 10, 12, .78); border: 1px solid #444; border-radius: 8px; color: #e8e8e8; pointer-events: auto; white-space: pre-wrap;
}
.lab-panel b { color: var(--gold); }
.lab-panel label { display: flex; gap: 6px; align-items: center; margin: 2px 0; }
.lab-panel input[type=range] { flex: 1; }
.lab-panel button { font: inherit; margin: 2px 2px 2px 0; padding: 3px 7px; border-radius: 5px; border: 1px solid #666; background: #2a2a2e; color: #eee; cursor: pointer; }
.lab-panel button.on { background: var(--fry); border-color: var(--gold); color: #111; }
