* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; color: #ddd;
  font-family: Georgia, 'Times New Roman', serif; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(140,0,0,.65) 100%); }
#flash { position: fixed; inset: 0; pointer-events: none; background: #a00; opacity: 0; }
#fade { position: fixed; inset: 0; pointer-events: none; background: #000; opacity: 0; }
#wardrobe-overlay { position: fixed; inset: 0; pointer-events: none; display: none;
  background: linear-gradient(90deg, #000 0 44%, rgba(0,0,0,.35) 47%, rgba(0,0,0,.1) 50%, rgba(0,0,0,.35) 53%, #000 56% 100%); }

#hud { position: fixed; inset: 0; pointer-events: none; }
#days { position: absolute; top: 14px; left: 16px; font-size: 20px; letter-spacing: 2px; color: #c9b9a0;
  text-shadow: 0 0 6px #000; }
#days .d { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #8a7a66; margin-left: 5px; vertical-align: -1px; }
#days .d.used { background: #7a0000; border-color: #b00; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2px 0 0 -2px;
  border-radius: 50%; background: rgba(255,255,255,.7); }
#crosshair.active { background: #ffd070; box-shadow: 0 0 8px #ffb000; width: 8px; height: 8px; margin: -4px 0 0 -4px; }
#hint { position: absolute; left: 50%; top: calc(50% + 26px); transform: translateX(-50%); font-size: 17px;
  color: #f0e0c0; text-shadow: 0 0 4px #000, 0 0 8px #000; white-space: nowrap; text-align: center; }
#toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font-size: 21px; color: #f3e6cc;
  text-shadow: 0 0 6px #000, 0 0 12px #000; opacity: 0; transition: opacity .3s; text-align: center; max-width: 90vw; }
#held { position: absolute; right: 18px; bottom: 16px; text-align: right; color: #e9dcc4; text-shadow: 0 0 5px #000; }
#held-name { display: block; font-size: 20px; }
#held-help { font-size: 13px; color: #a99; }
#note { position: absolute; left: 18px; bottom: 18px; }
#note .paper { background: #e8dcb8; color: #2a1d10; padding: 14px 20px; transform: rotate(-3deg); width: 210px;
  box-shadow: 0 4px 20px #000; font-family: 'Comic Sans MS', 'Segoe Print', cursive; font-size: 14px; }
#note b { display: block; font-size: 34px; letter-spacing: 8px; margin: 6px 0; color: #600; }
#note .sig { text-align: right; }
#struggle { position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); background: rgba(80,0,0,.75);
  padding: 10px 18px; border-radius: 6px; font-size: 18px; color: #fff; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { background: rgba(160,0,0,.85); } }

