:root {
  --orange: #FCB918;
  --yellow: #FFE781;
  --red: #C3423F;
  --gradient: linear-gradient(to bottom, #C3423F 0%, #FCB918 100%);
  --dark: #222222;
  --gray: #2a2a2a;
  --light-gray: #e5e5e5;
  --white: #ffffff;
  --text: #222222;
  --text-muted: #6b7280;
  --radius: 16px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  min-height: 100dvh;
  background: var(--white);
  position: relative;
}

/* ---- AUTH SCREEN ---- */
.auth-screen {
  min-height: 100dvh;
  
  align-items: center;
  justify-content: center;
  background: var(--dark);
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: cardIn 0.4s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand {
  background: var(--gradient);
  padding: 40px 32px 32px;
  text-align: center;
  color: white;
}
.auth-brand h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.auth-brand p { font-size: 14px; opacity: 0.85; margin-top: 4px; font-weight: 500; }

.auth-form { padding: 28px 32px 32px; }

.auth-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ---- HEADER (logged-in screens) ---- */
.header {
  background: var(--gradient);
  padding: 48px 24px 32px;
  text-align: center;
  color: white;
}
.header h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.header p { font-size: 14px; opacity: 0.9; margin-top: 4px; }

.logo-circle {
  width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.logo-circle img {
  width: 100%; height: 100%;
  object-fit: contain;
}

.screen { display: none; }
.screen.active { display: block; }
.auth-screen.active { display: flex !important; }

/* ---- POINTS CARD ---- */
.points-card {
  background: var(--gradient);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  color: white;
  margin: -20px 24px 24px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  margin-top: -20px;
  position: relative;
  z-index: 1;
  box-shadow: 0 8px 32px rgba(195,66,63,0.25);
}
.points-card .points-value { font-size: 48px; font-weight: 800; }
.points-card .points-label { font-size: 14px; opacity: 0.9; margin-top: 4px; }
.points-card .member-name { font-size: 18px; font-weight: 600; margin-bottom: 8px; }

.qr-container {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin: 24px auto;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.qr-container img { width: 200px; height: 200px; }
.qr-container p { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.section-title {
  font-size: 16px; font-weight: 700;
  padding: 0 24px; margin: 24px 0 12px;
}

.promo-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 0 24px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-left: 4px solid var(--orange);
}
.promo-card h3 { font-size: 15px; font-weight: 600; }
.promo-card p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.promo-card .promo-cost { font-size: 12px; color: var(--orange); font-weight: 600; margin-top: 6px; }

.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid #f0f0f0;
}
.history-item .hi-info { font-size: 13px; color: var(--text-muted); }
.history-item .hi-points { font-weight: 700; font-size: 15px; }
.history-item .hi-points.earn { color: #16a34a; }
.history-item .hi-points.redeem { color: #dc2626; }

/* ---- FORM ELEMENTS ---- */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.input-group input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
  -webkit-appearance: none;
}
.input-group input:focus { border-color: var(--orange); }

.btn {
  width: 100%; padding: 16px;
  border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700;
  font-family: inherit;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--gradient); color: white; }
.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--light-gray); color: var(--text); }
.btn-link { background: none; color: var(--red); font-weight: 600; padding: 12px; width: auto; margin: 4px auto 0; display: block; }

.code-inputs {
  display: flex; gap: 8px; justify-content: center; margin: 16px 0;
}
.code-inputs input {
  width: 48px; height: 56px;
  text-align: center; font-size: 24px; font-weight: 700;
  border: 2px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
}
.code-inputs input:focus { border-color: var(--orange); }

.error-msg { color: #dc2626; font-size: 13px; text-align: center; margin: 8px 0; }
.success-msg { color: #16a34a; font-size: 13px; text-align: center; margin: 8px 0; }

/* ---- TAB BAR ---- */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid #f0f0f0;
  display: flex;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  z-index: 10;
}
.tab-bar button {
  flex: 1; background: none; border: none;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0; gap: 4px;
  font-size: 11px; color: var(--text-muted);
  cursor: pointer; font-family: inherit;
}
.tab-bar button.active { color: var(--orange); }
.tab-bar button svg { width: 22px; height: 22px; }

/* ---- INSTALL BANNER ---- */
.install-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  background: var(--dark);
  color: white;
  padding: 14px 24px;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.install-banner.show { display: flex; }
.install-banner button {
  background: var(--gradient);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.install-banner .close-banner {
  background: none;
  color: white;
  padding: 4px 8px;
  font-size: 18px;
}

.loading { text-align: center; padding: 40px; color: var(--text-muted); }

.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Account screen */
#accountScreen > div:last-child {
  padding: 24px;
  max-width: 480px;
  margin: 0 auto;
}

/* ---- Tablet+ ---- */
@media (min-width: 640px) {
  .auth-card { max-width: 440px; }
  .auth-brand { padding: 48px 40px 36px; }
  .auth-brand h1 { font-size: 28px; }
  .auth-form { padding: 32px 40px 40px; }

  .header { padding: 56px 32px 40px; }
  .header h1 { font-size: 28px; }
  .header p { font-size: 16px; }

  .logo-circle { width: 88px; height: 88px; font-size: 34px; }

  .points-card {
    max-width: 520px;
    margin: -24px auto 32px;
    padding: 40px 32px;
    border-radius: 20px;
  }
  .points-card .points-value { font-size: 56px; }
  .points-card .member-name { font-size: 20px; }

  .qr-container { max-width: 360px; padding: 32px; }

  .section-title { max-width: 600px; margin-left: auto; margin-right: auto; padding: 0; }
  .promo-card { max-width: 600px; margin-left: auto; margin-right: auto; }
  .history-item { max-width: 600px; margin: 0 auto; padding: 16px 0; }

  .tab-bar button { font-size: 12px; padding: 10px 0; }
  .tab-bar button svg { width: 24px; height: 24px; }

  #homeScreen { padding-bottom: 100px; }
  #historyScreen { padding-bottom: 100px; }
}

/* ---- Desktop ---- */
@media (min-width: 1024px) {
  .header { padding: 64px 40px 48px; }
  .header h1 { font-size: 32px; }

  .points-card { max-width: 560px; padding: 48px 40px; }
  .points-card .points-value { font-size: 64px; }

  .promo-card { max-width: 680px; padding: 20px; }
  .history-item { max-width: 680px; padding: 18px 0; }
  .section-title { max-width: 680px; }

  #accountScreen > div:last-child { max-width: 560px; padding: 32px; }
}
