:root { --ink: #e9dcc0; --dim: rgba(233, 220, 192, .62); --gold: #d7a85a; --serif: "Cormorant Garamond", Georgia, serif; --fell: "IM Fell English", Georgia, serif; }
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: #000; color: var(--ink); overflow: hidden; font-family: var(--serif); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button, a { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: #000; transition: opacity 1.2s; z-index: 9; }
#loading.gone { opacity: 0; pointer-events: none; }
#bar { width: min(220px, 50vw); height: 1px; background: rgba(233, 220, 192, .15); }
#bar i { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .3s; }

#title { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px max(24px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); z-index: 8;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .35), rgba(0, 0, 0, .86)); opacity: 0; transition: opacity 1.6s; pointer-events: none; }
#title.ready { opacity: 1; pointer-events: auto; }
#title.gone { opacity: 0; pointer-events: none; transition: opacity 1.2s; }
h1 { font-family: var(--fell); font-style: italic; font-weight: 400; font-size: clamp(54px, 10.5vw, 150px); line-height: .95; letter-spacing: -.01em; text-shadow: 0 0 60px rgba(160, 190, 255, .28); }
.lede { margin-top: 22px; font-size: clamp(18px, 2vw, 24px); color: var(--dim); font-style: italic; }
.go { margin-top: 44px; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.go button, .go a { background: var(--ink); color: #0b0906; border: 1px solid var(--ink); padding: 14px 28px; font-size: 18px; letter-spacing: .02em; text-decoration: none; border-radius: 2px; transition: background .25s, color .25s, transform .25s; }
.go .quiet { background: transparent; color: var(--ink); border-color: rgba(233, 220, 192, .35); }
.go button:hover, .go a:hover { transform: translateY(-1px); background: #fff3d6; color: #0b0906; }
.fine { margin-top: 26px; font-size: 15px; color: var(--dim); }
.legal a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.legal { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 24px; right: 24px; font-size: 12.5px; color: rgba(233, 220, 192, .55); }

#hud { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s; z-index: 4; }
#hud.on { opacity: 1; }
#aim { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
#reticle { position: absolute; left: 0; top: 0; width: 5px; height: 5px; margin: -2.5px; border-radius: 50%; background: rgba(233, 220, 192, .5); transition: transform .25s, background .25s, box-shadow .25s; }
#reticle.hot { transform: scale(2.1); background: var(--gold); box-shadow: 0 0 14px rgba(215, 168, 90, .9); }
#spell { position: absolute; left: 0; top: 26px; transform: translateX(-50%); font-family: var(--fell); font-style: italic; font-size: 21px; color: var(--gold); opacity: 0; transition: opacity .3s; text-shadow: 0 1px 12px #000; white-space: nowrap; }
#spell.on { opacity: .95; }
#sub { position: absolute; left: 50%; bottom: calc(9vh + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(760px, 88vw); text-align: center; font-size: clamp(19px, 2.1vw, 26px); line-height: 1.32; opacity: 0; transition: opacity .5s; text-shadow: 0 1px 3px #000, 0 0 24px #000, 0 0 44px #000; }
#sub.on { opacity: 1; }
#sub b { display: block; font-family: var(--fell); font-weight: 400; font-style: italic; font-size: .68em; color: var(--gold); margin-bottom: 4px; letter-spacing: .02em; }
#sub.narr span { font-style: italic; color: var(--dim); }
#plaque { position: absolute; left: calc(26px + env(safe-area-inset-left)); bottom: calc(26px + env(safe-area-inset-bottom)); text-align: left; opacity: 0; transition: opacity .6s; text-shadow: 0 1px 10px #000; }
#plaque.on { opacity: .9; }
#plaque i { display: block; font-family: var(--fell); font-size: 22px; color: var(--gold); }
#plaque span { font-size: 15px; color: var(--dim); }
#inv { position: absolute; right: calc(22px + env(safe-area-inset-right)); top: calc(20px + env(safe-area-inset-top)); display: flex; gap: 12px; }
#inv i { width: 46px; height: 20px; opacity: 0; transform: translateY(-6px) rotate(-18deg); transition: opacity .8s, transform .8s; filter: drop-shadow(0 0 8px rgba(215, 168, 90, .7));
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 20'%3E%3Ccircle cx='9' cy='10' r='6.5' fill='none' stroke='%23d7a85a' stroke-width='2.4'/%3E%3Cpath d='M15.5 10H44M36 10v6M41 10v5' fill='none' stroke='%23d7a85a' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E"); }
#inv i[data-kind="book"] { width: 22px; height: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 26'%3E%3Cpath d='M3 2h14a2 2 0 0 1 2 2v20H5a2 2 0 0 1-2-2zM3 20h16M8 2v18' fill='none' stroke='%23d7a85a' stroke-width='2'/%3E%3C/svg%3E"); }
#inv i.on { opacity: 1; transform: none; }
#roomname { position: absolute; left: 0; right: 0; top: 16vh; text-align: center; font-family: var(--fell); font-style: italic; font-size: clamp(34px, 5.2vw, 72px); opacity: 0; transition: opacity 1.4s; text-shadow: 0 2px 30px #000, 0 0 60px #000; letter-spacing: -.01em; }
#roomname.on { opacity: .95; }
#mic { position: absolute; left: calc(22px + env(safe-area-inset-left)); top: calc(22px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--dim); }
#mic i { width: 7px; height: 7px; border-radius: 50%; background: rgba(233, 220, 192, .25); }
#mic[data-state="listening"] i { background: #9fd08a; box-shadow: 0 0 10px #9fd08a; animation: pulse 2.4s infinite; }
#mic[data-state="listening"] span::after { content: "Listening for spells"; }
#mic[data-state="denied"] span::after { content: "No microphone. Use the keys."; }
#mic[data-state="unsupported"] span::after { content: "Voice is not available here. Use the keys."; }
#mic[data-state="off"] { display: none; }
@keyframes pulse { 50% { opacity: .35; } }
#help { position: absolute; left: 0; right: 0; bottom: calc(22px + env(safe-area-inset-bottom)); text-align: center; font-size: 14px; color: var(--dim); opacity: 0; transition: opacity 1.5s; }
#help.on { opacity: 1; }
#pad { display: none; }
.touch #help { display: none; }
.touch #pad { display: flex; gap: 10px; position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); pointer-events: auto; }
#pad button { background: rgba(10, 9, 7, .55); border: 1px solid rgba(233, 220, 192, .35); color: var(--ink); padding: 14px 16px; min-width: 64px; border-radius: 40px; font-size: 15px; backdrop-filter: blur(6px); }

.touch #plaque { bottom: auto; top: calc(54px + env(safe-area-inset-top)); }
.touch #sub { bottom: calc(96px + env(safe-area-inset-bottom)); }

#map { position: fixed; inset: 0; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .6s; z-index: 6; background: rgba(0, 0, 0, .55); }
#map.on { opacity: 1; pointer-events: auto; }
#map.intro { background: rgba(0, 0, 0, .9); transition: opacity 1.2s; }
#mapc { box-shadow: 0 30px 90px rgba(0, 0, 0, .8); transform: rotate(-1.2deg); }

#caught, #paused { position: fixed; inset: 0; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .5s; z-index: 7; }
#caught { background: radial-gradient(ellipse at center, rgba(60, 20, 6, .35), rgba(0, 0, 0, .92)); }
#caught.on, #paused.on { opacity: 1; }
#paused.on { pointer-events: auto; background: rgba(0, 0, 0, .6); cursor: pointer; }
#caught p { font-family: var(--fell); font-style: italic; font-size: clamp(48px, 8vw, 110px); }
#paused p { font-size: 20px; color: var(--dim); font-style: italic; }

#end { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: 24px; opacity: 0; pointer-events: none; transition: opacity 2s; background: rgba(8, 6, 4, .9); overflow: auto; }
#end.on { opacity: 1; pointer-events: auto; }
.endin { display: flex; gap: clamp(24px, 5vw, 72px); align-items: center; max-width: 1080px; }
#card { height: min(74vh, 640px); width: auto; box-shadow: 0 30px 90px #000; }
.endtext h2 { font-family: var(--fell); font-style: italic; font-weight: 400; font-size: clamp(34px, 4.4vw, 60px); line-height: 1.02; }
.endtext p { margin-top: 12px; font-size: 20px; color: var(--dim); font-style: italic; }
#stats { margin-top: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
#stats span { display: block; font-size: 14px; color: var(--dim); }
#stats b { font-family: var(--fell); font-weight: 400; font-style: italic; font-size: 26px; }
#end .go { justify-content: flex-start; margin-top: 34px; }
#nogl { position: fixed; inset: 0; display: grid; place-items: center; background: #000; z-index: 20; padding: 24px; text-align: center; font-size: 20px; }
#nogl[hidden] { display: none; }

@media (max-width: 760px) {
  .endin { flex-direction: column; text-align: center; }
  #card { height: 42vh; }
  #end .go { justify-content: center; }
  #stats { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

#melt { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; z-index: 3; }
#melt.go { transition: opacity .9s ease-out; }
body.playing #gl { cursor: none; }
body.playing.turning #gl { cursor: grabbing; }
.touch #aim { transform: translate(50vw, 50vh) !important; }

#mini { position: absolute; right: calc(22px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 172px; height: 216px; transform: rotate(1.6deg); border-radius: 2px; box-shadow: 0 10px 34px rgba(0, 0, 0, .7), 0 0 0 1px rgba(60, 35, 10, .6); opacity: .94; }
.touch #mini { display: none; }

#mini { top: calc(62px + env(safe-area-inset-top)); bottom: auto; width: 150px; height: 188px; }
.stick { position: absolute; bottom: calc(30px + env(safe-area-inset-bottom)); width: 118px; height: 118px; border-radius: 50%; pointer-events: auto; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle, rgba(233, 220, 192, .07), rgba(10, 9, 7, .5)); border: 1px solid rgba(233, 220, 192, .38); backdrop-filter: blur(4px); opacity: .72; transition: opacity .25s; }
.stick:hover, .stick.held { opacity: 1; }
.stick.held { cursor: grabbing; }
.stick i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(233, 220, 192, .82); box-shadow: 0 2px 14px rgba(0, 0, 0, .6); }
.stick span { position: absolute; left: 0; right: 0; top: -22px; text-align: center; font-size: 13px; color: var(--dim); font-style: italic; }
#stickL { left: calc(30px + env(safe-area-inset-left)); }
#stickR { right: calc(30px + env(safe-area-inset-right)); }
#plaque { bottom: calc(176px + env(safe-area-inset-bottom)); }
#help { left: 170px; right: 170px; }
.touch #stickR { display: none; }
.touch #stickL { bottom: calc(26px + env(safe-area-inset-bottom)); }

.how { list-style: none; padding: 0; margin: 26px auto 0; max-width: 620px; text-align: left; display: grid; gap: 9px; font-size: clamp(15px, 1.5vw, 18px); color: var(--dim); }
.how b { color: var(--gold); font-weight: 500; font-style: italic; font-family: var(--fell); margin-right: 8px; }
#title .go { margin-top: 30px; }
#goal { position: absolute; left: calc(22px + env(safe-area-inset-left)); top: calc(18px + env(safe-area-inset-top)); max-width: min(430px, 62vw); padding: 11px 16px 11px 14px; background: rgba(10, 8, 5, .62); border-left: 2px solid var(--gold); backdrop-filter: blur(5px); opacity: 0; transition: opacity .6s; border-radius: 0 3px 3px 0; }
#goal.on { opacity: 1; }
#goal b { display: block; font-weight: 500; font-size: clamp(16px, 1.55vw, 20px); line-height: 1.25; color: var(--ink); }
#goal span { display: block; margin-top: 4px; font-size: 13px; color: var(--dim); }
#goal.danger { border-left-color: #d0482c; } #goal.danger b { color: #ffb9a3; }
#goal.new { animation: goalin 1.6s ease-out; }
@keyframes goalin { 0% { background: rgba(215, 168, 90, .55); transform: translateX(-8px); } 100% { background: rgba(10, 8, 5, .62); transform: none; } }
#mic { top: auto; bottom: calc(160px + env(safe-area-inset-bottom)); }
#way { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity .4s; will-change: transform; }
#way.on { opacity: .95; }
#way i { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; background: var(--gold); transform-origin: 50% 50%; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: 0 0 14px rgba(215, 168, 90, .9); animation: pulse 2.2s infinite; }
#way.off i { clip-path: polygon(50% 0, 100% 100%, 50% 72%, 0 100%); width: 18px; height: 18px; left: -9px; top: -9px; }
#way span { position: absolute; left: 50%; top: 13px; transform: translateX(-50%); white-space: nowrap; font-size: 13.5px; font-style: italic; color: var(--gold); text-shadow: 0 1px 6px #000, 0 0 14px #000; }
.touch #goal { max-width: 70vw; }
#way span { font-size: 16px; top: 16px; }
#way i { width: 18px; height: 18px; left: -9px; top: -9px; }
.how { background: rgba(6, 4, 2, .62); padding: 16px 20px; border-radius: 3px; color: rgba(233, 220, 192, .86); }

#cast { position: absolute; left: 50%; bottom: calc(22vh + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, 86vw); text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s; }
#cast.on { opacity: 1; pointer-events: auto; }
#typed { width: 100%; padding: 13px 18px; font: italic 26px var(--fell); color: var(--ink); text-align: center; background: rgba(10, 8, 5, .82); border: 1px solid var(--gold); border-radius: 3px; outline: none; }
#typed::placeholder { color: rgba(233, 220, 192, .4); }
#cast p { margin-top: 9px; font-size: 13.5px; color: var(--dim); text-shadow: 0 1px 6px #000; }
#castbtn { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(52px + env(safe-area-inset-bottom)); pointer-events: auto; background: rgba(10, 9, 7, .55); border: 1px solid rgba(233, 220, 192, .35); color: var(--ink); padding: 8px 18px; border-radius: 30px; font-size: 14.5px; font-style: italic; backdrop-filter: blur(5px); opacity: .8; }
#castbtn:hover { opacity: 1; border-color: var(--gold); }
#help { font-size: 13px; }

#mini { transition: box-shadow .5s, width .5s, height .5s; }
#mini.alert { width: 196px; height: 246px; box-shadow: 0 10px 34px rgba(0, 0, 0, .7), 0 0 0 2px rgba(190, 50, 30, .85), 0 0 26px rgba(190, 50, 30, .55); }
#sub { bottom: calc(15vh + env(safe-area-inset-bottom)); }
#way.off span { left: auto; right: 14px; transform: none; top: -9px; }

#goal em { display: none; margin-top: 9px; padding-top: 9px; border-top: 1px solid rgba(233, 220, 192, .22); font-style: normal; font-size: clamp(15px, 1.35vw, 17.5px); line-height: 1.4; color: #f3e7c9; }
#goal.hint em { display: block; }
#goal.hint { max-width: min(520px, 70vw); background: rgba(10, 8, 5, .82); }
#foe { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity .4s; will-change: transform; }
#foe.on { opacity: 1; }
#foe i { position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; background: #e2472b; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); animation: pulse 1s infinite; }
#foe.off i { clip-path: polygon(50% 0, 100% 100%, 50% 72%, 0 100%); }
#foe span { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); white-space: nowrap; font-size: 16px; font-style: italic; color: #ff9c86; text-shadow: 0 1px 6px #000, 0 0 14px #000; }
#foe.off span, #way.off span { left: auto; right: 16px; transform: none; top: -10px; }
#foe.off.left span, #way.off.left span { right: auto; left: 16px; }
#spell small { display: block; font-family: var(--serif); font-style: normal; font-size: 13px; color: var(--ink); opacity: .8; margin-top: 2px; }
#spell { text-align: center; }
