/* ==========================================================================
   Reverse Voice Game - Design System & Custom Styles
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-dark: #0f172a;
  --card-bg: #1e293b;
  --card-bg-hover: #334155;
  --card-border: #334155;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --secondary: #ec4899;
  --secondary-hover: #db2777;
  --success: #10b981;
  --success-hover: #059669;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-glow-primary: 0 0 20px rgba(99, 102, 241, 0.4);
  --shadow-glow-secondary: 0 0 20px rgba(236, 72, 153, 0.4);
  --shadow-glow-danger: 0 0 20px rgba(239, 68, 68, 0.4);
}

/* Reset & Mobile Viewport Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Layout Container */
.app-container {
  width: 100%;
  max-width: 480px;
  padding: 12px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header & Hero Banner */
.main-header {
  width: 100%;
  text-align: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--card-border);
}

.hero-banner-wrapper {
  position: relative;
  width: 100%;
  height: 160px;
  overflow: hidden;
}

.hero-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--card-bg) 10%, transparent 90%);
}

.header-content {
  padding: 12px 16px 20px;
  position: relative;
  margin-top: -30px;
}

.header-title {
  font-size: 1.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8 0%, #f472b6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.header-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Ad Container Slot */
.ad-container {
  width: 100%;
  min-height: 80px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 4px 0;
}

/* Game Flow Cards */
.card-flow-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.step-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.step-card.disabled {
  opacity: 0.38;
  pointer-events: none;
  filter: grayscale(0.4);
}

.step-card.active {
  opacity: 1;
  pointer-events: auto;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow-primary);
}

.card-image-wrapper {
  width: 100%;
  height: 140px;
  position: relative;
  overflow: hidden;
  background: #090d16;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Audio Visualizer & Waveform Canvas */
.visualizer-container {
  width: 100%;
  height: 60px;
  background: #090d16;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.visualizer-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.audio-status-text {
  position: absolute;
  font-size: 0.8rem;
  color: var(--text-dim);
  pointer-events: none;
}

/* Touch Friendly Buttons (min 56px height) */
.btn {
  width: 100%;
  min-height: 56px;
  height: 56px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.btn-primary {
  background-color: var(--primary);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--secondary);
}
.btn-secondary:hover {
  background-color: var(--secondary-hover);
}

.btn-success {
  background-color: var(--success);
}
.btn-success:hover {
  background-color: var(--success-hover);
}

.btn-danger {
  background-color: var(--danger);
}
.btn-danger:hover {
  background-color: var(--danger-hover);
}

.btn-recording {
  background-color: var(--danger);
  animation: pulse-danger 1.5s infinite;
  box-shadow: var(--shadow-glow-danger);
}

@keyframes pulse-danger {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Audio Player Widget */
.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.6);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

.audio-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* Result Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-backdrop.show .modal-card {
  transform: scale(1);
}

.modal-img-wrapper {
  width: 100%;
  height: 180px;
  overflow: hidden;
}

.modal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-body {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--success);
}

.modal-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Score Display in Result Modal */
.score-display-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.score-badge {
  background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 4px 18px;
  border-radius: 20px;
  letter-spacing: 1px;
  box-shadow: var(--shadow-glow-secondary);
}

.score-number-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.score-number {
  font-size: 3.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #10b981 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.score-unit {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* SEO & AdSense Informational Sections */
.info-sections-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 10px;
}

.info-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}

.info-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.word-category {
  margin-top: 10px;
}

.category-header {
  font-size: 0.95rem;
  font-weight: 700;
  color: #818cf8;
  margin-bottom: 8px;
}

.word-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.word-tag {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 12px;
}

.faq-item {
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 10px;
}
.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.faq-answer {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 20px 0 30px;
}

/* Confetti Overlay */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}