#dayscreen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .8s; }
#dayscreen-text { font-size: 64px; color: #b8a888; letter-spacing: 10px; text-shadow: 0 0 20px #000; }
#dayscreen-sub { margin-top: 10px; font-size: 18px; color: #887; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: radial-gradient(ellipse at center, rgba(30,10,8,.88), rgba(0,0,0,.97)); padding: 16px; text-align: center; }
.screen h1 { font-size: clamp(56px, 13vw, 120px); color: #ddd0b8; letter-spacing: 12px; font-weight: normal;
  text-shadow: 0 0 30px #600, 3px 3px 0 #300; animation: flick 6s infinite; }
.screen h2 { font-size: 44px; color: #ccb; font-weight: normal; }
@keyframes flick { 0%,92%,100% { opacity: 1 } 93% { opacity: .4 } 94% { opacity: 1 } 96% { opacity: .6 } }
.sub { color: #a99a86; font-size: 18px; max-width: 560px; }
.screen button { font-family: inherit; font-size: 17px; background: #1c1412; color: #d8c8b0; border: 1px solid #5a4030;
  padding: 10px 22px; cursor: pointer; min-width: 220px; }
.screen button:hover { background: #3a1a14; border-color: #a55; }
.screen button.big { font-size: 24px; padding: 14px 30px; border-color: #933; }
.diff { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.diff button { min-width: 0; padding: 8px 16px; }
.diff button.sel { background: #5a1a14; border-color: #d66; color: #fff; }
.controls { margin-top: 10px; font-size: 14px; color: #8a7d6d; line-height: 1.7; max-width: 640px; }
#best { font-size: 14px; color: #a88; }

#keypad { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); }
.kp { background: #2b2d30; border: 3px solid #555; border-radius: 8px; padding: 16px; width: 250px; box-shadow: 0 0 40px #000; }
.kp-title { text-align: center; color: #aaa; margin-bottom: 8px; font-family: monospace; letter-spacing: 3px; }
#kp-display { background: #0b1a0b; color: #4f4; font-family: monospace; font-size: 34px; text-align: center; letter-spacing: 10px;
  padding: 8px; margin-bottom: 12px; border: 2px inset #333; }
#kp-display.err { color: #f44; }
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kp button { font-size: 22px; padding: 12px 0; background: #444; color: #eee; border: 2px outset #666; border-radius: 4px; cursor: pointer; font-family: monospace; }
.kp button:active { border-style: inset; }
#kp-close { width: 100%; margin-top: 10px; font-size: 15px !important; }

#touch { position: fixed; inset: 0; pointer-events: none; }
#joy { position: absolute; left: 24px; bottom: 24px; width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.18); pointer-events: auto; }
#joy-knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.3); }
#tbtns { position: absolute; right: 16px; bottom: 90px; display: grid; grid-template-columns: 70px 70px; gap: 10px; pointer-events: auto; }
#tbtns button, #t-pause { width: 70px; height: 70px; border-radius: 50%; background: rgba(40,20,20,.55); color: #eee;
  border: 2px solid rgba(255,255,255,.3); font-size: 14px; font-family: inherit; }
#t-act { font-size: 26px !important; background: rgba(120,70,20,.6) !important; }
#t-pause { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; pointer-events: auto; }
body.touch #held { bottom: 250px; }
body.touch #note { bottom: auto; top: 60px; }

/* ---------- horror theme ---------- */
body { font-family: 'Special Elite', Georgia, serif; }
.screen h1, #dayscreen-text, #end-title { font-family: 'Creepster', Georgia, serif; font-weight: normal; }
.screen h1 { color: #8a0a0a; letter-spacing: 8px; text-shadow: 0 0 25px #f00, 0 0 60px #600, 4px 4px 0 #000; animation: flick 5s infinite, shake 7s infinite; }
@keyframes shake { 0%,96%,100% { transform: none } 97% { transform: translate(3px,-2px) skewX(3deg) } 98% { transform: translate(-4px,2px) } 99% { transform: translate(2px,1px) skewX(-4deg) } }
.screen { background: radial-gradient(ellipse at 50% 40%, rgba(40,4,4,.55), rgba(0,0,0,.93) 70%); }
.screen button { font-family: 'Special Elite', Georgia, serif; background: rgba(20,4,4,.85); border-color: #4a1010; }
.screen button:hover { background: #3a0808; border-color: #c22; color: #fff; text-shadow: 0 0 8px #f33; }
.enter { color: #a33; font-size: 22px; animation: pulse2 1.6s infinite; cursor: pointer; }
#splash { cursor: pointer; }
@keyframes pulse2 { 50% { opacity: .3 } }
.drips { position: absolute; top: 0; left: 0; right: 0; height: 120px; pointer-events: none;
  background:
    radial-gradient(circle at 5% 0, #5a0000 0 22px, transparent 23px),
    radial-gradient(circle at 18% 0, #4a0000 0 14px, transparent 15px),
    radial-gradient(circle at 37% 0, #5a0000 0 26px, transparent 27px),
    radial-gradient(circle at 58% 0, #4a0000 0 16px, transparent 17px),
    radial-gradient(circle at 76% 0, #5a0000 0 24px, transparent 25px),
    radial-gradient(circle at 93% 0, #4a0000 0 18px, transparent 19px); }
.drips::before, .drips::after { content: ''; position: absolute; top: 0; width: 6px; border-radius: 0 0 4px 4px; background: #5a0000; animation: drip 6s infinite ease-in; }
.drips::before { left: 37%; height: 60px; }
.drips::after { left: 76%; height: 40px; animation-delay: 2.5s; }
@keyframes drip { 0% { height: 20px } 70% { height: 110px; opacity: 1 } 100% { height: 110px; opacity: 0 } }
#end.bad #end-title { color: #b00; font-size: clamp(40px, 9vw, 90px); }
#dayscreen-text { color: #9a1010; text-shadow: 0 0 30px #f00, 0 0 5px #000; font-size: 84px; }
#dayscreen-sub { font-family: 'Special Elite', serif; color: #a88; }
#hint, #toast, #days { font-family: 'Special Elite', Georgia, serif; }
#toast { color: #e8c8b8; }
#t-hide { visibility: hidden; font-size: 11px !important; }
.screen { overflow-y: auto; justify-content: safe center; }
@media (max-height: 640px) { .screen h1 { font-size: 56px; } .controls { font-size: 12px; line-height: 1.5; } .screen { gap: 8px; } }
