:root {
  --bg: #1e2b22; --moss: #3a533d; --amber: #f4be5d; --text: #e8e1d7;
  --ink: #2a1d14; --paper: #f3e6cc;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--serif); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.7em; padding: 0.05em 0.4em; margin: 0 0.1em; border-radius: 6px; font: 600 0.78em/1.5 ui-monospace, Menlo, Consolas, monospace;
  color: #3a2614; background: linear-gradient(#fbe7bd, #e8c486); box-shadow: 0 2px 0 #9c7440, 0 0 0 1px rgba(90,60,30,.35); text-align: center; }

#vignette { position: fixed; inset: 0; pointer-events: none; transition: opacity 1.2s;
  background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 45%, rgba(18,10,14,.55) 100%); }
#vignette.low { background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 30%, rgba(14,8,12,.8) 100%); }
#vignette.faded { background: radial-gradient(ellipse at 50% 55%, rgba(10,6,10,.55) 10%, rgba(8,4,8,.92) 100%); }
#fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.toast { position: absolute; transform: translate(-50%, -50%); font-size: 15px; color: #fff3d0; white-space: nowrap;
  text-shadow: 0 0 10px rgba(255,190,90,.9), 0 1px 2px rgba(0,0,0,.6); animation: rise 1.4s ease-out forwards; font-style: italic; }
@keyframes rise { from { opacity: 0; margin-top: 0; } 15% { opacity: 1; } to { opacity: 0; margin-top: -46px; } }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; padding: max(12px, env(safe-area-inset-top)) 14px 14px; }
.hud-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lamp { pointer-events: auto; display: flex; align-items: center; gap: 9px; padding: 7px 14px 7px 10px; border-radius: 999px;
  background: rgba(30,24,26,.62); border: 1px solid rgba(244,190,93,.35); backdrop-filter: blur(6px); box-shadow: 0 4px 18px rgba(0,0,0,.3); }
.lamp .ico { width: 18px; height: 26px; color: var(--amber); filter: drop-shadow(0 0 6px rgba(255,190,90,.8)); }
.lampbar { width: 190px; height: 12px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.5); }
#lampFill { display: block; height: 100%; width: 100%; border-radius: 99px; transform-origin: left; background: linear-gradient(90deg, #d9803a, #f4be5d 60%, #ffe6a8);
  box-shadow: 0 0 12px rgba(255,190,90,.8); transition: background .5s; }
.lamp.low #lampFill { background: linear-gradient(90deg, #a44a2a, #d9803a); animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
#lampTime { font: 600 15px/1 ui-monospace, Menlo, Consolas, monospace; color: #ffe2a6; min-width: 3.1em; text-align: right; }
.hud-right { display: flex; gap: 8px; pointer-events: auto; }
.icon-btn, .pill-btn { height: 38px; border-radius: 999px; border: 1px solid rgba(244,190,93,.4); background: rgba(30,24,26,.62); color: var(--text);
  backdrop-filter: blur(6px); font-size: 15px; padding: 0 14px; }
