html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #e8e0d0; font-family: Georgia, "Times New Roman", serif; user-select: none; -webkit-user-select: none; }
canvas#game { display: block; width: 100vw; height: 100vh; touch-action: none; }
.hidden { display: none !important; }

#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,.85) 100%); }
#redflash { position: fixed; inset: 0; pointer-events: none; background: #8b0000; opacity: 0; mix-blend-mode: multiply; }
#blackout { position: fixed; inset: 0; pointer-events: none; background: #000; opacity: 0; }
/* visão pelas frestas da porta do armário */
#hideview { position: fixed; inset: 0; pointer-events: none; display: none;
  background:
    linear-gradient(90deg, rgba(20,12,6,.95) 0 6%, transparent 6% 94%, rgba(20,12,6,.95) 94%),
    repeating-linear-gradient(180deg, rgba(24,14,8,.85) 0 3.5%, transparent 3.5% 11%); }

#hud { position: fixed; inset: 0; pointer-events: none; }
#clock { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-size: 30px; letter-spacing: 3px; color: #d8cfc0; text-shadow: 0 0 10px #000, 0 0 4px #000; }
#clock.late { color: #ff4040; animation: pulse 1s infinite; }
#objective { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); font-size: 15px; font-style: italic; color: #b8ae9c; text-shadow: 0 0 6px #000; text-align: center; max-width: 80vw; }
#lives { position: absolute; top: 14px; right: 18px; font-size: 24px; letter-spacing: 4px; text-shadow: 0 0 6px #000; }
#battery { position: absolute; bottom: 20px; left: 20px; font-size: 13px; color: #b8ae9c; }
#battery .bar { width: 120px; height: 10px; border: 1px solid #b8ae9c; margin-top: 4px; }
#batfill { display: block; height: 100%; width: 100%; background: #e8d48a; }
#stamina { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); width: 160px; height: 4px; background: rgba(255,255,255,.12); }
#stamfill { display: block; height: 100%; width: 100%; background: #9fb8c8; }
#cross { position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: rgba(255,255,255,.55); }
#prompt { position: absolute; top: calc(50% + 26px); left: 50%; transform: translateX(-50%); font-size: 17px; color: #fff; text-shadow: 0 0 6px #000; white-space: nowrap; }
#toast { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); font-size: 20px; color: #f0e6d2; text-shadow: 0 0 8px #000; text-align: center; transition: opacity .4s; }
#lives { color: #c41818; }
#pausebtn { position: absolute; top: 12px; left: 14px; pointer-events: auto; min-width: 0; padding: 0; width: 42px; height: 42px; border: 1px solid #665; background: rgba(0,0,0,.4); color: #ccc; font-weight: bold; border-radius: 8px; }

#touch { position: fixed; inset: 0; pointer-events: none; }
#stick { position: absolute; left: 30px; bottom: 40px; width: 130px; height: 130px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.05); pointer-events: auto; }
#knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.3); }
.tbtn { position: absolute; pointer-events: auto; width: 66px; height: 66px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); background: rgba(0,0,0,.35); font-size: 28px; }
#t-use { right: 30px; bottom: 120px; width: 84px; height: 84px; font-size: 36px; }
#t-light { right: 130px; bottom: 40px; }
#t-run { right: 40px; bottom: 30px; }

