:root {
  --red: #c8102e;
  --red-deep: #8a0a1f;
  --blue: #0033a0;
  --blue-deep: #001f63;
  --ink: #0e1116;
  --paper: #ffffff;
  --muted: #6b7280;
  --line: #e5e7eb;
  --shadow: 0 10px 30px rgba(0, 31, 99, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(160deg, var(--blue) 0%, var(--blue-deep) 55%, var(--red-deep) 100%);
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.screen {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 28px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-x: hidden;
}
.screen.hidden { display: none; }

.brand {
  display: flex; align-items: center; gap: 14px;
  color: #fff;
  padding: 6px 4px;
}
.logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--red) 0%, #ff3b3b 100%);
  display: grid; place-items: center;
  font-weight: 900; font-size: 22px;
  box-shadow: 0 6px 20px rgba(200, 16, 46, 0.45);
  letter-spacing: 1px;
}
.brand-text h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.brand-text .muted { margin: 2px 0 0; color: #d8def0; font-size: 13px; }

.amount-card {
  background: var(--paper);
  border-radius: 18px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--red);
}
.amount-card .label { margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.amount-card .amount { margin: 6px 0 4px; font-size: 44px; font-weight: 900; color: var(--ink); letter-spacing: -0.02em; }
.amount-card .sublabel { margin: 8px 0 0; color: var(--blue); font-size: 16px; font-weight: 700; }

.tips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}
.tip {
  appearance: none;
  border: 2px solid var(--paper);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  padding: 18px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-family: inherit;
}
.tip:active { transform: scale(0.97); }
.tip:hover { background: #fff; }
.tip-wide { grid-column: span 2; }
.tip .pct { font-size: 26px; font-weight: 900; color: var(--blue); letter-spacing: -0.01em; }
.tip .hint { font-size: 12px; color: var(--muted); font-weight: 600; }
.tip[data-pct="0"] .pct { color: var(--red); }
.tip[data-pct="100"] { background: linear-gradient(135deg, #fff 0%, #ffe9ec 100%); border-color: #ffd2d8; }
.tip[data-pct="100"] .pct { color: var(--red); }

.footnote {
  color: #fff;
  font-size: 12px;
  text-align: center;
  margin: 8px auto 0;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.22);
  padding: 10px 14px;
  border-radius: 10px;
  max-width: 92%;
}

/* Result screen */
.result-card {
  background: var(--paper);
  border-radius: 22px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-top: 8vh;
  border-top: 6px solid var(--red);
  animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.result-emoji { font-size: 64px; line-height: 1; margin-bottom: 6px; }
.result-card h2 { margin: 0; color: var(--blue); font-size: 22px; font-weight: 800; }
.result-pct { margin: 8px 0; font-size: 56px; font-weight: 900; color: var(--red); letter-spacing: -0.02em; }
.result-line { margin: 10px 8px 6px; font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1.35; }
.result-sub { margin: 0 8px 18px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.reset {
  appearance: none;
  border: none;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.reset:active { transform: scale(0.98); }

/* Confetti / shake effects */
.shake { animation: shake 0.5s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
}
