/* =============================================
   DESIGN TOKENS
============================================= */
:root {
  --bg-dark:       #f8fafc;
  --bg-card:       #ffffff;
  --bg-input:      #f1f5f9;
  --border:        rgba(0,0,0,0.08);
  --border-focus:  rgba(59,130,246,0.5);

  --green:         #10b981;
  --green-glow:    rgba(16,185,129,0.25);
  --green-dark:    #059669;

  --orange:        #f97316;
  --orange-glow:   rgba(249,115,22,0.25);
  --orange-dark:   #ea580c;

  --blue:          #3b82f6;
  --blue-glow:     rgba(59,130,246,0.2);

  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #64748b;

  --radius-sm:     10px;
  --radius-md:     16px;
  --radius-lg:     24px;

  --shadow-card:   0 8px 32px rgba(0,0,0,0.06);
  --shadow-glow-g: 0 0 40px rgba(16,185,129,0.15);
  --shadow-glow-o: 0 0 40px rgba(249,115,22,0.15);

  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
}

/* =============================================
   RESET & BASE
============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* =============================================
   ANIMATED BACKGROUND
============================================= */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: floatOrb 12s ease-in-out infinite;
}

.orb-1 {
  width: 500px; height: 500px;
  background: var(--green);
  top: -150px; left: -150px;
  animation-duration: 14s;
}

.orb-2 {
  width: 400px; height: 400px;
  background: var(--orange);
  bottom: -100px; right: -100px;
  animation-duration: 11s;
  animation-delay: -4s;
}

.orb-3 {
  width: 300px; height: 300px;
  background: var(--blue);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 18s;
  animation-delay: -8s;
  opacity: 0.08;
}

@keyframes floatOrb {
  0%, 100% { transform: translate(0,0) scale(1); }
  33%       { transform: translate(30px,-40px) scale(1.05); }
  66%       { transform: translate(-20px,20px) scale(0.97); }
}

/* =============================================
   LAYOUT
============================================= */
.wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* =============================================
   HEADER
============================================= */
header {
  text-align: center;
  padding-top: 16px;
}

.header-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
  animation: bounceIn 0.7s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes bounceIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

header h1 {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  line-height: 1.2;
  background: linear-gradient(135deg, #0f172a 0%, #475569 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}

/* =============================================
   CARD
============================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-card);
  animation: slideUp 0.5s cubic-bezier(0.4,0,0.2,1) both;
}

.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }

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

.card-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* =============================================
   FUEL SECTION (two columns)
============================================= */
.fuel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.fuel-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fuel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 800;
}

.fuel-label .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-gas { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.dot-eth { background: var(--green);  box-shadow: 0 0 8px var(--green); }

/* =============================================
   INPUT GROUP
============================================= */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding-left: 2px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .prefix {
  position: absolute;
  left: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition);
}

.input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 13px 14px 13px 34px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.input-wrapper input:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--blue-glow);
}

.input-wrapper:focus-within .prefix { color: var(--blue); }

.input-wrapper input::placeholder {
  color: var(--text-muted);
  font-weight: 600;
}

/* suffix unit */
.input-wrapper.has-suffix input { padding-right: 48px; }

.input-wrapper .suffix {
  position: absolute;
  right: 14px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  pointer-events: none;
  letter-spacing: 0.04em;
}

/* =============================================
   DIVIDER
============================================= */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* =============================================
   EFFICIENCY SECTION
============================================= */
.efficiency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* =============================================
   CALCULATE BUTTON
============================================= */
.btn-calc {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
  box-shadow: 0 4px 24px rgba(34,197,94,0.35);
  -webkit-tap-highlight-color: transparent;
}

.btn-calc::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

.btn-calc:hover  { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(34,197,94,0.5); }
.btn-calc:active { transform: translateY(0); filter: brightness(0.92); }
.btn-calc:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.btn-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-icon { font-size: 1.3rem; }