#note { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, 86vw); padding: 30px 28px; background: #e9dcc0; color: #2b2116; font-family: "Brush Script MT", "Segoe Script", cursive; font-size: 22px; box-shadow: 0 0 60px #000; transform-origin: center; rotate: -1.5deg; }
#note small { display: block; margin-top: 18px; font-family: Georgia, serif; font-size: 13px; color: #5a4a36; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(0,0,0,.78); text-align: center; padding: 20px; }
#loading, #menu { background: radial-gradient(ellipse at center, #1a0d0d 0%, #000 75%); }
.title { font-size: clamp(38px, 9vw, 86px); margin: 0; letter-spacing: 6px; color: #d9d0bf; text-shadow: 0 0 24px #600, 0 0 4px #000; font-weight: normal; }
.title.red { color: #ff3a3a; }
.sub { margin: 0 0 16px; font-style: italic; color: #9c917e; }
.hint { color: #7d7466; font-size: 14px; margin: 4px; max-width: 520px; }
h2 { font-size: 34px; font-weight: normal; margin: 0; letter-spacing: 3px; }
#i-text, #o-text, #w-text { max-width: 560px; font-size: 18px; line-height: 1.5; color: #c9bfae; }
button { font-family: inherit; font-size: 18px; padding: 10px 26px; min-width: 220px; background: rgba(40,10,10,.7); color: #e8e0d0; border: 1px solid #6b2a2a; border-radius: 6px; cursor: pointer; }
button:hover { background: rgba(90,20,20,.85); }
button.big { font-size: 24px; padding: 14px 40px; }
button.small { min-width: 0; font-size: 14px; padding: 6px 14px; }
button:disabled { opacity: .35; cursor: default; }
#m-nights { display: flex; flex-direction: column; gap: 10px; }
.loadbar { width: min(360px, 70vw); height: 6px; background: #221; }
#loadfill { display: block; height: 100%; width: 0; background: #8b1a1a; }
@keyframes pulse { 50% { opacity: .5; } }

#nightlbl { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); font-size: 12px; letter-spacing: 4px; color: #8c8270; }
#objective { top: 70px !important; white-space: pre-line; line-height: 1.5; }
#minibag { margin-top: 6px; font-size: 16px; letter-spacing: 2px; }
#bagbtn { position: absolute; top: 12px; left: 64px; pointer-events: auto; min-width: 0; padding: 0; width: 42px; height: 42px; border: 1px solid #665; background: rgba(0,0,0,.4); border-radius: 8px; font-size: 20px; }

#bag { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, 92vw); max-height: 84vh; overflow: auto; padding: 22px 24px;
  background: linear-gradient(#2a1d14, #1a120c); border: 2px solid #5a3e26; border-radius: 14px; box-shadow: 0 0 60px #000; }
#bag h3 { margin: 0 0 14px; font-size: 26px; font-weight: normal; letter-spacing: 3px; color: #e6d7b8; }
#bag h4 { margin: 18px 0 8px; font-weight: normal; color: #b8a888; }
#bag-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.item { background: rgba(0,0,0,.35); border: 1px solid #4a3522; border-radius: 10px; padding: 10px; text-align: center; }
.item .ic { font-size: 34px; }
.item .nm { font-size: 13px; color: #d8c9a8; margin-top: 4px; }
.item .qt { font-size: 18px; color: #fff; }
.item button { min-width: 0; font-size: 13px; padding: 4px 10px; margin-top: 6px; }
#bag-notes button { display: block; width: 100%; text-align: left; font-size: 14px; margin: 4px 0; min-width: 0; }
#bag small { display: block; margin-top: 14px; color: #8c7c60; }

.souls { font-size: 20px; color: #a8c8ff; margin: 0; text-shadow: 0 0 12px #2a4a8a; }
#s-list, #g-list { display: flex; flex-direction: column; gap: 8px; width: min(560px, 92vw); max-height: 60vh; overflow: auto; }
.amulet { display: flex; align-items: center; gap: 12px; background: rgba(30,10,10,.7); border: 1px solid #5a2a2a; border-radius: 10px; padding: 10px 14px; text-align: left; }
.amulet .ic { font-size: 30px; }
.amulet .tx { flex: 1; }
.amulet .tx b { display: block; font-weight: normal; font-size: 17px; }
.amulet .tx small { color: #a89c88; }
.amulet .pips { letter-spacing: 2px; color: #a8c8ff; }
.amulet button { min-width: 110px; font-size: 15px; }
.gnote { background: #e9dcc0; color: #2b2116; padding: 12px 16px; border-radius: 4px; font-family: "Segoe Script", cursive; text-align: left; }
.gnote.locked { background: rgba(255,255,255,.06); color: #665d50; font-family: Georgia, serif; font-style: italic; }
#i-objs, #i-mods { color: #c9bfae; font-size: 16px; white-space: pre-line; }

.nightpick { display: flex; align-items: center; gap: 8px; }
.nightpick button.small { min-width: 0; width: 44px; height: 44px; padding: 0; font-size: 18px; }
.nightpick button.small:disabled { visibility: hidden; }

/* enigma */
#puzzle { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: min(380px, 90vw); padding: 20px 24px; text-align: center;
  background: linear-gradient(#24160f, #140c08); border: 2px solid #6a4a2a; border-radius: 14px; box-shadow: 0 0 60px #000; }
#puzzle h3 { margin: 0 0 14px; font-weight: normal; font-size: 22px; letter-spacing: 2px; color: #e6d7b8; }
#pz-body { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 16px; }
.spin { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.spin button { min-width: 0; width: 64px; padding: 4px 0; font-size: 18px; }
.spin .val { font-size: 40px; width: 72px; padding: 6px 0; background: #0b0705; border: 1px solid #5a3e26; border-radius: 8px; color: #f0e2c0; font-family: Georgia, serif; }
#pz-body .sep { font-size: 40px; color: #e6d7b8; }
.pz-btns { display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* final */
#ending { background: #000; }
#e-text { max-width: 640px; }
#e-text p { font-size: 19px; line-height: 1.6; color: #d8cdb8; opacity: 0; transition: opacity 2s; margin: 0 0 16px; }
#e-text p.show { opacity: 1; }

/* telas baixas / celular deitado */
.tbtn { min-width: 0; padding: 0; }
.screen { overflow-y: auto; justify-content: safe center; }
body.mobile #battery { top: 62px; bottom: auto; left: 14px; }
body.mobile #stamina { bottom: 8px; }
body.mobile #toast { bottom: auto; top: 38%; }
@media (max-height: 500px) {
  .title { font-size: 34px; letter-spacing: 3px; }
  h2 { font-size: 24px; }
  .screen { gap: 7px; padding: 10px; }
  button { font-size: 15px; padding: 6px 18px; min-width: 180px; }
  button.big { font-size: 18px; padding: 8px 26px; }
  .sub, .hint { font-size: 12px; margin: 0; }
  #i-text, #o-text, #w-text { font-size: 14px; }
  #i-objs, #i-mods { font-size: 13px; }
  #clock { font-size: 22px; top: 8px; }
  #nightlbl { top: 34px; }
  #objective { top: 50px !important; font-size: 12px; }
  #bag { padding: 12px 14px; }
  #bag h3 { font-size: 20px; margin-bottom: 8px; }
  .item .ic { font-size: 24px; }
  #puzzle { padding: 10px 14px; }
  .spin .val { font-size: 28px; width: 56px; }
  #e-text p { font-size: 14px; margin-bottom: 8px; }
}
#i-mods { color: #ff7a6a; }
