:root {
  /* Scratch-ticket palette: deep lottery green, gold foil lettering, silver scratch texture */
  --green-900: #0a3320;
  --green-700: #0e7a41;
  --green-600: #12945a;
  --green-500: #18ab63;
  --green-400: #3fd688;
  --green-bg: #e9f9ef;

  --gold-700: #a1660a;
  --gold-500: #f2b705;
  --gold-400: #ffce33;
  --gold-300: #ffe28a;
  --gold-bg: #fff6de;

  --silver-100: #f4f5f7;
  --silver-200: #e7e9ed;
  --silver-400: #c7cbd2;

  --red-600: #c0392b;
  --red-bg: #fdecea;

  --amber-700: #9a5b0a;
  --amber-500: #e08a1e;
  --amber-bg: #fdf1de;

  --ink: #16241c;
  --muted: #64705f;
  --paper: #f6f4ec;
  --card: #ffffff;

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

  --shadow-sm: 0 1px 2px rgba(10, 30, 20, 0.06);
  --shadow-md: 0 6px 18px rgba(10, 51, 32, 0.1);
  --shadow-gold: 0 10px 24px rgba(178, 128, 4, 0.28);
  --shadow-green: 0 10px 24px rgba(10, 51, 32, 0.28);

  --gradient-green: linear-gradient(135deg, #0e7a41 0%, #18ab63 55%, #3fd688 100%);
  --gradient-gold: linear-gradient(135deg, #f2b705 0%, #ffce33 55%, #ffe28a 100%);
  --gradient-scratch: repeating-linear-gradient(
    135deg,
    #e7e9ed 0px,
    #f4f5f7 6px,
    #dfe2e7 12px,
    #f4f5f7 18px
  );

  --font-display: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--gradient-green);
  color: #fff;
  box-shadow: var(--shadow-green);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: #fff;
  flex-shrink: 0;
}

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  padding: 9px;
  border-radius: 999px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.icon-btn:active {
  transform: scale(0.92);
}

.view .icon-btn {
  background: var(--silver-100);
  color: var(--ink);
}

.view .icon-btn:hover {
  background: var(--silver-200);
}

/* ---------- Layout ---------- */

#app {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 16px 24px;
}

body.has-bottom-nav #app {
  padding-bottom: 100px;
}

.hidden {
  display: none;
}

.view {
  animation: view-in 0.28s ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Home / scratch hero ---------- */

.scratch-panel {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 28px 20px 24px;
  background: var(--gradient-green);
  box-shadow: var(--shadow-green);
  overflow: hidden;
  margin-bottom: 28px;
  text-align: center;
}

.scratch-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-scratch);
  opacity: 0.12;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.scratch-panel .sparkle {
  position: absolute;
  color: var(--gold-300);
  opacity: 0.85;
  animation: twinkle 2.6s ease-in-out infinite;
}

.scratch-panel .sparkle.s1 {
  width: 16px;
  height: 16px;
  top: 16px;
  left: 20px;
  animation-delay: 0s;
}

.scratch-panel .sparkle.s2 {
  width: 11px;
  height: 11px;
  top: 30px;
  right: 26px;
  animation-delay: 0.6s;
}

.scratch-panel .sparkle.s3 {
  width: 13px;
  height: 13px;
  bottom: 18px;
  left: 30px;
  animation-delay: 1.2s;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.85) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.1) rotate(12deg);
  }
}

.scratch-panel h2 {
  position: relative;
  color: #fff;
  font-size: 1.3rem;
  margin: 0 0 4px;
}

.scratch-panel p {
  position: relative;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  margin: 0 0 22px;
}

.hero-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Buttons ---------- */

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 999px;
  padding: 15px 22px;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn-primary .btn-icon,
.btn-secondary .btn-icon,
.btn-danger .btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--gradient-gold);
  color: #4a3200;
  box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-large {
  padding: 18px 22px;
  font-size: 1.08rem;
}

.btn-secondary {
  background: var(--silver-100);
  color: var(--ink);
  border: 1.5px solid transparent;
}

.btn-secondary:hover {
  background: var(--silver-200);
}

.scratch-panel .btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.scratch-panel .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red-600);
}

.btn-danger:hover {
  filter: brightness(0.97);
}

/* ---------- Section headers ---------- */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 1.05rem;
  margin: 0;
  flex: 1;
}

.section-header a {
  color: var(--green-600);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
}

/* ---------- Ticket cards ---------- */

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: var(--shadow-sm);
  border-left: 5px solid var(--silver-400);
}

.ticket-card.is-winner {
  border-left-color: var(--gold-500);
  background: linear-gradient(to right, var(--gold-bg), var(--card) 40%);
}

.ticket-card.is-loser {
  border-left-color: var(--silver-400);
}

.ticket-card.is-indeterminate {
  border-left-color: var(--amber-500);
}

.ticket-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--silver-100);
  box-shadow: var(--shadow-sm);
}

.ticket-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.ticket-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 0.86rem;
  font-family: var(--font-display);
}

.ticket-badge .badge-icon {
  width: 15px;
  height: 15px;
}

.ticket-card.is-winner .ticket-badge {
  color: var(--gold-700);
}

