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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

#timer {
  position: absolute;
  top: 4vh;
  left: 50%;
  transform: translateX(-50%);
  color: #f2e9c9;
  font-size: clamp(20px, 4vw, 36px);
  font-weight: 700;
  text-shadow: 0 0 10px #000, 0 0 20px rgba(0,0,0,.8);
  letter-spacing: 1px;
}

#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255,255,255,0.75);
  box-shadow: 0 0 4px rgba(0,0,0,.8);
}

#hint {
  position: absolute;
  bottom: 3vh;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.55);
  font-size: clamp(11px, 1.6vw, 14px);
  letter-spacing: 1px;
}

/* ---------- vignette / heartbeat danger overlay ---------- */
#vignette {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(120,0,0,0) 35%, rgba(120,0,0,0.75) 100%);
  transition: opacity 120ms linear;
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(5,5,5,0.88);
  color: #eee;
  z-index: 20;
  padding: 4vh 6vw;
}

.hidden { display: none !important; }

#start-screen h1 {
  font-size: clamp(32px, 8vw, 64px);
  color: #d8c98a;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(216,201,138,0.4);
}
#start-screen h1 span { color: #7a1f1f; }

.desc {
  margin-top: 1.5vh;
  max-width: 60ch;
  color: #bbb;
  font-size: clamp(13px, 2.2vw, 17px);
}

.controls-box {
  margin: 3vh 0;
  display: grid;
  gap: 6px;
  font-size: clamp(13px, 2vw, 16px);
  color: #ccc;
}
.controls-box b { color: #d8c98a; }

button {
  font-family: inherit;
  font-size: clamp(15px, 2.4vw, 20px);
  font-weight: 700;
  letter-spacing: 1px;
  padding: 1.4vh 4vw;
  background: #7a1f1f;
  color: #fff;
  border: 2px solid #d8c98a;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}
button:hover { background: #9c2a2a; transform: scale(1.04); }
button:active { transform: scale(0.97); }

#pause-screen h2 { font-size: clamp(24px, 5vw, 40px); margin-bottom: 3vh; color: #d8c98a; }

/* ---------- jumpscare ---------- */
#jumpscare-img {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
  z-index: 30;
  display: none;
}
#jumpscare-img.show {
  display: block;
  animation: jumpscare-anim 550ms cubic-bezier(.3,1,.4,1) forwards;
}
@keyframes jumpscare-anim {
  0%   { transform: scale(1.6); filter: brightness(4) saturate(2); opacity: 0; }
  15%  { transform: scale(2.2) translate(1%,-1%); opacity: 1; filter: brightness(3) contrast(1.4); }
  30%  { transform: scale(1.9) translate(-1.5%,1%); filter: brightness(2); }
  45%  { transform: scale(2.1) translate(1%,1%); }
  60%  { transform: scale(1.85) translate(-1%,-1%); filter: brightness(1.4); }
  100% { transform: scale(1.9); filter: brightness(1); }
}

#gameover-screen {
  background: rgba(2,0,0,0.92);
  animation: gameover-fade-in 400ms ease-out;
}
@keyframes gameover-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

#you-died {
  font-size: clamp(48px, 12vw, 100px);
  font-weight: 700;
  color: #a30000;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(163,0,0,0.9), 0 0 60px rgba(163,0,0,0.5);
  margin-bottom: 2vh;
  animation: you-died-in 900ms cubic-bezier(.2,.9,.3,1) both;
}
@keyframes you-died-in {
  0% { opacity: 0; letter-spacing: 20px; filter: blur(6px); }
  100% { opacity: 1; letter-spacing: 4px; filter: blur(0); }
}

#gameover-screen h2 {
  font-size: clamp(20px, 4.5vw, 32px);
  color: #d8c98a;
  margin-bottom: 1.5vh;
}
#survive-time {
  font-size: clamp(15px, 2.4vw, 20px);
  color: #ccc;
  margin-bottom: 3vh;
}

