/* ==========================================================
   CONVERSATION ROULETTE — STYLES
   Mobile-first, clean, modern, minimalist.
   Palette & type based on the Rafa~ brandbook
   (Litoral Latino-Americano).
   ========================================================== */

:root {
  /* Rafa~ brand palette */
  --azul-caribe: #0B5D6B;
  --azul-noite: #0B2A30;
  --coral-vivo: #D94F4F;
  --coral-claro: #E85D5D;
  --mostarda: #F2A154;
  --areia: #F5B36B;
  --creme: #F7EFDD;

  --bg: var(--azul-caribe);
  --bg-soft: var(--azul-noite);
  --card: rgba(11, 42, 48, 0.55);
  --card-border: rgba(247, 239, 221, 0.16);
  --text: var(--creme);
  --text-dim: rgba(247, 239, 221, 0.68);
  --accent: var(--coral-vivo);
  --accent-2: var(--mostarda);
  --accent-soft: rgba(217, 79, 79, 0.18);
  --danger: var(--coral-claro);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  font-weight: 600;
  background: radial-gradient(circle at top, #0d6877 0%, var(--azul-caribe) 55%, var(--azul-noite) 100%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  touch-action: manipulation;
}

button {
  font-family: inherit;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 18px 40px;
  padding-top: max(0px, env(safe-area-inset-top));
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
}

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 10px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral-vivo);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-dim);
}

.stats {
  display: flex;
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.stat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--areia);
  font-variant-numeric: tabular-nums;
}

/* ---------- SCREENS ---------- */
.screens {
  flex: 1;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: flex;
}

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

/* ---------- HERO ---------- */
.hero {
  text-align: center;
  padding: 18px 0 26px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--creme);
}

.subtitle {
  margin-top: 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.tagline {
  margin-top: 10px;
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--mostarda);
  background: rgba(242, 161, 84, 0.14);
  padding: 7px 14px;
  border-radius: 999px;
  letter-spacing: 0.2px;
}

/* ---------- SETUP BLOCKS ---------- */
.setup-block {
  margin-bottom: 22px;
}

.setup-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
  font-weight: 700;
}

.chip-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.chip-group.wrap {
  grid-template-columns: repeat(2, 1fr);
}

.chip {
  appearance: none;
  border: 1.5px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  padding: 13px 8px;
  min-height: 46px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}

.chip:active {
  transform: scale(0.96);
}

.chip.selected {
  background: var(--coral-vivo);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(217, 79, 79, 0.35);
}

.link-btn {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--mostarda);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.6px;
  cursor: pointer;
  padding: 10px 12px;
  min-height: 40px;
}

.link-btn:active {
  opacity: 0.6;
}

.link-btn.active-all {
  color: var(--coral-vivo);
  text-decoration: underline;
}

/* ---------- SPIN BUTTON ---------- */
.btn-spin {
  margin-top: 8px;
  width: 100%;
  padding: 20px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--coral-vivo);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(217, 79, 79, 0.32);
  transition: transform 0.15s ease;
}

.btn-spin:active {
  transform: scale(0.98);
}

.btn-random {
  margin-top: 14px;
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
}

.btn-random:active {
  transform: scale(0.98);
  background: var(--card);
}

/* ---------- SPIN SCREEN ---------- */
.spin-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.spin-card {
  width: 100%;
  padding: 40px 24px;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  text-align: center;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--areia);
  box-shadow: var(--shadow);
}

/* ---------- QUESTION SCREEN ---------- */
.question-meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0 14px;
  flex-wrap: wrap;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--areia);
  text-transform: uppercase;
}

.question-card {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 30px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}

.question-text {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 20px;
}

.question-text.small {
  font-size: 18px;
  text-align: center;
  padding: 0 4px;
  margin: 14px 0 6px;
}

.question-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.icon-btn {
  border: 1.5px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 11px 18px;
  min-height: 44px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.subtle {
  color: var(--text-dim);
  background: transparent;
}

.hint-text {
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--mostarda);
  font-weight: 700;
  min-height: 18px;
}

/* ---------- TIME BLOCK ---------- */
.time-block {
  margin-top: 26px;
}

/* ---------- START BUTTON ---------- */
.btn-start {
  margin-top: 22px;
  width: 100%;
  padding: 19px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--coral-vivo);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(217, 79, 79, 0.32);
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.btn-start:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-start:not(:disabled):active {
  transform: scale(0.98);
}

.bottom-links {
  text-align: center;
  margin-top: 18px;
}

/* ---------- TIMER SCREEN ---------- */
.timer-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 42vh;
}

