/* RESIDENT FABLE — PS1 survival horror
   UI skin rules: dot-matrix font, hard 2px shadows (no glow), beveled
   panels, ordered-dither textures, steps() blinking (PS1 didn't ease). */

@font-face {
  font-family: 'DotGothic16';
  src: url('fonts/DotGothic16-latin.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --px-font: 'DotGothic16', 'Courier New', monospace;
  --ui-text: #c8ccb4;
  --ui-dim: #6e7460;
  --ui-gold: #d8b96a;
  --ui-blood: #8c1414;
  --bevel-light: #6a705a;
  --bevel-dark: #1c2016;
}

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: var(--px-font);
  user-select: none;
  cursor: default;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

#frame {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: #000;
}

#game {
  position: absolute;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden { display: none !important; }

/* hard ordered-dither texture (2px checkerboard) */
.dither {
  background-image: repeating-conic-gradient(rgba(0,0,0,0.28) 0% 25%, transparent 0% 50%);
  background-size: 2px 2px;
}

/* pixel-art arrows built from box-shadow grids — no vector glyphs */
.px {
  display: inline-block;
  width: 3px; height: 3px;
  background: transparent;
}
.px-down {
  box-shadow:
    0 0, 3px 0, 6px 0, 9px 0, 12px 0, 15px 0, 18px 0,
    3px 3px, 6px 3px, 9px 3px, 12px 3px, 15px 3px,
    6px 6px, 9px 6px, 12px 6px,
    9px 9px;
}
.px-up {
  box-shadow:
    9px 0,
    6px 3px, 9px 3px, 12px 3px,
    3px 6px, 6px 6px, 9px 6px, 12px 6px, 15px 6px,
    0 9px, 3px 9px, 6px 9px, 9px 9px, 12px 9px, 15px 9px, 18px 9px;
}
.px-right {
  box-shadow:
    0 0,
    0 3px, 3px 3px,
    0 6px, 3px 6px, 6px 6px,
    0 9px, 3px 9px, 6px 9px, 9px 9px,
    0 12px, 3px 12px, 6px 12px,
    0 15px, 3px 15px,
    0 18px;
}

/* hard blink — PS1 cursors snapped, never faded */
@keyframes hardblink { 0%, 54% { opacity: 1; } 55%, 100% { opacity: 0.18; } }
@keyframes hardbob { 0%, 49% { transform: translateY(0); } 50%, 100% { transform: translateY(3px); } }

/* cinematic bars */
.bar {
  position: absolute; left: 0; width: 100%; height: 0;
  background: #000; z-index: 5;
  transition: height 0.8s ease;
}
#bar-top { top: 0; }
#bar-bottom { bottom: 0; }
.bars-on #bar-top, .bars-on #bar-bottom { height: 9%; }

/* fade overlay */
#fade {
  position: absolute; inset: 0; z-index: 40;
  background: #000; opacity: 1;
  pointer-events: none;
  transition: opacity 1s ease;
}
#fade.red { background: #2a0000; }

/* ------------ message box ------------- */
#msgbox {
  position: absolute;
  left: 7%; right: 7%; bottom: 6%;
  z-index: 20;
  background: rgba(5, 7, 5, 0.86);
  border: 2px solid #565c48;
  outline: 2px solid #000;
  box-shadow: inset 0 0 0 2px #000;
  padding: 16px 24px 20px;
  min-height: 66px;
}
#msgtext {
  color: var(--ui-text);
  font-size: 16px;
  letter-spacing: 0.04em;
  line-height: 1.7;
  text-shadow: 2px 2px 0 #000;
}
#msgtext .key { color: var(--ui-gold); }
#msgmore {
  position: absolute; right: 16px; bottom: 8px;
  color: #9aa48c;
  animation: hardbob 0.7s steps(1) infinite;
}

