/* Global UI styling (clean + rounded, no "card stacking") */

:root{
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --line-strong: #cbd5e1;
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
}

*{ box-sizing:border-box; }

html, body{
  height:100%;
}

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:#fff;
}

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

.page{
  /* Site width: ~20% wider than the original 560px */
  max-width: 672px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

/* Header / Footer */
.topbar, header.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
  margin: 14px 0 20px;
}

.top-left{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 0;
}

.app-logo{
  width: 26px;
  height: 26px;
}

.app-title{
  font-weight: 800;
  letter-spacing: 0.2px;
}

.player-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  /* Top bar user display: keep pill spacing, no outline */
  border: none;
  border-radius: 999px;
  white-space: nowrap;
}

.player-pill-text{
  font-weight: 700;
  font-size: 13px;
}

.footerbar{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: none;
  margin-top: 20px;
}

.footer-links{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap: 14px;
}

.footer-links a{
  font-size: 12px;
  color: #334155;
  text-decoration:none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.footer-links a:hover{ text-decoration:underline; }

/* Typography helpers */
.muted{ color: var(--muted); font-size: 13px; }
h1{ font-size: 22px; margin: 18px 0 10px; }
h2{ font-size: 18px; margin: 16px 0 8px; }

/* Buttons */
button, .btn, .button, .auth-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor:pointer;
  text-decoration:none;
}

button:hover, .btn:hover, .button:hover, .auth-button:hover{
  background: var(--blue-hover);
  text-decoration:none;
}

/* Outline variant (same sizing as submit button) */
.btn.btn-outline, a.btn.btn-outline{
  background: transparent;
  color: var(--blue);
  border-color: var(--line-strong);
}

.btn.btn-outline:hover, a.btn.btn-outline:hover{
  background: transparent;
  border-color: var(--blue);
}

button:disabled, .btn:disabled{
  opacity: 0.6;
  cursor:not-allowed;
}

/* Inputs */
input[type="text"], input[type="password"], input[type="email"], input[type="number"], select{
  width:100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background:#fff;
  color: var(--text);
}

input:focus, select:focus, button:focus, a:focus{
  outline: 2px solid rgba(37, 99, 235, 0.20);
  outline-offset: 2px;
}

/* Match header + timer */
.match-header{
  margin: 12px 0 10px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
}

.match-title{
  font-weight: 800;
  margin-bottom: 6px;
}

.match-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap:wrap;
  color: var(--muted);
  font-size: 13px;
}

.match-timer{
  display:inline-block;
  margin-top:10px;
  background:#b7dbff;
  border:1px solid var(--line-strong);
  border-radius:999px;
  padding:6px 10px;
  font-weight:400;
  font-size:14px;
}

