/* ==========================================================================
   TRAIN: Word Chain & Railroad Quest Stylesheet (Game 8)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Hub Screen Box 9 (Steam Train Card with Blinking-Sync Steam Exhaust)
   -------------------------------------------------------------------------- */
.steam-train-stage {
  width: 100px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.steam-train-stage:hover {
  transform: scale(1.12) translateY(-2px);
}

/* Synchronized Steam Exhaust Clouds on Hub Box 9 */
.steam-exhaust-puff {
  position: absolute;
  top: -12px;
  left: 26px;
  width: 24px;
  height: 24px;
  pointer-events: none;
  z-index: 10;
}

.steam-exhaust-puff .steam-cloud-blob {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.95) 0%, rgba(226, 232, 240, 0.8) 60%, rgba(203, 213, 225, 0.1) 100%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
  opacity: 0;
  transform: scale(0.2) translate(0, 0);
  transition: opacity 0.08s ease, transform 0.38s cubic-bezier(0.25, 1, 0.5, 1);
}

.steam-exhaust-puff .blob-1 { width: 16px; height: 16px; top: 8px; left: 0; }
.steam-exhaust-puff .blob-2 { width: 22px; height: 22px; top: 0; left: 6px; }
.steam-exhaust-puff .blob-3 { width: 14px; height: 14px; top: -6px; left: 14px; }

/* When BlinkManager triggers .is-puffing (synchronized with eye blinks) */
.steam-exhaust-puff.is-puffing .blob-1 {
  opacity: 0.95;
  transform: scale(1.2) translate(-4px, -12px);
}

.steam-exhaust-puff.is-puffing .blob-2 {
  opacity: 0.9;
  transform: scale(1.6) translate(6px, -20px);
}

.steam-exhaust-puff.is-puffing .blob-3 {
  opacity: 0.85;
  transform: scale(1.4) translate(14px, -26px);
}

/* --------------------------------------------------------------------------
   Train Game Workspace Layout
   -------------------------------------------------------------------------- */
#train-app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 15%, #0B192C 0%, #030816 100%);
  color: #FFFFFF;
}

.train-workspace-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
}

@media (max-width: 980px) {
  .train-workspace-main {
    grid-template-columns: 1fr;
  }
}

.train-arena {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --------------------------------------------------------------------------
   Top Voyage Progress Station Dock
   -------------------------------------------------------------------------- */
.train-station-dock {
  background: rgba(15, 23, 42, 0.85);
  border: 3px solid #1E3A8A;
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 4px 0 #172554;
}

.train-voyage-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chain-step-pill {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid #475569;
  color: #94A3B8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.25s ease;
}

.chain-step-pill.active {
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  border-color: #60A5FA;
  color: #FFFFFF;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.6);
  transform: scale(1.05);
}

.chain-connector {
  color: #64748B;
  font-weight: 900;
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Railroad Scenic Track Stage (Where Train rolls with Word Cargo)
   -------------------------------------------------------------------------- */
.railroad-track-stage {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 70%, #0F172A 100%);
  border: 3px solid #334155;
  border-radius: var(--radius-lg);
  padding: 20px 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  box-shadow: inset 0 4px 16px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  min-height: 220px;
}

/* Railroad Steel Tracks & Timber Ties */
.railroad-track-bed {
  position: relative;
  width: 100%;
  height: 28px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: #1E293B;
  border-top: 4px solid #94A3B8;
  border-bottom: 4px solid #64748B;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
}

.rail-tie {
  width: 8px;
  height: 100%;
  background: #451A03;
  border-left: 1px solid #78350F;
  border-right: 1px solid #291203;
}

/* Train & Cargo Consist */
.train-consist-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  position: relative;
  z-index: 5;
}

.train-locomotive-wrap {
  width: 140px;
  height: 85px;
  position: relative;
  flex-shrink: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.train-chug-forward {
  animation: trainPistonChug 0.75s ease-in-out;
}

@keyframes trainPistonChug {
  0% { transform: translateX(0); }
  35% { transform: translateX(18px) rotate(-1deg); }
  65% { transform: translateX(-6px) rotate(1deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* Primary Word Cargo Flatbed Wagon */
.cargo-wagon-box {
  flex: 1;
  background: rgba(15, 23, 42, 0.85);
  border: 3px dashed #38BDF8;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.cargo-wagon-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #38BDF8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
}

/* Floating / Bubbling Word Letters */
.train-word-bubbles-rack {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 64px;
}

.word-letter-bubble {
  width: 52px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  border: 3px solid #7DD3FC;
  box-shadow: 
    0 4px 0 #075985,
    0 8px 16px rgba(2, 132, 199, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 900;
  color: #FFFFFF;
  user-select: none;
  animation: wordBubbleBob 2.4s ease-in-out infinite alternate;
}

@keyframes wordBubbleBob {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.04); }
  100% { transform: translateY(2px) scale(0.98); }
}

/* Highlight Target Last Letter */
.word-letter-bubble.last-target-letter {
  background: radial-gradient(circle at 35% 35%, #F59E0B 0%, #D97706 70%, #B45309 100%);
  border-color: #FEF08A;
  box-shadow: 
    0 4px 0 #92400E,
    0 0 20px rgba(245, 158, 11, 0.9),
    inset 0 2px 4px rgba(255, 255, 255, 0.8);
  animation: targetBubblePulse 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) infinite alternate;
}

@keyframes targetBubblePulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.14) translateY(-8px); box-shadow: 0 6px 0 #92400E, 0 0 28px rgba(250, 204, 21, 1); }
}

.target-pointer-arrow {
  position: absolute;
  bottom: -18px;
  font-size: 12px;
  color: #FDE047;
  animation: bounceArrow 0.8s ease infinite alternate;
}

@keyframes bounceArrow {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* Steam Dissolve Effect when Old Word Disappears */
.word-steam-dissolve {
  animation: wordSteamPuff 0.65s ease-out forwards;
}

@keyframes wordSteamPuff {
  0% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0px); }
  50% { opacity: 0.6; transform: scale(1.3) translateY(-24px); filter: blur(4px); }
  100% { opacity: 0; transform: scale(1.6) translateY(-40px); filter: blur(10px); }
}

/* --------------------------------------------------------------------------
   User Staging Input Wagon & Keyboard Area
   -------------------------------------------------------------------------- */
.train-user-wagon {
  background: rgba(15, 23, 42, 0.9);
  border: 3px solid #10B981;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 4px 0 #065F46;
  position: relative;
}

.user-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-input-prompt {
  font-size: 0.95rem;
  font-weight: 800;
  color: #A7F3D0;
}

.target-letter-badge-large {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #F59E0B;
  color: #78350F;
  font-weight: 900;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  border: 2px solid #FEF08A;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.8);
  margin-left: 4px;
}

.train-user-input-slots {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 56px;
}

.user-input-slot {
  width: 48px;
  height: 52px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.7);
  border: 2px dashed #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 900;
  color: #FFFFFF;
  transition: all 0.15s ease;
}

