* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: #05080b;
  color: white;
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
  user-select: none;
}

.app {
  width: min(1050px, 100%);
  margin: 0 auto;
  padding: 10px;
}

.topbar {
  text-align: center;
  margin-bottom: 10px;
}

.topbar h1 {
  margin: 6px 0 2px;
  font-size: clamp(1.6rem, 5vw, 2.3rem);
}

.topbar p {
  margin: 0;
  color: #ccc;
}

.panel {
  background: #141414;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
}

.screen {
  text-align: center;
  padding: 26px 14px;
}

.hidden {
  display: none !important;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  font-size: 0.95rem;
}

.message {
  margin: 10px 0 0;
  color: #f1d66b;
  text-align: center;
  font-weight: 700;
}

.escape-timer {
  margin: 8px 0 0;
  color: #ff3333;
  text-align: center;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  text-shadow: 0 0 18px red;
  animation: timerPulse 0.7s infinite alternate;
}

.main-btn {
  background: #d81f26;
  color: white;
  border: 0;
  border-radius: 14px;
  padding: 14px 24px;
  margin: 8px;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.map-board {
  position: relative;
  width: min(620px, 100%);
  margin: 0 auto;
  aspect-ratio: 1024 / 1536;
  overflow: hidden;
  border-radius: 18px;
  background: #000;
  touch-action: manipulation;
  box-shadow:
    0 0 25px rgba(0, 0, 0, 0.9),
    0 0 35px rgba(0, 80, 120, 0.22);
}

.map-board::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 48%, rgba(0, 0, 0, 0.42)),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.2));
}

.map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  pointer-events: none;
}

.room-hotspot {
  position: absolute;
  border: 0;
  background: transparent !important;
  outline: none !important;
  cursor: pointer;
  z-index: 20;
  touch-action: manipulation;
}

/* HITBOXES - PORTRAIT SHIP MAP */
.captain-bridge { top: 3%; left: 30%; width: 40%; height: 17%; }
.restaurant { top: 25%; left: 10%; width: 31%; height: 17%; }
.hallway { top: 21%; left: 41%; width: 18%; height: 25%; }
.crew-quarters { top: 25%; left: 59%; width: 31%; height: 17%; }
.rooms-left { top: 45%; left: 10%; width: 31%; height: 18%; }
.grand-staircase { top: 45%; left: 39%; width: 22%; height: 20%; }
.rooms-right { top: 45%; left: 59%; width: 31%; height: 18%; }
.lounge { top: 67%; left: 26%; width: 48%; height: 16%; }
.balcony-deck { top: 86%; left: 28%; width: 44%; height: 12%; }
.left-lifeboat { top: 81%; left: 0%; width: 18%; height: 17%; }
.right-lifeboat { top: 81%; left: 82%; width: 18%; height: 17%; }

.rope-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.rope {
  position: absolute;
  width: clamp(24px, 3.6vw, 34px);
  height: clamp(24px, 3.6vw, 34px);
  transform: translate(-50%, -50%);
  border: 4px solid #b87933;
  border-radius: 50%;
  box-shadow:
    0 0 10px rgba(255, 190, 80, 0.8),
    0 8px 8px rgba(0, 0, 0, 0.9);
  animation: ropeFloat 1.4s infinite alternate;
}

.rope::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 3px solid #d6a052;
  border-radius: 50%;
}

.rope::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 4px;
  height: 38px;
  background: #d6a052;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 4px;
}

.token {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
}

.player-token {
  width: clamp(42px, 6vw, 68px);
  height: clamp(42px, 6vw, 68px);
  transform: translate(-50%, -78%);
  z-index: 8;
  filter:
    drop-shadow(0 0 10px rgba(255, 235, 150, 0.9))
    drop-shadow(0 10px 10px black);
  transition: top 0.45s ease, left 0.45s ease;
}

.killer-token {
  width: clamp(56px, 8vw, 86px);
  height: clamp(56px, 8vw, 86px);
  transform: translate(-50%, -82%);
  z-index: 9;
  opacity: 0;
  filter:
    drop-shadow(0 0 18px rgba(80, 180, 255, 0.85))
    drop-shadow(0 12px 12px black);
  transition:
    top 0.45s ease,
    left 0.45s ease,
    opacity 0.35s ease,
    filter 0.35s ease;
}

.visible-captain {
  opacity: 0.8;
  animation: captainPulse 1.1s infinite alternate;
}

.hidden-captain {
  opacity: 0;
}

.token.moving {
  animation: movePop 0.35s ease;
}

.flash-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 160, 255, 0.3);
  pointer-events: none;
  opacity: 0;
  z-index: 30;
}

.flash-overlay.active {
  animation: flash 0.35s ease;
}

@keyframes ropeFloat {
  from { transform: translate(-50%, -50%) translateY(0) scale(0.95); }
  to { transform: translate(-50%, -50%) translateY(-5px) scale(1.06); }
}

@keyframes captainPulse {
  from {
    opacity: 0.28;
    filter:
      blur(5px)
      drop-shadow(0 0 8px rgba(80, 180, 255, 0.5));
  }

  to {
    opacity: 0.85;
    filter:
      blur(0)
      drop-shadow(0 0 22px rgba(80, 180, 255, 0.95));
  }
}

@keyframes movePop {
  0% { scale: 1; }
  50% { scale: 1.1; }
  100% { scale: 1; }
}

@keyframes flash {
  0%, 100% { opacity: 0; }
  45% { opacity: 1; }
}

@keyframes timerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

@media (max-width: 700px) {
  .app {
    padding: 6px;
  }

  .hud-grid {
    grid-template-columns: repeat(2, 1fr);
    font-size: 0.82rem;
  }

  .panel {
    padding: 8px;
  }

  .map-board {
    width: min(100%, 430px);
  }
}