:root {
  --bg: #050c1b;
  --card: rgba(15, 28, 56, 0.82);
  --card-solid: #0f1c38;
  --border: rgba(125, 211, 252, 0.22);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --gold: #fbbf24;
  --gold-light: #fef08a;
  --danger: #f87171;
  --success: #34d399;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(14, 165, 233, 0.28), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(245, 158, 11, 0.18), transparent 40%),
    linear-gradient(180deg, #09152e 0%, #050c1b 60%, #030712 100%);
  color: var(--text);
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

.wrap { max-width: 460px; margin: 0 auto; padding: 16px 16px 64px; }

/* Brand Hero Header */
.hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 24px 18px 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.45), rgba(30, 58, 138, 0.55));
  border: 1px solid rgba(125, 211, 252, 0.35);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  margin-bottom: 16px;
}
.hero::after {
  content: "";
  position: absolute; top: -40px; right: -40px; width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.28), transparent 70%);
  pointer-events: none;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: rgba(56, 189, 248, 0.16); border: 1px solid rgba(125, 211, 252, 0.4);
  font-size: 11px; letter-spacing: 2px; color: #bae6fd; font-weight: 700;
}
.hero h1 {
  margin: 10px 0 6px; font-size: 22px; font-weight: 800; line-height: 1.3;
  background: linear-gradient(180deg, #ffffff 20%, #fde68a 100%);
  -webkit-background-clip: text; color: transparent;
}
.hero p { margin: 0; font-size: 13px; color: #cbd5e1; line-height: 1.5; }

.back-bar {
  display: flex; align-items: center; margin-bottom: 12px;
}
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(15, 28, 56, 0.9); border: 1px solid var(--border);
  color: #bae6fd; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* Inline feedback banner (always visible when status changes) */
.status-banner {
  padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5;
  margin-bottom: 14px; display: none; font-weight: 500;
}
.status-banner.show { display: block; animation: fadeIn 0.22s ease; }
.status-banner.info { background: rgba(14, 165, 233, 0.18); border: 1px solid rgba(56, 189, 248, 0.5); color: #e0f2fe; }
.status-banner.success { background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(52, 211, 153, 0.55); color: #d1fae5; }
.status-banner.error { background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(248, 113, 113, 0.55); color: #fee2e2; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* Hub Portal Cards (tab=hub) */
.hub-grid { display: flex; flex-direction: column; gap: 14px; }
.hub-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
  width: 100%; padding: 22px 18px; border-radius: 20px;
  text-align: left; color: #fff; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.38);
  transition: transform 0.15s ease;
}
.hub-card:active { transform: scale(0.985); }
.hub-card.lottery { background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 55%, #78350f 100%); border-color: rgba(251, 191, 36, 0.5); }
.hub-card.wish { background: linear-gradient(135deg, #0e7490 0%, #1e1b4b 65%, #4c1d95 100%); border-color: rgba(56, 189, 248, 0.5); }
.hub-icon {
  width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.hub-card h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.hub-card p { margin: 0; font-size: 13px; color: #cbd5e1; line-height: 1.45; }
.hub-arrow { margin-left: auto; font-size: 20px; color: rgba(255,255,255,0.6); }

/* Glass Cards */
.card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 16px;
  margin-bottom: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}
.card-title {
  margin: 0 0 14px; font-size: 16px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: #e2e8f0; font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.error-msg { display: none; font-size: 12px; color: #fca5a5; margin-top: 2px; }

input[type="text"], input[type="tel"], input[type="number"], textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(5, 12, 27, 0.85); color: #fff; font-size: 15px;
  outline: none; transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--accent); }
:is(:user-invalid, .user-invalid-fallback) { border-color: var(--danger) !important; }
:is(:user-invalid, .user-invalid-fallback) + .error-msg { display: block; }

.sms-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; }
.btn-sms {
  padding: 0 14px; border-radius: 12px; border: 1px solid rgba(56, 189, 248, 0.55);
  background: rgba(2, 132, 199, 0.25); color: #e0f2fe;
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn-sms:disabled { opacity: 0.5; cursor: not-allowed; }

/* Upload dropzone */
.upload-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed rgba(56, 189, 248, 0.5);
  border-radius: 16px; padding: 26px 14px; text-align: center;
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.08), rgba(15, 23, 42, 0.6));
  cursor: pointer; position: relative; min-height: 150px;
}
.upload-box input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-title { font-size: 15px; font-weight: 700; color: #bae6fd; }
.upload-preview {
  width: 100%; max-height: 240px; object-fit: contain; border-radius: 12px;
  margin-top: 12px; display: none; border: 1px solid rgba(255,255,255,0.2);
}

/* Buttons */
.btn {
  width: 100%; padding: 14px 18px; border-radius: 14px; border: none;
  font-size: 16px; font-weight: 800; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
  transition: transform 0.12s, opacity 0.15s;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #1e1b4b;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
}
.btn-outline {
  background: rgba(15, 28, 56, 0.7); border: 1px solid var(--border);
  box-shadow: none; font-size: 13px; padding: 8px 12px; color: #e2e8f0;
  border-radius: 10px; cursor: pointer; font-weight: 600;
}

/* Quota & Prizes */
.quota-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.16), rgba(251, 191, 36, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.32);
  font-size: 14px; margin-bottom: 14px;
}
.prize-strip {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px;
}
.prize-chip {
  flex-shrink: 0; padding: 8px 12px; border-radius: 12px;
  background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.32);
  font-size: 12px;
}
.prize-chip strong { color: var(--gold-light); display: block; margin-bottom: 2px; }

/* Code list */
.code-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px; border-radius: 14px;
  background: rgba(5, 12, 27, 0.78); border: 1px solid rgba(251, 191, 36, 0.3);
  margin-bottom: 10px;
}
.code-val {
  font-size: 21px; font-weight: 900; letter-spacing: 2px; color: var(--gold);
  font-family: ui-monospace, Consolas, monospace;
}
.ocr-meta { font-size: 12px; color: #cbd5e1; margin-top: 4px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-green { background: rgba(16,185,129,0.22); color: #34d399; }
.badge-yellow { background: rgba(245,158,11,0.22); color: #fbbf24; }
.badge-red { background: rgba(239,68,68,0.22); color: #f87171; }
.badge-purple { background: rgba(168,85,247,0.25); color: #d8b4fe; }

.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

/* Native dialog for savable lottery ticket card */
dialog:modal {
  overscroll-behavior: contain;
  background: var(--card-solid); color: var(--text);
  border: 1px solid rgba(251, 191, 36, 0.55);
  border-radius: 20px; padding: 18px;
  max-width: 410px; width: calc(100% - 28px);
}
dialog::backdrop {
  background: rgba(2, 6, 20, 0.85);
  backdrop-filter: blur(4px);
  overflow: hidden;
  overscroll-behavior: contain;
}
#ticket-poster-img {
  width: 100%; border-radius: 12px; display: block;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
}