/* Auth (login) */
.auth{
  margin: 18px auto 0;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.auth-logo{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  margin-bottom: 8px;
}

.auth-logo img{
  width: 30px;
  height: 30px;
}

.auth-title{
  font-weight: 900;
  letter-spacing: 0.2px;
  font-size: 18px;
}

.auth-subtitle{
  margin: 0 0 14px;
  text-align:center;
  color: var(--muted);
  font-size: 13px;
}

.auth-form{
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.auth-input{
  width:100%;
}

/* Problems: one outline only, no nested "card" wrappers */
.problem{
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px 10px;
  margin: 12px 0;
  background:#fff; /* still white; no gray fills */
}

.part.text{
  margin: 8px 0;
  line-height: 1.5;
}

/* Answer area: no extra border wrapper */
.answer{ margin-top: 10px; }

.ce-answer{
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  background: #fff;
}

.ce-answer.is-empty:before{
  content: attr(data-placeholder);
  color: #94a3b8;
}

/* Rating history / pills */
.badge{
  display:inline-flex;
  align-items:center;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  color:#fff;
  border: none !important;
  box-shadow: none;
}

.badge.win{ background: var(--green); }
.badge.draw{ background: var(--green); }
.badge.loss{ background: var(--red); }

/* Generic .card for legacy pages: keep subtle, no shadow, no stacking look */
.card{
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: transparent;
}

.card-title{
  font-weight: 800;
  margin-bottom: 10px;
}

/* Small utilities */
.u-inline{ display:inline; }

/* Home action tiles (rounded "button cards") */
.actions-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 24px;
}

.action-card{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: transparent;
  text-decoration:none;
  color: inherit;
  box-shadow: none;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.action-card:hover{
  border-color: var(--line-strong);
  transform: none;
  box-shadow: none;
  text-decoration:none;
}

.action-card.primary{ border-color: #22c55e; }
.action-card.primary:hover{ border-color: #16a34a; }

.action-card.learn{ border-color: #3b82f6; }
.action-card.learn:hover{ border-color: #2563eb; }

.action-card.leaderboard{ border-color: #f59e0b; }
.action-card.leaderboard:hover{ border-color: #d97706; }

.action-card.danger{ border-color: #f97373; }
.action-card.danger:hover{ border-color: #ef4444; }

.action-icon{
  width: 32px;
  height: 32px;
  flex-shrink:0;
}

.action-main{
  display:flex;
  flex-direction:column;
  gap: 2px;
  min-width:0;
}

.action-label{
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.action-sub{
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 420px){
  .actions-grid{ grid-template-columns: 1fr; }
}

/* Button icons (keep button height consistent across pages) */
.btn img, .button img, .auth-button img, button img{
  width: 16px;
  height: 16px;
}

/* Banners */
.quote-banner{
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: transparent;
  box-shadow: none;
  margin: 0 0 14px;
}
.quote-text{ font-weight: 400; font-style: italic; font-size: 14px; line-height: 1.35; }
.quote-author{ margin-top: 6px; font-size: 12px; color: var(--muted); }

.billing-banner{
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px;
  background: transparent;
  box-shadow: none;
  margin: 0 0 14px;
  font-size: 13px;
}

/* Billing banners (only specific messages get soft backgrounds) */
.billing-banner.success,
.billing-banner.ok{
  border-color:#86efac;
  background:#ecfdf5; /* light green */
  color:#065f46;
}

.billing-banner.warning{
  border-color:#fcd34d;
  background: transparent; /* keep outline-only unless explicitly needed */
  color: var(--text);
}

.billing-banner.error{
  border-color:#fca5a5;
  background: transparent;
}

.billing-banner.info{
  border-color:#93c5fd;
  background: transparent;
}

/* Submit outcome banners */
.outcome{
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  margin: 12px 0;
  background: transparent;
}

.outcome.pending{
  border-color:#fcd34d;
  background:#fffbeb; /* warning yellow */
  color:#92400e;
}

.outcome.win{
  border-color:#86efac;
  background:#ecfdf5; /* light green (same as trial banner) */
  color:#065f46;
}

.outcome.loss{
  border-color:#fca5a5;
  background:#fef2f2; /* light red */
  color:#991b1b;
}

/* Sections */
.section{ margin-top: 18px; }
.section h2, .section h3{
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.empty{ color: var(--muted); font-size: 14px; }

/* Rating history */
.rating-card{
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: transparent;
  box-shadow: none;
  margin-bottom: 10px;
}
.rating-top{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
.rating-vs{
  font-weight: 750;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rating-change{
  display:flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rating-delta{ font-weight: 900; }
.rating-delta.positive{ color: var(--green); }
.rating-delta.negative{ color: var(--red); }
.rating-sep{ color: var(--muted); }
.rating-bottom{
  display:flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 10px;
}
.rating-date{ font-size: 12px; }

/* Learn / Leaderboard subnav */
.section-header{ margin-bottom: 12px; }

.leaderboard-subnav{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
}

.leaderboard-subnav-left{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}

.leaderboard-subnav-icon{
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

.leaderboard-subnav-title{
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* Leaderboard tables (outline-only, no fills) */
.table-wrap{
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 12px;
}

.leaderboard-table{
  width: 100%;
  border-collapse: collapse;
}

/* Some browsers center <th> by default; keep headers aligned with cells */
.leaderboard-table th{
  text-align: left;
}

.leaderboard-table th,
.leaderboard-table td{
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.leaderboard-table thead th{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 800;
}

.leaderboard-table tbody tr:last-child td{ border-bottom: none; }

.leaderboard-table .rank,
.leaderboard-table .rating,
.leaderboard-table .record{
  text-align: right;
  white-space: nowrap;
}

.leaderboard-table .name{
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-self-table td{
  font-weight: 700;
}

@media (max-width: 560px){
  .table-wrap{ overflow-x: auto; }
  .leaderboard-table{ min-width: 420px; }
}

.topics{
  display:flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.topic-link{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  text-decoration:none;
}

.topic-link:hover{
  border-color: var(--line-strong);
  text-decoration:none;
}

.examples{
  white-space: pre-line;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: transparent;
  margin: 10px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
}

.timer-pill{
  display:inline-block;
  background:#b7dbff;
  border:1px solid var(--border);
  border-radius:999px;
  padding:6px 10px;
  font-weight:400;
  font-size:14px;
}

/* Learn / Tutorial pages: small spacing tweaks (no backgrounds, keep existing button sizing) */
.learn-page .section{ margin-top: 14px; }
.learn-page .section-header{ margin-bottom: 8px; }

.learn-page .card{
  padding: 16px 18px; /* a touch more breathing room */
}

.learn-page .card h1{
  margin: 2px 0 10px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.learn-page .card h2{
  margin: 16px 0 10px;
}

.learn-page .card p{ margin: 10px 0; }

.learn-page .card ul,
.learn-page .card ol{
  margin: 10px 0 12px 18px;
  padding-left: 16px;
}

.learn-page .card li{ margin: 6px 0; }

.learn-page .spacer{ height: 14px; }

.learn-page mjx-container{ overflow-x: auto; overflow-y: hidden; }
.learn-page mjx-container[display="true"]{ margin: 10px 0; }

/* Admin page: make seeder buttons full width */
.admin-page .grid{
  display: block; /* no multi-column cards */
}
.admin-page .grid .card{
  margin: 0 0 12px;
}
.admin-page form.inline,
.admin-page form.inline button{
  width: 100%;
}
.admin-page form.inline{ display:block; }
.admin-page form.inline .button,
.admin-page button.button{
  display: block;
  width: 100%;
}

/* Admin: seed grid (many small buttons per row) */
body.admin-page .page{
  max-width: 1400px;
}
.admin-seed-grid{
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
}
.admin-seed-form{ margin: 0; }
.admin-seed-btn{
  width: 100%;
  justify-content: center;
  padding: 8px 0;
  white-space: nowrap;
}
@media (max-width: 1200px){
  .admin-seed-grid{ grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
@media (max-width: 820px){
  .admin-seed-grid{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .admin-seed-grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Landing page small spacing */
.landing-copy p{margin:0 0 10px 0;}
.pricing-table td{vertical-align:top;}
.small{font-size:13px; color:#555;}

/* Contact page */
.contact-message{resize:none;}

.learn-topics a.btn:hover,
.learn-topics a.btn-outline:hover,
.learn-topics .btn:hover,
.learn-topics .btn-outline:hover{
  border-color:#2563eb;
}

.topics-grid .topic-link:hover{
  border-color:#2563eb !important;
}