/* ------------ confirm ------------- */
#confirm {
  position: absolute; left: 50%; top: 58%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(5, 7, 5, 0.92);
  border: 2px solid #565c48;
  outline: 2px solid #000;
  padding: 16px 36px;
  text-align: center;
}
#confirm-text {
  color: var(--ui-text); font-size: 16px; letter-spacing: 0.04em;
  margin-bottom: 14px;
  text-shadow: 2px 2px 0 #000;
}
.confirm-opts span {
  display: inline-block;
  color: var(--ui-dim);
  font-size: 16px;
  margin: 0 16px;
  padding: 3px 14px;
  letter-spacing: 0.1em;
  text-shadow: 2px 2px 0 #000;
}
.confirm-opts span.sel {
  color: #f0e8c8;
  background: #5a1410;
  box-shadow: 0 0 0 2px #2a0806;
  animation: hardblink 0.8s steps(1) infinite;
}

/* ------------ interact prompt: shows the actual button/key ------------- */
#prompt {
  position: absolute; left: 50%; bottom: 13%;
  transform: translateX(-50%);
  z-index: 8;
  animation: hardbob 0.8s steps(1) infinite;
}
.btn-chip {
  display: inline-block;
  font-family: var(--px-font);
  font-size: 16px;
  line-height: 1;
  padding: 5px 8px 6px;
  background: rgba(5, 7, 5, 0.85);
  border: 2px solid;
  text-shadow: 2px 2px 0 #000;
}
.btn-chip.pad { border-radius: 50%; padding: 6px 9px 7px; }
.btn-chip.kb { border-radius: 0; }

/* ------------ inventory ------------- */
#inventory {
  position: absolute; inset: 0; z-index: 30;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.32) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, rgba(18, 24, 18, 0.93), rgba(3, 5, 3, 0.97));
  display: flex; align-items: center; justify-content: center;
}
.inv-frame {
  display: flex; gap: 36px;
  padding: 30px 40px;
  background:
    repeating-conic-gradient(rgba(0,0,0,0.22) 0% 25%, transparent 0% 50%),
    #1a2018;
  background-size: 2px 2px, auto;
  border: 3px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  outline: 3px solid #000;
}
.inv-left { width: 200px; }
.inv-name {
  color: #b9c0a8; font-size: 16px; letter-spacing: 0.14em;
  text-shadow: 2px 2px 0 #000;
  border-bottom: 2px solid #3a4030;
  padding-bottom: 8px; margin-bottom: 10px;
}
#ecg {
  display: block;
  background: #040704;
  border: 2px solid;
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
  image-rendering: pixelated;
}
#condition {
  margin-top: 10px; font-size: 16px; letter-spacing: 0.3em; text-align: center;
  text-shadow: 2px 2px 0 #000;
}
.cond-fine    { color: #58b858; }
.cond-caution { color: #d8a93f; }
.cond-danger  { color: #c83a2a; animation: hardblink 0.8s steps(1) infinite; }

.inv-equip { margin-top: 22px; }
.inv-equip-label {
  color: var(--ui-dim); font-size: 13px; letter-spacing: 0.2em; margin-bottom: 6px;
  text-shadow: 2px 2px 0 #000;
}

#slots {
  display: grid;
  grid-template-columns: repeat(2, 96px);
  grid-auto-rows: 96px;
  gap: 8px;
}
.slot {
  position: relative;
  width: 96px; height: 96px;
  background:
    repeating-conic-gradient(rgba(0,0,0,0.25) 0% 25%, transparent 0% 50%),
    #11160f;
  background-size: 2px 2px, auto;
  border: 3px solid;
  border-color: var(--bevel-dark) #3c4232 #3c4232 var(--bevel-dark);
}
.equip-slot { width: 96px; height: 96px; }
.slot.sel {
  border-color: var(--ui-gold) #8a6c24 #8a6c24 var(--ui-gold);
  animation: hardblink 0.9s steps(1) infinite;
}
.slot.combining { border-color: #c83a2a #6a1410 #6a1410 #c83a2a; }
.slot canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
}
.slot .count {
  position: absolute; right: 5px; bottom: 3px;
  color: #e0e4cc; font-size: 16px; font-family: var(--px-font);
  text-shadow: 2px 2px 0 #000;
}
#item-name {
  margin-top: 14px; height: 26px;
  color: #e0d8b4; font-size: 16px; letter-spacing: 0.1em; text-align: center;
  text-shadow: 2px 2px 0 #000;
}
#item-menu {
  position: absolute;
  background: rgba(5, 7, 5, 0.95);
  border: 2px solid #565c48;
  outline: 2px solid #000;
  z-index: 5;
  min-width: 132px;
}
#item-menu div {
  color: var(--ui-dim); font-size: 16px; letter-spacing: 0.16em;
  padding: 7px 16px;
  text-shadow: 2px 2px 0 #000;
}
#item-menu div.sel { color: #f0e8c8; background: #5a1410; }
.inv-right { position: relative; }

