:root {
  --blood: #a70d16;
  --blood-bright: #e1262f;
  --bone: #d8d0bf;
  --ink: #080707;
  --panel: rgba(10, 9, 9, .88);
  --line: rgba(216, 208, 191, .18);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #050505; color: var(--bone); }

body {
  font-family: "Kanit", sans-serif;
  overflow: hidden;
}

button { font: inherit; }
.hidden { display: none !important; }
.muted { color: #8d8780; font-size: .78rem; }
.eyebrow { margin: 0 0 .5rem; color: #d14449; font: 600 .7rem/1 "Chakra Petch"; letter-spacing: .22em; text-transform: uppercase; }

.age-gate {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 32%, rgba(112, 0, 8, .22), transparent 30%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px),
    #050505;
}

.warning-card {
  width: min(580px, calc(100% - 32px)); padding: 48px; text-align: center;
  border: 1px solid rgba(186, 23, 31, .45); background: rgba(9, 8, 8, .94);
  box-shadow: 0 30px 100px #000, inset 0 0 50px rgba(130,0,8,.08);
}

.warning-card h1 {
  margin: 0; color: #eee6d7; font: 700 clamp(5rem, 18vw, 9rem)/.9 "Chakra Petch";
  letter-spacing: .16em; text-indent: .16em; text-shadow: 0 0 24px rgba(211, 12, 24, .45);
}

.warning-card p:not(.eyebrow) { color: #a8a097; line-height: 1.8; }
.warning-card small { display: block; margin-top: 1rem; color: #615c58; }
.sensory-warning {
  margin: 20px 0; padding: 14px 16px; text-align: left;
  border: 1px solid rgba(225, 38, 47, .65);
  border-left: 4px solid var(--blood-bright);
  background: rgba(105, 7, 13, .18);
}
.sensory-warning strong {
  display: block; color: #ee9a9e;
  font: 600 .86rem "Chakra Petch"; letter-spacing: .04em;
}
.sensory-warning p:not(.eyebrow) {
  margin: 7px 0; color: #c1b8ae; font-size: .84rem; line-height: 1.6;
}
.sensory-warning span { color: #817973; font-size: .75rem; }
.consent { display: flex; align-items: center; justify-content: center; gap: .65rem; margin: 1.6rem 0; color: #c8c0b5; }
.consent input { accent-color: var(--blood); width: 18px; height: 18px; }

.prologue {
  position: fixed; inset: 0; z-index: 18; display: grid; place-items: center; overflow: auto;
  padding: 32px 16px;
  background: #050505;
}
.prologue-backdrop {
  position: fixed; inset: 0;
  background:
    linear-gradient(90deg, rgba(0,0,0,.9), rgba(0,0,0,.42), rgba(0,0,0,.9)),
    linear-gradient(0deg, rgba(5,5,5,.96), transparent 70%),
    url("assets/slaughterhouse-exterior.png") center / cover;
  filter: saturate(.55) contrast(1.15);
  transform: scale(1.02);
}
.prologue-card {
  position: relative; width: min(760px, 100%); padding: 38px 42px;
  border-top: 1px solid rgba(216,208,191,.2); border-bottom: 1px solid rgba(216,208,191,.2);
  border-left: 3px solid var(--blood);
  background: linear-gradient(110deg, rgba(8,7,7,.96), rgba(15,10,11,.88));
  box-shadow: 0 28px 90px #000; backdrop-filter: blur(12px);
}
.prologue-card h1 {
  margin: 0 0 20px; color: #eee7dd;
  font: 600 clamp(1.8rem, 5vw, 3rem)/1.2 "Chakra Petch";
}
.prologue-text { color: #bbb3a9; line-height: 1.85; }
.prologue-text p { margin: 0 0 13px; }
.prologue-card .primary { margin-top: 13px; }
.prologue-card small { display: block; margin-top: 11px; color: #6f6862; text-align: center; }

.primary, .choices button, .medicine {
  border: 1px solid rgba(204, 43, 50, .55); color: #eee7dd;
  background: linear-gradient(100deg, rgba(117, 10, 16, .84), rgba(49, 7, 10, .9));
  cursor: pointer; transition: .2s ease;
}

.primary { width: 100%; padding: 14px 22px; font-weight: 500; letter-spacing: .05em; }
.primary:disabled { filter: grayscale(1); opacity: .35; cursor: not-allowed; }
.primary:not(:disabled):hover, .choices button:hover, .medicine:hover { border-color: #ef4b52; transform: translateY(-1px); filter: brightness(1.18); }

.game { min-height: 100vh; position: relative; isolation: isolate; }
.scene {
  position: fixed; inset: 0; z-index: -3; background-position: center; background-size: cover;
  transition: background-image .8s ease, filter 1s ease; transform: scale(1.02);
}
.scene::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.82), rgba(0,0,0,.18) 45%, rgba(0,0,0,.82)),
              linear-gradient(0deg, #070606 0, transparent 42%, rgba(0,0,0,.3));
}
.noise {
  position: fixed; inset: -40%; z-index: -1; pointer-events: none; opacity: .08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  animation: noise .22s steps(2) infinite;
}
@keyframes noise { 0%{transform:translate(0)} 25%{transform:translate(3%, -2%)} 50%{transform:translate(-2%, 3%)} 75%{transform:translate(2%, 2%)} }
.flash { position: fixed; inset: 0; z-index: 12; pointer-events: none; background: #9b0008; opacity: 0; }
.flash.active { animation: flash .45s ease; }
@keyframes flash { 0%,100%{opacity:0} 15%{opacity:.28} 30%{opacity:.03} 45%{opacity:.18} }

.topbar {
  height: 72px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: linear-gradient(#090808e8, #090808a6); backdrop-filter: blur(12px);
}
.topbar strong { display: block; font: 600 1rem "Chakra Petch"; letter-spacing: .03em; }
.case-label { color: var(--blood-bright); font: 700 .65rem "Chakra Petch"; letter-spacing: .16em; }
.top-actions { display: flex; gap: 8px; }
.icon-button { padding: 8px 12px; color: #aaa29a; border: 1px solid var(--line); background: rgba(0,0,0,.3); cursor: pointer; }
.icon-button:hover { color: white; border-color: #6e6862; }

.status-panel {
  position: absolute; left: 28px; top: 98px; width: 240px; padding: 18px;
  display: grid; grid-template-columns: 48px 1fr; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px);
}
.portrait {
  grid-row: span 2; width: 48px; height: 58px; display: grid; place-items: center;
  color: #d5cdc0; border: 1px solid #4e4741; background: #191616;
  font: 700 1.6rem "Chakra Petch"; box-shadow: inset 0 -18px 30px #090808;
}
.status-panel strong { display: block; font-size: .85rem; font-weight: 500; }
.meter { grid-column: 1 / -1; }
.meter > div:first-child { display: flex; justify-content: space-between; font-size: .74rem; }
.track { height: 4px; margin-top: 5px; background: #302c29; overflow: hidden; }
.track i { display: block; height: 100%; width: 100%; background: #a10e16; transition: width .35s ease; box-shadow: 0 0 8px #d21821; }
.sanity .track i { background: #a9a19a; box-shadow: 0 0 8px #ddd; }
.evidence { grid-column: 1 / -1; display: flex; justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--line); }

.story-panel {
  position: absolute; left: max(300px, calc(50% - 380px)); bottom: 34px; width: min(760px, calc(100vw - 620px));
  max-height: calc(100vh - 130px); padding: 26px 30px; overflow: auto;
  background: linear-gradient(110deg, rgba(8,7,7,.94), rgba(13,10,10,.84));
  border-left: 3px solid var(--blood); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  box-shadow: 0 25px 80px rgba(0,0,0,.55); backdrop-filter: blur(12px);
}
.story-panel h2 { margin: 0 0 12px; color: #eee7dd; font: 600 clamp(1.35rem, 3vw, 2rem) "Chakra Petch"; }
.story { color: #bdb5ac; font-size: .98rem; line-height: 1.8; }
.story p { margin: 0 0 .7rem; }
.story em { color: #e1d8ca; font-style: normal; }
.choices { display: grid; gap: 8px; margin-top: 18px; }
.choices button { position: relative; padding: 11px 15px 11px 42px; text-align: left; background: rgba(34, 24, 25, .86); border-color: #493638; }
.choices button::before { content: "›"; position: absolute; left: 16px; color: #d22c34; font: 600 1.3rem "Chakra Petch"; }
.choices button:disabled { opacity: .35; cursor: not-allowed; }
.roll-result { margin-top: 14px; padding: 11px; text-align: center; color: #ddd4c8; border: 1px solid #514745; background: #0b0909; font: 600 .9rem "Chakra Petch"; }
.roll-result.success { border-color: #486149; color: #b9d3b5; }
.roll-result.fail { border-color: #79232a; color: #ef9397; }
.dice-panel {
  margin-top: 16px; padding: 15px; display: flex; align-items: center; gap: 16px;
  border: 1px solid #5b4647; background: rgba(17, 11, 12, .96);
}
.dice {
  flex: 0 0 64px; width: 64px; height: 64px; display: grid; place-items: center;
  color: #171111; background: #d8d0bf; border: 3px solid #eee7d9; border-radius: 10px;
  box-shadow: 0 5px 0 #766e63, 0 9px 24px #000; font: 700 2rem "Chakra Petch";
}
.dice.rolling { animation: dice-roll .12s linear infinite; }
@keyframes dice-roll {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(8deg) scale(.92); }
  50% { transform: rotate(-7deg) scale(1.06); }
  75% { transform: rotate(5deg) scale(.96); }
}
.dice-copy { flex: 1; display: grid; gap: 8px; color: #a9a097; font-size: .8rem; }
.roll-button {
  padding: 10px 14px; color: #f0e8dd; cursor: pointer;
  border: 1px solid #b9262e; background: linear-gradient(100deg, #7c0d14, #31080b);
}
.roll-button:hover { filter: brightness(1.2); }
.roll-button:disabled { opacity: .45; cursor: wait; }

.bag-panel {
  position: absolute; right: 28px; top: 98px; width: 230px; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px);
}
.bag-head { display: flex; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--line); font: 600 .8rem "Chakra Petch"; }
.bag-head b { color: #c0262e; }
.inventory { display: grid; gap: 7px; margin-top: 10px; }
.item { display: flex; align-items: center; gap: 9px; padding: 8px; color: #aaa29a; font-size: .78rem; background: #141111; }
.item i { width: 8px; height: 8px; border: 1px solid #9e1b22; transform: rotate(45deg); }
.empty { color: #55504c; padding: 14px 0; font-size: .78rem; text-align: center; }
.medicine { width: 100%; margin-top: 10px; padding: 8px; font-size: .76rem; }
.toast {
  position: fixed; top: 88px; left: 50%; z-index: 15; transform: translate(-50%, -20px);
  padding: 10px 18px; color: #eee6da; opacity: 0; background: #731018; border: 1px solid #d02c34;
  pointer-events: none; transition: .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body.low-sanity .scene { filter: contrast(1.25) saturate(.45) hue-rotate(-10deg); animation: breathe 3s ease-in-out infinite; }
body.critical .game { animation: shake .16s linear infinite; }
@keyframes breathe { 50% { transform: scale(1.045); filter: contrast(1.45) saturate(.3) hue-rotate(-18deg); } }
@keyframes shake { 25% { transform: translate(1px,-1px); } 75% { transform: translate(-1px,1px); } }

@media (max-width: 900px) {
  body { overflow: auto; }
  .game { min-height: 100svh; padding-bottom: 20px; }
  .topbar { padding: 0 16px; }
  .status-panel { position: relative; top: auto; left: auto; margin: 16px; width: calc(100% - 32px); }
  .story-panel { position: relative; left: auto; bottom: auto; width: calc(100% - 32px); margin: 16px; max-height: none; }
  .bag-panel { position: relative; top: auto; right: auto; width: calc(100% - 32px); margin: 16px; }
  .scene { position: fixed; }
}

@media (max-width: 520px) {
  .warning-card { padding: 32px 22px; }
  .prologue { align-items: start; padding-top: 18px; }
  .prologue-card { padding: 28px 22px; }
  .prologue-text { font-size: .9rem; line-height: 1.7; }
  .topbar strong { font-size: .78rem; }
  .top-actions button { font-size: 0; }
  .top-actions button::first-letter { font-size: 1rem; }
  .story-panel { padding: 22px 18px; }
}
