:root {
  --game-accent: linear-gradient(135deg, #0284c7, #06b6d4);
  --game-accent-dim: rgba(2, 132, 199, 0.15);
  --game-accent-contrast: #ffffff;
  --river-surface: #e0f2fe;
  --river-border: #38bdf8;
  --chip-bg: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%);
  --chip-text: #0369a1;
  --chip-border: #bae6fd;
  --chip-selected-bg: #bae6fd;
}

/* River Rail Container */
.flow-rail-container {
  background: var(--game-accent-dim);
  border: 2px solid var(--river-border);
  border-radius: 20px;
  padding: 1.25rem;
  margin: 1.25rem 0;
  position: relative;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.12);
}

.flow-rail-title {
  font-family: var(--font-sans, 'Nunito', sans-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: #0369a1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Visible Horizontal River Rail Track */
.flow-rail-track {
  background: var(--game-accent);
  min-height: 76px;
  border-radius: 38px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.22), 0 4px 14px rgba(6, 182, 212, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Word Tiles: Rounded "Current" Chips */
.current-chip {
  background: var(--chip-bg);
  color: var(--chip-text);
  font-family: var(--font-sans, 'Nunito', sans-serif);
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.65rem 1.2rem;
  border-radius: 26px;
  border: 2px solid var(--chip-border);
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: grab;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  transition: transform 350ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 250ms ease, background 250ms ease, border-color 250ms ease;
  will-change: transform;
}

.current-chip:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 14px rgba(2, 132, 199, 0.3);
  border-color: #38bdf8;
}

.current-chip:active,
.current-chip.dragging {
  cursor: grabbing;
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.4);
  z-index: 10;
  border-color: #0284c7;
}

/* Selected Chip state for Tap-to-Insert */
.current-chip.selected-chip {
  background: #e0f2fe;
  color: #0284c7;
  border-color: #0284c7;
  transform: translateY(-5px) scale(1.08);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.35), 0 8px 18px rgba(2, 132, 199, 0.3);
  animation: selectedFloat 1.2s ease-in-out infinite alternate;
}

@keyframes selectedFloat {
  0% { transform: translateY(-5px) scale(1.08); }
  100% { transform: translateY(-8px) scale(1.1); }
}

/* Gap Target Slots for Phone Context Tap-to-Insert */
.gap-target {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 48px;
  padding: 0 4px;
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 250ms ease;
  position: relative;
  z-index: 1;
}

.gap-target:hover,
.gap-target:focus,
.gap-target.active-gap {
  background: rgba(255, 255, 255, 0.4);
  border-color: #ffffff;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}

.gap-target-icon {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.9;
}

/* Rail Settling with .motion-slide-chain */
.flow-rail-track.settling .current-chip {
  animation: motionSlideChain 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--tile-index, 0) * 70ms);
}

/* Incorrect Submission "Eddy" Swirl Animation (Jitter/Swirl in place, no flat red error state) */
@keyframes eddySwirl {
  0% { transform: scale(1) rotate(0deg) translateY(0); }
  20% { transform: scale(1.05) rotate(-5deg) translateY(-4px); }
  40% { transform: scale(0.95) rotate(5deg) translateY(4px); }
  60% { transform: scale(1.03) rotate(-3deg) translateY(-2px); }
  80% { transform: scale(0.98) rotate(2deg) translateY(1px); }
  100% { transform: scale(1) rotate(0deg) translateY(0); }
}

.flow-rail-track.eddy-active .current-chip {
  animation: eddySwirl 480ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
  animation-delay: calc(var(--tile-index, 0) * 40ms);
}

/* Phone Context Overrides */
[data-context="phone"] .flow-rail-container {
  padding: 0.85rem;
  margin: 0.85rem 0;
}

[data-context="phone"] .flow-rail-track {
  padding: 10px 12px;
  gap: 6px;
  min-height: 68px;
}

[data-context="phone"] .current-chip {
  font-size: 0.98rem;
  padding: 0.55rem 0.95rem;
  border-radius: 20px;
  cursor: pointer; /* Drag is replaced with tap-to-select + gap insert on phone */
}

[data-context="phone"] .gap-target {
  min-width: 24px;
  height: 42px;
}

/* Instructions badge */
.flow-instructions-badge {
  display: inline-block;
  font-size: 0.82rem;
  color: #0369a1;
  background: #e0f2fe;
  padding: 0.3rem 0.75rem;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  font-weight: 600;
}
