/* ============================================================
   1st C&A: Traitors — dark candlelit castle theme
   Built on the Scouts design tokens (Nunito Sans + purple thread)
   ============================================================ */

:root {
  /* --- Night / castle surfaces --- */
  --t-void:    #07050b;   /* deepest black, page base */
  --t-bg:      #0c0812;   /* app background */
  --t-bg2:     #120c1c;   /* raised section */
  --t-panel:   #1a1226;   /* card / plaque face */
  --t-panel2:  #221733;   /* hover / inset */
  --t-line:    #2c2140;   /* hairline borders */
  --t-line2:   #3a2c54;   /* stronger border */

  /* --- Candlelight + gold --- */
  --t-gold:        #e6b34d;
  --t-gold-bright: #f6d488;
  --t-gold-dim:    #9a7634;
  --t-candle:      #ffb24d;  /* flame glow */

  /* --- Allegiance --- */
  --t-traitor:        #c0202a;   /* blood red */
  --t-traitor-deep:   #6e0f14;
  --t-traitor-glow:   #ff3b46;
  --t-faithful:       #1f9d6b;   /* emerald */
  --t-faithful-deep:  #0c4d35;
  --t-faithful-glow:  #43e0a0;

  /* --- Scout brand thread --- */
  --t-purple:       #7413dc;
  --t-purple-bright:#a866f0;

  /* --- Text --- */
  --t-fg:      #f3eefb;
  --t-fg2:     #c5bcd8;
  --t-fg3:     #8d83a6;
  --t-fg-faint:#5f5775;

  --t-font: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* radii — poster-square per brand */
  --t-r-sm: 6px;
  --t-r-md: 12px;
  --t-r-lg: 20px;

  --t-ease: cubic-bezier(.2, .7, .2, 1);
  --t-dur:  200ms;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--t-void);
  color: var(--t-fg);
  font-family: var(--t-font);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

#root { min-height: 100dvh; }