/* ------------ title screen ------------- */
#title {
  position: absolute; inset: 0; z-index: 50;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.25) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 35%, #0e0e0e, #000 75%);
  display: flex; align-items: center; justify-content: center;
}
#title-card { text-align: center; }
#title-sub1 {
  color: #50504a; font-size: 13px; letter-spacing: 0.5em; margin-bottom: 26px;
  text-shadow: 2px 2px 0 #000;
}
#title-main { line-height: 0; }
#title-main canvas {
  image-rendering: pixelated;
  animation: titleflicker 7s steps(1) infinite;
}
@keyframes titleflicker {
  0%, 91%, 94%, 100% { opacity: 1; }
  92%, 93% { opacity: 0.7; }
}
#title-sub2 {
  color: #6e6e62; font-size: 16px; letter-spacing: 0.5em; margin-top: 16px;
  text-shadow: 2px 2px 0 #000;
}
#title-menu { margin-top: 48px; }
.tm-item {
  position: relative;
  display: inline-block;
  color: #58584e; font-size: 16px; letter-spacing: 0.3em;
  margin: 10px 0; padding: 2px 26px;
  text-shadow: 2px 2px 0 #000;
}
#title-menu { display: flex; flex-direction: column; align-items: center; }
.tm-item.sel { color: #e8dfb8; }
.tm-item.sel::before {
  content: '';
  position: absolute; left: 0; top: 7px;
  width: 3px; height: 3px;
  color: var(--ui-blood);
  box-shadow:
    0 0,
    0 3px, 3px 3px,
    0 6px, 3px 6px, 6px 6px,
    0 9px, 3px 9px,
    0 12px;
  animation: hardblink 0.7s steps(1) infinite;
}
.tm-item.disabled { color: #2c2c28; }
#title-hint {
  margin-top: 52px; color: #3c3c36; font-size: 13px; letter-spacing: 0.08em;
  line-height: 2;
}
.pad-hint { color: #34342f; }
.pad-hint.dim { color: #2a2a26; font-size: 13px; }

/* ------------ cinematic text (intro/death/win) ------------- */
#cine {
  position: absolute; inset: 0; z-index: 45;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
#cine-text {
  color: #9b9a8a; font-size: 19px; letter-spacing: 0.08em;
  text-align: center; line-height: 2.1;
  max-width: 72%;
  text-shadow: 2px 2px 0 #000;
}
#cine-text .big {
  display: block;
  font-size: 48px; letter-spacing: 0.14em;
  color: var(--ui-blood);
  text-shadow: 3px 3px 0 #000, 0 0 24px rgba(140, 10, 10, 0.4);
  margin-bottom: 20px;
}
#cine-text .small { font-size: 13px; color: #55554c; }

/* ------------ controller indicator ------------- */
#pad-status {
  position: absolute; left: 10px; bottom: 8px; z-index: 60;
  color: #4a5a3e; font-size: 13px; letter-spacing: 0.04em;
  font-family: var(--px-font);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  text-shadow: 2px 2px 0 #000;
}
#pad-status.on { opacity: 0.85; }

