/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Quicksand', system-ui, sans-serif;
  font-weight: 500;
  background: #ffffff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px 60px;
  color: #2D1A14;
}

/* ── Language Toggle ──────────────────────────────────── */
.lang-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 50;
  display: flex;
  background: #F5EDE9;
  border-radius: 14px;
  padding: 3px;
  gap: 2px;
  box-shadow: 0 2px 8px rgba(212,82,42,0.10);
}

.lang-btn {
  background: transparent;
  border: none;
  border-radius: 11px;
  padding: 6px 10px;
  font-family: 'Quicksand', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #A06050;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.lang-btn.active {
  background: white;
  color: #C44020;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(196,64,32,0.12);
}

/* ── Container ────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 390px;
  text-align: center;
  margin-top: 36px;
}

/* ── Header ───────────────────────────────────────────── */
.header { margin-bottom: 24px; }

.title {
  font-size: 36px;
  font-weight: 700;
  color: #C44020;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.subtitle {
  font-size: 14px;
  font-weight: 500;
  color: #A06050;
  margin-top: 4px;
}

/* ── Connect Screen ───────────────────────────────────── */
.connect-card {
  background: #FFFAF8;
  border: 1.5px solid #FFE0D6;
  border-radius: 28px;
  padding: 40px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.connect-pig {
  width: 120px;
  height: 120px;
  object-fit: contain;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.connect-hint {
  font-size: 15px;
  font-weight: 600;
  color: #80504A;
  line-height: 1.5;
}

.btn-connect {
  background: linear-gradient(135deg, #FF7A50, #E83828);
  color: white;
  border: none;
  border-radius: 22px;
  padding: 15px 40px;
  font-family: 'Quicksand', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(232,56,40,0.30);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-connect:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(232,56,40,0.40); }
.btn-connect:active { transform: scale(0.97); }

/* ── App Section ──────────────────────────────────────── */
#appSection {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.hidden { display: none !important; }

/* ── Mode Toggle ──────────────────────────────────────── */
.mode-toggle {
  display: flex;
  background: #F5EDE9;
  border-radius: 16px;
  padding: 4px;
  gap: 4px;
  width: 100%;
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 12px;
  padding: 10px 8px;
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #A06050;
  cursor: pointer;
  transition: all 0.2s;
}
.mode-btn.active {
  background: white;
  color: #C44020;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(196,64,32,0.12);
}

/* ── Stats ────────────────────────────────────────────── */
.stats {
  display: flex;
  align-items: center;
  gap: 20px;
  background: #FFFAF8;
  border: 1.5px solid #FFE0D6;
  border-radius: 20px;
  padding: 14px 30px;
  width: 100%;
  justify-content: center;
}

.stat { display: flex; flex-direction: column; align-items: center; }

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: #C44020;
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: #A06050;
  margin-top: 3px;
}

.stat-dot { font-size: 20px; color: #FFBCAE; }

/* ── Pig Area ─────────────────────────────────────────── */
.pig-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 200px;
  width: 200px;
}

.pig-shadow { display: none; }

.pig {
  width: 150px;
  height: 150px;
  object-fit: contain;
  position: absolute;
  bottom: 14px;
  --pig-scale: 1;
  transform: scale(var(--pig-scale));
  transform-origin: bottom center;
  transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pig.bounce { animation: pigBounce 0.55s ease; }
@keyframes pigBounce {
  0%   { transform: scale(var(--pig-scale)) translateY(0); }
  28%  { transform: scale(calc(var(--pig-scale) * 1.13)) translateY(-14px); }
  58%  { transform: scale(calc(var(--pig-scale) * 0.95)) translateY(5px); }
  78%  { transform: scale(calc(var(--pig-scale) * 1.04)) translateY(-4px); }
  100% { transform: scale(var(--pig-scale)) translateY(0); }
}

/* ── Rank Badge ───────────────────────────────────────── */
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: all 0.4s ease;
}

.rank-piglet        { background: #FFF0EC; color: #C44020; border: 1.5px solid #FFBCAE; }
.rank-saving-piglet { background: #EEF4FF; color: #2563EB; border: 1.5px solid #BFDBFE; }
.rank-steady-pig    { background: #ECFDF5; color: #059669; border: 1.5px solid #A7F3D0; }
.rank-golden-pig    { background: #FFFBEB; color: #D97706; border: 1.5px solid #FDE68A; }
.rank-diamond-pig   { background: linear-gradient(135deg, #EEF4FF, #F5F3FF); color: #7C3AED; border: 1.5px solid #DDD6FE; }

/* ── Progress (Normal) ────────────────────────────────── */
.progress-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: #FFE0D6;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF8060, #E83828);
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-label {
  font-size: 12px;
  font-weight: 600;
  color: #A06050;
}

/* ── Purpose Mode ─────────────────────────────────────── */
.purpose-section { width: 100%; }

.goal-setup {
  background: #FFFAF8;
  border: 1.5px solid #FFE0D6;
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goal-hint {
  font-size: 14px;
  font-weight: 600;
  color: #80504A;
}

.goal-input-row {
  display: flex;
  gap: 8px;
}

.goal-input {
  flex: 1;
  border: 2px solid #FFBCAE;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Quicksand', sans-serif;
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  font-weight: 600;
  color: #C44020;
  outline: none;
  transition: border-color 0.15s;
}
.goal-input:focus { border-color: #E05030; }
.goal-input::placeholder { color: #D4A090; font-weight: 500; }

.btn-set-goal {
  background: linear-gradient(135deg, #FF7A50, #E83828);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s;
}
.btn-set-goal:hover { transform: translateY(-1px); }

.goal-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.goal-progress-track {
  width: 100%;
  height: 12px;
  background: #FFE0D6;
  border-radius: 10px;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF8060, #E83828);
  border-radius: 10px;
  transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.goal-pct {
  font-size: 22px;
  font-weight: 700;
  color: #C44020;
}

.btn-reset-goal {
  background: none;
  border: none;
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #A06050;
  cursor: pointer;
  text-decoration: underline;
  opacity: 0.7;
}
.btn-reset-goal:hover { opacity: 1; }

/* ── Deposit Buttons ──────────────────────────────────── */
.deposit-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-deposit {
  flex: 1;
  background: white;
  border: 2px solid #FFBCAE;
  border-radius: 16px;
  padding: 15px 6px;
  font-family: 'Quicksand', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #C44020;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(212,82,42,0.06);
}
.btn-deposit:hover { background: #FFF5F2; border-color: #E05030; transform: translateY(-2px); }
.btn-deposit:active { transform: scale(0.96); }
.btn-deposit:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Break Button ─────────────────────────────────────── */
.btn-break {
  width: 100%;
  background: linear-gradient(135deg, #FF7A50, #E83828);
  color: white;
  border: none;
  border-radius: 18px;
  padding: 17px;
  font-family: 'Quicksand', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(232,56,40,0.28);
  transition: all 0.15s;
}
.btn-break:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(232,56,40,0.38); }
.btn-break:active { transform: scale(0.97); }
.btn-break:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Wallet row ───────────────────────────────────────── */
.wallet-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: -4px;
}
.wallet-label {
  font-size: 11px;
  font-weight: 500;
  color: #C0907A;
  opacity: 0.6;
}
.btn-disconnect {
  background: none;
  border: none;
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #C0907A;
  opacity: 0.55;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.btn-disconnect:hover { opacity: 1; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-box {
  background: white;
  border-radius: 28px;
  padding: 36px 26px 28px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-pig {
  width: 90px;
  height: 90px;
  object-fit: contain;
  margin-bottom: 14px;
  animation: sadWiggle 1.4s ease infinite;
}
@keyframes sadWiggle {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(-4deg); }
  75%       { transform: rotate(4deg); }
}

.modal-box h2 {
  font-size: 20px;
  font-weight: 700;
  color: #C44020;
  margin-bottom: 10px;
}

.modal-body {
  font-size: 14px;
  font-weight: 500;
  color: #7A5048;
  line-height: 1.6;
  margin-bottom: 6px;
  white-space: pre-line;
}

.modal-count {
  font-size: 16px;
  font-weight: 700;
  color: #E05030;
  margin-bottom: 4px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.btn-keep {
  background: linear-gradient(135deg, #FF7A50, #E83828);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-family: 'Quicksand', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(232,56,40,0.28);
  transition: transform 0.15s;
}
.btn-keep:hover { transform: translateY(-1px); }

.btn-break-anyway {
  background: #FFF0EC;
  color: #C44020;
  border: 2px solid #FFBCAE;
  border-radius: 14px;
  padding: 12px;
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-break-anyway:hover { background: #FFE0D6; }

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 14, 8, 0.90);
  color: white;
  padding: 12px 22px;
  border-radius: 22px;
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.20);
  animation: toastUp 0.3s ease;
}
@keyframes toastUp {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* ── Responsive / Mobile ──────────────────────────────── */
@media (max-width: 480px) {
  body { padding: 12px 12px 40px; }

  .container { margin-top: 44px; }

  .header { margin-bottom: 14px; }
  .title { font-size: 28px; }
  .subtitle { font-size: 13px; }

  #appSection { gap: 10px; }

  .stats { padding: 10px 18px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 10px; }

  .pig-wrap { height: 150px; width: 150px; }
  .pig { width: 120px; height: 120px; }

  .btn-deposit { font-size: 13px; padding: 12px 4px; }
  .btn-break { padding: 14px; font-size: 15px; }

  .connect-card { padding: 28px 20px; }
  .connect-pig { width: 90px; height: 90px; }
}
