/* ─── Variables — Sealed brand palette ───────────────────────────────────────── */
:root {
  /* Brand primaries */
  --bg:         #0B0614;
  --surface:    #1A0B30;
  --surface2:   #2B0A4D;
  --surface3:   #3A1260;
  --accent:     #FFD166;
  --accent2:    #FFA500;
  --accent3:    #D100FF;
  --purple:     #6A00FF;
  --text:       #F8F6FF;
  --text-muted: #9A8AB0;
  --border:     #3A2060;
  --border2:    #5A30A0;

  /* Tier colours */
  --good:       #4CAF76;
  --great:      #5B9CF6;
  --fantastic:  #D100FF;
  --perfect:    #FFD166;

  --good-bg:      rgba(76,  175, 118, 0.15);
  --great-bg:     rgba(91,  156, 246, 0.15);
  --fantastic-bg: rgba(209,   0, 255, 0.15);
  --perfect-bg:   rgba(255, 209, 102, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius:    10px;

  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'Monaco', monospace;

  --transition: 0.18s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
}

ul { list-style: none; }

input, textarea, select, button {
  font-family: inherit;
}

img { max-width: 100%; display: block; }

/* ─── Inputs ─────────────────────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 169, 110, 0.2);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
  line-height: 1;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #1a1412;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #1a1412;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
}
.btn-secondary:hover {
  background: var(--surface3);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1.1rem;
  border-radius: var(--radius);
  min-height: 52px;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  min-height: 36px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  padding: 0;
  line-height: 1;
  min-height: 32px;
}
.btn-icon:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Tier chip colours ──────────────────────────────────────────────────────── */
.chip-good {
  background: var(--good-bg);
  color: var(--good);
  border-color: var(--good);
}
.chip-great {
  background: var(--great-bg);
  color: var(--great);
  border-color: var(--great);
}
.chip-fantastic {
  background: var(--fantastic-bg);
  color: var(--fantastic);
  border-color: var(--fantastic);
}
.chip-perfect {
  background: var(--perfect-bg);
  color: var(--perfect);
  border-color: var(--perfect);
}

/* ─── Tier badge ─────────────────────────────────────────────────────────────── */
.badge-good,
.badge-great,
.badge-fantastic,
.badge-perfect {
  display: inline-block;
  padding: 0.2em 0.7em;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-good      { background: var(--good-bg);      color: var(--good);      border: 1px solid var(--good); }
.badge-great     { background: var(--great-bg);     color: var(--great);     border: 1px solid var(--great); }
.badge-fantastic { background: var(--fantastic-bg); color: var(--fantastic); border: 1px solid var(--fantastic); }
.badge-perfect   { background: var(--perfect-bg);   color: var(--perfect);   border: 1px solid var(--perfect); }

/* ─── Tier chips row ─────────────────────────────────────────────────────────── */
.tier-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.tier-chip-label {
  display: inline-flex;
  cursor: pointer;
}
.tier-chip-label input[type="radio"] {
  display: none;
  width: auto;
}
.tier-chip-label input[type="radio"]:checked + .tier-chip {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}

.tier-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3em 0.75em;
  border-radius: 100px;
  border: 1.5px solid transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap;
  min-height: 30px;
  opacity: 0.55;
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}

.tier-chip:hover {
  opacity: 0.85;
}

.tier-chip.active,
.tier-chip[data-active="true"] {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px currentColor;
}

.tier-chip.chip-good.active,
.tier-chip.chip-good[data-active="true"] {
  background: var(--good-bg);
  color: var(--good);
  border-color: var(--good);
}
.tier-chip.chip-great.active,
.tier-chip.chip-great[data-active="true"] {
  background: var(--great-bg);
  color: var(--great);
  border-color: var(--great);
}
.tier-chip.chip-fantastic.active,
.tier-chip.chip-fantastic[data-active="true"] {
  background: var(--fantastic-bg);
  color: var(--fantastic);
  border-color: var(--fantastic);
}
.tier-chip.chip-perfect.active,
.tier-chip.chip-perfect[data-active="true"] {
  background: var(--perfect-bg);
  color: var(--perfect);
  border-color: var(--perfect);
}

/* ─── Code input ─────────────────────────────────────────────────────────────── */
.code-input {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.75rem 1rem;
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border2);
  border-radius: var(--radius);
  color: var(--accent2);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.2);
}

.name-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  margin-top: 0.5rem;
}
.name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.2);
}

/* ─── Role buttons ───────────────────────────────────────────────────────────── */
.role-btns {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.role-btns .btn {
  flex: 1;
}

/* ─── Form error ─────────────────────────────────────────────────────────────── */
.form-error {
  color: #e87b5a;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

/* ─── Phase visibility ───────────────────────────────────────────────────────── */
.phase.hidden { display: none !important; }
.hidden { display: none !important; }

/* ─── Landing page ───────────────────────────────────────────────────────────── */
body.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
}

.landing-wrap {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.landing-hero {
  text-align: center;
}

.landing-logo {
  width: min(320px, 80vw);
  height: auto;
  display: block;
  margin: 0 auto 0.75rem;
  filter: drop-shadow(0 0 24px rgba(255, 209, 102, 0.35));
}

.tagline {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-top: 0.4rem;
}

.landing-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
}

@media (max-width: 540px) {
  .landing-cards {
    grid-template-columns: 1fr;
  }
}

.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.landing-card.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface) 100%);
  box-shadow: 0 0 30px rgba(200, 169, 110, 0.1);
}

.landing-card h2 {
  font-size: 1.2rem;
  color: var(--accent2);
}

.landing-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.landing-bank {
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* ─── Back link ──────────────────────────────────────────────────────────────── */
.back-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  transition: color var(--transition);
}
.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 1rem;
}

/* ─── Toast notification ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  white-space: nowrap;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.error {
  border-color: var(--perfect);
  color: var(--perfect);
}

/* ─── Bank page ──────────────────────────────────────────────────────────────── */
body.bank-screen {
  padding: 0;
}

.bank-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.bank-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.bank-header h1 {
  font-size: 1.5rem;
  color: var(--accent2);
}

.bank-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.55;
}

.bank-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.bank-input {
  font-size: 1rem;
  width: 100%;
}

.bank-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.bank-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
}

.bank-tier-badge {
  flex-shrink: 0;
}

.bank-date-text {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bank-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.inline-delete {
  display: inline-flex;
  margin: 0;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

/* ─── Reconnect overlay ──────────────────────────────────────────────────────── */
#reconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 20, 18, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(4px);
}
#reconnect-overlay p {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  animation: pulse-text 1.4s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* ─── Mute toggle ────────────────────────────────────────────────────────────── */
#mute-btn {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 9001;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.1rem;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  padding: 0;
  line-height: 1;
}
#mute-btn:hover {
  background: var(--surface3);
  color: var(--text);
}
#mute-btn.muted {
  color: var(--text-muted);
  opacity: 0.5;
}