/* ------------ pause menu ------------- */
#pausemenu {
  position: absolute; inset: 0; z-index: 35;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.3) 0 2px, transparent 2px 4px),
    rgba(0, 0, 0, 0.72);
  display: flex; align-items: center; justify-content: center;
}
#pm-card {
  min-width: 320px;
  padding: 26px 40px 22px;
  text-align: center;
  background:
    repeating-conic-gradient(rgba(0,0,0,0.22) 0% 25%, transparent 0% 50%),
    #14181a;
  background-size: 2px 2px, auto;
  border: 3px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  outline: 3px solid #000;
}
#pm-title {
  color: #8c1414; font-size: 18px; letter-spacing: 0.45em;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 20px;
}
#pm-list div {
  color: var(--ui-dim); font-size: 16px; letter-spacing: 0.18em;
  padding: 7px 14px; margin: 2px 0;
  text-shadow: 2px 2px 0 #000;
}
#pm-list div.sel { color: #f0e8c8; background: #5a1410; }
#pm-list div.debug { color: #4a6a4a; font-size: 14px; }
#pm-list div.debug.sel { color: #a8e8a8; background: #1d3a1d; }
#pm-hint { margin-top: 18px; color: #3c3c36; font-size: 12px; letter-spacing: 0.15em; }

/* ------------ character select ------------- */
#charselect {
  position: absolute; inset: 0; z-index: 55;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.3) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 40%, #101216, #000 80%);
  display: flex; align-items: center; justify-content: center;
}
#cs-card { text-align: center; }
#cs-title {
  color: #8c1414; font-size: 24px; letter-spacing: 0.4em;
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 36px;
}
#cs-grid {
  display: grid;
  grid-template-columns: repeat(3, 132px);
  gap: 18px;
  justify-content: center;
}
.cs-tile {
  padding: 10px 10px 8px;
  background:
    repeating-conic-gradient(rgba(0,0,0,0.22) 0% 25%, transparent 0% 50%),
    #14181a;
  background-size: 2px 2px, auto;
  border: 3px solid;
  border-color: var(--bevel-dark) #3c4232 #3c4232 var(--bevel-dark);
}
.cs-tile.sel {
  border-color: var(--ui-gold) #8a6c24 #8a6c24 var(--ui-gold);
  animation: hardblink 0.9s steps(1) infinite;
}
.cs-port {
  width: 96px; height: 96px;
  image-rendering: pixelated;
  display: block;
  margin: 0 auto;
}
.cs-name {
  margin-top: 8px;
  color: #c8ccb4; font-size: 14px; letter-spacing: 0.2em;
  text-shadow: 2px 2px 0 #000;
}
.cs-tile.sel .cs-name { color: #f0e8c8; }
#cs-tag {
  margin-top: 26px; height: 22px;
  color: #6e7460; font-size: 14px; letter-spacing: 0.08em;
  text-shadow: 2px 2px 0 #000;
}
#cs-hint { margin-top: 18px; color: #3c3c36; font-size: 12px; letter-spacing: 0.15em; }

/* ------------ controller setup wizard ------------- */
#padwizard {
  position: absolute; inset: 0; z-index: 70;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.3) 0 2px, transparent 2px 4px),
    rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
}
#pw-card { text-align: center; max-width: 80%; }
#pw-title {
  color: #6e6e62; font-size: 14px; letter-spacing: 0.5em; margin-bottom: 32px;
  text-shadow: 2px 2px 0 #000;
}
#pw-step {
  color: #e8dfb8; font-size: 26px; letter-spacing: 0.14em;
  text-shadow: 3px 3px 0 #000;
  min-height: 40px;
}
#pw-hint {
  color: #58584e; font-size: 14px; letter-spacing: 0.1em; margin-top: 14px;
  text-shadow: 2px 2px 0 #000;
}
#pw-live {
  color: #4a5a3e; font-family: var(--px-font); font-size: 13px;
  margin-top: 22px; min-height: 18px;
  text-shadow: 2px 2px 0 #000;
}
#pw-progress { color: #44443c; font-size: 13px; letter-spacing: 0.3em; margin-top: 26px; }
#pw-cancel { color: #33332e; font-size: 12px; letter-spacing: 0.2em; margin-top: 36px; }
