:root {
  --cream: #fff9ed;
  --ink: #3f3028;
  --coral: #df6548;
  --green: #3f8a68;
  --gold: #f5ce56;
  --night: #162344;
  --shadow: 0 18px 50px rgba(23, 20, 34, .28);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; overflow: hidden; background: var(--night); color: var(--ink); font-family: "Trebuchet MS", Arial, sans-serif; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.game {
  position: relative;
  width: min(100vw, 177.7778vh);
  height: min(100vh, 56.25vw);
  margin: auto;
  overflow: hidden;
  isolation: isolate;
  background: #243b72;
}

.scene-bg { position: absolute; z-index: -3; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .35s ease, transform .7s ease; }
.game.transitioning .scene-bg { opacity: .3; transform: scale(1.025); }
.layer { position: absolute; inset: 0; }
.ambient-layer, .actor-layer { pointer-events: none; }
.interaction-layer, .message-layer { pointer-events: none; }
.interaction-layer > *, .message-layer > * { pointer-events: auto; }

.corner-controls { position: absolute; z-index: 60; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 9px; }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; padding: 0; color: white; background: rgba(21, 27, 48, .58); border: 1px solid rgba(255,255,255,.5); border-radius: 50%; box-shadow: 0 6px 18px rgba(0,0,0,.18); backdrop-filter: blur(8px); cursor: pointer; }
.icon-button:hover, .icon-button:focus-visible { background: rgba(21,27,48,.84); transform: translateY(-2px); }
.hidden { display: none !important; }

.actor { position: absolute; z-index: 5; object-fit: contain; filter: drop-shadow(0 12px 12px rgba(0,0,0,.16)); animation: actorIn .55s cubic-bezier(.2,.8,.2,1) both; transform-origin: center bottom; }
.actor.marici { left: 5%; bottom: 0; width: 22%; max-height: 82%; }
.actor.ruti { left: 8%; bottom: 1%; width: 18%; }
.actor.cuti { left: 25%; bottom: 1%; width: 20%; }
.actor.dog-search { right: 8%; bottom: 0; width: 64%; }
.actor.dog-care { left: 24%; bottom: 20%; width: 58%; }
.actor.dog-happy { left: 20%; bottom: 1%; width: 62%; }
.actor.dog-search, .actor.dog-care, .actor.dog-happy { mix-blend-mode: multiply; }
.actor.forest-dog { left: 39%; bottom: 0; width: 54%; }
.actor.dog-area-ruti { left: 3%; bottom: 1%; width: 14%; }
.actor.dog-area-cuti { left: 14%; bottom: 1%; width: 15%; }
.actor.water-bowl { left: 43%; bottom: 8%; width: 11%; }
.actor.friend-cheer { animation: friendCheer .7s ease 2; }
.actor.action-drink { animation: dogDrink 1.2s ease both; }
.actor.action-tunnel { animation: dogTunnel 1.2s ease both; }
.actor.action-toy { animation: dogToy 1.2s ease both; }
.actor.care-check { animation: careCheck .8s ease; }
.actor.care-clean { animation: careClean .8s ease; }
.actor.care-drink { animation: careDrink .9s ease; }
.actor.care-eat { animation: careEat .9s ease; }
.actor.bus-front { left: 28%; bottom: -5%; width: 44%; }
.actor.bus-side { left: 8%; bottom: 1%; width: 66%; }
.actor.bus-return { left: 8%; bottom: 0; width: 72%; }
.actor.bed { left: 29%; bottom: 1%; width: 42%; }