.timer-circle {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--coral-vivo);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 8px var(--accent-soft);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.timer-circle.finished {
  border-color: var(--danger);
  box-shadow: 0 0 0 8px rgba(232, 93, 93, 0.18);
}

.timer-display {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.timer-status {
  margin-top: 22px;
  font-size: 15px;
  font-weight: 700;
  color: var(--areia);
  letter-spacing: 0.3px;
}

.timer-status.finished {
  color: var(--danger);
}

.timer-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.btn-secondary {
  width: 100%;
  padding: 17px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  min-height: 52px;
}

.btn-secondary.primary {
  background: var(--coral-vivo);
  color: #fff;
}

.btn-secondary.outline {
  background: transparent;
  border: 1.5px solid var(--card-border);
  color: var(--text);
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* ---------- MIC / LISTENING INDICATOR ---------- */
.listening-indicator {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--areia);
  min-height: 18px;
}

.listening-indicator.on::before {
  content: "🎙️ ";
}

.mic-notice {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

.mic-notice button {
  margin-top: 10px;
  border: none;
  background: var(--coral-vivo);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- LIVE TRANSCRIPT ---------- */
.transcript-live-wrap {
  margin-top: 20px;
}

.transcript-live {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 70px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text);
  -webkit-overflow-scrolling: touch;
}

.transcript-live:empty::before {
  content: "Comece a falar e suas palavras vão aparecer aqui...";
  color: var(--text-dim);
}

/* ---------- FEEDBACK SCREEN ---------- */
.feedback-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 20px 0 4px;
}

.feedback-subtitle {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--mostarda);
  letter-spacing: 0.3px;
  margin-bottom: 18px;
}

.feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.feedback-stat {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.feedback-stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--areia);
  font-variant-numeric: tabular-nums;
}

.feedback-stat-label {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.feedback-card {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 14px;
}

.feedback-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
}

.repeated-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.repeated-word-chip {
  background: var(--accent-soft);
  color: var(--areia);
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
}

.feedback-tip {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.fluency-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text);
}

.transcript-full {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 12px;
  white-space: pre-wrap;
}

/* ---------- APP FOOTER ---------- */
.app-footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 18px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}

.app-footer p {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}

.app-footer a {
  color: var(--mostarda);
  text-decoration: none;
  font-weight: 700;
}

.app-footer a:hover,
.app-footer a:active {
  text-decoration: underline;
}

/* ---------- IN-APP BROWSER OVERLAY ---------- */
.inapp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(11, 42, 48, 0.92);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.inapp-card {
  width: 100%;
  max-width: 400px;
  background: var(--azul-caribe);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  max-height: 90vh;
  overflow-y: auto;
}

.inapp-icon {
  font-size: 34px;
  margin-bottom: 10px;
}

.inapp-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 10px;
  color: var(--creme);
}

.inapp-text {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.inapp-text strong {
  color: var(--mostarda);
}

.inapp-btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--coral-vivo);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(217, 79, 79, 0.32);
  min-height: 52px;
  line-height: 20px;
  box-sizing: border-box;
}

.inapp-btn-primary:active {
  transform: scale(0.98);
}

.inapp-note {
  margin-top: 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.inapp-manual {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  text-align: left;
}

.inapp-manual p {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
}

.inapp-manual p + p {
  margin-top: 6px;
}

.inapp-btn-secondary {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
}

.inapp-btn-secondary:active {
  background: var(--card);
  transform: scale(0.98);
}

#inappContinueBtn {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------- RESPONSIVE / MOBILE-FIRST TUNING ---------- */

/* Very small phones (SE, older Android, ~360px and below) */
@media (max-width: 359px) {
  .app {
    padding-left: 14px;
    padding-right: 14px;
  }
  .hero h1 {
    font-size: 22px;
  }
  .question-text {
    font-size: 19px;
  }
  .timer-circle {
    width: 180px;
    height: 180px;
  }
  .timer-display {
    font-size: 36px;
  }
  .chip {
    font-size: 12.5px;
    padding: 11px 6px;
  }
  .feedback-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 480px) {
  .hero h1 {
    font-size: 30px;
  }
  .question-text {
    font-size: 25px;
  }
}

@media (min-width: 640px) {
  .app {
    padding-left: 32px;
    padding-right: 32px;
  }
}

/* Short viewports (landscape phones) — keep timer usable without scrolling */
@media (max-height: 620px) {
  .timer-wrap {
    min-height: auto;
    padding: 10px 0;
  }
  .timer-circle {
    width: 160px;
    height: 160px;
  }
  .timer-display {
    font-size: 32px;
  }
}