.ticket-card.is-loser .ticket-badge {
  color: var(--muted);
}

.ticket-card.is-indeterminate .ticket-badge {
  color: var(--amber-700);
}

.ticket-date {
  font-size: 0.76rem;
  color: var(--muted);
}

.ticket-prize {
  font-weight: 800;
  color: var(--gold-700);
  font-size: 0.92rem;
  font-family: var(--font-display);
}

.btn-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

.btn-delete svg {
  width: 100%;
  height: 100%;
}

.btn-delete:hover {
  background: var(--red-bg);
  color: var(--red-600);
}

.empty-state {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  padding: 30px 10px;
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ---------- Processing ---------- */

.processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 90px 20px;
  text-align: center;
}

.scan-icon {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: var(--gradient-green);
  box-shadow: var(--shadow-green);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.scan-icon svg {
  width: 42px;
  height: 42px;
  color: #fff;
}

.scan-icon::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gold-300);
  box-shadow: 0 0 10px 2px var(--gold-300);
  animation: scan-sweep 1.6s ease-in-out infinite;
}

@keyframes scan-sweep {
  0% {
    top: 6%;
  }
  50% {
    top: 92%;
  }
  100% {
    top: 6%;
  }
}

#processing-status {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Auth ---------- */

.auth-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 22px;
  text-align: center;
  margin-top: 20px;
}

.auth-icon {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  color: var(--gold-500);
}

.auth-card h2 {
  font-size: 1.15rem;
  margin: 0 0 8px;
}

.auth-card > p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

#auth-form input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--silver-200);
}

#auth-form input:focus {
  outline: none;
  border-color: var(--green-500);
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  margin-top: -2px;
}

.auth-remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--green-500);
}

.auth-card > p.auth-switch {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-switch a {
  color: var(--green-600, var(--green-500));
  font-weight: 600;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ---------- Account (Settings) ---------- */

.account-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
  margin-bottom: 16px;
}

.account-card h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.account-card button {
  margin-top: 8px;
}

/* ---------- Error ---------- */

.error-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 22px;
  text-align: center;
  margin-top: 20px;
}

.error-icon {
  display: block;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  color: var(--red-600);
}

#error-message {
  color: var(--ink);
  margin-bottom: 22px;
  line-height: 1.45;
}

.error-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.error-actions .btn-primary {
  background: var(--gradient-green);
  color: #fff;
  box-shadow: var(--shadow-green);
}

/* ---------- Result ---------- */

.result-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
  margin-top: 10px;
  overflow: hidden;
  position: relative;
}

.result-photo {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--silver-100);
  margin-bottom: 16px;
}

.game-label {
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.ticket-game {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  background: var(--silver-100);
  color: var(--ink);
}

.result-banner svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.result-card.is-winner .result-banner {
  background: var(--gradient-gold);
  color: #4a3200;
  box-shadow: var(--shadow-gold);
}

.result-card.is-loser .result-banner {
  background: var(--silver-100);
  color: var(--muted);
}

.result-card.is-indeterminate .result-banner {
  background: var(--amber-bg);
  color: var(--amber-700);
}

.match-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gold-bg);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.95rem;
  color: var(--gold-700);
  font-weight: 600;
}

.match-list li .match-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.review-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--amber-bg);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--amber-700);
}

.review-list li .review-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.total-prize {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 14px 0 4px;
}

.total-prize strong {
  color: var(--gold-700);
}

.disclaimer {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--silver-100);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  line-height: 1.45;
  margin: 16px 0;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-card.is-loser .result-actions .btn-primary,
.result-card.is-indeterminate .result-actions .btn-primary {
  background: var(--gradient-green);
  color: #fff;
  box-shadow: var(--shadow-green);
}

/* Confetti burst on a winning ticket */
.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  opacity: 0.95;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
  z-index: 5;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(260px) rotate(540deg);
    opacity: 0;
  }
}

/* ---------- Settings / forms ---------- */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
}

.settings-form label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  margin-top: 10px;
}

.settings-form input,
.settings-form select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--silver-200);
  background: #fff;
}

.settings-form input:focus,
.settings-form select:focus {
  outline: none;
  border-color: var(--green-500);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 2px 0 4px;
  line-height: 1.4;
}

.settings-form button {
  margin-top: 18px;
}

.settings-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--green-bg);
  color: var(--green-900);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.88rem;
  line-height: 1.4;
  margin-bottom: 16px;
}

.games-supported {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
  margin-bottom: 16px;
}

.games-supported h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.game-tag-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-tag {
  background: var(--green-bg);
  color: var(--green-900);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 999px;
}

.settings-danger {
  margin-top: 20px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
}

.settings-danger h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.settings-danger button {
  margin-top: 10px;
}

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: none;
  justify-content: space-around;
  align-items: center;
  background: var(--card);
  border-top: 1px solid var(--silver-200);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(10, 30, 20, 0.06);
}

body.has-bottom-nav .bottom-nav {
  display: flex;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 18px;
  border-radius: 14px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: var(--green-600);
  background: var(--green-bg);
}

@media (min-width: 600px) {
  .hero-actions {
    flex-direction: row;
  }
}
