:root {
  --violet: #7c3aed;
  --violet-dark: #4c1d95;
  --violet-soft: #ede9fe;
  --gold: #fbbf24;
  --gold-soft: #fef3c7;
  --white: #ffffff;
  --text: #f8fafc;
  --muted: #a5b4fc;
  --danger: #f87171;
  --ok: #4ade80;
  --touch: 48px;
  --surface: rgba(30, 27, 75, 0.88);
  --surface-border: rgba(167, 139, 250, 0.35);
}

* { box-sizing: border-box; }

body.app-shell {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  background: #0f0a1e;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 100% 70% at 50% -10%, rgba(124, 58, 237, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 60%, rgba(251, 191, 36, 0.15) 0%, transparent 50%),
    linear-gradient(165deg, #0f0a1e 0%, #1e1b4b 40%, #312e81 100%);
}

.app-header,
.app-main,
.bottom-nav {
  position: relative;
  z-index: 1;
}

.app-header {
  padding: 1rem 1rem 0.5rem;
}

.brand-plate {
  text-align: center;
  margin-bottom: 0.75rem;
}

.brand-wordmark {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-igame { color: var(--white); }
.brand-360 { color: var(--gold); }
.brand-select-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--violet-dark);
  background: linear-gradient(135deg, var(--gold), #f59e0b);
  border-radius: 999px;
  vertical-align: middle;
}

.brand-tagline {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.greeting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.65rem;
}

.greeting-personal {
  margin: 0;
  font-weight: 600;
  flex: 1 1 auto;
  font-size: 1.05rem;
}

.greeting-cycle {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
}

.greeting-sub {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  width: 100%;
  line-height: 1.45;
}

.cycle-chip {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.35);
  border: 1px solid var(--surface-border);
}

.cycle-chip.is-live {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(74, 222, 128, 0.45);
  color: #86efac;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-left: auto;
}

.header-action-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  text-decoration: none;
  padding: 0.2rem 0.35rem;
}

.header-action-link:hover,
.header-action-link:focus-visible {
  text-decoration: underline;
}

.header-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.1);
  color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}

.header-help-btn:hover,
.header-help-btn:focus-visible {
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.55);
}

.header-help-icon {
  display: block;
}

.header-action-btn {
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  line-height: 1.2;
}

.header-action-signout {
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.header-action-signout:hover,
.header-action-signout:focus-visible {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.55);
}

.account-auth-group {
  margin-left: auto;
}

.account-auth-link {
  font-size: 0.85rem;
  color: var(--gold);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}

.app-main {
  padding: 0 1rem 1rem;
  max-width: 480px;
  margin: 0 auto;
}

.surface-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  backdrop-filter: blur(12px);
}

.surface-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.empty-state { margin: 0.5rem 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0.65rem 1.1rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.btn-block { width: 100%; }
.btn.primary {
  background: linear-gradient(135deg, var(--violet), #6d28d9);
  color: var(--white);
}
.btn.secondary {
  background: rgba(124, 58, 237, 0.35);
  color: var(--white);
  border: 1px solid var(--surface-border);
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--surface-border);
}
.btn:disabled,
.btn.is-busy {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.form-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0.5rem 0 0;
}

.status-banner {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid var(--surface-border);
}

.status-banner.ok { border-color: rgba(74, 222, 128, 0.4); color: var(--ok); }
.status-banner.err { border-color: rgba(248, 113, 113, 0.4); color: var(--danger); }

.invite-banner {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  font-size: 0.9rem;
  line-height: 1.5;
}

.invite-banner.is-info {
  background: rgba(124, 58, 237, 0.18);
  border-color: rgba(167, 139, 250, 0.4);
}

.invite-banner.is-ended {
  background: rgba(49, 46, 69, 0.75);
  border-color: rgba(148, 113, 113, 0.4);
}

.invite-banner.is-ended strong {
  color: #e9d5ff;
}

.game-status-card.is-ended {
  background: rgba(49, 46, 69, 0.65);
  border-color: rgba(167, 139, 250, 0.25);
}

.game-status-card.is-ended strong {
  color: #c4b5fd;
}

.invite-banner .muted {
  display: block;
  margin-top: 0.35rem;
}

.game-status-card {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.85rem;
  background: rgba(49, 46, 129, 0.6);
  border: 1px solid var(--surface-border);
}

.game-status-card.is-live {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(74, 222, 128, 0.4);
}

.game-status-card.is-live strong,
.game-status-card.is-live .game-status-body strong {
  color: #86efac;
}

.game-status-card.is-not-invited {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.35);
}

