/* ============================================================
   Theme system - see css/themes.css for the 4 theme definitions (War
   Room / Gold Rush / Blood Market / Light), switched via data-theme on
   <html>. Every color used below is a token from that file; this file
   only owns non-color structural tokens (radius/font/mono).
   ============================================================ */
:root {
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

.mono,
.topbar-pnl-value,
.position-row .pnl,
table td.mono,
[data-pnl] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

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

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5em 0;
  font-weight: 700;
}

p {
  margin: 0 0 1em 0;
  color: var(--text-secondary);
}

.hidden {
  display: none !important;
}

/* ---- layout shell ---------------------------------------------------- */

.tw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tw-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tw-logo span {
  color: var(--accent);
}

.tw-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tw-coin-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  color: var(--gold);
  cursor: pointer;
}

.tw-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.btn:not(.btn-primary):not(.btn-buy):not(.btn-sell):not(.btn-outline):hover {
  background: var(--bg-surface-3);
  border-color: var(--border-normal);
}

.btn:active {
  transform: scale(0.97) translateY(0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Primary/CTA buttons (Quick Play, Save, Submit, ...) are always GOLD - the
   COD-style "menu chrome" accent - via --accent-teal, which every theme in
   themes.css aliases to its own --gold value (not literally teal anymore;
   the name is legacy so main.css/premium.css's many existing consumers
   don't all need renaming - see themes.css's file header). */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-teal-dark) 100%);
  color: var(--btn-primary-text);
  font-weight: 700;
  border: none;
}

.btn-primary:hover {
  box-shadow: 0 0 25px var(--gold-glow), 0 4px 15px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-teal-dark) 100%);
}

/* Buy is a trading action, not a generic "primary" one - it stays green (or
   Midnight's purple) in every theme by using --buy-color instead of the
   shifting brand accent, which is gold almost everywhere now. */
.btn-buy {
  background: linear-gradient(135deg, var(--buy-color) 0%, var(--buy-color-dark) 100%);
  color: var(--btn-primary-text);
  font-weight: 700;
  border: none;
}

.btn-buy:hover {
  box-shadow: 0 0 25px var(--glow-teal), 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-sell {
  background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-red-dark) 100%);
  color: #ffffff;
  font-weight: 700;
  border: none;
}

.btn-sell:hover {
  box-shadow: 0 0 25px var(--glow-red), 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-outline {
  background: transparent;
  border-color: var(--accent-teal);
  color: var(--accent-teal);
}

.btn-outline:hover {
  background: var(--gold-subtle);
  box-shadow: 0 0 15px var(--gold-glow);
}

.btn-block {
  width: 100%;
}

/* ---- forms --------------------------------------------------------------- */

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px var(--input-focus);
}

.field.error input,
.field.error select,
.field input.error,
.field select.error {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 3px var(--red-subtle);
}

.form-error {
  color: var(--sell);
  font-size: 13px;
  min-height: 18px;
  margin-top: 6px;
}

/* ---- cards / surfaces ------------------------------------------------------ */

