:root {
  --pi-purple: #7d2ae8;
  --pi-purple-deep: #5b21b6;
  --gold: #f5b301;
  --bg: #0f0a1e;
  --surface: #1a1230;
  --text: #f5f2ff;
  --muted: #a99ec9;
  --danger: #ff6b6b;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

/* Layout rules below use display:flex/grid, which would otherwise defeat the
   [hidden] attribute the auth UI toggles. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 80% at 50% 0%, #241645 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--pi-purple), var(--pi-purple-deep));
  color: #fff;
  font-size: 18px;
}

.brand-name {
  letter-spacing: -0.02em;
}

.auth {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.auth-status[data-state="error"] {
  color: var(--danger);
}

.auth-status[data-state="authenticated"] {
  color: var(--gold);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(140deg, var(--pi-purple), var(--pi-purple-deep));
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

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

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
  color: var(--gold);
}

.account-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.account-meta small {
  color: var(--muted);
  font-size: 12px;
}

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

.alert {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffd5d5;
  font-size: 14px;
}

/* Not an error: the app simply isn't running inside a Pi host app yet. */
.alert[data-tone="info"] {
  background: rgba(125, 42, 232, 0.15);
  border-color: rgba(125, 42, 232, 0.45);
  color: #e6dcff;
}

.card {
  margin-top: 28px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.payment-status {
  margin: 14px 0 0;
  font-size: 13px;
  word-break: break-word;
}

.payment-status[data-kind="ok"] {
  color: #7ee08a;
}

.payment-status[data-kind="error"] {
  color: var(--danger);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .auth-status {
    display: none;
  }
}

/* Debug panel (?debug=1) — the only console available inside Pi Browser. */
.debug-panel {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 999;
  background: rgba(6, 3, 15, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #cfc4ee;
}

.debug-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--gold);
}

.debug-panel button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: inherit;
  margin-left: 6px;
  padding: 3px 8px;
  font: inherit;
  cursor: pointer;
}

.debug-panel ol {
  list-style: none;
  margin: 0;
  padding: 8px 10px;
  max-height: 40vh;
  overflow-y: auto;
}

.debug-panel li {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  word-break: break-word;
}

.debug-panel li[data-kind="error"] {
  color: #ff9d9d;
}
