:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #111827, #0b1220);
  color: #f9fafb;
}

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.screen {
  display: none;
  background: rgba(17, 24, 39, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1.25rem;
  margin-top: 1rem;
}

.screen.active {
  display: block;
}

h1, h2 {
  margin-top: 0;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  margin-top: 0.35rem;
  background: #111827;
  color: #f9fafb;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 0.85rem;
  font-size: 1rem;
}

button {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.95rem;
  font-size: 1rem;
  margin-top: 0.5rem;
  cursor: pointer;
}

.room-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.room-code {
  margin: 0;
  color: #cbd5e1;
}

.room-code strong {
  margin-left: 0.35rem;
  color: #f9fafb;
  font-size: 1.35rem;
  letter-spacing: 0.15em;
}

.invite-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  margin: 0;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(147, 197, 253, 0.45);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.15);
  color: #bfdbfe;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease;
}

.invite-btn:hover {
  background: rgba(37, 99, 235, 0.3);
}

.invite-btn:active {
  transform: scale(0.96);
}

.invite-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.invite-btn[hidden] {
  display: none;
}

.invite-btn svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#inviteStatus {
  margin: -0.5rem 0 0.75rem;
}

.primary-btn {
  background: #2563eb;
  color: #fff;
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.secondary-btn {
  background: #374151;
  color: #fff;
}

.link-btn {
  background: transparent;
  color: #93c5fd;
}

.player-slots {
  list-style: none;
  padding: 0;
  margin: 0;
}

.player-slots li {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  margin: 0.5rem 0;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.status-connected {
  color: #86efac;
}

.status-disconnected {
  color: #fca5a5;
}

.status-empty {
  color: #9ca3af;
}

.hint-text {
  color: #cbd5e1;
  margin-bottom: 0;
  line-height: 1.55;
}

.outcome-recap {
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid rgba(147, 197, 253, 0.5);
  background: rgba(147, 197, 253, 0.08);
  border-radius: 6px;
}

.outcome-recap .hint-text {
  margin: 0;
  font-style: italic;
}

/* How everyone voted: one line until opened, so it never pushes the scene down. */
.vote-details {
  margin-top: 0.45rem;
}

.vote-details summary {
  cursor: pointer;
  color: #93c5fd;
  font-size: 0.9rem;
  font-weight: 600;
}

.vote-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.vote-list .vote-reason {
  color: #cbd5e1;
  font-style: italic;
}

.reason-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.reason-row p {
  width: 100%;
  margin: 0 0 0.1rem;
  color: #cbd5e1;
  font-size: 0.9rem;
}

.reason-chip {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.8rem;
  border: 1px solid rgba(147, 197, 253, 0.45);
  border-radius: 999px;
  background: transparent;
  color: #bfdbfe;
  font-size: 0.9rem;
}

.reason-chip[aria-pressed="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.error-banner {
  min-height: 1.25rem;
  margin: 1rem 0 0;
  color: #fda4af;
  font-weight: 600;
}

.eyebrow {
  color: #93c5fd;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h3 {
  margin: 1.5rem 0 0.5rem;
}

.accordion {
  margin-top: 0.75rem;
  border: 1px solid rgba(147, 197, 253, 0.18);
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.7);
  overflow: hidden;
}

.accordion summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  background: rgba(37, 99, 235, 0.14);
  transition: background 0.15s ease;
}

.accordion summary:hover {
  background: rgba(37, 99, 235, 0.22);
}

.accordion[open] summary {
  border-bottom: 1px solid rgba(147, 197, 253, 0.18);
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion summary::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  margin: 0 0.25rem 0.2rem 0;
  border-right: 2px solid #93c5fd;
  border-bottom: 2px solid #93c5fd;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.accordion[open] summary::after {
  margin-bottom: -0.2rem;
  transform: rotate(-135deg);
}

.accordion summary:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: -2px;
}

.accordion > ul {
  margin: 0;
  padding: 0.85rem 1rem 1rem;
}

.resource-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.resource-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.player-connected {
  border-left: 3px solid #86efac;
}

