/* styles.css — Pass the Mic */

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

:root {
  --bg: #0d0e12;
  --bg-soft: #171922;
  --surface: #1f222e;
  --border: #2c2f3d;
  --text: #f2f3f7;
  --muted: #8b8fa3;
  --accent: #FFD23F;
}

html, body {
  height: 100%;
  min-height: 100dvh; /* fill the visible viewport even as mobile browser chrome resizes */
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ---------------- Screens ---------------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ---------------- Setup ---------------- */
.setup-card {
  width: min(680px, 92vw);
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(22px, 4vw, 44px);
  animation: cardIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.setup-title {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.setup-subtitle {
  color: var(--muted);
  margin: 6px 0 28px;
  font-size: 15px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stepper {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.stepper input {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  padding: 12px 4px;
  width: 100%;
}
.stepper input:focus { outline: none; }
.step-btn {
  width: 46px;
  align-self: stretch;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  transition: background 0.15s;
}
.step-btn:hover { background: rgba(255,255,255,0.07); }

select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 13px 12px;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }

.segmented {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.seg {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 9px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg.active { background: var(--accent); color: #14151b; }

.toggle-field {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.toggle {
  width: 54px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle .knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.toggle.on { background: var(--accent); }
.toggle.on .knob { transform: translateX(24px); background: #14151b; }

#player-names {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.name-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
}
.color-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
}
.color-dot:hover { transform: scale(1.12); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }
.color-dot:active { transform: scale(0.96); }
.name-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 8px 0;
}
.name-row input:focus { outline: none; }

.start-btn {
  width: 100%;
  margin-top: 26px;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #14151b;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}
.start-btn:hover { filter: brightness(1.07); }
.start-btn:active { transform: scale(0.99); }

/* ---------------- Game ---------------- */
#game-screen {
  background: var(--bg);
  transition: background-color 0.45s ease; /* smooth fade as the mic passes */
}
.hidden { display: none !important; }

.reveal {
  text-align: center;
  padding: 5vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2vh;
  animation: fadeIn 0.4s ease;
}
.reveal-title {
  font-size: clamp(16px, 2.4vw, 26px);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  animation: fadeIn 0.5s ease both;
}
.reveal-prompt {
  font-size: clamp(30px, 7vw, 84px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  max-width: 16ch;
  text-transform: uppercase; /* prompts are stored in natural case */
  animation: promptIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.reveal-cue {
  font-size: clamp(28px, 5vw, 56px);
  font-weight: 800;
  color: var(--accent);
  min-height: 1.2em;
}
.reveal-cue.pop { animation: pop 0.4s ease; }

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
}
.active-name {
  font-size: clamp(48px, 14vw, 220px);
  font-weight: 900;
  letter-spacing: -0.03em;
  text-align: center;
  padding: 0 4vw;
  color: var(--ink, #fff); /* --ink is set to a readable contrast vs the player bg */
}
.active-name.swap { animation: nameIn 0.45s cubic-bezier(0.22, 1, 0.36, 1); }

.round-end {
  display: flex;
  align-items: center;
  justify-content: center;
}
.reset-icon {
  width: clamp(64px, 12vw, 140px);
  height: clamp(64px, 12vw, 140px);
  color: var(--muted);
  animation: spin 1.2s ease;
}

.prompt-reminder {
  position: fixed;
  bottom: 28px; left: 32px;
  max-width: 40vw;
  font-size: clamp(13px, 1.6vw, 20px);
  font-weight: 600;
  color: var(--ink, var(--muted));
  opacity: 0.8;
}
.timer-display {
  position: fixed;
  bottom: 24px; right: 32px;
  font-size: clamp(22px, 3vw, 40px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink, var(--text));
}
.timer-display.low {
  color: #ff3b3b; /* two-class rule still wins over var(--ink) */
  animation: timerPulse 1s ease-in-out infinite;
}

.control-bar {
  position: fixed;
  top: 20px; right: 24px;
  display: flex;
  gap: 8px;
  opacity: 0.35;
  transition: opacity 0.2s;
}
.control-bar:hover { opacity: 1; }
.ctrl {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.ctrl:hover { background: rgba(255,255,255,0.08); }
.ctrl:active { transform: scale(0.94); }

/* ---------------- Animations ---------------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes promptIn {
  0% { transform: translateY(18px) scale(0.96); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes nameIn {
  0% { transform: scale(0.7) translateY(12px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes timerPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: 0.7; }
}

/* ---------------- Mobile ---------------- */
@media (max-width: 600px) {
  .field-grid { grid-template-columns: 1fr; gap: 14px; }
  .setup-subtitle { margin-bottom: 20px; }

  /* Difficulty: 4 tiers wrap to a 2x2 grid with comfortable tap targets. */
  .segmented { display: grid; grid-template-columns: 1fr 1fr; }
  .seg { padding: 12px 0; font-size: 15px; }

  /* Bigger, always-visible controls for touch. */
  .control-bar { top: auto; bottom: 14px; right: 14px; left: 14px; opacity: 0.92; justify-content: center; }
  .ctrl { padding: 12px 16px; font-size: 15px; }

  /* Keep the corners clear of the control bar / browser chrome. */
  .prompt-reminder { bottom: 70px; left: 16px; max-width: 60vw; }
  .timer-display { bottom: 66px; right: 16px; }

  .start-btn { padding: 18px; }
}

@media (max-width: 600px) and (orientation: landscape) {
  .control-bar { top: 10px; bottom: auto; left: auto; opacity: 0.6; }
  .prompt-reminder { bottom: 14px; }
  .timer-display { bottom: 12px; }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
