:root{
  color-scheme: dark;
  --bg:#101a12; --panel:#18241b; --edge:#2f4434;
  --text:#eaf3ea; --muted:#9db3a3; --gold:#ffd166; --leaf:#7fc98a;
  --safe-b: env(safe-area-inset-bottom);
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent}
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--text); overflow:hidden;
  font-family:"Iowan Old Style","Palatino Linotype",Georgia,serif;
  user-select:none;
}
.scene{position:absolute; inset:0; display:none}
.scene.active{display:block}

/* ---------- shared bits ---------- */
.btn{
  appearance:none; border:2px solid var(--edge); background:var(--panel); color:var(--text);
  font:inherit; font-size:15px; padding:11px 16px; border-radius:12px; cursor:pointer;
}
.btn:hover{border-color:var(--leaf)}
.btn.big{font-size:19px; padding:14px 22px; border-color:var(--gold); color:var(--gold)}
.btn.ghost{background:transparent; color:var(--muted)}
.pill{
  display:inline-flex; align-items:center; gap:5px; padding:6px 11px; border-radius:999px;
  background:#0d1710cc; border:1px solid var(--edge); font-size:13px; font-family:system-ui,sans-serif;
}
.pill.link{cursor:pointer; color:var(--text)}
.tip{color:var(--muted); font-size:13.5px; line-height:1.6; margin:0}
.field{display:flex; flex-direction:column; gap:6px; width:100%; text-align:left}
.field > span{font-size:13px; color:var(--muted); font-family:system-ui,sans-serif}
.field input{
  padding:12px 14px; border-radius:12px; background:#0d1710; border:2px solid var(--edge);
  color:var(--text); font:inherit; font-size:17px;
}
.chips{display:flex; flex-wrap:wrap; gap:8px}
.chip{
  padding:9px 14px; border-radius:999px; background:var(--panel); border:2px solid var(--edge);
  color:var(--text); font:inherit; font-size:14px; cursor:pointer;
}
.chip[aria-checked="true"]{border-color:var(--gold); color:var(--gold); background:#2a2412}

/* ---------- title ---------- */
.title-wrap{
  position:absolute; inset:0; overflow-y:auto;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:16px;
  padding:34px 20px calc(30px + var(--safe-b)); text-align:center; max-width:520px; margin:0 auto;
}
h1{font-size:clamp(30px,8vw,46px); margin:0; color:var(--gold); letter-spacing:-1px}
h2{font-size:clamp(22px,6vw,30px); margin:0}
.lede{font-size:16.5px; line-height:1.65; margin:0; white-space:pre-line}
.hero-preview{width:120px; height:170px}
.hero-preview svg{width:100%; height:100%}

/* ---------- the world ---------- */
#bg{position:absolute; inset:0; background-size:cover; background-position:center bottom}
#things{position:absolute; inset:0}
.thing{
  position:absolute; display:flex; flex-direction:column; align-items:center; gap:3px;
  cursor:pointer; transform-origin:50% 100%;
}
.thing .halo{
  width:54px; height:54px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-size:27px; background:#0d1710aa; border:2px solid #ffffff44;
  animation:bob 3.4s ease-in-out infinite;
}
.thing.hot .halo{border-color:var(--gold); background:#3a2f10cc}
.thing .name{
  font-size:11.5px; font-family:system-ui,sans-serif; background:#0d1710cc; padding:2px 7px;
  border-radius:999px; white-space:nowrap; color:var(--muted);
}
.thing.hot .name{color:var(--gold)}
@keyframes bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}

#hero{position:absolute; width:78px; transform-origin:50% 100%; transition:left .1s linear, bottom .1s linear}
#hero svg{width:100%; height:auto}

#hud{
  position:absolute; top:calc(8px + env(safe-area-inset-top)); left:0; right:0;
  display:flex; gap:7px; justify-content:center; flex-wrap:wrap; padding:0 10px; z-index:430;
}

/* The story sits at the TOP, out of the way of the controls, and can always
   be dismissed. It used to sit exactly where the verb menu opens, which made
   the game unplayable. */