.message-card {
  position: absolute;
  z-index: 35;
  left: clamp(14px, 3vw, 44px);
  bottom: clamp(14px, 3vw, 38px);
  width: min(360px, calc(100% - 28px));
  padding: clamp(13px, 1.8vw, 19px);
  background: rgba(255, 249, 237, .95);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: cardIn .4s ease both;
}
.message-card.center {
  left: clamp(14px, 3vw, 44px);
  bottom: clamp(14px, 3vw, 38px);
  width: min(350px, 38%);
  transform: none;
  text-align: left;
}
.message-card.important { background: rgba(255, 249, 237, .98); }
.eyebrow { margin: 0 0 5px; color: var(--coral); font-size: .76rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.message-card h1, .message-card h2 { margin: 0 0 9px; font-family: Georgia, serif; line-height: 1.02; }
.message-card h1 { font-size: clamp(1.35rem, 2.7vw, 2.15rem); }
.message-card h2 { font-size: clamp(1.15rem, 2.3vw, 1.75rem); }
.message-card p { margin: 0; font-size: clamp(.78rem, 1.35vw, .96rem); line-height: 1.35; }
.actions { display: flex; flex-wrap: wrap; justify-content: inherit; gap: 9px; margin-top: 11px; }
.button { min-height: 44px; padding: 10px 18px; color: white; background: var(--coral); border: 0; border-radius: 999px; box-shadow: 0 8px 20px rgba(223,101,72,.25); font-weight: 900; cursor: pointer; }
.button.secondary { color: var(--ink); background: white; border: 2px solid #ddc9b5; box-shadow: none; }
.button:hover, .button:focus-visible { transform: translateY(-2px); }

.hotspot { position: absolute; z-index: 18; display: grid; place-items: center; min-width: 58px; min-height: 58px; padding: 8px; color: white; background: rgba(223,101,72,.9); border: 3px solid white; border-radius: 50%; box-shadow: 0 0 0 9px rgba(223,101,72,.18), 0 12px 25px rgba(0,0,0,.22); font-size: .76rem; font-weight: 900; text-align: center; cursor: pointer; animation: pulse 1.6s ease-in-out infinite; }
.hotspot.paw::before { content: "♥"; font-size: 1.35rem; }
.hotspot.disabled { filter: grayscale(1); opacity: .55; cursor: not-allowed; animation: none; }
.hotspot.found { animation: found .45s ease both; pointer-events: none; }
.hotspot-label { position: absolute; left: 50%; top: calc(100% + 7px); transform: translateX(-50%); padding: 5px 9px; color: var(--ink); background: white; border-radius: 999px; box-shadow: 0 6px 16px rgba(0,0,0,.16); font-size: .7rem; white-space: nowrap; }

.door-hotspot { left: 37%; top: 50%; }
.computer-hotspot { right: 15%; top: 43%; }
.map-foundation { left: 8%; top: 13%; }
.map-park { right: 8%; top: 13%; }
.map-alley { left: 7%; bottom: 16%; }
.map-alley:not(.disabled) { min-width: 118px; min-height: 118px; background: rgba(63,138,104,.96); box-shadow: 0 0 0 16px rgba(63,138,104,.22), 0 14px 30px rgba(0,0,0,.28); }
.map-alley:not(.disabled) .hotspot-label { padding: 8px 13px; color: white; background: var(--green); font-size: .82rem; }
.map-forest { right: 8%; bottom: 12%; }
.clue-prints { left: 34%; top: 62%; }
.clue-bowl { right: 27%; top: 55%; }
.clue-sound { right: 12%; top: 28%; }
.sound-search { right: 18%; top: 43%; min-width: 88px; min-height: 88px; background: rgba(63,138,104,.92); }
.boarding-hotspot { right: 25%; bottom: 25%; }
.play-pool { left: 48%; top: 61%; }
.play-tunnel { left: 13%; top: 62%; }
.play-toy { right: 15%; bottom: 16%; }
.forest-flower { left: 17%; bottom: 18%; }
.forest-trail { left: 50%; bottom: 13%; }
.forest-bird { right: 17%; top: 22%; }

.inventory-screen, .reward-screen { position: absolute; z-index: 30; inset: 0; display: grid; align-content: center; justify-items: center; padding: 4vh 5vw; background: rgba(25, 30, 45, .74); backdrop-filter: blur(7px); }
.inventory-panel, .reward-panel { width: min(980px, 100%); max-height: 94%; overflow: auto; padding: clamp(18px, 3vw, 32px); background: rgba(255,249,237,.97); border-radius: 28px; box-shadow: var(--shadow); text-align: center; }
.inventory-panel h2, .reward-panel h2 { margin: 0 0 5px; font-family: Georgia, serif; font-size: clamp(1.5rem, 3.5vw, 2.5rem); }
.inventory-panel p, .reward-panel p { margin: 0 0 17px; }
.item-grid { display: grid; grid-template-columns: repeat(5, minmax(95px, 1fr)); gap: 11px; }
.item { position: relative; display: grid; grid-template-rows: 80px auto; align-items: center; gap: 5px; min-height: 120px; padding: 10px; color: var(--ink); background: white; border: 2px solid #ead9c8; border-radius: 17px; font-weight: 900; cursor: pointer; }
.item img { width: 100%; height: 78px; object-fit: contain; }
.item.selected { color: white; background: var(--green); border-color: var(--green); }
.item.wrong { animation: shake .35s ease; }
.bag-count { margin-top: 12px; font-weight: 900; }

.tool-tray { position: absolute; z-index: 22; left: 50%; bottom: 3%; display: flex; gap: 10px; max-width: 94%; padding: 10px; transform: translateX(-50%); background: rgba(255,249,237,.88); border: 1px solid rgba(255,255,255,.85); border-radius: 22px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.tool { display: grid; width: clamp(64px, 8vw, 90px); min-width: 58px; grid-template-rows: 48px auto; place-items: center; gap: 3px; padding: 6px; color: var(--ink); background: white; border: 2px solid transparent; border-radius: 14px; font-size: .68rem; font-weight: 900; cursor: pointer; }
.tool img { width: 48px; height: 48px; object-fit: contain; }
.tool.done { color: white; background: var(--green); pointer-events: none; }

.meter { position: absolute; z-index: 23; right: 5%; top: 12%; width: min(280px, 36%); padding: 11px 14px; color: var(--ink); background: rgba(255,249,237,.92); border-radius: 18px; box-shadow: var(--shadow); }
.meter strong { display: flex; justify-content: space-between; font-size: .78rem; }
.paws { display: flex; gap: 5px; margin-top: 7px; }
.paws span { display: grid; width: 27px; height: 27px; place-items: center; color: #c9b9aa; background: white; border-radius: 50%; transition: .25s ease; }
.paws span.on { color: white; background: var(--coral); transform: scale(1.08); }

.road-bg { animation: roadPan 5s linear infinite; }
.driving-bus { animation: busRide 1.2s ease-in-out infinite alternate; }
.wheel { position: absolute; z-index: 8; width: 9%; animation: wheelSpin .65s linear infinite; }
.wheel.one { left: 24%; bottom: 4%; }
.wheel.two { right: 20%; bottom: 4%; }

.toast { position: absolute; z-index: 80; left: 50%; bottom: 4%; max-width: min(560px, 90%); padding: 10px 17px; color: white; background: rgba(24,29,43,.86); border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.24); font-weight: 900; text-align: center; opacity: 0; transform: translate(-50%, 15px); pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.name-input { width: min(340px, 100%); margin-top: 15px; padding: 12px 16px; border: 2px solid #d8c2ad; border-radius: 999px; text-align: center; font-size: 1.05rem; font-weight: 900; }
.medal { display: grid; width: 120px; height: 120px; place-items: center; margin: 0 auto 13px; color: #7a4b18; background: radial-gradient(circle at 35% 30%, #fff1a4, #f5c348 58%, #d78c1d); border: 8px solid #fff1b0; border-radius: 50%; box-shadow: 0 12px 25px rgba(117,71,16,.28); font-size: 2.8rem; }

.rotate-hint { display: none; position: fixed; z-index: 200; inset: 0; align-content: center; justify-items: center; gap: 8px; padding: 28px; color: white; background: var(--night); text-align: center; }
.rotate-hint strong { font-size: 1.5rem; }

@keyframes actorIn { from { opacity: 0; transform: translateY(20px) scale(.94); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px); } }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(223,101,72,.1), 0 12px 25px rgba(0,0,0,.22); } }
@keyframes found { 60% { transform: scale(1.25); opacity: 1; } to { transform: scale(.2); opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes roadPan { from { object-position: 0 center; } to { object-position: 100% center; } }
@keyframes busRide { to { transform: translateY(-5px); } }
@keyframes wheelSpin { to { transform: rotate(360deg); } }
@keyframes friendCheer { 50% { transform: translateY(-12px) rotate(-4deg); } }
@keyframes dogDrink { 45%,70% { transform: translate(-6vw, 7vh) scale(.88) rotate(7deg); } }
@keyframes dogTunnel { 45%,70% { transform: translate(-20vw, 1vh) scale(.72); opacity: .58; } }
@keyframes dogToy { 35% { transform: translate(10vw,-10vh) rotate(-8deg); } 70% { transform: translate(16vw,0) rotate(5deg); } }
@keyframes careCheck { 50% { transform: scale(.96); } }
@keyframes careClean { 30%,70% { transform: translateX(-8px) rotate(-2deg); } 50% { transform: translateX(8px) rotate(2deg); } }
@keyframes careDrink { 50%,75% { transform: translate(7vw,5vh) rotate(6deg) scale(.92); } }
@keyframes careEat { 30%,60% { transform: translateY(7px) rotate(3deg); } 45%,75% { transform: translateY(-2px) rotate(-3deg); } }

@media (max-width: 900px) {
  .message-card, .message-card.center { width: min(315px, 42%); padding: 11px 14px; }
  .message-card h1 { font-size: 1.35rem; }
  .message-card h2 { font-size: 1.16rem; }
  .message-card p { font-size: .76rem; }
  .message-card .button { min-height: 38px; padding: 7px 13px; font-size: .8rem; }
  .item-grid { grid-template-columns: repeat(5, minmax(72px, 1fr)); gap: 7px; }
  .item { grid-template-rows: 54px auto; min-height: 89px; padding: 6px; font-size: .67rem; }
  .item img { height: 52px; }
  .inventory-panel { padding: 15px; }
  .tool-tray { gap: 5px; padding: 6px; }
  .tool { grid-template-rows: 36px auto; }
  .tool img { width: 36px; height: 36px; }
}
/* Aviso para virar o celular */
@media (max-width: 900px) and (orientation: portrait) {
  .rotate-hint {
    display: grid !important;
  }

  #game {
    filter: blur(2px);
    pointer-events: none;
  }
}

@media (orientation: landscape) {
  .rotate-hint {
    display: none !important;
  }

  #game {
    filter: none;
    pointer-events: auto;
  }
}

@media (orientation: portrait) and (max-width: 800px) {
  body { overflow: hidden; }
  .game { display: block; width: 100vw; height: 100vh; height: 100svh; }
  .rotate-hint { display: none; }
  .message-card, .message-card.center {
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100% - 24px);
    max-height: 42%;
    overflow: auto;
  }
  .message-card h1 { font-size: 1.45rem; }
  .message-card h2 { font-size: 1.22rem; }
  .message-card p { font-size: .86rem; }
  .actions { gap: 7px; }
  .message-card .button { flex: 1 1 auto; }
  .inventory-screen, .reward-screen { padding: 12px; }
  .inventory-panel, .reward-panel { max-height: 88%; padding: 14px; border-radius: 20px; }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-tray { bottom: max(8px, env(safe-area-inset-bottom)); overflow-x: auto; }
  .meter { top: 72px; right: 12px; width: min(250px, calc(100% - 24px)); }
  .hotspot { min-width: 64px; min-height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* Ajuste celular deitado - O Primeiro Chamado */
@media (max-width: 900px) and (orientation: landscape) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  #game {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .scene-bg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--night);
  }

  .message-card,
  .message-card.center {
    transform: scale(0.82);
    transform-origin: left bottom;
  }
}