/* =============================================
   RESULT CARD
============================================= */
#result-section { display: none; }

#result-section.visible {
  display: block;
  animation: slideUp 0.45s cubic-bezier(0.4,0,0.2,1) both;
}

.result-card {
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  text-align: center;
}

.result-card.winner-gas {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border-color: rgba(249,115,22,0.35);
  box-shadow: var(--shadow-card), var(--shadow-glow-o);
}

.result-card.winner-eth {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: rgba(34,197,94,0.35);
  box-shadow: var(--shadow-card), var(--shadow-glow-g);
}

.result-card.winner-tie {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: rgba(59,130,246,0.3);
  box-shadow: var(--shadow-card), 0 0 40px rgba(59,130,246,0.1);
}

.result-shine {
  position: absolute;
  top: -60%; left: -60%;
  width: 220%; height: 220%;
  background: radial-gradient(circle at center, rgba(255,255,255,0.6) 0%, transparent 60%);
  pointer-events: none;
}

.result-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 10px;
  animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.result-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 14px;
}

.badge-gas { background: rgba(249,115,22,0.15); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); }
.badge-eth { background: rgba(34,197,94,0.15);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3); }
.badge-tie { background: rgba(59,130,246,0.15); color: var(--blue);   border: 1px solid rgba(59,130,246,0.3); }

.result-headline {
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 8px;
}

.result-sub {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Cost per km pills */
.cost-pills {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.cost-pill {
  background: rgba(255,255,255,0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 130px;
  position: relative;
  transition: transform var(--transition);
}

.cost-pill.is-winner {
  border-color: rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.8);
}

.cost-pill .pill-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.cost-pill .pill-value {
  font-size: 1.25rem;
  font-weight: 900;
}

.cost-pill .pill-unit {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.pill-value.gas-color { color: var(--orange); }
.pill-value.eth-color { color: var(--green); }
.pill-value.tie-color { color: var(--blue); }

.winner-crown {
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
}

/* =============================================
   ECONOMY BOX (Feat #4 — economia por tanque)
============================================= */
.economy-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.6);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.economy-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.economy-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.economy-text .economy-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.economy-text .economy-value {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text-primary);
}

.economy-text .economy-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Ratio hint */
.ratio-hint {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
}

.ratio-hint strong { color: var(--text-primary); }

/* =============================================
   CLEAR BUTTON (Feat #3)
============================================= */
.btn-clear-wrap {
  display: none;
  justify-content: center;
  margin-top: -8px;
}

.btn-clear-wrap.visible { display: flex; }

.btn-clear {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 8px 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-clear:hover {
  color: var(--text-secondary);
  border-color: rgba(0,0,0,0.18);
  background: rgba(0,0,0,0.03);
}

.btn-clear:active { opacity: 0.7; }

/* =============================================
   HOW IT WORKS
============================================= */
.how-section {
  animation: slideUp 0.5s cubic-bezier(0.4,0,0.2,1) 0.15s both;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 12px;
  margin-top: 4px;
}

.how-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.how-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--blue);
}

.how-item p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.4;
}

/* =============================================
   FOOTER
============================================= */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 0 4px;
}

/* =============================================
   ERROR STATE
============================================= */
.input-wrapper input.error {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248,113,113,0.2);
  animation: shake 0.35s ease both;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.error-msg {
  font-size: 0.75rem;
  color: #f87171;
  font-weight: 700;
  padding-left: 2px;
  display: none;
}

.error-msg.show { display: block; }

/* =============================================
   RESPONSIVE
============================================= */
@media (max-width: 400px) {
  .fuel-grid,
  .efficiency-grid { grid-template-columns: 1fr; }

  .card { padding: 22px 18px; }

  .cost-pills { flex-direction: column; align-items: center; }
  .cost-pill  { width: 100%; max-width: 220px; }

  .how-grid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .wrapper { padding: 16px 12px 40px; }
}
