:root {
  --night: #253d73;
  --brick: #9f3f21;
  --cream: #fff8e7;
  --paper: #fffdf8;
  --ink: #2d251e;
  --gold: #f5d967;
  --coral: #d96c4f;
  --green: #2d7654;
  --shadow: 0 20px 70px rgba(18, 22, 42, .32);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; overflow-x: hidden; background: #111a35; color: var(--ink); font-family: "Trebuchet MS", Arial, sans-serif; }
button { font: inherit; }

.game-shell { min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.game-stage {
  position: relative;
  width: min(96vw, 1160px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 360px);
  align-items: stretch;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
  border: 3px solid rgba(255,255,255,.7);
  border-radius: 30px;
  box-shadow: var(--shadow);
}
.scene-viewport { position: relative; aspect-ratio: 1; overflow: hidden; isolation: isolate; background: var(--night); }
.scene-bg { position: absolute; z-index: -2; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .35s ease, transform 1.2s ease; }
.game-stage.changing .scene-bg { opacity: .28; transform: scale(1.025); }
.scene-layer, .effects-layer { position: absolute; inset: 0; pointer-events: none; }

.game-hud { position: absolute; z-index: 20; left: 18px; right: 18px; top: 16px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 9px 12px; color: white; background: rgba(18,23,48,.64); border: 1px solid rgba(255,255,255,.26); border-radius: 18px; backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.progress { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; min-width: 0; }
.progress-label { font-size: .78rem; font-weight: 800; white-space: nowrap; }
.progress-track { height: 7px; overflow: hidden; background: rgba(255,255,255,.25); border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--gold); border-radius: inherit; transition: width .5s ease; }
.sound-button { padding: 7px 10px; color: white; background: transparent; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; font-size: .72rem; font-weight: 800; cursor: pointer; }

.sprite { position: absolute; z-index: 3; pointer-events: none; filter: drop-shadow(0 14px 12px rgba(0,0,0,.18)); animation: arrive .55s cubic-bezier(.2,.8,.3,1) both; }
.sprite-ruti-wall { left: 9%; bottom: 58%; width: 30%; }
.sprite-marici { right: 3%; bottom: 13%; width: 29%; }
.sprite-ruti-shelter { left: 17%; bottom: 17%; width: 25%; }
.sprite-ruti-walk { left: 10%; bottom: 22%; width: 28%; animation: arrive .55s ease both, bob 1.8s ease-in-out .6s infinite; }
.sprite-mouse { right: 9%; bottom: 25%; width: 11%; animation: arrive .4s ease both, bob 1.2s ease-in-out .4s infinite; }
.sprite-ruti-alley { left: 18%; bottom: 1%; width: 24%; }
.sprite-cuti-alley { right: 8%; bottom: 1%; width: 28%; transition: opacity .4s ease, transform .4s ease; }
.sprite-cuti-alley.hidden { opacity: 0; transform: translateX(30px) scale(.8); }
.sprite-friends { left: 25%; bottom: 2%; width: 50%; }
.sprite-sleeping { left: 27%; bottom: 3%; width: 46%; }
.sprite-cadillac { left: 4%; bottom: 19%; width: 92%; }

.dialogue { position: relative; z-index: 15; display: flex; flex-direction: column; justify-content: center; min-width: 0; max-height: 100%; overflow-y: auto; padding: clamp(24px, 3vw, 38px); background: var(--paper); border-left: 1px solid #eadfd5; }
.chapter { margin: 0 0 5px; color: var(--coral); font-size: clamp(.66rem, 1.5vw, .82rem); font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.dialogue h1 { margin: 0 0 8px; color: #403025; font-family: Georgia, serif; font-size: clamp(1.35rem, 3vw, 2.25rem); line-height: 1.05; }
.scene-text { max-width: 690px; margin: 0; color: #61554b; font-size: clamp(.88rem, 1.9vw, 1.08rem); line-height: 1.45; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; }
.actions button { min-height: 44px; padding: 9px 16px; border: 2px solid transparent; border-radius: 999px; font-weight: 900; cursor: pointer; transition: transform .18s ease, background .18s ease; }
.actions button:hover, .actions button:focus-visible { transform: translateY(-2px); }
.primary-action { color: white; background: var(--coral); box-shadow: 0 8px 20px rgba(217,108,79,.24); }
.choice-action { color: #50392b; background: white; border-color: #d9c6b3 !important; }
.choice-action.used { color: white; background: var(--green); border-color: var(--green) !important; }
.choice-action.wrong { animation: shake .35s ease; }

.hotspot { position: absolute; z-index: 8; display: grid; width: clamp(50px, 9vw, 74px); aspect-ratio: 1; place-items: center; padding: 4px; color: white; background: rgba(217,108,79,.88); border: 3px solid white; border-radius: 50%; box-shadow: 0 0 0 8px rgba(217,108,79,.22), 0 10px 25px rgba(0,0,0,.25); font-size: clamp(.56rem, 1.2vw, .74rem); font-weight: 900; text-align: center; cursor: pointer; pointer-events: auto; animation: pulse 1.7s ease-in-out infinite; }
.hotspot.found { color: var(--green); background: white; animation: found .4s ease both; pointer-events: none; }
.clue-one { left: 23%; top: 55%; }
.clue-two { left: 55%; top: 43%; animation-delay: -.6s; }
.clue-three { right: 15%; top: 62%; animation-delay: -1.1s; }
.sound-clue { right: 16%; top: 56%; width: clamp(66px, 12vw, 96px); background: rgba(45,118,84,.9); box-shadow: 0 0 0 9px rgba(45,118,84,.2), 0 10px 25px rgba(0,0,0,.25); }

.trust { width: min(280px, 100%); margin-top: 12px; }
.trust-label { display: flex; justify-content: space-between; color: #64584e; font-size: .75rem; font-weight: 900; }
.trust-track { height: 9px; margin-top: 5px; overflow: hidden; background: #eadfd5; border-radius: 999px; }
.trust-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width .4s ease; }

.star { position: absolute; z-index: 10; color: var(--gold); font-size: 2rem; font-weight: 900; animation: starPop .75s ease both; }
.screen-flash { position: absolute; inset: 0; background: white; animation: flash .55s ease both; }

@keyframes arrive { from { opacity: 0; transform: translateY(20px) scale(.94); } }
@keyframes bob { 50% { transform: translateY(-7px); } }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 13px rgba(217,108,79,.12), 0 10px 25px rgba(0,0,0,.25); } }
@keyframes found { 70% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(.2); opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes starPop { from { opacity: 0; transform: scale(.3) rotate(-30deg); } 55% { transform: scale(1.35) rotate(10deg); } to { opacity: 0; transform: translateY(-35px); } }
@keyframes flash { to { opacity: 0; } }

@media (max-width: 820px) {
  .game-shell { padding: 0; background: var(--night); }
  .game-stage { width: 100vw; display: block; border: 0; border-radius: 0; }
  .scene-viewport { width: 100%; aspect-ratio: 1; }
  .scene-bg { object-position: center; }
  .game-hud { left: 10px; right: 10px; top: max(8px, env(safe-area-inset-top)); grid-template-columns: auto 1fr; gap: 10px; }
  .brand span, .progress-label { display: none; }
  .sound-button { grid-column: 1 / -1; position: absolute; right: 10px; top: 11px; }
  .progress { padding-right: 88px; }
  .dialogue { min-height: 260px; max-height: none; padding: 24px 18px max(28px, env(safe-area-inset-bottom)); border: 0; border-top: 1px solid #eadfd5; }
  .actions { display: grid; grid-template-columns: 1fr; }
  .actions button { width: 100%; }
  .sprite-ruti-wall { left: 4%; bottom: 58%; width: 38%; }
  .sprite-marici { right: 2%; bottom: 17%; width: 34%; }
  .sprite-ruti-shelter { left: 8%; bottom: 17%; width: 31%; }
  .sprite-ruti-walk { left: 6%; bottom: 31%; width: 34%; }
  .sprite-mouse { right: 6%; bottom: 32%; width: 15%; }
  .sprite-ruti-alley { left: 18%; bottom: 1%; width: 30%; }
  .sprite-cuti-alley { right: 5%; bottom: 1%; width: 34%; }
  .sprite-friends { left: 20%; bottom: 2%; width: 60%; }
  .sprite-sleeping { left: 21%; bottom: 3%; width: 58%; }
  .sprite-cadillac { left: 2%; bottom: 30%; width: 96%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
