:root{
  --green-dark:#081f16;
  --green:#123c2c;
  --green-mid:#1b5c46;
  --orange:#ff8a00;
  --orange-light:#ffb15c;
  --gold:#c9a24b;
  --gold-light:#e6c47a;
  --red:#7a0f1f;
  --ink:#0a0f0c;
  --paper:#f3e8d0;
  --paper-dark:#e6d6ac;
  --text-light:#f5ecd9;
  --shadow:0 10px 30px rgba(0,0,0,.55);
  --radius:14px;
  font-size:16px;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  min-height:100vh;
  background:
    radial-gradient(ellipse at 50% -10%, #1c4636 0%, transparent 60%),
    linear-gradient(160deg,#081912 0%,#0a1a12 40%,#05100b 100%);
  font-family:Georgia,'Times New Roman',serif;
  color:var(--text-light);
  overflow:hidden;
}

#app{
  position:relative;
  width:100vw;
  height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
}

.hidden{display:none !important;}

/* ============ SCREENS ============ */
.screen{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* ---------- start screen ---------- */
#screen-start{
  background:
    radial-gradient(circle at 30% 20%, rgba(255,138,0,.12), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(255,46,147,.10), transparent 50%),
    linear-gradient(160deg,#081912,#05100b);
}
.start-card{
  width:min(640px,90vw);
  padding:44px 40px 36px;
  background:linear-gradient(180deg,#153a2c,#0d271d);
  border:3px solid var(--gold);
  border-radius:20px;
  box-shadow:var(--shadow), inset 0 0 40px rgba(255,138,0,.06);
  text-align:center;
  position:relative;
}
.start-card::before{
  content:"";
  position:absolute; inset:8px;
  border:1px solid rgba(230,196,122,.35);
  border-radius:14px;
  pointer-events:none;
}
.deer-badge{
  width:84px;height:84px;margin:0 auto 14px;
  filter:drop-shadow(0 4px 10px rgba(0,0,0,.5));
}
.deer-badge svg{width:100%;height:100%;}
.deer-badge.small{width:44px;height:44px;margin:0;}

.start-card h1{
  margin:6px 0 2px;
  font-size:2.1rem;
  letter-spacing:3px;
  color:var(--orange-light);
  text-shadow:0 2px 0 #000, 0 0 18px rgba(255,138,0,.5);
}
.start-card h1 span{color:var(--gold-light);font-size:1.35rem;letter-spacing:8px;}
.tagline{color:var(--gold);font-style:italic;margin:2px 0 18px;font-size:.95rem;}
.intro-text{
  color:var(--text-light);
  line-height:1.55;
  font-size:.98rem;
  background:rgba(0,0,0,.2);
  border:1px solid rgba(230,196,122,.25);
  border-radius:10px;
  padding:16px 18px;
  margin-bottom:22px;
}
.hint-small{margin-top:14px;font-size:.8rem;color:#9fc9b3;font-style:italic;}

.btn-primary{
  font-family:Georgia,serif;
  font-weight:700;
  font-size:1.05rem;
  letter-spacing:1px;
  padding:14px 34px;
  border-radius:999px;
  border:2px solid var(--gold-light);
  background:linear-gradient(180deg,var(--orange-light),var(--orange) 60%,#c96500);
  color:#2a1500;
  cursor:pointer;
  box-shadow:0 6px 0 #a34e00, 0 10px 18px rgba(0,0,0,.4);
  transition:transform .08s ease;
}
.btn-primary:hover{transform:translateY(-2px);}
.btn-primary:active{transform:translateY(2px);box-shadow:0 2px 0 #a34e00;}

/* ============ GAME SCREEN ============ */
#screen-game{
  flex-direction:column;
  align-items:stretch;
  padding:14px;
  gap:10px;
}

/* ---------- HUD ---------- */
#hud{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  background:linear-gradient(180deg,#173d2e,#0e2a20);
  border:2px solid var(--gold);
  border-radius:12px;
  padding:8px 16px;
  flex-wrap:wrap;
}
.hud-left{display:flex;align-items:center;gap:10px;}
.hud-title{line-height:1.1;}
.hud-name{font-weight:700;color:var(--gold-light);letter-spacing:2px;font-size:.85rem;}
.hud-room{color:var(--orange-light);font-size:1.05rem;font-weight:700;}

#room-nav{display:flex;gap:6px;flex-wrap:wrap;}
.room-btn{
  font-family:Georgia,serif;
  font-size:.78rem;
  padding:7px 12px;
  border-radius:8px;
  border:1px solid rgba(230,196,122,.4);
  background:rgba(0,0,0,.25);
  color:var(--text-light);
  cursor:pointer;
}
.room-btn:hover{border-color:var(--orange-light);color:var(--orange-light);}
.room-btn.active{background:var(--orange);color:#2a1500;border-color:var(--orange-light);font-weight:700;}
.room-btn .done-dot{color:#7fe0a0;margin-left:4px;}

.hud-right{display:flex;align-items:center;gap:12px;}
.score-meters{display:flex;gap:8px;}
.meter{display:flex;flex-direction:column;align-items:center;gap:3px;width:44px;}
.meter-bar{width:10px;height:34px;border-radius:5px;background:rgba(0,0,0,.4);border:1px solid rgba(230,196,122,.3);position:relative;overflow:hidden;}
.meter-fill{position:absolute;bottom:0;left:0;width:100%;height:0%;background:linear-gradient(0deg,var(--orange),var(--gold-light));transition:height .5s ease;}
.meter-label{font-size:.58rem;color:var(--gold);text-align:center;letter-spacing:.5px;}

.score-total{
  font-weight:700;font-size:1.3rem;color:var(--orange-light);
  background:rgba(0,0,0,.3);border:1px solid var(--gold);border-radius:10px;padding:4px 12px;
}
.score-total .score-max{font-size:.85rem;color:var(--gold);}

.btn-secondary{
  font-family:Georgia,serif;font-weight:700;font-size:.85rem;
  padding:9px 14px;border-radius:8px;border:1px solid var(--gold-light);
  background:linear-gradient(180deg,#1e5b45,#123c2c);color:var(--text-light);cursor:pointer;
}
.btn-secondary:hover{border-color:var(--orange-light);color:var(--orange-light);}
.btn-ghost{
  font-size:1rem;padding:7px 10px;border-radius:8px;border:1px solid rgba(230,196,122,.4);
  background:transparent;color:var(--gold-light);cursor:pointer;
}
.btn-ghost:hover{color:var(--orange-light);border-color:var(--orange-light);}
.btn-ghost.small{padding:2px 8px;font-size:.8rem;}

/* ---------- viewport ---------- */
#viewport{
  position:relative;
  flex:1;
  min-height:0;
  border-radius:14px;
  overflow:hidden;
  border:3px solid var(--gold);
  box-shadow:var(--shadow);
  background:#000;
}
#room-bg{
  position:absolute;inset:0;width:100%;height:100%;object-fit:cover;
  user-select:none;pointer-events:none;
}

.hotspot{
  position:absolute;
  border:2px dashed rgba(255,177,92,.0);
  border-radius:10px;
  cursor:pointer;
  background:rgba(255,138,0,0);
  transition:background .15s ease, border-color .15s ease;
}
.hotspot:hover{
  border-color:rgba(255,177,92,.85);
  background:rgba(255,138,0,.12);
  box-shadow:0 0 22px rgba(255,138,0,.35) inset;
}
.hotspot.filled{
  border-color:rgba(127,224,160,.7);
  background:rgba(46,255,138,.06);
}
.hotspot.filled:hover{background:rgba(46,255,138,.14);}
.hotspot-icon{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  pointer-events:none;
}
.hotspot-icon svg{width:56%;height:56%;filter:drop-shadow(0 4px 8px rgba(0,0,0,.6));}
.hotspot-pulse{
  position:absolute;inset:0;border-radius:10px;
  box-shadow:0 0 0 0 rgba(255,138,0,.5);
  animation:pulse 2.2s infinite;
  pointer-events:none;
}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 rgba(255,138,0,.35);}
  70%{box-shadow:0 0 0 14px rgba(255,138,0,0);}
  100%{box-shadow:0 0 0 0 rgba(255,138,0,0);}
}

.npc{
  position:absolute;
  bottom:6%;
  width:9%;
  max-width:120px;
  min-width:60px;
  aspect-ratio:120/220;
  cursor:pointer;
  filter:drop-shadow(0 8px 10px rgba(0,0,0,.5));
  transition:transform .15s ease;
}
.npc svg{width:100%;height:100%;}
.npc:hover{transform:translateY(-4px);}
#npc-owner{left:62%;}
#npc-owner.hidden-npc{display:none;}
#npc-player{left:14%;cursor:default;pointer-events:none;opacity:.96;}
#npc-player.hidden-npc{display:none;}

.floating-item{
  position:fixed;
  width:52px;height:52px;
  pointer-events:none;
  z-index:500;
  transform:translate(-50%,-50%);
  filter:drop-shadow(0 6px 10px rgba(0,0,0,.6)) drop-shadow(0 0 8px rgba(255,138,0,.6));
}
.floating-item svg{width:100%;height:100%;}

/* ---------- caption bar ---------- */
#caption-bar{
  min-height:16px;
  text-align:center;
  color:var(--gold-light);
  font-style:italic;
  font-size:.92rem;
  padding:2px 10px;
}

/* ---------- inventory ---------- */
#inventory-bar{
  display:flex;align-items:center;gap:14px;
  background:linear-gradient(180deg,#173d2e,#0e2a20);
  border:2px solid var(--gold);
  border-radius:12px;
  padding:10px 16px;
}
.inv-label{font-size:.7rem;letter-spacing:2px;color:var(--gold);writing-mode:horizontal-tb;white-space:nowrap;}
#inventory-items{display:flex;gap:8px;flex:1;overflow-x:auto;padding:2px;}
.inv-item{
  position:relative;
  width:56px;height:56px;flex:0 0 auto;
  border-radius:10px;
  border:2px solid rgba(230,196,122,.4);
  background:rgba(0,0,0,.3);
  cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:transform .1s ease, border-color .1s ease;
}
.inv-item svg{width:72%;height:72%;}
.inv-item:hover{transform:translateY(-3px);border-color:var(--orange-light);}
.inv-item.selected{border-color:var(--orange);box-shadow:0 0 0 3px rgba(255,138,0,.35);}
.inv-item.used{opacity:.25;cursor:default;filter:grayscale(1);}
.inv-item .inv-pts{
  position:absolute;bottom:-6px;right:-6px;
  background:var(--gold);color:#2a1500;font-size:.6rem;font-weight:700;
  border-radius:8px;padding:1px 5px;border:1px solid #2a1500;
}
.inv-empty-msg{color:#9fc9b3;font-style:italic;font-size:.85rem;padding:8px;}

.inv-held{display:flex;align-items:center;gap:8px;flex:0 0 auto;padding-left:12px;border-left:1px solid rgba(230,196,122,.3);}
.inv-held-label{font-size:.75rem;color:var(--gold);white-space:nowrap;}
#inv-held-icon{
  width:44px;height:44px;border-radius:8px;border:2px solid var(--orange-light);
  background:rgba(255,138,0,.12);
  display:flex;align-items:center;justify-content:center;color:var(--gold);font-size:1.2rem;
}
#inv-held-icon svg{width:72%;height:72%;}

/* ============ overlays ============ */
.overlay{
  position:absolute;inset:0;
  background:rgba(4,10,7,.72);
  display:flex;align-items:center;justify-content:center;
  z-index:700;
  padding:20px;
}

/* dialogue */
#dialogue-overlay{align-items:flex-end;justify-content:center;}
.dialogue-box{
  width:min(820px,94vw);
  margin-bottom:min(4vh,30px);
  display:flex;gap:18px;
  background:linear-gradient(180deg,var(--paper),var(--paper-dark));
  border:3px solid var(--gold);
  border-radius:16px;
  padding:20px 22px;
  box-shadow:var(--shadow);
  color:#241608;
}
.dialogue-portrait{
  width:78px;height:142px;flex:0 0 auto;
  filter:drop-shadow(0 4px 6px rgba(0,0,0,.35));
}
.dialogue-portrait svg{width:100%;height:100%;}
.dialogue-content{flex:1;min-width:0;}
.dialogue-speaker{font-weight:700;color:var(--red);letter-spacing:1px;margin-bottom:6px;font-size:.95rem;}
.dialogue-text{font-size:1rem;line-height:1.5;margin-bottom:14px;}
.dialogue-choices{display:flex;flex-direction:column;gap:8px;}
.dlg-choice{
  text-align:left;
  font-family:Georgia,serif;
  font-size:.92rem;
  padding:9px 14px;
  border-radius:8px;
  border:1px solid rgba(122,15,31,.35);
  background:rgba(255,255,255,.35);
  color:#241608;
  cursor:pointer;
}
.dlg-choice:hover{background:var(--orange-light);border-color:var(--red);}
.dlg-choice .arrow{color:var(--red);margin-right:6px;}

/* toast */
.toast{
  position:absolute;
  top:18%;
  left:50%;
  transform:translateX(-50%);
  background:linear-gradient(180deg,#1e5b45,#123c2c);
  border:2px solid var(--gold-light);
  color:var(--orange-light);
  font-weight:700;
  padding:10px 22px;
  border-radius:999px;
  box-shadow:var(--shadow);
  z-index:800;
  animation:toastPop 1.8s ease forwards;
}
@keyframes toastPop{
  0%{opacity:0;transform:translate(-50%,10px) scale(.9);}
  12%{opacity:1;transform:translate(-50%,0) scale(1);}
  80%{opacity:1;}
  100%{opacity:0;transform:translate(-50%,-14px) scale(.95);}
}

/* win */
.win-card{
  width:min(560px,90vw);
  text-align:center;
  padding:40px 36px;
  background:linear-gradient(180deg,#153a2c,#0d271d);
  border:3px solid var(--gold-light);
  border-radius:20px;
  box-shadow:var(--shadow), 0 0 60px rgba(255,138,0,.25);
}
.win-card h2{
  color:var(--orange-light);
  letter-spacing:2px;
  text-shadow:0 2px 0 #000,0 0 20px rgba(255,138,0,.6);
  margin:14px 0 10px;
}
.win-card p{color:var(--text-light);line-height:1.5;margin-bottom:18px;}
.win-score{font-size:2.6rem;font-weight:700;color:var(--gold-light);margin-bottom:22px;}
.win-score span{font-size:1.2rem;color:var(--gold);}

/* ============ responsive ============ */
@media (max-width:900px){
  #hud{flex-direction:column;align-items:stretch;}
  .hud-right{justify-content:space-between;}
  .score-meters{order:3;width:100%;justify-content:center;}
  #room-nav{order:2;justify-content:center;}
  .npc{width:14%;}
  .dialogue-box{flex-direction:column;align-items:center;text-align:center;}
  .dialogue-portrait{width:64px;height:118px;}
}