.icon-btn { width: 38px; padding: 0; font-size: 18px; }
.icon-btn svg { display: block; margin: auto; } .icon-btn .slash { display: none; } .icon-btn.muted .slash { display: inline; }
#pips { display: flex; gap: 3px; margin-left: 4px; }
#pips i { width: 9px; height: 13px; border-radius: 60% 60% 45% 45%; background: linear-gradient(#f3d6b8, #b88c70); box-shadow: 0 0 6px rgba(255,200,140,.6); transition: opacity .25s, transform .25s; }
#pips i.spent { opacity: .18; transform: scale(.8); box-shadow: none; }
#pips.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.tbtn .fc { position: absolute; top: 6px; right: 12px; font: 700 13px/1 ui-monospace, Menlo, monospace; color: #3a2410; background: #f4be5d; border-radius: 99px; padding: 3px 6px; }
.tbtn { position: relative; }
.icon-btn.muted { opacity: .6; }
.icon-btn:hover, .pill-btn:hover { border-color: var(--amber); color: #fff; }
#chips { display: flex; gap: 8px; margin-top: 10px; }
.chip { display: flex; align-items: center; gap: 6px; padding: 5px 11px 5px 7px; border-radius: 999px; font-size: 13.5px; color: rgba(232,225,215,.8);
  background: rgba(30,24,26,.5); border: 1px dashed rgba(232,225,215,.3); transition: all .5s; }
.chip svg { width: 18px; height: 18px; color: rgba(232,225,215,.75); }
.chip.active { color: #fff; border: 1px solid var(--amber); box-shadow: 0 0 14px rgba(244,190,93,.45); }
.chip.active svg { color: var(--amber); }
.chip.done { background: linear-gradient(#f6cf7c, #e0a24c); color: #3a2410; border: 1px solid #ffe2a0; box-shadow: 0 0 16px rgba(255,190,90,.6); }
.chip.done svg { color: #4a2c10; }
.chip.done span::after { content: " ✓"; }
#outcome { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 9px 18px; border-radius: 999px;
  background: rgba(30,24,26,.62); border: 1px solid rgba(244,190,93,.35); backdrop-filter: blur(6px); font-size: 15px; white-space: nowrap; letter-spacing: .01em;
  box-shadow: 0 4px 18px rgba(0,0,0,.3); }
#hint { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); font-size: 16px; font-style: italic; color: #ffe8bd; text-align: center;
  padding: 8px 18px; border-radius: 999px; background: rgba(30,24,26,.66); border: 1px solid rgba(244,190,93,.25); backdrop-filter: blur(6px);
  text-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: nowrap; transition: opacity .4s; opacity: 0; }
#hint b { color: var(--amber); font-style: normal; }

/* door marker */
#marker { position: fixed; left: 0; top: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; transform: translate(-50%, -100%); will-change: transform; }
#marker .pin { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(#fff2c8, #f4be5d 60%, #d48a3a);
  box-shadow: 0 0 22px 6px rgba(255,190,90,.55), 0 2px 6px rgba(0,0,0,.4); border: 2px solid #fff4d6; animation: bob 1.6s ease-in-out infinite; }
#marker .pin svg { width: 24px; height: 24px; color: #4a2c10; }
#marker .mlabel { margin-top: 6px; text-align: center; line-height: 1.15; text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 12px rgba(0,0,0,.6); }
#marker .mlabel b { display: block; font-size: 14px; color: #fff3d6; }
#marker .mlabel em { font-size: 12px; color: var(--amber); }
#marker .arrow { display: none; font-size: 22px; color: var(--amber); text-shadow: 0 0 10px rgba(255,190,90,.9); }
#marker.edge .arrow { display: block; position: absolute; top: 10px; }
#marker.edge .mlabel em { display: none; }
#marker.here .pin { animation: bob .6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-7px); } }
#prompt { cursor: pointer; position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); padding: 10px 20px; border-radius: 999px; font-size: 18px;
  background: rgba(40,28,22,.8); border: 1px solid var(--amber); box-shadow: 0 0 24px rgba(244,190,93,.45); color: #fff3d6; animation: pop .3s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(.8); opacity: 0; } }
.k-touch, .k-touch-flex { display: none !important; }
body.touch .k-touch-flex { display: flex !important; } body.touch .k-desk-flex { display: none !important; }
body.touch .k-touch { display: inline !important; } body.touch .k-desk { display: none; }

/* touch */
#touch { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 14px max(16px, env(safe-area-inset-bottom)); pointer-events: none; }
.tgroup { display: flex; gap: 12px; align-items: flex-end; pointer-events: auto; }
.tbtn { width: 70px; height: 70px; border-radius: 50%; border: 1.5px solid rgba(244,190,93,.55); background: rgba(34,26,28,.55); color: #ffe2a6;
  backdrop-filter: blur(5px); font-size: 24px; display: grid; place-items: center; touch-action: none; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.tbtn.on { background: rgba(244,190,93,.35); border-color: #ffe2a0; }
.tbtn.flap { width: 96px; height: 96px; }
.tbtn.flap svg { width: 56px; height: 36px; color: #f0c7a8; }
.tbtn small { display: block; font-size: 11px; margin-top: -6px; letter-spacing: .06em; text-transform: uppercase; }
.tbtn.deliver { opacity: .35; }
.tbtn.deliver.ready { opacity: 1; background: radial-gradient(#ffe2a0, #e0a24c); color: #3a2410; box-shadow: 0 0 24px rgba(255,190,90,.7); animation: bob 1s infinite; }
.tbtn.deliver svg { width: 28px; height: 22px; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: flex-start; padding: 0 0 max(18px, 3vh) 4vw; z-index: 20; transition: opacity .9s ease, transform 1.2s ease; }
#title.leaving { opacity: 0; transform: scale(1.06); pointer-events: none; }
.title-bg { position: absolute; inset: 0; background: url("assets/hero.jpg") center 30% / cover no-repeat; animation: drift 24s ease-in-out infinite alternate; }
@keyframes drift { to { transform: scale(1.05) translate(-0.6%, -0.8%); } }
.title-bg::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,14,16,0) 0%, rgba(20,14,16,.25) 60%, rgba(14,10,12,.7) 100%), linear-gradient(transparent 50%, rgba(16,12,12,.75)); }
.title-bg { overflow: hidden; }
.title-card { position: relative; width: min(470px, 92vw); padding: 16px 26px 16px; border-radius: 22px; text-align: center;
  background: linear-gradient(180deg, rgba(34,26,28,.66), rgba(24,20,20,.82)); border: 1px solid rgba(244,190,93,.4);
  box-shadow: 0 20px 60px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,230,180,.15); backdrop-filter: blur(4px); }
.mark { position: absolute; top: -92px; left: 18px; width: 70px; height: 82px; object-fit: cover; border-radius: 42px;
  border: 2px solid rgba(244,190,93,.7); box-shadow: 0 0 30px rgba(255,190,90,.55); }
.kicker { margin: 4px 0 0; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: rgba(244,190,93,.85); }
h1 { margin: 2px 0 4px; font-size: clamp(38px, 5.6vw, 58px); line-height: 1; font-weight: 600; letter-spacing: .01em; color: #fff3de;
  text-shadow: 0 0 24px rgba(255,190,90,.45), 0 3px 8px rgba(0,0,0,.6); }
.pitch { margin: 0 auto 14px; max-width: 34em; font-size: 18px; line-height: 1.4; font-style: italic; color: #ffdca0; }
.howto { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; font-size: 14.5px; color: #eadfcc; padding: 12px 6px;
  border-top: 1px dashed rgba(244,190,93,.3); border-bottom: 1px dashed rgba(244,190,93,.3); }
.howto .alt { flex-basis: 100%; font-size: 13px; color: rgba(232,225,215,.7); }
.start-btn { margin-top: 12px; padding: 13px 44px; border: 0; border-radius: 999px; font-size: 21px; font-weight: 700; color: #3a2410; letter-spacing: .02em;
  background: linear-gradient(#ffe3a4, #f4be5d 55%, #df9a44); box-shadow: 0 0 28px rgba(255,190,90,.55), 0 4px 0 #a86a2a, inset 0 1px 0 #fff4d6; transition: transform .15s, box-shadow .15s; }
.start-btn:hover, .start-btn:focus-visible { transform: translateY(-2px); box-shadow: 0 0 40px rgba(255,200,110,.8), 0 6px 0 #a86a2a, inset 0 1px 0 #fff4d6; outline: none; }
.start-btn:active { transform: translateY(2px); box-shadow: 0 0 20px rgba(255,190,90,.5), 0 1px 0 #a86a2a; }
.tag { margin: 12px 0 0; font-size: 13px; color: rgba(232,225,215,.6); letter-spacing: .04em; }

/* ---------- cards ---------- */
.card { position: fixed; left: 50%; z-index: 15; transform: translateX(-50%); width: min(520px, 92vw); border-radius: 18px; padding: 20px 24px; }
.paper { bottom: 26px; color: var(--ink); background:
  radial-gradient(ellipse at 20% 10%, rgba(255,255,255,.55), transparent 50%), radial-gradient(ellipse at 90% 90%, rgba(190,140,80,.25), transparent 60%),
  linear-gradient(#f8ecd2, #ecd9b4); box-shadow: 0 16px 50px rgba(0,0,0,.5), 0 0 0 1px rgba(120,80,40,.35), inset 0 0 30px rgba(160,110,50,.25);
  animation: cardIn .6s cubic-bezier(.2,.9,.3,1.2); }
@keyframes cardIn { from { opacity: 0; transform: translate(-50%, 30px) rotate(-1.5deg); } }
.whead { display: flex; gap: 12px; align-items: center; }
.wsym { width: 42px; height: 42px; flex: none; padding: 8px; border-radius: 50%; color: #f6dfa8; background: #3b2a1c; box-shadow: 0 0 0 2px #e6b765; }
.whead h2 { margin: 0; font-size: 21px; } .whead p { margin: 2px 0 0; font-size: 14px; color: #7a5a3a; font-style: italic; }
.wtext { margin: 12px 0 10px; font-size: 18.5px; line-height: 1.45; font-style: italic; }
.wfoot { margin: 0; font-size: 14px; color: #7a5a3a; display: flex; justify-content: space-between; align-items: center; }
.link-btn { border: 0; background: none; color: #9a5a1a; font-size: 15px; font-weight: 700; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
#endcard { top: 50%; transform: translate(-50%, -50%); text-align: center; padding: 26px 28px 22px;
  background: linear-gradient(180deg, rgba(38,28,28,.8), rgba(26,20,20,.9)); border: 1px solid rgba(244,190,93,.5);
  box-shadow: 0 20px 70px rgba(0,0,0,.6), 0 0 60px rgba(255,190,90,.18); animation: endIn .8s ease-out; backdrop-filter: blur(5px); }
@keyframes endIn { from { opacity: 0; transform: translate(-50%, -44%); } }
#endcard h2 { margin: 6px 0 8px; font-size: 32px; color: #fff3de; text-shadow: 0 0 20px rgba(255,190,90,.5); }
#endcard p { margin: 0 auto 10px; max-width: 30em; font-size: 17px; line-height: 1.45; color: #eadfcc; }
#eStats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 2px; }
#eStats span { padding: 6px 12px; border-radius: 999px; background: rgba(244,190,93,.12); border: 1px solid rgba(244,190,93,.35); font-size: 14px; color: #ffe2a6; }
.ebtns { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#endcard .link-btn { color: #f4be5d; }
#endcard.win { top: auto; bottom: 18px; transform: translateX(-50%); width: min(560px, 94vw); padding: 14px 22px 14px; animation: winIn 1s ease-out; }
#endcard.win h2 { font-size: 27px; margin: 2px 0 4px; } #endcard.win p { font-size: 15.5px; margin-bottom: 6px; }
#endcard.win #eStats { margin: 6px 0 0; } #endcard.win .start-btn { margin-top: 10px; padding: 10px 36px; font-size: 19px; }
.wsyms { display: flex; gap: 8px; flex-basis: 100%; justify-content: center; margin-bottom: 4px; }
.wsyms svg { width: 30px; height: 30px; padding: 6px; border-radius: 50%; color: #4a2c10; background: radial-gradient(#fff2c8, #f4be5d 60%, #d48a3a);
  box-shadow: 0 0 16px rgba(255,190,90,.8); opacity: 0; animation: symOn .6s ease-out forwards; }
@keyframes symOn { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
@keyframes winIn { from { opacity: 0; transform: translate(-50%, 30px); } }
#endcard.fail h2 { color: #f0dcc8; text-shadow: 0 0 20px rgba(200,150,120,.4); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .lampbar { width: 110px; }
  #outcome { top: auto; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 116px); font-size: 12.5px; padding: 7px 12px; max-width: 94vw; white-space: normal; text-align: center; }
  #chips { gap: 5px; } .chip { font-size: 12px; padding: 4px 8px 4px 5px; } .chip svg { width: 15px; height: 15px; }
  #hint { bottom: auto; top: 112px; font-size: 14px; white-space: normal; }
  #prompt { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 188px); font-size: 16px; }
  #hint { width: auto; max-width: 92vw; }
  .pill-btn { width: 38px; padding: 0; font-size: 18px; } .pill-btn .rtxt { display: none; }
  #lampTime { font-size: 13px; min-width: 2.6em; } .lamp { gap: 6px; padding: 6px 10px 6px 8px; }
  #pips i { width: 7px; height: 11px; }
  .paper { bottom: auto; top: 100px; }
  #title { justify-content: center; padding-left: 0; }
  .title-card { padding: 14px 16px 12px; }
  .mark { display: none; }
  .pitch { font-size: 15.5px; margin-bottom: 10px; }
  .howto { font-size: 13px; gap: 4px 12px; }
  .start-btn { font-size: 19px; padding: 12px 38px; margin-top: 12px; }
  #endcard h2 { font-size: 26px; } #endcard p { font-size: 15px; }
}
@media (max-width: 720px) and (orientation: portrait) {
  .title-bg { background-position: 52% 30%; }
}
@media (max-height: 520px) {
  .title-card { margin-top: 6vh; } .howto .alt { display: none; } .mark { display: none; }
}