/* ---------- touch controls ---------- */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; position: fixed; inset: 0; z-index: 11; touch-action: none; }
#look-zone { position: absolute; top: 0; right: 0; width: 60%; height: 100%; }
#joystick {
  position: absolute; left: 6vw; bottom: 8vh; width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(216,201,138,0.45); touch-action: none;
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: rgba(216,201,138,0.5); pointer-events: none;
}
.tbtn {
  position: absolute; padding: 0; width: 76px; height: 76px; border-radius: 50%;
  font-size: 14px; background: rgba(122,31,31,0.55); touch-action: none;
}
.tbtn:hover { transform: none; }
#jump-btn { right: 5vw; bottom: 8vh; }
#sprint-btn { right: calc(5vw + 92px); bottom: 5vh; width: 64px; height: 64px; }
#sprint-btn.on { background: rgba(216,201,138,0.7); color: #000; }
#pause-btn { right: 4vw; top: 3vh; width: 48px; height: 48px; font-size: 16px; }
#view-btn { right: calc(4vw + 60px); top: 3vh; width: 48px; height: 48px; font-size: 15px; }

/* ---------- menus ---------- */
.overlay { overflow-y: auto; }
.menu-col { display: flex; flex-direction: column; gap: 12px; margin-top: 3vh; min-width: 240px; }
button.secondary { background: rgba(40,36,20,0.9); }
button.small { padding: 8px 14px; font-size: 14px; }
.overlay h2 { color: #d8c98a; font-size: clamp(22px, 4.5vw, 36px); margin-bottom: 2vh; letter-spacing: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 6px 0; width: 100%; max-width: 640px; }
input, select {
  font: inherit; font-size: 15px; padding: 8px 10px; border-radius: 6px;
  background: #15130a; color: #eee; border: 1px solid #5a5230; min-width: 0; flex: 1 1 140px;
}
.status { color: #bbb; font-size: 14px; min-height: 18px; margin: 4px 0; }
.status.err { color: #ff6b6b; }
.panel { border: 1px solid #3a3520; border-radius: 8px; padding: 8px; margin: 10px 0; width: 100%; max-width: 660px; }
#room-list { width: 100%; max-width: 660px; max-height: 32vh; overflow-y: auto; display: grid; gap: 6px; margin: 8px 0; }
.room-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px;
  background: rgba(216,201,138,0.08); border: 1px solid #3a3520; text-align: left;
}
.room-item .rn { flex: 1; font-weight: 700; color: #eee; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .rm { font-size: 12px; color: #d8c98a; text-transform: uppercase; }
.room-item .rp { font-size: 13px; color: #aaa; }
.empty { color: #888; font-size: 14px; padding: 10px; }
.mode-cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-bottom: 3vh; }
.mode-card { display: flex; flex-direction: column; gap: 6px; width: 220px; padding: 18px; }
.mode-card small { font-weight: 400; font-size: 13px; color: #ddd; }
.mode-card.hard { background: #3e0909; border-color: #ff4b4b; }
#lobby-players { list-style: none; margin: 10px 0; min-width: 240px; }
#lobby-players li { padding: 6px 10px; border-bottom: 1px solid #3a3520; color: #eee; }
#lobby-players li .host { color: #d8c98a; font-size: 12px; margin-left: 6px; }
#lobby-results { margin: 8px 0; color: #ccc; font-size: 14px; }
#lobby-results table { border-collapse: collapse; margin: 6px auto; }
#lobby-results td { padding: 3px 10px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 22px; max-width: 640px; width: 100%; margin-bottom: 3vh; text-align: left; }
.settings-grid label { display: flex; flex-direction: column; gap: 4px; color: #ccc; font-size: 14px; }
.settings-grid label.chk { flex-direction: row; align-items: center; gap: 8px; }
.settings-grid input[type=checkbox] { flex: 0 0 auto; width: 20px; height: 20px; accent-color: #7a1f1f; }
.settings-grid input[type=range] { padding: 0; accent-color: #d8c98a; }
.controls-box { font-size: 13px; }
body.touch .controls-box { display: none; }

/* ---------- HUD extras ---------- */
#role-tag { position: absolute; top: 4vh; left: 4vw; font-weight: 700; letter-spacing: 1px; color: #d8c98a; text-shadow: 0 0 8px #000; }
#role-tag.hunter { color: #ff4b4b; }
#alive-count { position: absolute; top: calc(4vh + 24px); left: 4vw; color: #ccc; font-size: 13px; text-shadow: 0 0 6px #000; }
#fps { position: absolute; bottom: 2vh; left: 2vw; color: #8f8; font: 12px monospace; }
#toast {
  position: absolute; top: 14vh; left: 50%; transform: translateX(-50%); color: #fff; font-size: 16px;
  background: rgba(0,0,0,0.55); padding: 6px 14px; border-radius: 6px; opacity: 0; transition: opacity 300ms;
}
#toast.show { opacity: 1; }