.user-input-slot.filled {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  border: 2px solid #34D399;
  color: #FFFFFF;
  box-shadow: 0 4px 0 #064E3B, inset 0 2px 4px rgba(255, 255, 255, 0.5);
  animation: slotPopIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slotPopIn {
  0% { transform: scale(0.7); }
  100% { transform: scale(1); }
}

.user-input-slot.required-slot {
  border-color: #F59E0B;
  background: rgba(245, 158, 11, 0.15);
}

.slot-hint-char {
  color: rgba(253, 224, 71, 0.6);
  font-size: 1.4rem;
}

/* Action Control Buttons */
.train-actions-bar {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Tactile On-Screen Keyboard Sidebar
   -------------------------------------------------------------------------- */
.train-side-keyboard-panel {
  background: rgba(15, 23, 42, 0.95);
  border: 3px solid #0284C7;
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 4px 0 #0369A1;
}

.keyboard-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #38BDF8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.train-side-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.key-btn {
  min-width: 26px;
  height: 38px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 900;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #334155 0%, #1E293B 100%);
  border: 2px solid #475569;
  color: #FFFFFF;
  box-shadow: 0 3px 0 #0F172A;
  transition: transform 0.1s ease, background 0.1s ease;
  user-select: none;
  touch-action: manipulation;
}

.key-btn:hover {
  background: linear-gradient(180deg, #475569 0%, #334155 100%);
  border-color: #38BDF8;
  transform: translateY(-2px);
}

.key-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0F172A;
}

/* --------------------------------------------------------------------------
   Train Selection Modal (Old Smokey, Emerald Express, Golden Hauler)
   -------------------------------------------------------------------------- */
.train-card-box {
  background: rgba(15, 23, 42, 0.98);
  border: 4px solid #38BDF8;
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 800px;
  width: 92%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(56, 189, 248, 0.3);
  text-align: center;
}

.train-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
}

@media (max-width: 768px) {
  .train-grid {
    grid-template-columns: 1fr;
  }
}

.train-selection-card {
  background: rgba(30, 41, 59, 0.8);
  border: 3px solid #475569;
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.train-selection-card:hover {
  transform: translateY(-6px) scale(1.04);
  border-color: #FDE047;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(253, 224, 71, 0.5);
}

.train-selection-card .train-svg-preview {
  width: 130px;
  height: 75px;
}

.train-selection-card .name {
  font-size: 1.1rem;
  font-weight: 900;
  color: #FFFFFF;
}

.train-selection-card .tagline {
  font-size: 0.8rem;
  color: #94A3B8;
}

/* --------------------------------------------------------------------------
   Train Grand Terminal Victory Modal Summary
   -------------------------------------------------------------------------- */
.train-chain-summary-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid #059669;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: #6EE7B7;
  margin: 12px 0;
}

.chain-badge {
  background: #047857;
  color: #FFFFFF;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1.5px solid #34D399;
}