#say{
  position:absolute; left:0; right:0; top:calc(46px + env(safe-area-inset-top));
  padding:0 12px; z-index:410; display:flex; justify-content:center;
}
#say p{
  margin:0; max-width:600px; background:#0d1710f0; border:2px solid var(--edge);
  border-radius:14px; padding:11px 40px 11px 14px; font-size:15px; line-height:1.5;
  white-space:pre-line; max-height:34vh; overflow-y:auto; position:relative;
  box-shadow:0 6px 22px #0007;
}
#say-close{
  position:absolute; top:calc(46px + env(safe-area-inset-top) + 4px); right:16px;
  width:30px; height:30px; border-radius:50%; border:2px solid var(--edge);
  background:#0d1710; color:var(--muted); font-size:14px; cursor:pointer; z-index:411; line-height:1;
}
#say-close:hover{color:var(--text); border-color:var(--leaf)}

#verbs, #usepick{
  position:absolute; left:0; right:0; bottom:calc(170px + var(--safe-b)); z-index:420; padding:0 12px;
  background:linear-gradient(180deg,#101a1200,#101a12dd 22%); padding-top:16px; padding-bottom:8px;
}
.verb-title{
  text-align:center; font-size:14px; color:var(--gold); margin-bottom:7px;
  font-family:system-ui,sans-serif;
}
.verb-row{
  display:flex; flex-wrap:wrap; gap:7px; justify-content:center; max-width:560px; margin:0 auto;
}
.verb-row .btn{font-size:14px; padding:10px 13px}

#bag{
  position:absolute; left:0; right:0; bottom:calc(118px + var(--safe-b)); z-index:390; padding:0 12px;
}
.bag-row{display:flex; gap:7px; justify-content:center; flex-wrap:wrap}
.bag-item{
  display:flex; flex-direction:column; align-items:center; gap:1px; padding:6px 9px; border-radius:11px;
  background:#0d1710dd; border:2px solid var(--edge); cursor:pointer; font:inherit;
  color:var(--text);
}
.bag-item .e{font-size:21px; line-height:1}
.bag-item .n{font-size:9.5px; font-family:system-ui,sans-serif; color:var(--muted)}
.bag-item.on{border-color:var(--gold)}

.pad{
  position:absolute; left:0; right:0; bottom:calc(12px + var(--safe-b));
  display:flex; gap:16px; justify-content:center; align-items:center; z-index:400;
}
/* A grid, not absolute positioning — it cannot overflow its own box and drop
   buttons off the bottom of the screen, which is exactly what it did before. */
.dpad{
  display:grid; gap:6px;
  grid-template-columns:repeat(3, 48px);
  grid-template-areas: ". up ." "left down right";
}
.dpad .up{grid-area:up}
.dpad .left{grid-area:left}
.dpad .down{grid-area:down}
.dpad .right{grid-area:right}
.padbtn{
  border-radius:14px; background:#0d1710e6; border:2px solid var(--edge);
  color:var(--text); font-size:19px; cursor:pointer; width:48px; height:46px; padding:0;
}
.dpad .padbtn:active{border-color:var(--leaf); background:#16301cee}
.padbtn.act{width:72px; height:66px; font-size:26px; border-color:var(--gold); color:var(--gold)}
.padbtn:disabled{opacity:.35}

#toast{
  position:absolute; left:50%; top:calc(64px + env(safe-area-inset-top)); transform:translateX(-50%);
  background:#0d1710f2; border:2px solid var(--gold); color:var(--text); padding:11px 16px;
  border-radius:13px; font-size:14.5px; max-width:88%; text-align:center; z-index:440; white-space:pre-line;
}
.speakrow{
  display:flex; align-items:center; gap:9px; font-size:15px; color:var(--text);
  background:var(--panel); border:2px solid var(--edge); border-radius:12px; padding:11px 14px;
  cursor:pointer; width:100%;
}
.speakrow input{width:20px; height:20px; accent-color:var(--gold)}

