/* Help the President Find His Dick — v0.1.0 */
:root {
  --blue: #1a4f9c;
  --blue-deep: #0d2a55;
  --red: #c62828;
  --red-hot: #ff1744;
  --cream: #fff6e0;
  --cream-dark: #f0e0b8;
  --gold: #f5c542;
  --gold-dark: #c9920a;
  --algae: #3d9e4a;
  --algae-bright: #7cff6b;
  --ink: #1a1420;
  --outline: #120c18;
  --panel: rgba(255, 246, 224, 0.96);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --ui: clamp(14px, 3.6vw, 18px);
  --title: clamp(1.35rem, 6vw, 2.6rem);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: var(--blue-deep);
  color: var(--ink);
  font-family: "Trebuchet MS", "Comic Sans MS", "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, a, input { font: inherit; }

.app {
  position: fixed;
  inset: 0;
  padding:
    calc(0.5rem + var(--safe-top))
    calc(0.5rem + var(--safe-right))
    calc(1.6rem + var(--safe-bottom))
    calc(0.5rem + var(--safe-left));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.version {
  position: fixed;
  right: calc(0.45rem + var(--safe-right));
  bottom: calc(0.25rem + var(--safe-bottom));
  z-index: 1000;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: rgba(255, 246, 224, 0.75);
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.site-return {
  position: fixed;
  left: calc(0.5rem + var(--safe-left));
  top: calc(0.35rem + var(--safe-top));
  z-index: 1001;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff6e0;
  text-decoration: none;
  background: rgba(13, 42, 85, 0.88);
  border: 2px solid #120c18;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  box-shadow: 0 2px 0 #120c18;
}
.site-return:hover,
.site-return:focus-visible {
  background: #f5c542;
  color: #1a1420;
  outline: 2px solid #1a4f9c;
  outline-offset: 2px;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  border: 4px solid var(--outline);
  border-radius: 14px;
  overflow: hidden;
  background: var(--cream);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
}

.screen-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* —— Buttons —— */
.btn {
  appearance: none;
  border: 3px solid var(--outline);
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--outline);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:hover, .btn:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  transform: translateY(-1px);
}

.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.btn-primary { background: var(--red); color: #fff; }
.btn-secondary { background: var(--cream); }
.btn-ghost {
  background: rgba(255, 246, 224, 0.9);
  padding: 0.45rem 0.7rem;
  font-size: 0.9em;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 3px solid var(--outline);
  background: var(--cream);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--outline);
  display: grid;
  place-items: center;
}
.icon-btn[aria-pressed="true"] { background: var(--gold); }
.icon-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* —— Menu —— */
.menu {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(245, 197, 66, 0.35), transparent 45%),
    linear-gradient(180deg, #5aa0e8 0%, #2f6bb8 42%, #3d9e4a 42%, #2a7a36 100%);
  color: var(--cream);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  gap: 0.75rem;
}

.menu-title {
  margin: 0;
  font-size: var(--title);
  line-height: 1.05;
  color: #fff;
  text-shadow:
    3px 3px 0 var(--outline),
    -1px 0 0 var(--red),
    1px 0 0 var(--blue);
  max-width: 18ch;
}

.menu-sub {
  margin: 0;
  font-size: clamp(0.95rem, 3.2vw, 1.15rem);
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
}

.menu-art {
  width: min(92%, 420px);
  height: clamp(140px, 28vh, 220px);
  position: relative;
  margin: 0.35rem auto;
}

.president-bust, .pool-art {
  position: absolute;
  border: 3px solid var(--outline);
}

.president-bust {
  left: 8%;
  bottom: 8%;
  width: 42%;
  height: 78%;
  background: linear-gradient(180deg, #f7d7b8, #e8b98f);
  border-radius: 40% 40% 18% 18%;
  z-index: 2;
}

.president-bust::before {
  content: "";
  position: absolute;
  left: 12%;
  top: 28%;
  width: 22%;
  height: 12%;
  background: var(--ink);
  border-radius: 50%;
  box-shadow: 52px 0 0 var(--ink);
}

.president-bust::after {
  content: "";
  position: absolute;
  left: 28%;
  top: 52%;
  width: 44%;
  height: 10%;
  border: 3px solid var(--ink);
  border-color: transparent transparent var(--ink);
  border-radius: 50%;
}

.pres-hair {
  position: absolute;
  left: 8%;
  top: -6%;
  right: 8%;
  height: 28%;
  background: #f2f2f2;
  border: 3px solid var(--outline);
  border-radius: 50% 50% 20% 20%;
}

.pres-suit {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: -8%;
  height: 38%;
  background: var(--blue);
  border: 3px solid var(--outline);
  border-radius: 12px;
  z-index: -1;
}

.pres-tie {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 14px;
  height: 34px;
  margin-left: -7px;
  background: var(--red);
  border: 2px solid var(--outline);
  clip-path: polygon(50% 0, 100% 20%, 70% 100%, 30% 100%, 0 20%);
}

.pool-art {
  right: 4%;
  bottom: 0;
  width: 58%;
  height: 55%;
  background: linear-gradient(180deg, #6ec8ff, #3d9e4a 55%, #256b30);
  border-radius: 50% 50% 18% 18%;
  overflow: hidden;
}

.bubble {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  animation: rise 3.2s linear infinite;
  opacity: 0.85;
}
@keyframes rise {
  from { transform: translateY(40px); opacity: 0; }
  20% { opacity: 0.9; }
  to { transform: translateY(-70px); opacity: 0; }
}

.menu-tools {
  position: absolute;
  top: calc(0.55rem + var(--safe-top));
  right: calc(0.55rem + var(--safe-right));
  display: flex;
  gap: 0.4rem;
  z-index: 5;
}

/* —— HUD —— */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem;
  background: linear-gradient(180deg, var(--blue), var(--blue-deep));
  color: #fff;
  border-bottom: 4px solid var(--outline);
  z-index: 5;
}

.timer {
  justify-self: center;
  font-size: clamp(1.35rem, 5vw, 1.9rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.7rem;
  border: 3px solid var(--outline);
  border-radius: 10px;
  background: var(--cream);
  color: var(--ink);
  min-width: 5.2ch;
  text-align: center;
}
.timer.warn { background: var(--gold); }
.timer.danger { background: var(--red); color: #fff; }
.timer.pulse { animation: pulse 0.45s ease-in-out infinite alternate; }
@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.detector {
  justify-self: start;
  min-width: 0;
}
.detector-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  opacity: 0.9;
}
.detector-meter {
  display: flex;
  gap: 3px;
  margin-top: 2px;
}
.detector-seg {
  width: 14px;
  height: 10px;
  border: 2px solid var(--outline);
  background: #6b7280;
  border-radius: 3px;
}
.detector-seg.on:nth-child(1) { background: #9ca3af; }
.detector-seg.on:nth-child(2) { background: #fbbf24; }
.detector-seg.on:nth-child(3) { background: #f97316; }
.detector-seg.on:nth-child(4) { background: #ef4444; }
.detector-level {
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18ch;
}

.hud-actions {
  justify-self: end;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* —— Scene —— */
.scene-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.scene {
  position: absolute;
  inset: 0;
  background: var(--cream-dark);
}

.hotspot {
  position: absolute;
  border: 2px dashed transparent;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
.hotspot:hover, .hotspot:focus-visible, .hotspot.is-focus {
  border-color: rgba(26, 79, 156, 0.85);
  background: rgba(245, 197, 66, 0.22);
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.35);
}
.hotspot-emoji {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(1px 1px 0 #000);
}
.hotspot-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(255, 246, 224, 0.92);
  border: 2px solid var(--outline);
  border-radius: 6px;
  padding: 0.1rem 0.3rem;
  margin-top: 0.15rem;
  pointer-events: none;
}

.scene-caption {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 3;
  background: rgba(18, 12, 24, 0.78);
  color: #fff;
  border: 3px solid var(--outline);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font-size: 0.92rem;
  pointer-events: none;
}

/* Location backgrounds */
.loc-pool {
  background:
    linear-gradient(180deg, #87ceeb 0 48%, #3d9e4a 48% 100%);
}
.loc-pool .pool-surface {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 52%;
  bottom: 12%;
  border: 4px solid var(--outline);
  border-radius: 50% / 28%;
  background: linear-gradient(180deg, #5ec8ff, #3d9e4a 60%, #236b2d);
  overflow: hidden;
}

.loc-lawn {
  background:
    linear-gradient(180deg, #8ec8ff 0 36%, #4caf50 36% 100%);
}
.loc-lawn .mansion {
  position: absolute;
  left: 50%;
  top: 6%;
  width: min(70%, 280px);
  height: 28%;
  transform: translateX(-50%);
  background: #fffaf0;
  border: 4px solid var(--outline);
  border-radius: 8px 8px 0 0;
}
.loc-lawn .mansion::before {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  top: -28%;
  height: 40%;
  background: var(--red);
  border: 4px solid var(--outline);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.loc-briefing {
  background: linear-gradient(180deg, #dfe9f5, #b8c7d9);
}
.loc-briefing .podium {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 26%;
  height: 28%;
  transform: translateX(-50%);
  background: var(--blue);
  border: 4px solid var(--outline);
  border-radius: 8px 8px 4px 4px;
}

.loc-oval {
  background:
    radial-gradient(ellipse at 50% 70%, rgba(245, 197, 66, 0.25), transparent 55%),
    linear-gradient(180deg, #5a3d2b, #3b2418);
}
.loc-oval .carpet {
  position: absolute;
  inset: 18% 10% 8%;
  border: 4px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle, #b71c1c, #7f1010);
}

.loc-basement {
  background: #1b1520;
  color: #fff;
}
.loc-basement .floor {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, #2a2230 0 40px, #231c29 40px 80px),
    repeating-linear-gradient(0deg, #2a2230 0 40px, #231c29 40px 80px);
  opacity: 0.95;
}

/* —— Overlays —— */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(10, 16, 32, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.75rem;
}

.overlay.center { align-items: center; }

.dialog, .panel {
  width: min(100%, 560px);
  background: var(--panel);
  border: 4px solid var(--outline);
  border-radius: 14px;
  padding: 0.85rem 1rem 1rem;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35);
  max-height: min(78vh, 640px);
  overflow: auto;
}

.dialog-speaker {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--blue);
  text-transform: uppercase;
}

.dialog-text {
  margin: 0 0 0.85rem;
  font-size: clamp(1rem, 3.8vw, 1.2rem);
  line-height: 1.35;
}

.panel h2 {
  margin: 0 0 0.55rem;
  font-size: 1.25rem;
}

.inv-list, .map-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.inv-list li, .map-btn {
  border: 3px solid var(--outline);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  text-align: left;
}
.map-btn {
  width: 100%;
  cursor: pointer;
  font-weight: 800;
}
.map-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.map-btn.current { background: var(--gold); }
.map-btn:focus-visible { outline: 3px solid var(--blue); }

/* —— Puzzles —— */
.note-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.6rem 0;
}
.note-slots, .note-pieces {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 140px;
  border: 3px dashed var(--outline);
  border-radius: 10px;
  padding: 0.45rem;
  background: #fffdf6;
}
.note-piece, .note-slot {
  border: 3px solid var(--outline);
  border-radius: 8px;
  padding: 0.55rem;
  background: #fff8dc;
  min-height: 44px;
  font-weight: 700;
  cursor: grab;
  touch-action: none;
}
.note-slot {
  background: rgba(26, 79, 156, 0.08);
  cursor: default;
  min-height: 52px;
}
.note-slot.filled { background: #e8f5e9; cursor: grab; }
.note-piece:focus-visible, .note-slot:focus-visible {
  outline: 3px solid var(--blue);
}

.seal-puzzle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin: 0.6rem 0;
}
.seal-rings {
  position: relative;
  width: min(220px, 70vw);
  height: min(220px, 70vw);
}
.seal-ring {
  position: absolute;
  inset: 0;
  border: 6px solid var(--gold);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: rgba(255, 246, 224, 0.5);
}
.seal-ring.r2 { inset: 18%; border-color: var(--blue); }
.seal-ring.r3 { inset: 36%; border-color: var(--red); font-size: 1.9rem; }
.seal-controls {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* —— Stealth —— */
.stealth-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.player {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--outline);
  z-index: 4;
  transition: none;
}
.guard {
  position: absolute;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 4px;
  background: var(--blue);
  border: 2px solid #fff;
  z-index: 3;
}
.flashlight {
  position: absolute;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  border-left: 70px solid transparent;
  border-right: 70px solid transparent;
  border-bottom: 110px solid rgba(255, 241, 118, 0.28);
  margin-left: -70px;
  margin-top: -110px;
  z-index: 2;
  pointer-events: none;
}
.door-zone {
  position: absolute;
  border: 2px solid var(--gold);
  background: rgba(245, 197, 66, 0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.2rem;
  pointer-events: none;
}
.joystick {
  position: absolute;
  left: calc(0.7rem + var(--safe-left));
  bottom: calc(0.7rem + var(--safe-bottom));
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.35);
  z-index: 8;
  touch-action: none;
}
.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--outline);
  pointer-events: none;
}

/* —— End screens —— */
.end-screen {
  background: var(--cream);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  gap: 0.65rem;
}
.newspaper {
  width: min(100%, 480px);
  background: #f7f1df;
  border: 4px solid var(--outline);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
  padding: 0.85rem 1rem;
  text-align: left;
}
.newspaper .masthead {
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
}
.newspaper h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.2rem, 4.5vw, 1.7rem);
  line-height: 1.1;
}
.stats {
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 700;
}
.stats li { margin: 0.2rem 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(2.4rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 1100;
  background: rgba(18, 12, 24, 0.92);
  color: #fff;
  border: 3px solid var(--gold);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 800;
  max-width: min(92vw, 420px);
  text-align: center;
}

.how-list {
  text-align: left;
  margin: 0.5rem 0 1rem;
  padding-left: 1.15rem;
  line-height: 1.45;
}

.accuse-options {
  display: grid;
  gap: 0.45rem;
  margin: 0.7rem 0 1rem;
}

@media (max-width: 520px) {
  .hud {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "timer timer"
      "det actions";
  }
  .timer { grid-area: timer; }
  .detector { grid-area: det; }
  .hud-actions { grid-area: actions; }
  .detector-level { max-width: 14ch; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble, .timer.pulse { animation: none; }
}
