* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #f2f4f8; }

.ut-outer {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ut-container {
  width: 100%;
  max-width: 820px;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(0,0,0,0.15);
}

/* ---------- Header ---------- */
.ut-header {
  background: #1c4e9e;
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ut-instruction { font-size: 13px; font-weight: 600; max-width: 340px; }
.ut-instruction-short { display: none; }
.ut-header-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ut-progress, .ut-score, .ut-life { font-size: 13px; font-weight: 700; }
.ut-home-btn {
  background: #2ecc71; color: #fff; border: none; border-radius: 20px; padding: 6px 16px;
  font-size: 12px; font-weight: 700; cursor: pointer;
}

/* ---------- Scene ---------- */
.ut-scene {
  position: relative;
  min-height: 480px;
  background: linear-gradient(#bfe3fb 0%, #bfe3fb 30%, #8fd68a 30%, #6fc562 100%);
  padding-bottom: 10px;
}

.ut-loading, .ut-warning {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; gap: 14px; color: #3a3a3a;
}
.ut-spinner {
  width: 36px; height: 36px; border: 4px solid #cfe8ff; border-top-color: #1c4e9e;
  border-radius: 50%; animation: ut-spin 0.8s linear infinite;
}
@keyframes ut-spin { to { transform: rotate(360deg); } }
.ut-warning-icon { font-size: 40px; }

/* ---------- Sky decoration ---------- */
.ut-sky { position: relative; height: 90px; }
.ut-cloud { position: absolute; font-size: 26px; opacity: 0.9; }
.ut-cloud-1 { top: 8px; left: 8%; }
.ut-cloud-2 { top: 20px; right: 12%; }
.ut-tree { position: absolute; bottom: 0; font-size: 34px; }
.ut-tree-1 { left: 4%; }
.ut-tree-2 { right: 6%; }
.ut-station { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); font-size: 38px; }

/* ---------- Train ---------- */
.ut-track-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px 18px;
  flex-wrap: wrap;
}
.ut-engine { font-size: 46px; position: relative; }
.ut-smoke { position: absolute; top: -14px; left: 6px; font-size: 16px; opacity: 0.8; animation: ut-puff 2s ease-in-out infinite; }
@keyframes ut-puff {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(-6px); opacity: 1; }
}

.ut-wagons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ut-wagon {
  width: 62px; height: 62px;
  background: #fff;
  border: 3px dashed #4a6fa5;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #1c4e9e;
  cursor: default;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ut-wagon.filled { border-style: solid; border-color: #2ecc71; background: #f4fff8; cursor: pointer; }
.ut-wagon.drag-over { border-color: #ff9f1c; background: #fff4e0; transform: scale(1.06); }
.ut-wagon.correct-flash { animation: ut-bounce 0.4s; border-color: #2ecc71; background: #d7f9e4; }
.ut-wagon.incorrect-flash { animation: ut-shake 0.4s; border-color: #e74c3c; background: #fdecea; }
@keyframes ut-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes ut-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.ut-feedback {
  text-align: center; font-size: 14px; font-weight: 700; padding: 8px 16px; border-radius: 10px;
  margin: 0 auto 10px; max-width: 400px;
}
.ut-feedback-correct { background: rgba(46,204,113,0.92); color: #fff; }
.ut-feedback-incorrect { background: rgba(231,76,60,0.92); color: #fff; }

/* ---------- Platform ---------- */
.ut-platform-label { text-align: center; font-size: 12px; font-weight: 700; color: #4a3200; margin-bottom: 6px; }
.ut-platform {
  background: #e8d6b3;
  border-top: 4px solid #c9a86a;
  margin: 0 16px;
  border-radius: 10px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
}
.ut-crate {
  width: 58px; height: 58px;
  background: #d9822b;
  border: 3px solid #a85d16;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: #fff;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ut-crate:hover { transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,0.2); }
.ut-crate.dragging { opacity: 0.4; }

.ut-go-wrap { display: flex; justify-content: center; margin-top: 18px; }
.ut-go-btn {
  background: #2ecc71; color: #fff; border: none; border-radius: 16px;
  padding: 14px 50px; font-size: 22px; font-weight: 900; cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,0.2); transition: transform 0.15s, opacity 0.15s;
}
.ut-go-btn:hover:not(:disabled) { transform: translateY(-2px); }
.ut-go-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Result screen ---------- */
.ut-result { text-align: center; padding: 50px 30px; background: #fff; }
.ut-result-icon { font-size: 56px; margin-bottom: 8px; }
.ut-result h2 { margin: 0 0 8px; color: #2f3542; }
.ut-result p { color: #6b6b6b; margin: 0 0 20px; }
.ut-result-stats { display: flex; justify-content: center; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.ut-result-stats span { display: block; font-size: 24px; font-weight: 800; color: #ff9f1c; }
.ut-result-stats small { color: #999; font-size: 12px; }
.ut-result-answer { font-size: 14px; font-weight: 700; color: #4a3200; margin-bottom: 20px; }
.ut-result-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.ut-btn {
  border: none; border-radius: 12px; padding: 12px 26px; font-size: 14px; font-weight: 700;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.ut-btn-primary { background: #2ecc71; color: #fff; }
.ut-btn-secondary { background: #5b8def; color: #fff; }

/* ---------- Home confirmation modal ---------- */
.ut-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.ut-modal {
  background: #fff; border-radius: 16px; padding: 26px 24px; max-width: 340px; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.ut-modal p { font-size: 15px; font-weight: 600; color: #2f3542; margin: 0 0 18px; }
.ut-modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .ut-outer { padding: 10px; }
  .ut-container { border-radius: 12px; }
  .ut-header { padding: 10px 12px; }
  .ut-instruction-long { display: none; }
  .ut-instruction-short { display: inline; }
  .ut-instruction { flex-basis: 100%; text-align: center; order: 1; font-size: 11px; max-width: none; }
  .ut-header-right { order: 2; margin: 0 auto; gap: 10px; }
  .ut-progress, .ut-score, .ut-life { font-size: 11px; }

  .ut-scene { min-height: 420px; }
  .ut-sky { height: 70px; }
  .ut-tree { font-size: 24px; }
  .ut-cloud { font-size: 20px; }
  .ut-station { font-size: 28px; }
  .ut-engine { font-size: 34px; }
  .ut-wagon { width: 48px; height: 48px; font-size: 19px; }
  .ut-crate { width: 48px; height: 48px; font-size: 18px; }
  .ut-platform { margin: 0 10px; padding: 10px; gap: 8px; }
  .ut-go-btn { padding: 12px 40px; font-size: 18px; }
}