.player-disconnected {
  border-left: 3px solid #fca5a5;
}

.event-panel,
.event-result {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid rgba(147, 197, 253, 0.3);
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.08);
}

.result-epilogue {
  white-space: pre-line;
  line-height: 1.6;
}

.result-verdict {
  margin: 1rem 0 0.5rem;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid #93c5fd;
  background: rgba(147, 197, 253, 0.08);
  border-radius: 0 8px 8px 0;
  font-weight: 600;
}

.result-notes {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.result-recap-panel {
  margin-top: 1rem;
}

.result-recap {
  margin: 0;
  padding: 0.85rem 1rem 1rem 2.2rem;
  display: grid;
  gap: 0.6rem;
}

.result-recap li {
  line-height: 1.4;
}

.recap-scene,
.recap-tie {
  display: block;
  color: #93c5fd;
  font-size: 0.85rem;
}

.recap-tie {
  color: #cbd5e1;
  font-style: italic;
}

/* Start screen: pick an adventure (name between arrows), then its picture. */
.adventure-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: -0.35rem 0 0.9rem;
}

.adventure-name {
  flex: 1;
  margin: 0;
  text-align: center;
  color: #93c5fd;
  font-size: 1.15rem;
  font-weight: 600;
}

.adventure-step {
  width: 2.4rem;
  height: 2.4rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(147, 197, 253, 0.45);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.15);
  color: #bfdbfe;
  font-size: 1.4rem;
  line-height: 1;
}

.adventure-step:hover {
  background: rgba(37, 99, 235, 0.3);
}

.home-art[hidden] {
  display: none;
}

.lobby-adventure {
  margin: -0.4rem 0 0.9rem;
  color: #93c5fd;
  font-weight: 600;
}

/* The Haunted House picture: every few seconds the lights go out and the red
   emergency lights blink on, the way the story begins. */
.haunt-lights {
  animation: haunt-blackout 7s step-end infinite;
}

.haunt-emergency {
  opacity: 0;
  animation: haunt-emergency 7s step-end infinite;
}

.haunt-eyes {
  animation: haunt-eyes 5s step-end infinite;
}

@keyframes haunt-eyes {
  0% { opacity: 0.9; }
  46% { opacity: 0; }
  50% { opacity: 0.9; }
}

@keyframes haunt-blackout {
  0% { opacity: 1; }
  78% { opacity: 0.06; }
  96% { opacity: 1; }
}

@keyframes haunt-emergency {
  0% { opacity: 0; }
  82% { opacity: 1; }
  96% { opacity: 0; }
}

.home-art {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 1.1rem;
  border-radius: 12px;
}

.home-hazard {
  animation: home-blink 1.2s steps(1, end) infinite;
}

.home-beacon {
  animation: home-pulse 2.4s ease-in-out infinite;
}

.home-ripple {
  transform-box: fill-box;
  transform-origin: center;
  animation: home-ripple 2.4s ease-out infinite;
}

@keyframes home-ripple {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.6); opacity: 0; }
}

@keyframes home-blink {
  50% { opacity: 0.12; }
}

@keyframes home-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .home-hazard,
  .home-beacon,
  .home-ripple,
  .haunt-lights,
  .haunt-emergency,
  .haunt-eyes {
    animation: none;
  }
}

.group-banner {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border-left: 3px solid #86efac;
  background: rgba(134, 239, 172, 0.08);
  line-height: 1.5;
}

.away-panel {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08);
}

.away-panel .eyebrow {
  color: #fcd34d;
}

.event-panel h3,
.event-result h3 {
  margin-top: 0.35rem;
}

#eventBody,
#discoveryText,
#resultSummary {
  white-space: pre-line;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.event-choices {
  display: grid;
  gap: 0.6rem;
}

.event-choice {
  display: grid;
  gap: 0.25rem;
  text-align: left;
  margin-top: 0;
  background: #1f2937;
  color: #f9fafb;
  border: 1px solid #475569;
}

.event-choice span {
  color: #cbd5e1;
  font-size: 0.9rem;
}
