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

body {
  background: #1a1a2e;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e0ddd5;
  width: 100vw;
  height: 100vh;
}

#canvas-container {
  position: fixed;
  inset: 0;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  cursor: default;
}

/* Hoverable door cursor */
body.door-hover #canvas-container canvas { cursor: pointer; }

/* ── HUD ──────────────────────────────────────────────────────────────────── */

#hud {
  position: fixed;
  top: 0.8rem;
  left: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.3s;
}

body.fpp-mode #hud { opacity: 0; pointer-events: none; }
body.fpp-mode #event-log { opacity: 0; pointer-events: none; }
body.fpp-mode #polly-hint { opacity: 0; }
body.fpp-mode #door-hint { display: none !important; }

#time-panel {
  background: rgba(10, 12, 25, 0.82);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.5rem;
  padding: 0.5rem 0.8rem;
  pointer-events: auto;
}

#day-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ab;
}

#time-label {
  font-size: 1.6rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: #e8e4da;
}

#people-status {
  background: rgba(10, 12, 25, 0.82);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 11rem;
  pointer-events: auto;
}

.person-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}

.person-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.person-name {
  flex: 1;
  color: #d0ccc5;
  font-weight: 500;
}

.person-name.clickable {
  cursor: pointer;
  transition: color 0.15s;
}
.person-name.clickable:hover { color: #88ccff; text-decoration: underline; }

.person-activity {
  font-size: 0.65rem;
  color: #778;
}

.person-stage {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
}

.person-stage.healthy          { background: rgba(60,180,80,0.2);   color: #6dd88a; }
.person-stage.infected.stage-0 { background: rgba(255,200,50,0.2);  color: #f0c840; }
.person-stage.infected.stage-1 { background: rgba(255,150,40,0.25); color: #f09040; }
.person-stage.infected.stage-2 { background: rgba(255,80,30,0.25);  color: #ff6030; }
.person-stage.infected.stage-3 { background: rgba(220,30,20,0.3);   color: #ff4030; }
.person-stage.infected.stage-4 {
  background: rgba(160,10,10,0.4);
  color: #ff3030;
  animation: pulse-red 1s ease-in-out infinite;
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

#speed-panel {
  background: rgba(10, 12, 25, 0.82);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.5rem;
  padding: 0.4rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  pointer-events: auto;
}

.panel-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #778;
  margin-right: 0.2rem;
}

.speed-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #aaa;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s;
}

.speed-btn:hover  { background: rgba(255,255,255,0.12); color: #ddd; }
.speed-btn.active { background: rgba(100,160,255,0.2); border-color: rgba(100,160,255,0.45); color: #8ab8ff; }

#pause-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #aaa;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: 0.3rem;
}
#pause-btn:hover  { background: rgba(255,255,255,0.12); color: #ddd; }
#pause-btn.paused { background: rgba(255,160,40,0.2); border-color: rgba(255,160,40,0.45); color: #ffb84a; }

#strain-panel {
  background: rgba(10, 12, 25, 0.82);
  border: 1px solid rgba(80,255,100,0.15);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  min-width: 11rem;
  pointer-events: none;
}

.strain-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #88dd99;
  margin-bottom: 0.25rem;
}

.strain-stats {
  display: flex;
  gap: 0.5rem;
  font-size: 0.65rem;
  color: #778;
}

.strain-stats span { white-space: nowrap; }
.strain-stats .tunnel-active { color: #cc8844; }

.strain-airborne {
  margin-left: 0.5rem;
  font-size: 0.6rem;
  font-weight: 700;
  color: #ffdd44;
  background: rgba(255,220,50,0.15);
  border-radius: 0.25rem;
  padding: 0.05rem 0.3rem;
  letter-spacing: 0.06em;
  animation: pulse-orange 1.2s ease-in-out infinite;
}

.polly-freaking {
  animation: pulse-red 0.6s ease-in-out infinite !important;
}

.person-trait {
  font-size: 0.6rem;
  color: #556;
  font-style: italic;
  flex-shrink: 0;
}

.hanta-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.28rem;
  border-radius: 0.22rem;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.hanta-badge.hanta-s0 { background: rgba(180,100,255,0.18); color: #cc88ff; }
.hanta-badge.hanta-s1 { background: rgba(160,60,255,0.25);  color: #bb66ff; }
.hanta-badge.hanta-s2 { background: rgba(130,20,230,0.32);  color: #aa44ee; animation: pulse-purple 1.2s ease-in-out infinite; }
.hanta-badge.hanta-s3 { background: rgba(100,0,200,0.45);   color: #9933dd; animation: pulse-purple 0.7s ease-in-out infinite; }

@keyframes pulse-purple {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.person-stage.hanta-carrier { background: rgba(180,100,255,0.15); color: #bb88ee; }

.cat-manic {
  font-size: 0.6rem;
  font-weight: 600;
  color: #998877;
}

.cat-manic.manic-frenzied { color: #ff8844; animation: pulse-orange 1.5s ease-in-out infinite; }
.cat-manic.manic-berserk  { color: #ff3322; animation: pulse-red 0.8s ease-in-out infinite; }

@keyframes pulse-orange {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* ── Event Log ────────────────────────────────────────────────────────────── */

#event-log {
  position: fixed;
  bottom: 0.8rem;
  right: 0.8rem;
  width: clamp(16rem, 22vw, 24rem);
  max-height: 40vh;
  background: rgba(10, 12, 25, 0.88);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  transition: opacity 0.3s;
}

#event-log-header {
  padding: 0.3rem 0.4rem;
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.log-tab {
  background: none;
  border: 1px solid transparent;
  color: #556;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.18rem 0.5rem;
  border-radius: 0.28rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.log-tab:hover { color: #8899bb; border-color: rgba(255,255,255,0.1); }
.log-tab.log-tab-active {
  background: rgba(100,160,255,0.1);
  border-color: rgba(100,160,255,0.2);
  color: #7aaadd;
}

#event-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.3rem 0;
}

#minds-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.3rem 0;
  display: none;
}
#minds-list::-webkit-scrollbar { width: 3px; }
#minds-list::-webkit-scrollbar-track { background: transparent; }
#minds-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.minds-entry {
  padding: 0.25rem 0.7rem;
  font-size: 0.71rem;
  line-height: 1.45;
  border-left: 2px solid rgba(100,160,255,0.2);
  animation: fadein 0.3s ease;
}
.minds-entry.minds-sev2 { border-left-color: rgba(255,150,60,0.45); }
.minds-entry.minds-sev3 { border-left-color: rgba(255,80,50,0.55); }

.minds-time {
  color: #445;
  font-size: 0.62rem;
  display: block;
  margin-bottom: 0.06rem;
}

.minds-actor { color: #7ab8dd; font-weight: 600; }
.minds-obs   { color: #988; font-style: italic; }

#event-list::-webkit-scrollbar { width: 3px; }
#event-list::-webkit-scrollbar-track { background: transparent; }
#event-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.event-item {
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  line-height: 1.45;
  border-left: 2px solid transparent;
  animation: fadein 0.3s ease;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.event-item.severity-1 { border-left-color: #f0c840; }
.event-item.severity-2 { border-left-color: #f08040; }
.event-item.severity-3 { border-left-color: #ff5030; }
.event-item.severity-4 { border-left-color: #cc1010; }

.event-time {
  color: #556;
  font-size: 0.65rem;
  display: block;
  margin-bottom: 0.1rem;
}

/* ── Door hint ────────────────────────────────────────────────────────────── */

#door-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 12, 25, 0.88);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 0.5rem;
  padding: 0.55rem 1.2rem;
  font-size: 0.8rem;
  color: #c8d8e8;
  pointer-events: none;
  z-index: 15;
  letter-spacing: 0.04em;
}

/* ── Polly hint ───────────────────────────────────────────────────────────── */

#polly-hint {
  position: fixed;
  bottom: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 12, 25, 0.75);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 2rem;
  padding: 0.35rem 1rem;
  font-size: 0.72rem;
  color: #778;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.3s;
}

.hint-parrot { color: #8dca8d; }

/* ── FPP Overlay ──────────────────────────────────────────────────────────── */

#fpp-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  display: none;
}

body.fpp-mode #fpp-overlay { display: block; }

#fpp-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.4rem;
  color: rgba(255,255,255,0.55);
  line-height: 1;
  user-select: none;
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
}

#fpp-controls-hint {
  position: absolute;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.06em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

#fpp-pov-label {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 12, 25, 0.85);
  border: 1px solid rgba(100,200,255,0.3);
  border-radius: 0.4rem;
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #88ccff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}
#fpp-pov-label.hidden { display: none; }

#fpp-exit-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(10, 12, 25, 0.8);
  border: 1px solid rgba(255,255,255,0.18);
  color: #aab8cc;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: 0.4rem;
  cursor: pointer;
  pointer-events: auto;
  letter-spacing: 0.04em;
  transition: all 0.15s;
}

#fpp-exit-btn:hover {
  background: rgba(30, 40, 70, 0.9);
  border-color: rgba(180,200,255,0.35);
  color: #ccd8ee;
}

#fpp-prompt {
  position: absolute;
  bottom: 7rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 12, 25, 0.88);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 0.5rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.78rem;
  color: #c8d0dc;
  max-width: 32rem;
  text-align: center;
  line-height: 1.5;
  pointer-events: auto;
}

#fpp-prompt.hidden { display: none; }

#fpp-speech {
  position: absolute;
  bottom: 11rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 38, 0.92);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 0.7rem;
  padding: 0.7rem 1.2rem;
  max-width: 28rem;
  text-align: center;
  animation: fadein 0.25s ease;
}

#fpp-speech.hidden { display: none; }

.speech-name {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #88aacc;
  margin-bottom: 0.3rem;
}

.speech-text {
  display: block;
  font-size: 0.88rem;
  color: #d8d4cc;
  font-style: italic;
  line-height: 1.5;
}

/* ── Polly dialog ─────────────────────────────────────────────────────────── */

#polly-dialog {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  z-index: 100;
  backdrop-filter: blur(4px);
}

#polly-dialog.hidden { display: none; }

#polly-card {
  background: #141928;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0.75rem;
  width: clamp(18rem, 40vw, 36rem);
  max-width: 90vw;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

#polly-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background: rgba(40, 80, 40, 0.3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

#polly-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #8dca8d;
}

#polly-close {
  background: none;
  border: none;
  color: #668;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  transition: color 0.15s;
}

#polly-close:hover { color: #aaa; }

#polly-body { padding: 1.2rem 1.3rem; }

#polly-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #ccc8be;
  font-style: italic;
}

/* ── Game Over ────────────────────────────────────────────────────────────── */

#game-over {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  backdrop-filter: blur(6px);
}

#game-over.hidden { display: none; }

#game-over-card {
  background: #0e1020;
  border: 1px solid rgba(200, 30, 30, 0.4);
  border-radius: 0.75rem;
  padding: 2.5rem 3rem;
  text-align: center;
  width: clamp(18rem, 40vw, 34rem);
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 40px rgba(200,30,30,0.15);
}

#game-over-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #cc3333;
  margin-bottom: 0.5rem;
}

#game-over-subtitle {
  font-size: 0.9rem;
  color: #778;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

#game-over-stats {
  background: rgba(255,255,255,0.04);
  border-radius: 0.5rem;
  padding: 0.8rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
  color: #aaa;
  line-height: 1.8;
  text-align: left;
}

#restart-btn {
  background: rgba(200, 30, 30, 0.2);
  border: 1px solid rgba(200, 30, 30, 0.5);
  color: #ee5555;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  border-radius: 0.4rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

#restart-btn:hover { background: rgba(200, 30, 30, 0.35); color: #ff7777; }
