:root {
  --ink: #2e2236;
  --paper: #fffaf2;
  --gold: #f5c242;
  --accent: #e0457b;
  --purple: #2a1b4d;
  --shadow: 0 10px 30px rgba(30, 10, 40, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6c9a8; font-family: "Fredoka", system-ui, sans-serif; color: var(--ink); }
#app canvas { display: block; }
.hidden { display: none !important; }

kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 1px;
  border-radius: 6px; background: #fff; border: 1px solid #d9cbbf; border-bottom-width: 3px;
  font: 600 12px "Fredoka", sans-serif; color: var(--ink); text-align: center;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; text-decoration: none;
  font: 600 16px "Fredoka", sans-serif; color: var(--ink);
  background: #fff; border: 2px solid #e6d8cc; border-radius: 999px; padding: 10px 22px;
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.btn.primary { background: linear-gradient(135deg, #ff7aa8, #e0457b); color: #fff; border-color: transparent; }
.btn.big { font-size: 22px; padding: 14px 40px; }
.btn small { opacity: .6; font-weight: 500; }

/* ---------- HUD ---------- */
.panel {
  background: rgba(255, 250, 242, .88); backdrop-filter: blur(6px);
  border-radius: 18px; box-shadow: var(--shadow); padding: 12px 16px;
}
.hud-left { position: fixed; top: 16px; left: 16px; width: 270px; }
.hud-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.keys { display: flex; gap: 6px; margin-bottom: 8px; }
.keys span {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 20px;
  background: #ece2d8; filter: grayscale(1); opacity: .45; transition: all .4s;
}
.keys span.got { filter: none; opacity: 1; background: #fff3cf; box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(245,194,66,.7); }
.hud-row { font-size: 14px; margin-bottom: 6px; }
.objective { font-size: 13.5px; line-height: 1.35; color: #5a4660; border-top: 1px dashed #e0d2c6; padding-top: 8px; }

#minimap {
  position: fixed; top: 16px; right: 16px; width: 200px; height: 200px; border-radius: 50%;
  box-shadow: var(--shadow), 0 0 0 4px rgba(255,250,242,.9);
}
.hint {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(46, 34, 54, .88); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 18px; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap;
  animation: pulse 1.6s ease-in-out infinite;
}
.hint b { color: var(--gold); }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.04); } }

.toast {
  position: fixed; top: 64px; left: 50%; transform: translate(-50%, -20px); opacity: 0;
  background: #fff; padding: 12px 22px; border-radius: 16px; font-weight: 600; font-size: 17px;
  box-shadow: var(--shadow); transition: all .35s; pointer-events: none; text-align: center; max-width: 520px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.controls {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; font-size: 13px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5);
  white-space: nowrap;
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 10;
  background: rgba(40, 20, 50, .35); backdrop-filter: blur(2px);
}
.menu { background: linear-gradient(180deg, rgba(42,27,77,.15), rgba(42,27,77,.55)); }
.menu-box {
  background: rgba(255, 250, 242, .94); border-radius: 28px; padding: 34px 44px; max-width: 620px;
  text-align: center; box-shadow: 0 20px 60px rgba(30,10,40,.4);
}
.menu-kicker { font-size: 14px; letter-spacing: .2em; text-transform: uppercase; color: #8a6f8f; }
.menu-author { font: italic 700 22px "Playfair Display", serif; color: var(--accent); }
.menu-title {
  font: 700 64px "Fredoka", sans-serif; margin: 4px 0 10px; line-height: 1;
  background: linear-gradient(135deg, #ff7aa8, #b13fd1 50%, #f39a12); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.menu-text { font-size: 17px; line-height: 1.5; margin: 0 0 14px; }
.menu-text .hl { color: var(--accent); }
.teaser {
  display: inline-block; background: var(--purple); color: #fff; border-radius: 14px; padding: 10px 18px;
  font-size: 15px; margin-bottom: 20px; box-shadow: 0 0 0 3px rgba(245,194,66,.6);
}
.teaser b { color: var(--gold); }
.menu-actions { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }
.menu-controls { font-size: 13px; color: #7a6a7e; }

.loading {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 20;
  background: #f6c9a8; font-size: 24px; font-weight: 600; color: var(--purple);
}

/* ---------- Card ---------- */
.card {
  display: flex; gap: 28px; background: var(--paper); border-radius: 26px; padding: 26px;
  max-width: 900px; width: calc(100% - 48px); max-height: calc(100% - 48px);
  box-shadow: 0 24px 70px rgba(30,10,40,.45); animation: pop .35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.card-cover img { width: 270px; border-radius: 6px 14px 14px 6px; box-shadow: -6px 10px 24px rgba(0,0,0,.35); display: block; }
.card-body { display: flex; flex-direction: column; min-width: 0; }
.card-kicker { font-size: 13px; letter-spacing: .15em; text-transform: uppercase; color: #8a6f8f; }
.card-body h2 { font: 700 32px "Playfair Display", serif; margin: 4px 0 12px; line-height: 1.15; }
.card-text { font-size: 15.5px; line-height: 1.55; overflow-y: auto; padding-right: 8px; flex: 1; }
.card-text p { margin: 0 0 10px; }
.card-status { margin: 12px 0; padding: 10px 14px; border-radius: 12px; background: #f3ebe2; font-weight: 600; font-size: 15px; }
.card-status.win { background: #fff3cf; box-shadow: 0 0 0 2px var(--gold); }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Final ---------- */
.final-overlay { background: radial-gradient(ellipse at center, rgba(42,27,77,.55), rgba(20,10,35,.85)); }
.final { text-align: center; color: #fff; max-width: 640px; padding: 20px; animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
.final-kicker { font-size: 16px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-bottom: 16px; }
.final-cover {
  width: min(250px, 30vh); aspect-ratio: 5/8; margin: 0 auto 14px; border-radius: 6px 14px 14px 6px; overflow: hidden;
  box-shadow: 0 0 0 3px var(--gold), 0 0 60px rgba(245,194,66,.6), 0 20px 50px rgba(0,0,0,.5);
}
.final-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.final-cover .mystery {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(160deg, #3a2470, #1a1035); color: var(--gold); padding: 16px;
}
.final-cover .mystery .q { font: 700 120px "Playfair Display", serif; line-height: 1; text-shadow: 0 0 30px rgba(245,194,66,.7); }
.final-cover .mystery .t { font-size: 15px; color: #fff; }
.final-title { font: italic 700 44px "Playfair Display", serif; margin: 0 0 6px; text-shadow: 0 4px 20px rgba(0,0,0,.4); }
.final-info { font-size: 18px; margin-bottom: 14px; }
.final-info b { color: var(--gold); }
.countdown { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; }
.countdown .cd-label { font-size: 15px; opacity: .85; }
.countdown .cd-row { display: flex; gap: 10px; }
.countdown .cd { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 8px 12px; min-width: 70px; }
.countdown .cd b { display: block; font-size: 30px; color: var(--gold); }
.countdown .cd span { font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .1em; }
.final-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* telas menores */
@media (max-height: 760px) {
  .final-title { font-size: 34px; }
  .countdown .cd b { font-size: 24px; }
  .final-kicker { margin-bottom: 10px; }
}
@media (max-width: 900px) {
  .hud-left { width: 220px; padding: 10px 12px; }
  .keys span { width: 30px; height: 30px; font-size: 16px; }
  .objective { display: none; }
  #minimap { width: 140px; height: 140px; }
  .controls { display: none; }
  .card { flex-direction: column; align-items: center; overflow-y: auto; }
  .card-cover img { width: 160px; }
}

/* ---------- cronômetro ---------- */
.timer {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(46, 34, 54, .85); color: #fff; font: 700 18px "Fredoka", sans-serif;
  padding: 6px 18px; border-radius: 999px; box-shadow: var(--shadow); letter-spacing: .04em;
}
.keys span { position: relative; }
.keys span em { position: absolute; right: -4px; top: -6px; font-style: normal; font-size: 13px; filter: none; opacity: 1; }

/* ---------- painel do desafio ---------- */
.chal { position: fixed; top: 16px; left: 302px; width: 270px; border: 3px solid var(--npc, #e0457b); }
.chal-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.chal-body { font-size: 14.5px; line-height: 1.45; }
.chal-note { font-size: 12.5px; color: #5a4660; background: #f3ebe2; border-radius: 8px; padding: 4px 8px; margin-top: 5px; }
.chal-goal { margin-top: 6px; font-weight: 600; color: var(--npc, #e0457b); }
.chal-big { font-size: 28px; font-weight: 700; }
.chal-big.warn { color: #d62f3c; animation: pulse 0.6s ease-in-out infinite; }
.chal-foot { margin-top: 8px; font-size: 12px; color: #8a6f8f; }
.simon { display: flex; gap: 6px; margin-top: 6px; }
.simon i { width: 16px; height: 16px; border-radius: 50%; background: #e3d6ca; }
.simon i.on { background: #3ddc84; box-shadow: 0 0 8px #3ddc84; }

/* ---------- diálogo ---------- */
.dialog {
  position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%); z-index: 12;
  width: min(700px, calc(100% - 32px)); background: rgba(255, 250, 242, .97);
  border: 3px solid var(--npc, #e0457b); border-radius: 22px; padding: 16px 22px 12px;
  box-shadow: 0 16px 50px rgba(30, 10, 40, .4); animation: rise .25s ease-out;
}
@keyframes rise { from { transform: translate(-50%, 20px); opacity: 0; } }
.dlg-book { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: #8a6f8f; }
.dlg-name { font: italic 700 22px "Playfair Display", serif; color: var(--npc, #e0457b); margin-bottom: 4px; }
.dlg-text { font-size: 18px; line-height: 1.45; min-height: 52px; }
.dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.dlg-actions .btn small { background: rgba(0,0,0,.12); border-radius: 6px; padding: 0 6px; margin-right: 2px; opacity: 1; }
.dlg-next { text-align: right; font-size: 12.5px; color: #8a6f8f; margin-top: 6px; }

/* ---------- medalha ---------- */
.final-time {
  display: inline-flex; align-items: center; gap: 14px; text-align: left;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 16px;
  padding: 10px 18px; margin-bottom: 12px; font-size: 16px;
}
.final-time .medal { font-size: 44px; line-height: 1; }
.final-time small { opacity: .8; }

@media (max-width: 900px) {
  .chal { left: 16px; top: 150px; width: 220px; }
  .timer { top: auto; bottom: 16px; }
}
@media (max-height: 820px) {
  .final-cover { width: min(250px, 21vh); margin-bottom: 10px; }
  .final-title { font-size: 32px; }
  .final-time { padding: 6px 14px; margin-bottom: 8px; }
  .final-time .medal { font-size: 34px; }
  .countdown { margin-bottom: 14px; }
}

/* ---------- regras do desafio ---------- */
.rules {
  background: var(--paper); border-radius: 26px; padding: 26px 32px; max-width: 620px; width: calc(100% - 40px);
  border: 4px solid var(--npc, #e0457b); box-shadow: 0 24px 70px rgba(30,10,40,.45); animation: pop .35s cubic-bezier(.2,1.4,.4,1);
}
.rules-icon { font-size: 54px; line-height: 1; margin-bottom: 4px; }
.rules h2 { font: 700 30px "Playfair Display", serif; margin: 2px 0 10px; color: var(--npc, #e0457b); }
.rules-sub { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.rules ol { margin: 0 0 14px; padding-left: 22px; font-size: 16px; line-height: 1.5; }
.rules li { margin-bottom: 6px; }
.rules-note { background: #fff3cf; border-radius: 12px; padding: 10px 14px; font-size: 14.5px; margin-bottom: 14px; box-shadow: 0 0 0 2px #f5c242; }

/* ---------- mensagem grande no centro ---------- */
.bigmsg {
  position: fixed; top: 38%; left: 50%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; z-index: 9;
  font: 700 54px "Fredoka", sans-serif; color: #fff; text-align: center; white-space: nowrap;
  text-shadow: 0 4px 0 rgba(0,0,0,.25), 0 0 30px rgba(224,69,123,.8);
}
.bigmsg.show { animation: bigpop 1.2s ease-out forwards; }
@keyframes bigpop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }

/* ---------- painel Genius ---------- */
.genius { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 120px; margin: 4px 0 8px; }
.genius i { aspect-ratio: 1; border-radius: 12px; background: var(--c); opacity: .3; transition: opacity .08s, transform .08s; }
.genius i:nth-child(1) { border-top-left-radius: 50px; } .genius i:nth-child(2) { border-top-right-radius: 50px; }
.genius i:nth-child(3) { border-bottom-left-radius: 50px; } .genius i:nth-child(4) { border-bottom-right-radius: 50px; }
.genius i.lit { opacity: 1; transform: scale(1.06); box-shadow: 0 0 18px var(--c); }

/* ---------- diálogo: botões claros ---------- */
.dialog { cursor: pointer; }
.dlg-count { position: absolute; top: 14px; right: 18px; font-size: 12px; color: #8a6f8f; background: #f3ebe2; border-radius: 999px; padding: 2px 10px; }
.dlg-actions { justify-content: flex-end; }
.dlg-actions .btn { font-size: 17px; padding: 10px 20px; }
.dlg-actions .btn kbd { margin-left: 6px; }
.dlg-actions .btn.primary kbd { background: rgba(255,255,255,.95); border-color: rgba(0,0,0,.15); }
.btn.pulse { animation: btnpulse 1.4s ease-in-out infinite; }
@keyframes btnpulse { 50% { box-shadow: 0 0 0 6px rgba(224, 69, 123, .25); } }

/* ---------- lista de tarefas do livro ---------- */
.tasks-title { font-size: 13px; margin-bottom: 4px; }
.tasks { list-style: none; margin: 0 0 6px; padding: 0; font-size: 13.5px; }
.tasks li { padding: 3px 6px; border-radius: 8px; opacity: .75; }
.tasks li.done { opacity: .55; text-decoration: line-through; }
.tasks li.next { opacity: 1; background: #fff3cf; box-shadow: inset 0 0 0 2px #f5c242; font-weight: 600; }
.next-step { margin-top: 6px; background: #2e2236; color: #fff; border-radius: 10px; padding: 7px 10px; font-size: 13.5px; line-height: 1.35; }
.next-step b { color: #f5c242; }

/* ---------- guarda-roupa ---------- */
.look-btn { margin-top: 8px; width: 100%; justify-content: center; padding: 7px 12px; font-size: 14px; }
.wardrobe { background: var(--paper); border-radius: 26px; padding: 24px 28px; max-width: 640px; width: calc(100% - 40px); box-shadow: 0 24px 70px rgba(30,10,40,.45); animation: pop .3s cubic-bezier(.2,1.4,.4,1); }
.wardrobe h2 { font: 700 30px "Playfair Display", serif; margin: 2px 0 4px; }
.wardrobe-sub { margin: 0 0 14px; color: #6a5670; }
.wardrobe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.look { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: 18px; border: 2px solid #e6d8cc; background: #fff; cursor: pointer; font: 600 15px "Fredoka", sans-serif; color: var(--ink); transition: transform .12s; }
.look:hover:not(.locked) { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.12); }
.look.on { border-color: #e0457b; box-shadow: 0 0 0 3px rgba(224,69,123,.25); }
.look.locked { opacity: .5; cursor: not-allowed; background: #f3ebe2; }
.look-ico { font-size: 36px; }
.look small { font-weight: 500; font-size: 12px; color: #8a6f8f; text-align: center; }

.menu-credit { font-size: 12.5px; color: #8a6f8f; margin-bottom: 8px; }

/* ---------- cartão de pista ---------- */
.clue {
  background: #fffaf0; border-radius: 22px; padding: 26px 30px 22px; max-width: 520px; width: calc(100% - 40px); text-align: center;
  border: 4px solid #e0457b; box-shadow: 0 0 0 8px rgba(224,69,123,.18), 0 24px 70px rgba(30,10,40,.5);
  animation: pop .35s cubic-bezier(.2,1.4,.4,1); display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.clue-ico { font-size: 52px; line-height: 1; }
.clue-num { font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: #e0457b; font-weight: 700; }
.clue-text { font: italic 700 23px/1.35 "Playfair Display", serif; color: #2e2236; text-wrap: balance; }
.clue-tip { font-size: 14.5px; color: #5a4660; background: #f3ebe2; border-radius: 12px; padding: 8px 12px; }
.chal-note { font-size: 13px; }

/* ---------- tecla E na dica ---------- */
.hint .key {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; margin-right: 8px;
  background: #fff; color: #2e2236; border-radius: 8px; border-bottom: 4px solid #c9bcb0; font-weight: 700; font-size: 18px; vertical-align: middle;
}

/* ---------- termômetro da investigação ---------- */
.heat { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; border-radius: 12px; padding: 6px 10px; margin-bottom: 8px; transition: background .3s, color .3s; }
.heat span { font-size: 22px; }
.heat.h1 { background: #e3eef8; color: #2f5f8a; }
.heat.h2 { background: #fff3cf; color: #8a6200; }
.heat.h3 { background: #ffe0c2; color: #b4501a; }
.heat.h4 { background: #ffd0d0; color: #c4203a; animation: heatpulse .6s ease-in-out infinite; }
@keyframes heatpulse { 50% { transform: scale(1.04); } }

/* ---------- tutorial ---------- */
.tut {
  position: fixed; top: 232px; right: 16px; width: 330px; z-index: 8;
  background: rgba(255, 250, 242, .97); border: 3px solid #e0457b; border-radius: 20px; padding: 12px 16px 14px;
  box-shadow: 0 14px 40px rgba(30, 10, 40, .35); animation: rise .3s ease-out;
}
.tut-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #8a6f8f; }
.tut-skip { border: 0; background: none; color: #8a6f8f; font: 600 12px "Fredoka", sans-serif; cursor: pointer; text-transform: none; letter-spacing: 0; }
.tut-skip:hover { color: #e0457b; }
.tut-progress { height: 6px; background: #efe4da; border-radius: 99px; margin: 6px 0 10px; overflow: hidden; }
.tut-progress i { display: block; height: 100%; background: linear-gradient(90deg, #ff7aa8, #e0457b); border-radius: 99px; transition: width .4s; }
.tut-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tut-ico { font-size: 34px; line-height: 1; }
.tut-head h3 { margin: 0; font: 700 22px "Playfair Display", serif; color: #2e2236; }
.tut-text { font-size: 15.5px; line-height: 1.5; color: #3d2f44; }
.tut-text kbd { font-size: 13px; }
.tut-act { margin-top: 12px; display: flex; justify-content: flex-end; }
.tut-status { width: 100%; text-align: center; font-weight: 700; font-size: 15px; padding: 8px; border-radius: 12px; background: #f3ebe2; color: #6a5670; animation: heatpulse 1.2s ease-in-out infinite; }
.tut-status.ok { background: #d9f5e4; color: #1f7a45; animation: none; }
.tut-focus { outline: 4px solid #ffb21f; outline-offset: 5px; animation: tutglow 1s ease-in-out infinite; }
@keyframes tutglow { 50% { outline-color: rgba(255, 178, 31, .35); } }

/* ================= celular / toque ================= */
#touchUI, #touchLook, .touch-only { display: none; }
body.touch .desk-only { display: none; }
body.touch .touch-only { display: block; }
body.touch { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
body.touch #app canvas { touch-action: none; }
body.touch #touchLook { display: block; position: fixed; top: 0; right: 0; bottom: 0; width: 55%; z-index: 1; touch-action: none; }
body.touch #touchUI { display: block; position: fixed; inset: 0; pointer-events: none; z-index: 13; }
#joy {
  position: absolute; left: calc(22px + env(safe-area-inset-left, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  width: 130px; height: 130px; border-radius: 50%; pointer-events: auto; touch-action: none;
  background: radial-gradient(circle, rgba(255,250,242,.28), rgba(255,250,242,.12)); border: 3px solid rgba(255,250,242,.7);
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
#joyKnob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: #fffaf2; box-shadow: 0 4px 12px rgba(0,0,0,.3), inset 0 -4px 0 #e6d8cc; transition: transform .05s;
}
.tbtns {
  position: absolute; right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: auto auto; grid-template-areas: "small small" "act jump"; gap: 12px; align-items: end; pointer-events: none;
}
.tsmall { grid-area: small; display: flex; gap: 10px; justify-content: flex-end; }
.tbtn {
  pointer-events: auto; touch-action: none; border: 0; border-radius: 50%; display: grid; place-items: center; align-content: center;
  font: 700 26px "Fredoka", sans-serif; color: #2e2236; background: rgba(255,250,242,.92); box-shadow: 0 6px 18px rgba(0,0,0,.28), inset 0 -5px 0 #e6d8cc;
}
.tbtn:active { transform: scale(.94); }
.tbtn small { font-size: 11px; font-weight: 600; margin-top: -2px; }
.tbtn.small { width: 46px; height: 46px; font-size: 20px; }
.tbtn.jump { grid-area: jump; width: 86px; height: 86px; background: linear-gradient(135deg, #ff7aa8, #e0457b); color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.28), inset 0 -5px 0 #b22d5e; }
.tbtn.act { grid-area: act; width: 74px; height: 74px; opacity: .75; }
.tbtn.act.ready { opacity: 1; background: #fff3cf; box-shadow: 0 0 0 4px #f5c242, 0 6px 18px rgba(0,0,0,.28); animation: heatpulse 1s ease-in-out infinite; }
body.touch .btn kbd, body.touch .btn small, body.touch .look-btn { display: none; }
body.touch .controls { display: none; }
body.touch .hint { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); font-size: 15px; padding: 9px 16px; white-space: normal; max-width: calc(100% - 32px); text-align: center; animation: none; }
body.touch .hint .key { min-width: 26px; height: 26px; font-size: 15px; }
body.touch .dialog { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); padding: 12px 16px 10px; }
body.touch .dlg-text { font-size: 16px; min-height: 0; }
body.touch .toast { font-size: 14px; max-width: calc(100% - 32px); top: 60px; }
body.touch .bigmsg { font-size: 36px; white-space: normal; width: calc(100% - 32px); }
body.touch #minimap { width: 118px; height: 118px; top: 12px; right: 12px; }
body.touch .timer { top: 12px; font-size: 14px; padding: 4px 12px; }
body.touch .hud-left { top: 12px; left: 12px; width: min(250px, 46vw); padding: 8px 10px; cursor: pointer; }
body.touch .hud-left .hud-title::after { content: ' ▾'; font-size: 12px; color: #8a6f8f; }
body.touch .hud-left.collapsed .hud-title::after { content: ' ▸ toque para abrir'; }
body.touch .hud-left.collapsed .hud-row, body.touch .hud-left.collapsed .tasks, body.touch .hud-left.collapsed .tasks-title { display: none; }
body.touch .keys span { width: 28px; height: 28px; font-size: 15px; }
body.touch .objective { display: block; font-size: 12.5px; }
body.touch .next-step { font-size: 12.5px; padding: 6px 8px; }
body.touch .chal { top: auto; bottom: calc(165px + env(safe-area-inset-bottom, 0px)); left: 12px; width: min(240px, 52vw); padding: 8px 10px; }
body.touch .chal-body { font-size: 13px; }
body.touch .chal-foot { display: none; }
body.touch .genius { width: 84px; }
body.touch .tut { top: auto; bottom: calc(165px + env(safe-area-inset-bottom, 0px)); right: 12px; left: auto; width: min(330px, calc(100% - 24px)); padding: 10px 12px; }
body.touch .tut-text { font-size: 14px; }
body.touch .tut-head h3 { font-size: 18px; }
@media (orientation: landscape) and (max-height: 500px) {
  body.touch .tut { bottom: auto; top: 12px; right: 140px; width: min(320px, 42vw); }
  body.touch .chal { bottom: auto; top: 90px; }
  body.touch .dialog { bottom: 12px; width: min(560px, calc(100% - 300px)); }
  body.touch .hint { bottom: 12px; max-width: 46vw; }
  body.touch #joy { width: 112px; height: 112px; }
}
@media (max-width: 600px) {
  .menu-box { padding: 22px 18px; width: calc(100% - 32px); }
  .menu-title { font-size: 44px; }
  .menu-text { font-size: 15px; }
  .menu-actions { flex-wrap: wrap; }
  .btn.big { font-size: 19px; padding: 12px 30px; }
  .card { padding: 16px; gap: 14px; }
  .card-body h2 { font-size: 24px; }
  .rules { padding: 18px; }
  .rules h2 { font-size: 24px; }
  .rules ol { font-size: 14.5px; }
  .wardrobe-grid { grid-template-columns: repeat(2, 1fr); }
  .clue-text { font-size: 19px; }
  .final-title { font-size: 30px; }
  .countdown .cd { min-width: 58px; padding: 6px 8px; }
  .countdown .cd b { font-size: 22px; }
}
/* correções do layout de toque */
body.touch .timer { bottom: auto; }
body.touch .tut { animation: tutin .3s ease-out; }
@keyframes tutin { from { opacity: 0; transform: translateY(14px); } }
body.touch .hud-left.collapsed .objective { font-size: 0; border-top: 0; padding-top: 0; }
body.touch .hud-left.collapsed .objective .next-step { font-size: 12px; margin-top: 4px; }
body.touch .hud-left.collapsed .keys { margin-bottom: 0; }
@media (orientation: portrait) {
  body.touch .hud-left { width: min(210px, 52vw); }
  body.touch .toast { top: auto; bottom: calc(320px + env(safe-area-inset-bottom, 0px)); }
}
@media (orientation: portrait) {
  body.touch .toast { bottom: auto; top: 214px; }
  body.touch .timer { left: auto; right: 12px; transform: none; top: 138px; }
}
body.touch .hud-left.collapsed .hud-title::after { content: ' ▸'; }
@media (orientation: landscape) and (max-height: 500px) {
  body.touch .dialog { left: calc(150px + env(safe-area-inset-left, 0px)); right: calc(230px + env(safe-area-inset-right, 0px)); width: auto; transform: none; animation: tutin .25s ease-out; }
}

/* ---------- tela cheia ---------- */
.fs-hud {
  position: fixed; top: 16px; right: 228px; width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
  background: rgba(255, 250, 242, .9); color: #2e2236; font-size: 20px; box-shadow: var(--shadow); display: grid; place-items: center;
}
.fs-hud:hover { transform: scale(1.06); }
body.touch .fs-hud { display: none; }
@media (max-width: 900px) { .fs-hud { right: 168px; } }

/* ================= celular: layout em faixas (sobrescreve o anterior) =================
   em cima: painel · minimapa · cronômetro → cartão do tutorial/desafio
   meio: livre para a Luiza
   embaixo: joystick e botões → acima deles, dica/avisos/diálogo */
/* fora do "jogando", os controles saem da frente */
body.touch[data-state="dialog"] #joy,
body.touch[data-state="dialog"] .tsmall,
body.touch[data-state="dialog"] #btnJump,
body.touch[data-state="dialog"] .hint,
body.touch[data-state="dialog"] .toast { display: none; }
body.touch[data-state="rules"] #touchUI, body.touch[data-state="clue"] #touchUI, body.touch[data-state="card"] #touchUI,
body.touch[data-state="wardrobe"] #touchUI, body.touch[data-state="final"] #touchUI, body.touch[data-state="cutscene"] #touchUI,
body.touch[data-state="menu"] #touchUI { display: none; }
body.touch:not([data-state="play"]) .hint { display: none; }
body.touch .tut, body.touch .chal { box-sizing: border-box; overflow-y: auto; }
body.touch .tut .tut-act .btn { padding: 8px 18px; font-size: 15px; }

@media (orientation: portrait) {
  body.touch .hud-left { top: 10px; left: 10px; width: min(214px, 56vw); padding: 7px 9px; }
  body.touch #minimap { width: 104px; height: 104px; top: 10px; right: 10px; }
  body.touch .timer { top: 122px; right: 10px; left: auto; bottom: auto; transform: none; font-size: 13px; }
  body.touch .tut, body.touch .chal {
    top: 156px; bottom: auto; left: 10px; right: 10px; width: auto; max-height: 30vh; padding: 8px 12px; animation: tutin .3s ease-out;
  }
  body.touch .tut-head { margin-bottom: 2px; } body.touch .tut-ico { font-size: 24px; }
  body.touch .tut-head h3 { font-size: 16px; } body.touch .tut-text { font-size: 13.5px; line-height: 1.4; }
  body.touch .tut-progress { margin: 4px 0 6px; } body.touch .tut-act { margin-top: 6px; }
  body.touch .chal-body { font-size: 13px; } body.touch .genius { width: 70px; float: right; margin: 0 0 4px 8px; }
  body.touch .hint { bottom: calc(176px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); font-size: 14px; }
  body.touch .toast { top: auto; bottom: calc(232px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translate(-50%, 10px); max-width: calc(100% - 24px); font-size: 13.5px; padding: 8px 14px; }
  body.touch .toast.show { transform: translate(-50%, 0); }
  body.touch .dialog { bottom: calc(108px + env(safe-area-inset-bottom, 0px)); left: 10px; right: 10px; width: auto; transform: none; animation: tutin .25s ease-out; }
  body.touch .bigmsg { top: 42%; font-size: 28px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.touch .hud-left { top: 8px; left: 8px; width: 230px; padding: 7px 9px; }
  body.touch #minimap { width: 96px; height: 96px; top: 8px; right: 8px; }
  body.touch .timer { top: 8px; right: 112px; left: auto; bottom: auto; transform: none; font-size: 13px; }
  body.touch .tut, body.touch .chal { top: 8px; bottom: auto; left: 248px; right: 232px; width: auto; max-height: calc(100% - 170px); padding: 6px 10px; animation: tutin .3s ease-out; }
  body.touch .tut-progress { margin: 3px 0 4px; } body.touch .tut-head { margin-bottom: 0; } body.touch .tut-act { margin-top: 4px; }
  body.touch .tut .tut-act .btn { padding: 5px 14px; font-size: 13px; }
  body.touch .tut-text { line-height: 1.35; }
  body.touch .tut-text { font-size: 13px; } body.touch .tut-head h3 { font-size: 16px; } body.touch .tut-ico { font-size: 22px; }
  body.touch .hint { bottom: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 400px); font-size: 13px; }
  body.touch .toast { top: auto; bottom: 62px; left: 50%; transform: translate(-50%, 10px); max-width: calc(100% - 400px); font-size: 13px; padding: 7px 12px; }
  body.touch .toast.show { transform: translate(-50%, 0); }
  body.touch .dialog { bottom: 8px; left: 10px; right: 104px; width: auto; transform: none; padding: 10px 14px 8px; }
  body.touch .dlg-text { font-size: 14.5px; }
  body.touch .bigmsg { top: 42%; font-size: 28px; }
  body.touch #joy { width: 104px; height: 104px; left: 16px; bottom: 14px; }
  body.touch .tbtn.jump { width: 74px; height: 74px; } body.touch .tbtn.act { width: 64px; height: 64px; } body.touch .tbtn.small { width: 40px; height: 40px; font-size: 17px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  /* conversa no alto; personagens ficam visíveis embaixo */
  body.touch .dialog { top: 8px; bottom: auto; left: 10px; right: 104px; padding: 8px 12px 8px; }
  body.touch .dlg-book, body.touch .dlg-next { display: none; }
  body.touch .dlg-name { font-size: 17px; margin-bottom: 2px; }
  body.touch .dlg-count { top: 8px; }
  body.touch .dlg-actions { margin-top: 6px; }
  body.touch .dlg-actions .btn { padding: 6px 14px; font-size: 14px; }
  body.touch[data-state="dialog"] .hud-left, body.touch[data-state="dialog"] #minimap, body.touch[data-state="dialog"] .timer, body.touch[data-state="dialog"] .fs-hud { visibility: hidden; }
}

/* arrastar em qualquer área livre gira a câmera; painéis com botões ficam por cima */
body.touch #touchLook { left: 0; width: auto; }
body.touch .hud-left { z-index: 3; }

/* ---------- imagem para o story ---------- */
#shareOv { z-index: 20; background: rgba(20, 10, 35, .8); }
.sharebox { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; max-height: 100%; }
.sharebox img { height: min(70vh, 720px); max-width: calc(100vw - 32px); aspect-ratio: 9 / 16; object-fit: contain; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.5); -webkit-touch-callout: default; user-select: auto; }
.share-tip { color: #fff; font-size: 15px; text-align: center; max-width: 360px; }
.share-tip b { color: #f5c242; }

/* ---------- modo foto ---------- */
.photo-hud {
  position: fixed; top: 16px; right: 278px; width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
  background: rgba(255, 250, 242, .9); font-size: 20px; box-shadow: var(--shadow); display: grid; place-items: center;
}
@media (max-width: 900px) { .photo-hud { right: 218px; } }
body.touch .photo-hud { display: none; }
body.photo-mode #hud, body.photo-mode .bigmsg { display: none !important; }
.photo-bar {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 14;
  display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(680px, calc(100% - 24px));
  background: rgba(30, 20, 40, .72); backdrop-filter: blur(6px); border-radius: 20px; padding: 10px 12px; color: #fff;
}
.ph-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.ph-label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; opacity: .75; margin-right: 2px; }
.ph-btn { border: 0; border-radius: 999px; padding: 6px 12px; font: 600 13.5px "Fredoka", sans-serif; background: rgba(255,255,255,.14); color: #fff; cursor: pointer; }
.ph-btn.on { background: #fff3cf; color: #2e2236; box-shadow: 0 0 0 2px #f5c242; }
.ph-tip { font-size: 12px; opacity: .7; }
.photo-bar .btn { padding: 8px 18px; font-size: 15px; }
#shareOv.photo-shot .sharebox img { height: auto; width: min(90vw, 1100px); aspect-ratio: auto; max-height: 72vh; }
body.touch .photo-bar { bottom: 10px; padding: 8px; gap: 6px; }
body.touch .ph-btn { padding: 6px 10px; font-size: 12.5px; }
body.touch .ph-tip .touch-only { display: inline; }
body:not(.photo-ok) .photo-btn, body:not(.photo-ok) .photo-btn-hint, body:not(.photo-ok) #photoBar { display: none !important; }