.game-status-card.is-not-invited strong,
.game-status-card.is-not-invited .game-status-body strong {
  color: #fca5a5;
}

.access-card.is-not-invited {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.06);
  margin-bottom: 0.85rem;
}

.access-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.access-status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #f87171;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.access-card.is-not-invited h2 {
  color: #fca5a5;
  margin: 0;
  font-size: 1.05rem;
}

.access-icon-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.access-icon-item {
  display: grid;
  gap: 0.15rem;
  justify-items: center;
  padding: 0.45rem 0.25rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.access-icon-item span {
  font-size: 1.25rem;
  line-height: 1;
}

.access-icon-item small {
  font-size: 0.62rem;
  color: rgba(196, 181, 253, 0.85);
  line-height: 1.2;
  text-align: center;
}

.access-icon-pulse span {
  animation: access-soft-pulse 2.8s ease-in-out infinite;
}

@keyframes access-soft-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}

.access-lead {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.prize-board {
  display: grid;
  gap: 0.5rem;
}

.prize-tier {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(15, 10, 30, 0.5);
}

.prize-tier.legacy { border-left: 3px solid var(--gold); }
.prize-tier.fortune { border-left: 3px solid var(--violet); }
.prize-tier.prestige { border-left: 3px solid var(--muted); }

.ticket-card {
  display: block;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 12px;
  background: rgba(15, 10, 30, 0.55);
  border: 1px solid var(--surface-border);
}

.ticket-card-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.ticket-card.won {
  border-color: rgba(74, 222, 128, 0.5);
  background: rgba(20, 45, 35, 0.45);
}

.ticket-card.won.is-paid-out {
  border-color: rgba(134, 239, 172, 0.65);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.15);
}
.ticket-card.lost {
  background: rgba(30, 20, 40, 0.45);
  border-color: rgba(148, 113, 113, 0.35);
}
.ticket-card.lost .ticket-code {
  color: #c4b5fd;
  opacity: 0.85;
}
.ticket-card.lost .ticket-type {
  color: #a78bfa;
  opacity: 0.75;
}

.ticket-code {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.ticket-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
}

.ticket-state {
  font-size: 0.8rem;
  font-weight: 600;
}

.ticket-state.won { color: var(--ok); }
.ticket-state.paid { color: #a5b4fc; }
.ticket-state.lost { color: #f0abfc; }

.ticket-win-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(74, 222, 128, 0.2);
}

.ticket-win-amount {
  font-size: 1rem;
  color: #86efac;
}

.win-payout-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.win-payout-badge.paid {
  background: rgba(220, 252, 231, 0.95);
  color: #166534;
  border: 1px solid #86efac;
}

.win-payout-badge.pending {
  background: rgba(254, 243, 199, 0.95);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.win-payout-badge.failed {
  background: rgba(254, 226, 226, 0.95);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.win-payout-dot { font-weight: 900; }

.result-win-lead {
  margin: 0 0 0.75rem;
  color: #c4b5fd;
  font-size: 0.9rem;
}

.result-win-card {
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.65rem;
  border-radius: 12px;
  background: rgba(20, 45, 35, 0.45);
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.result-win-card.legacy { border-left: 3px solid var(--gold); }
.result-win-card.fortune { border-left: 3px solid var(--violet); }
.result-win-card.prestige { border-left: 3px solid var(--muted); }

.result-win-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.result-win-tier {
  font-weight: 700;
  color: #86efac;
}

.result-win-amount {
  font-size: 1.1rem;
  color: #ecfccb;
}

.result-win-ticket {
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.ticket-code-inline {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  color: #e9d5ff;
}

.result-win-payout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.result-win-payout-note {
  font-size: 0.78rem;
  color: #a7f3d0;
}

.referral-lead { margin: 0 0 0.35rem; font-size: 0.9rem; line-height: 1.45; }

.ambassador-details {
  margin-top: 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  background: rgba(30, 27, 75, 0.35);
  padding: 0.55rem 0.75rem;
}

.ambassador-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: #c4b5fd;
}

.ambassador-panel { margin-top: 0.65rem; }

.ambassador-badge-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.25);
}

.ambassador-badge-row.is-earned {
  border-color: rgba(250, 204, 21, 0.45);
  background: rgba(250, 204, 21, 0.08);
}

.ambassador-badge-icon {
  font-size: 1.35rem;
  line-height: 1;
  color: #fbbf24;
}

.ambassador-badge-progress { margin: 0.2rem 0 0; font-size: 0.82rem; }

.ambassador-copy { margin: 0.35rem 0; font-size: 0.82rem; line-height: 1.45; }

.ambassador-celebration-card {
  border-color: rgba(250, 204, 21, 0.35);
  background: linear-gradient(145deg, rgba(250, 204, 21, 0.1), rgba(124, 58, 237, 0.2));
}

.ambassador-celebration-card.is-pending {
  border-color: rgba(167, 139, 250, 0.35);
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.22), rgba(30, 27, 75, 0.5));
}