/* ---------- making your person ---------- */
.maker{display:flex; gap:14px; align-items:flex-start; width:100%; text-align:left}
.maker .hero-preview{
  flex:0 0 118px; width:118px; height:180px; position:sticky; top:0;
  background:#0d1710; border:2px solid var(--edge); border-radius:14px; padding:6px;
}
.maker-opts{flex:1; min-width:0; max-height:300px; overflow-y:auto; display:flex; flex-direction:column; gap:10px}
.mk-row > span{
  display:block; font-size:11.5px; color:var(--muted); margin-bottom:4px;
  font-family:system-ui,sans-serif; text-transform:uppercase; letter-spacing:.5px;
}
.mk-chips{display:flex; flex-wrap:wrap; gap:5px}
.mk-chip{
  padding:6px 10px; border-radius:999px; background:var(--panel); border:2px solid var(--edge);
  color:var(--text); font:inherit; font-size:12.5px; cursor:pointer;
}
.mk-chip[aria-checked="true"]{border-color:var(--gold); color:var(--gold); background:#2a2412}
.mk-swatches{display:flex; flex-wrap:wrap; gap:5px}
.mk-sw{
  width:28px; height:28px; border-radius:50%; border:2px solid var(--edge); cursor:pointer; padding:0;
}
.mk-sw[aria-checked="true"]{border-color:var(--gold); box-shadow:0 0 0 2px var(--gold)}
/* ---------- the things in the dark ---------- */
#zombies{position:absolute; inset:0; pointer-events:none}
.zombie{
  position:absolute; width:70px; transform-origin:50% 100%;
  transition:left .1s linear, bottom .1s linear; filter:drop-shadow(0 0 10px #0008);
}
.zombie svg{width:100%; height:auto}
.zombie.scared{opacity:.55; animation:cower 1.6s ease-in-out infinite}
@keyframes shamble{0%,100%{transform:translateX(-50%) rotate(-3deg)}50%{transform:translateX(-50%) rotate(3deg)}}
@keyframes cower{0%,100%{opacity:.5; transform:translateX(-50%) scale(.9)}50%{opacity:.65}}

/* ---------- something solid on the sides you cannot leave by ---------- */
#barriers{position:absolute; inset:0; pointer-events:none; z-index:2}
.barrier{position:absolute; transition:filter .2s}
.barrier.bump{filter:brightness(1.6)}
.barrier.left, .barrier.right{top:0; bottom:0; width:11%}
.barrier.left{left:0}
.barrier.right{right:0}
.barrier.top{left:0; right:0; top:0; height:26%}
.barrier.bottom{left:0; right:0; bottom:0; height:7%}
.barrier.trees{
  background:linear-gradient(180deg,#0b1710f2 0%,#0b171099 65%,#0b171000 100%);
}
.barrier.trees.left{background:linear-gradient(90deg,#0b1710f2,#0b171000)}
.barrier.trees.right{background:linear-gradient(270deg,#0b1710f2,#0b171000)}
.barrier.trees.bottom{background:linear-gradient(0deg,#0b1710f2,#0b171000)}
.barrier.wall{background:linear-gradient(180deg,#171310dd,#17131000)}
.barrier.wall.left{background:linear-gradient(90deg,#171310dd,#17131000)}
.barrier.wall.right{background:linear-gradient(270deg,#171310dd,#17131000)}
.barrier.wall.bottom{background:linear-gradient(0deg,#171310dd,#17131000)}
.barrier.water{background:linear-gradient(180deg,#0d2a38dd,#0d2a3800)}
.barrier.water.left{background:linear-gradient(90deg,#0d2a38dd,#0d2a3800)}
.barrier.water.right{background:linear-gradient(270deg,#0d2a38dd,#0d2a3800)}
.barrier.water.bottom{background:linear-gradient(0deg,#0d2a38dd,#0d2a3800)}
.barrier.rock{background:linear-gradient(180deg,#0e1220dd,#0e122000)}
.barrier.rock.left{background:linear-gradient(90deg,#0e1220dd,#0e122000)}
.barrier.rock.right{background:linear-gradient(270deg,#0e1220dd,#0e122000)}
.barrier.rock.bottom{background:linear-gradient(0deg,#0e1220dd,#0e122000)}

/* ---------- the ways out, on the edge they lead to ---------- */
/* A sign saying the way is open — you walk through it, you do not tap it. */
.wayout{
  position:absolute; display:flex; align-items:center; gap:5px; z-index:2;
  pointer-events:none; background:#0d171099; border:1px solid #ffd16688; color:var(--gold);
  padding:4px 9px; border-radius:999px; font-size:11px; font-family:system-ui,sans-serif;
  opacity:.75; animation:bob 3.6s ease-in-out infinite;
}
.wayout b{font-weight:600; color:#e8f0e8; font-size:10.5px}
.wayout span{font-size:13px}
.wayout.left{left:6px; top:50%; transform:translateY(-50%)}
.wayout.right{right:6px; top:50%; transform:translateY(-50%)}
.wayout.top{left:50%; top:calc(96px + env(safe-area-inset-top)); transform:translateX(-50%)}
.wayout.bottom{left:50%; bottom:calc(230px + var(--safe-b)); transform:translateX(-50%)}