.panel {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.pill-gold {
  color: var(--gold);
  border-color: var(--gold);
}

.text-buy {
  color: var(--buy);
  text-shadow: 0 0 20px var(--glow-teal);
}

.text-sell {
  color: var(--sell);
  text-shadow: 0 0 20px var(--glow-red);
}

.text-warning {
  color: var(--warning);
}

.text-secondary {
  color: var(--text-secondary);
}

.mono {
  font-family: var(--mono);
}

/* ---- tier badges -------------------------------------------------------- */

.tier-Recruit,
.tier-Trader,
.tier-Broker,
.tier-Analyst,
.tier-Veteran,
.tier-Elite,
.tier-War\.Lord {
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}

.tier-Recruit {
  color: var(--tier-recruit);
}
.tier-Trader {
  color: var(--tier-trader);
}
.tier-Broker {
  color: var(--tier-broker);
}
.tier-Analyst {
  color: var(--tier-analyst);
}
.tier-Veteran {
  color: var(--tier-veteran);
}
.tier-Elite {
  color: var(--tier-elite);
}
.tier-War\.Lord {
  background: linear-gradient(135deg, var(--tier-warlord) 0%, var(--accent-gold-dark) 100%);
  color: var(--btn-cta-text, #000000);
  font-weight: 800;
  box-shadow: 0 0 15px var(--gold-glow);
  border: none;
}

/* ---- logo ("Spike & Crush" - staircase wordmark) ----------------------- */

.sc-logo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sc-logo {
  display: inline-flex;
  align-items: flex-end;
  gap: 0px;
  line-height: 1;
}

.sc-logo-tagline {
  display: block;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  margin-top: 16px;
  font-family: var(--mono, monospace);
  text-transform: uppercase;
  text-align: center;
}

.sc-s1,
.sc-p,
.sc-i,
.sc-k,
.sc-e,
.sc-amp,
.sc-c,
.sc-r,
.sc-u,
.sc-s2,
.sc-h {
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.02em;
  display: inline-block;
  line-height: 1;
}

.sc-s1 { font-size: 28px; color: #008F6A; text-shadow: 0 0 20px #008F6A66; }
.sc-p  { font-size: 34px; color: #00A87C; text-shadow: 0 0 20px #00A87C66; }
.sc-i  { font-size: 40px; color: #00C896; text-shadow: 0 0 20px #00C89666; }
.sc-k  { font-size: 46px; color: #00E0AA; text-shadow: 0 0 20px #00E0AA66; }
.sc-e  { font-size: 52px; color: #00FF88; text-shadow: 0 0 20px #00FF8866; }
.sc-amp {
  font-size: 56px;
  color: #FFFFFF;
  opacity: 0.9;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
  margin: 0 2px;
  letter-spacing: normal;
}
.sc-c  { font-size: 52px; color: #FF4444; text-shadow: 0 0 20px #FF444466; }
.sc-r  { font-size: 46px; color: #EE3333; text-shadow: 0 0 20px #EE333366; }
.sc-u  { font-size: 40px; color: #DD2222; text-shadow: 0 0 20px #DD222266; }
.sc-s2 { font-size: 34px; color: #CC1111; text-shadow: 0 0 20px #CC111166; }
.sc-h  { font-size: 28px; color: #BB0000; text-shadow: 0 0 20px #BB000066; }

/* nav bar version: real font-size overrides (~0.45x) rather than transform:scale,
   since scale() doesn't shrink the layout box and let the navbar's flexbox
   crop the oversized box instead of rendering it small */
.nav-logo {
  display: flex;
  align-items: flex-end;
}

.nav-logo .sc-s1 { font-size: 13px; }
.nav-logo .sc-p  { font-size: 15px; }
.nav-logo .sc-i  { font-size: 18px; }
.nav-logo .sc-k  { font-size: 21px; }
.nav-logo .sc-e  { font-size: 23px; }
.nav-logo .sc-amp{ font-size: 25px; }
.nav-logo .sc-c  { font-size: 23px; }
.nav-logo .sc-r  { font-size: 21px; }
.nav-logo .sc-u  { font-size: 18px; }
.nav-logo .sc-s2 { font-size: 15px; }
.nav-logo .sc-h  { font-size: 13px; }

.nav-logo .sc-logo-tagline {
  display: none;
}

/* home page hero entrance animation - hero logo only */
@keyframes spikeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-logo .sc-s1 { animation: spikeIn 0.3s ease 0.0s both; }
.hero-logo .sc-p  { animation: spikeIn 0.3s ease 0.05s both; }
.hero-logo .sc-i  { animation: spikeIn 0.3s ease 0.10s both; }
.hero-logo .sc-k  { animation: spikeIn 0.3s ease 0.15s both; }
.hero-logo .sc-e  { animation: spikeIn 0.3s ease 0.20s both; }
.hero-logo .sc-amp{ animation: spikeIn 0.3s ease 0.25s both; }
.hero-logo .sc-c  { animation: spikeIn 0.3s ease 0.30s both; }
.hero-logo .sc-r  { animation: spikeIn 0.3s ease 0.35s both; }
.hero-logo .sc-u  { animation: spikeIn 0.3s ease 0.40s both; }
.hero-logo .sc-s2 { animation: spikeIn 0.3s ease 0.45s both; }
.hero-logo .sc-h  { animation: spikeIn 0.3s ease 0.50s both; }

/* results screen: full size with extra glow */
.results-logo .sc-logo {
  filter: brightness(1.2);
}

/* lobby page: medium size, centered */
.lobby-logo {
  align-items: center;
}
.lobby-logo .sc-logo {
  transform: scale(0.6);
  transform-origin: center top;
}

/* auth-callback page: small size, centered */
.callback-logo {
  align-items: center;
}
.callback-logo .sc-logo {
  transform: scale(0.5);
  transform-origin: center top;
}

@media (max-width: 480px) {
  .sc-s1 { font-size: 17px !important; }
  .sc-p  { font-size: 20px !important; }
  .sc-i  { font-size: 24px !important; }
  .sc-k  { font-size: 28px !important; }
  .sc-e  { font-size: 31px !important; }
  .sc-amp{ font-size: 34px !important; }
  .sc-c  { font-size: 31px !important; }
  .sc-r  { font-size: 28px !important; }
  .sc-u  { font-size: 24px !important; }
  .sc-s2 { font-size: 20px !important; }
  .sc-h  { font-size: 17px !important; }
  .sc-logo-tagline { font-size: 8px; }
}

.logo-hero-wrapper {
  position: relative;
  display: inline-block;
}

.logo-chart-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.25;
  pointer-events: none;
}

/* ---- irony accent: sarcastic bad-news copy (legacy amber, kept for elements that aren't strictly spike/crush) -- */

.tw-tagline-irony,
.tw-hero-tagline-secondary,
.text-irony {
  color: var(--accent-irony);
}

.tw-hero-tagline-secondary {
  font-size: 14px;
  margin-top: 2px;
}

/* ---- announcement banner (admin-authored, Communications tab) -------------- */

.tw-announcement-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.tw-announcement-banner.type-info { background: rgba(79, 195, 247, 0.12); color: #4fc3f7; }
.tw-announcement-banner.type-warning { background: rgba(255, 140, 0, 0.14); color: #ff8c00; }
.tw-announcement-banner.type-celebration { background: rgba(0, 200, 150, 0.14); color: var(--accent-teal, #00c896); }

.tw-announcement-banner .close-btn {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.tw-announcement-banner .close-btn:hover { opacity: 1; }

/* ---- toast / notification -------------------------------------------------- */

#twToast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tw-toast-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 220px;
  max-width: 320px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: tw-toast-in 0.2s ease;
}

.tw-toast-item.warning {
  border-left-color: var(--warning);
}
.tw-toast-item.danger {
  border-left-color: var(--sell);
}

@keyframes tw-toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---- scrollbars -------------------------------------------------------- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-surface-3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold-glow);
}

/* ---- loading skeleton ---------------------------------------------------- */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-1) 25%, var(--bg-surface-2) 50%, var(--bg-surface-1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* ---- legal / compliance ------------------------------------------------------ */
/* Colours here are deliberately a flat rgba(255,255,255,...) rather than the
   var(--text-secondary)/var(--border) tokens used everywhere else - this
   text is meant to read as unobtrusive fine print in EVERY theme (including
   light), not to visually match each theme's normal text hierarchy. */

.legal-footer {
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding: 20px 24px;
}

.legal-footer-content {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.legal-text {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  line-height: 1.6;
  margin: 0 0 8px;
}

.legal-links {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  margin: 0;
}

.legal-links a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
}

.legal-links a:hover {
  color: rgba(255, 255, 255, 0.8);
}

.register-legal {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}

.wallet-disclaimer,
.tournament-disclaimer-box {
  background: rgba(255, 140, 0, 0.08);
  border: 1px solid rgba(255, 140, 0, 0.15);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 24px;
  line-height: 1.5;
}

.tournament-disclaimer {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ---- static legal pages (terms/privacy/responsible) -------------------------- */

.legal-page-content h2 {
  font-size: 18px;
  margin: 28px 0 10px;
  color: var(--accent);
}
.legal-page-content h2:first-child {
  margin-top: 0;
}
.legal-page-content p,
.legal-page-content li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.legal-page-content .updated-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ---- responsive ------------------------------------------------------------ */

@media (max-width: 720px) {
  .tw-container {
    padding: 20px 12px;
  }
  .tw-header {
    padding: 12px 14px;
  }
}

/* ---- FIX: match summary toast (shown after leaving early) --------------------- */

.match-summary-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  z-index: 9000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: tw-toast-slide-up-summary 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tw-toast-slide-up-summary {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.match-summary-toast .toast-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.match-summary-toast .toast-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.match-summary-toast .toast-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
}

.match-summary-toast .toast-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.match-summary-toast .toast-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.match-summary-toast .toast-good { color: var(--buy); font-weight: 700; }
.match-summary-toast .toast-bad { color: var(--sell); font-weight: 700; }

.match-summary-toast .toast-replay-btn {
  width: 100%;
  background: var(--overlay-medium, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
}

.match-summary-toast .toast-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.match-summary-toast .toast-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 100%;
  animation: tw-toast-progress-deplete 15s linear forwards;
}
@keyframes tw-toast-progress-deplete {
  from { width: 100%; }
  to { width: 0%; }
}