/* The candlelit room — a fixed atmospheric backdrop behind everything */
.t-room {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, #2a1840 0%, transparent 55%),
    radial-gradient(90% 60% at 12% 8%, rgba(230,179,77,.10) 0%, transparent 45%),
    radial-gradient(90% 60% at 88% 90%, rgba(192,32,42,.08) 0%, transparent 50%),
    radial-gradient(140% 120% at 50% 120%, #0e0818 0%, var(--t-void) 70%);
}
.t-room::after {  /* vignette */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(110% 90% at 50% 40%, transparent 45%, rgba(0,0,0,.7) 100%);
}

.t-app {
  position: relative; z-index: 1;
  max-width: 520px; margin: 0 auto;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}

/* ---------------- Type ---------------- */
.t-eyebrow {
  font-size: .72rem; font-weight: 800; letter-spacing: .32em;
  text-transform: uppercase; color: var(--t-gold);
  margin: 0;
}
.t-kicker {
  font-size: .68rem; font-weight: 700; letter-spacing: .26em;
  text-transform: uppercase; color: var(--t-fg3); margin: 0;
}
h1.t-h1 {
  font-weight: 900; line-height: .98; letter-spacing: -.01em;
  font-size: clamp(2.6rem, 11vw, 3.6rem); margin: 0;
}
h2.t-h2 {
  font-weight: 900; line-height: 1.02; letter-spacing: -.01em;
  font-size: clamp(1.8rem, 7vw, 2.4rem); margin: 0;
}
.t-serif { font-style: normal; }
.t-body { font-weight: 300; color: var(--t-fg2); line-height: 1.55; }
.t-muted { color: var(--t-fg3); }
.t-gold { color: var(--t-gold); }

/* gold hairline rule with centre diamond */
.t-rule { display: flex; align-items: center; gap: 12px; color: var(--t-gold-dim); }
.t-rule::before, .t-rule::after {
  content: ""; height: 1px; flex: 1;
  background: linear-gradient(90deg, transparent, var(--t-gold-dim), transparent);
}
.t-rule .diamond { width: 6px; height: 6px; background: var(--t-gold); transform: rotate(45deg); }

/* ---------------- Buttons ---------------- */
.t-btn {
  appearance: none; border: 0; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 17px 22px;
  font-size: 1rem; font-weight: 800; letter-spacing: .04em;
  border-radius: var(--t-r-md);
  transition: transform var(--t-dur) var(--t-ease), background var(--t-dur), box-shadow var(--t-dur);
}
.t-btn:active { transform: scale(.97); }
.t-btn:disabled { opacity: .4; cursor: not-allowed; }

.t-btn--gold {
  background: linear-gradient(180deg, var(--t-gold-bright), var(--t-gold));
  color: #2a1c05; text-transform: uppercase; letter-spacing: .12em;
  box-shadow: 0 0 0 1px var(--t-gold-dim), 0 8px 28px rgba(230,179,77,.22);
}
.t-btn--gold:hover { box-shadow: 0 0 0 1px var(--t-gold-bright), 0 10px 34px rgba(230,179,77,.34); }

.t-btn--ghost {
  background: transparent; color: var(--t-fg);
  box-shadow: inset 0 0 0 1px var(--t-line2);
}
.t-btn--ghost:hover { background: var(--t-panel); box-shadow: inset 0 0 0 1px var(--t-gold-dim); }

.t-btn--danger {
  background: linear-gradient(180deg, #d8323b, var(--t-traitor));
  color: #fff; text-transform: uppercase; letter-spacing: .1em;
  box-shadow: 0 0 0 1px var(--t-traitor-deep), 0 8px 28px rgba(192,32,42,.32);
}
.t-btn--purple {
  background: var(--t-purple); color: #fff; text-transform: uppercase; letter-spacing: .1em;
  box-shadow: 0 0 0 1px #5a0fae, 0 8px 24px rgba(116,19,220,.32);
}
.t-btn--sm { width: auto; padding: 11px 16px; font-size: .82rem; }

/* ---------------- Panels / cards ---------------- */
.t-card {
  background: linear-gradient(180deg, var(--t-panel), var(--t-bg2));
  border: 1px solid var(--t-line);
  border-radius: var(--t-r-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), 0 18px 50px rgba(0,0,0,.5);
}

.t-field {
  width: 100%; padding: 16px 18px; font-family: inherit; font-size: 1.05rem; font-weight: 600;
  color: var(--t-fg); background: var(--t-bg); border: 1px solid var(--t-line2);
  border-radius: var(--t-r-md); outline: none; transition: border var(--t-dur), box-shadow var(--t-dur);
}
.t-field::placeholder { color: var(--t-fg-faint); font-weight: 400; }
.t-field:focus { border-color: var(--t-gold); box-shadow: 0 0 0 3px rgba(230,179,77,.18); }

.t-code-field {
  text-align: center; letter-spacing: .5em; text-transform: uppercase;
  font-weight: 900; font-size: 1.6rem; padding-left: .5em;
}

/* ---------------- Candle flame ---------------- */
.t-candle { position: relative; width: 14px; height: 30px; display: inline-block; }
.t-candle .flame {
  position: absolute; left: 50%; top: 0; width: 10px; height: 18px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 70%, #fff7d6 0%, var(--t-candle) 45%, #ff6a1f 80%, transparent 100%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  filter: blur(.4px);
  transform-origin: 50% 100%;
  animation: t-flicker 1.6s ease-in-out infinite;
  box-shadow: 0 0 18px 4px rgba(255,150,40,.45);
}
.t-candle .stick {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 6px; height: 14px; border-radius: 2px;
  background: linear-gradient(180deg, #efe3c4, #b9a06a);
}
@keyframes t-flicker {
  0%,100% { transform: translateX(-50%) scaleY(1) rotate(-1deg); opacity: .95; }
  25%     { transform: translateX(-52%) scaleY(1.08) rotate(1deg); opacity: 1; }
  50%     { transform: translateX(-49%) scaleY(.94) rotate(-1.5deg); opacity: .9; }
  75%     { transform: translateX(-51%) scaleY(1.04) rotate(1.5deg); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .t-candle .flame { animation: none; }
}

/* ---------------- Layout helpers ---------------- */
.t-stack { display: flex; flex-direction: column; }
.t-pad { padding: 22px; }
.t-screen { flex: 1; display: flex; flex-direction: column; padding: 22px; gap: 18px; }
.t-center { align-items: center; text-align: center; justify-content: center; }
.t-spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.t-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: var(--t-r-pill, 999px);
  font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--t-line2); color: var(--t-fg2); background: var(--t-bg);
}
.t-pill--gold { color: var(--t-gold); border-color: var(--t-gold-dim); }
.t-pill--red  { color: #ff9aa0; border-color: var(--t-traitor-deep); background: rgba(192,32,42,.12); }
.t-pill--green{ color: var(--t-faithful-glow); border-color: var(--t-faithful-deep); background: rgba(31,157,107,.12); }

/* fade/slide entrance — capture-safe (no opacity:0 base) */
.t-enter { animation: t-enter var(--t-dur) var(--t-ease) both; }
@keyframes t-enter { from { transform: translateY(9px); } to { transform: none; } }

/* scrollable region */
.t-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.t-scroll::-webkit-scrollbar { width: 0; }

/* sticky footer action bar */
.t-actionbar {
  position: sticky; bottom: 0; z-index: 5;
  padding: 16px 22px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--t-bg) 30%);
  display: flex; flex-direction: column; gap: 10px;
}