.ambassador-celebration-body {
  display: grid;
  gap: 0.65rem;
  text-align: center;
}

.ambassador-celebration-icon {
  font-size: 2.25rem;
  line-height: 1;
  color: #fbbf24;
}

.ambassador-celebration-body h2 {
  margin: 0;
  font-size: 1.15rem;
}

.ambassador-celebration-tagline {
  margin: 0;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.95rem;
}

.ambassador-celebration-body .muted {
  margin: 0;
  line-height: 1.45;
}

.ambassador-celebration-link {
  display: inline-block;
  margin-top: 0.25rem;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}

.ambassador-celebration-link:hover,
.ambassador-celebration-link:focus-visible {
  text-decoration: underline;
}

.ambassador-progress-pill {
  display: inline-block;
  margin: 0.15rem auto 0;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(124, 58, 237, 0.35);
  border: 1px solid rgba(167, 139, 250, 0.35);
}

.ambassador-celebration-card.is-earned .ambassador-progress-pill {
  background: rgba(250, 204, 21, 0.15);
  border-color: rgba(250, 204, 21, 0.4);
  color: #fde68a;
}

.entitlement-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(167, 139, 250, 0.15);
}

.referral-stats { margin: 0.35rem 0; }

.referral-share-panel {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(167, 139, 250, 0.28);
  background: rgba(30, 27, 75, 0.55);
}

.referral-share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.referral-share-head strong { font-size: 0.95rem; }

.referral-share-close {
  min-width: 2.25rem;
  min-height: 2.25rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.referral-share-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
}

.referral-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.referral-qr-canvas {
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.35rem;
  max-width: 100%;
  height: auto;
}

.referral-qr-fallback {
  margin: 0;
  font-size: 0.82rem;
  text-align: center;
}

.referral-link-preview {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  word-break: break-all;
  line-height: 1.4;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.referral-share-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.share-chip {
  min-height: 2.75rem;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  background: rgba(124, 58, 237, 0.22);
  color: var(--white);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.share-chip:active { transform: scale(0.98); }

.share-chip-wa {
  border-color: rgba(37, 211, 102, 0.45);
  background: rgba(37, 211, 102, 0.15);
}

.hint.err { color: var(--err, #f87171); font-size: 0.85rem; }

.sent-invites {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.hint.ok { color: var(--ok); font-size: 0.85rem; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(15, 10, 30, 0.95);
  border-top: 1px solid var(--surface-border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.nav-item {
  flex: 1;
  min-height: var(--touch);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-item.active {
  color: var(--gold);
}

.nav-item-hub {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border: none;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

.nav-item-hub:hover,
.nav-item-hub:focus-visible {
  color: var(--gold);
}

.expand-panel {
  margin: 0.75rem 0 0;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  overflow: hidden;
}

.expand-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
}

.expand-summary::-webkit-details-marker { display: none; }

.summary-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.summary-text small {
  color: var(--muted);
  font-size: 0.78rem;
}

.result-board-body { padding: 0 1rem 1rem; }

.result-board-lead,
.result-board-note {
  margin: 0.35rem 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.result-board-cycle {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.result-board-list {
  display: grid;
  gap: 0.5rem;
}

.result-board-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: rgba(15, 10, 30, 0.55);
}

.result-board-cat { font-weight: 700; font-size: 0.85rem; }
.result-board-code { font-size: 0.82rem; letter-spacing: 0.04em; }
.result-board-status {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.result-board-row.is-won {
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.1);
}
.result-board-row.is-won .result-board-status { color: var(--ok); }
.result-board-row.is-none {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.1);
}
.result-board-row.is-none .result-board-status { color: var(--danger); }

[hidden] { display: none !important; }

.payment-help-link { color: var(--gold); }

@media (min-width: 520px) {
  .app-main { padding-left: 1.25rem; padding-right: 1.25rem; }
}
