@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg:        #07070f;
  --bg-card:   #0e0e1a;
  --border:    #1e1e36;
  --teal:      #3dd6d6;
  --teal-dim:  #1a8a8a;
  --purple:    #9b6dff;
  --gold:      #c9a84c;
  --danger:    #c9524c;
  --text:      #d0cfe8;
  --text-dim:  #7a799a;
  --radius:    8px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Raleway', sans-serif;
  font-weight: 400;
  line-height: 1.8;
}

/* ── Top bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 2rem;
  background: rgba(7,7,15,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--teal);
  letter-spacing: 0.03em;
  white-space: nowrap;
  justify-self: start;
  text-decoration: none;
}

.topbar-brand:hover { color: #5ae8e8; }

.topbar-page {
  font-weight: 500;
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
}

.topbar-logout {
  font-size: 0.9rem;
  text-align: right;
  white-space: nowrap;
  justify-self: end;
}

.topbar-logout a {
  color: var(--text-dim);
  text-decoration: none;
}

.topbar-logout a:hover { color: var(--teal); }

/* ── Page content ── */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.page h1 {
  font-weight: 700;
  font-size: 1.6rem;
  color: #fff;
  letter-spacing: 0.01em;
  margin-bottom: 1rem;
}

.page h2 {
  font-weight: 600;
  font-size: 1.2rem;
  color: #fff;
  letter-spacing: 0.01em;
  margin: 1.2rem 0 0.75rem;
}

.page p { margin-bottom: 1rem; }

/* ── Centered short-interaction pages (sign in, confirm, messages) ── */
.center-page { text-align: center; }
.center-page form { margin-left: auto; margin-right: auto; }

/* ── Wider forms (e.g. Create World) that need room for a text area ── */
.form-wide { max-width: 560px; }

/* ── Forms centered under a centered .btn-group (e.g. adventure new-direction form) ── */
.form-centered { margin-left: auto; margin-right: auto; align-items: center; }
.form-centered .field { align-items: center; width: 100%; }
.form-centered .field label { text-align: center; }
.form-centered .field input[type="text"] { width: 100%; }

/* ── Prompt heading above the adventure exit buttons/new-direction form ── */
.direction-prompt {
  display: block;
  text-align: center;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  margin: 1.5rem 0 0.75rem;
}

/* ── Forms ── */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
  max-width: 360px;
}

input[type="email"],
input[type="text"],
textarea,
select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  color: var(--text);
  font-family: 'Raleway', sans-serif;
  font-size: 0.95rem;
}

textarea { resize: vertical; line-height: 1.5; }

input[type="email"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--teal-dim);
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field label,
.field-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}

.field-error {
  color: #e08b8b;
  font-size: 0.85rem;
  margin-bottom: 0;
}

.field-success {
  color: var(--teal);
  font-size: 0.85rem;
  margin-bottom: 0;
}

.radio-group { display: flex; flex-direction: column; gap: 0.6rem; }

.radio-option {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.radio-option input[type="radio"] { flex-shrink: 0; accent-color: var(--teal); }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  border-radius: var(--radius);
  font-family: 'Raleway', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--teal);
  color: var(--bg);
  border: 1px solid transparent;
}
.btn-primary:hover { background: #5ae8e8; box-shadow: 0 0 16px rgba(61,214,214,0.4); }

.btn-primary:disabled {
  cursor: default;
  opacity: 0.75;
}
.btn-primary:disabled:hover { background: var(--teal); box-shadow: none; }

.btn-small { padding: 0.45rem 1.1rem; font-size: 0.85rem; }

.btn-spinner {
  display: none;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.5em;
  vertical-align: -0.15em;
  border: 2px solid rgba(7,7,15,0.35);
  border-top-color: var(--bg);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

/* [hidden] and .btn-spinner have equal specificity, so without this the
   author rule above would win over the UA [hidden] rule and the spinner
   would render before the button is ever clicked. */
.btn-spinner:not([hidden]) {
  display: inline-block;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--teal-dim); color: var(--text); }

.btn-danger {
  background: var(--teal);
  color: var(--bg);
  border: 1px solid transparent;
}
.btn-danger:hover { background: #5ae8e8; box-shadow: 0 0 16px rgba(61,214,214,0.4); }

.btn-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 2rem;
}

.btn-group-left { justify-content: flex-start; }

/* A .btn-group used as a form's own trailing button row already sits in the
   form's flex gap — its standalone margin would double up that spacing. */
.btn-group-tight { margin: 0; }

/* A form used only to wrap a single button inside a .btn-group (e.g. the
   delete-confirm page) shouldn't pick up the generic form layout below. */
.btn-group form {
  margin: 0;
  max-width: none;
}

/* ── Adventure screen (location) ── */
.health-status {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.buy-more-link,
.buy-more-link:visited,
.buy-more-link:hover,
.buy-more-link:active {
  color: var(--teal);
  text-decoration: none;
}

.event-text {
  color: var(--gold);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.adventure-ended {
  color: var(--danger);
  font-weight: 600;
  margin-top: 1.5rem;
}

/* ── Adventure list (home screen) ── */
.adventure-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: 100%;
  margin-bottom: 2rem;
}

.adventure-card {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.adventure-card:hover { border-color: var(--teal-dim); }

a.adventure-card,
a.adventure-card:visited,
a.adventure-card:hover,
a.adventure-card:active {
  text-decoration: none;
}

.adventure-select-form {
  flex: 1;
  min-width: 0;
  margin: 0;
  max-width: none;
}

.adventure-delete-form,
.adventure-copy-form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  margin: 0;
  max-width: none;
  padding-right: 0.7rem;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
}

.icon-btn:hover { color: var(--danger); background-color: rgba(201, 82, 76, 0.12); }

.icon-btn svg { width: 18px; height: 18px; }

.copy-worldid-btn:hover,
.settings-worldid-btn:hover {
  color: var(--teal);
  background-color: rgba(61, 214, 214, 0.12);
}
.copy-worldid-btn.copied { color: var(--teal); background-color: rgba(61, 214, 214, 0.12); }

/* ── World settings screen ── */
.field-note {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 0;
}

.email-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.email-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.5rem 0.5rem 1rem;
}

.email-text { font-size: 0.9rem; word-break: break-all; }

.email-remove-form { margin: 0; max-width: none; }

.email-add-form {
  flex-direction: row;
  align-items: center;
  margin-top: 0.5rem;
  max-width: none;
}

.email-add-form input[type="email"] { flex: 1; }

.settings-footer-note {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.settings-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.settings-section h2 { margin-top: 0; }

/* ── Buy credits screen ── */
.buy-credits-note {
  text-align: center;
  margin-bottom: 1.5rem;
}

.paypal-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.paypal-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: #009cde;
}

.tier-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  width: 100%;
}

.tier-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  width: 200px;
  max-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  transition: border-color 0.2s;
}

.tier-card:hover { border-color: var(--teal-dim); }

.tier-amount {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--teal);
}

.tier-credits { color: var(--text-dim); font-size: 0.9rem; }

.tier-card .tier-desc {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
  margin-bottom: 0;
}

.adventure-name {
  display: block;
  width: 100%;
  padding: 1.1rem 1.4rem;
  background: none;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  color: var(--teal);
}

@media (max-width: 600px) {
  .topbar { padding: 0.75rem 1rem; }
  .topbar-page { font-size: 0.85rem; }
  .page { padding: 2rem 1.25rem; }
}
