/* Skill Arena - skill-based competition platform */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2128;
  --border: #2d333b;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #2f81f7;
  --accent-hover: #58a6ff;
  --accent-soft: #0d2d5e;
  --success: #3fb950;
  --warn-bg: #2d2410;
  --warn-border: #5c4813;
  --radius: 10px;
  --maxw: 1140px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #f6f8fa;
    --surface-2: #eaeef2;
    --border: #d0d7de;
    --text: #1f2328;
    --text-muted: #59636e;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --accent-soft: #ddf4ff;
    --warn-bg: #fff8c5;
    --warn-border: #d4a72c;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.65;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); margin-top: 2em; }
h3 { font-size: 1.15rem; margin-top: 1.7em; }
p { margin: 0 0 1.1em; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 780px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: -.03em; }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 22px; align-items: center; }
.nav a { color: var(--text-muted); font-size: .94rem; font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; color: var(--text); cursor: pointer; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--surface);
         border-bottom: 1px solid var(--border); flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 20px 16px; }
  .nav.open { display: flex; }
  .nav a { padding: 10px 0; width: 100%; }
}

/* Skill banner - the single most important message on the site */
.skill-banner {
  background: var(--accent-soft); border-bottom: 1px solid var(--border);
  padding: 10px 0; font-size: .9rem; text-align: center; color: var(--text);
}
.skill-banner strong { color: var(--accent-hover); }

/* Hero */
.hero { padding: 64px 0 52px; border-bottom: 1px solid var(--border); }
.hero .lede { font-size: 1.15rem; color: var(--text-muted); max-width: 62ch; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }

.btn { display: inline-block; background: var(--accent); color: #fff; padding: 12px 22px;
       border-radius: 8px; font-weight: 600; font-size: .96rem; border: none; cursor: pointer; }
.btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-soft); color: var(--accent-hover); }

section { padding: 52px 0; }
section.tight { padding: 30px 0; }
.alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-head { max-width: 64ch; margin-bottom: 30px; }
.section-head h2 { margin-top: 0; }
.section-head p { color: var(--text-muted); margin-bottom: 0; }

/* Cards */
.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 22px 24px; display: flex; flex-direction: column; transition: border-color .18s, transform .18s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h3 { margin-top: 0; font-size: 1.08rem; }
.card p { font-size: .93rem; color: var(--text-muted); flex: 1; }
.tag { display: inline-block; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
       color: var(--accent); border: 1px solid var(--accent); border-radius: 20px; padding: 3px 10px; margin-bottom: 12px; }
.tag-skill { color: var(--success); border-color: var(--success); }

/* Steps */
.steps { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); counter-reset: s; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.step h3 { margin-top: 0; font-size: 1.02rem; }
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
          border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem; margin-bottom: 12px; }

/* Tables */
.facts { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: .95rem; }
.facts th, .facts td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.facts th { width: 34%; font-weight: 600; color: var(--text-muted); background: var(--surface-2); }
.table-scroll { overflow-x: auto; }

/* Notice */
.notice { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius);
          padding: 14px 18px; font-size: .9rem; color: var(--text); margin: 22px 0; }
.notice strong { display: block; margin-bottom: 4px; }

.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.3em; }
.prose li { margin-bottom: .45em; }
.crumbs { font-size: .85rem; color: var(--text-muted); padding: 18px 0 0; }
.crumbs a { color: var(--text-muted); }
.crumbs span { margin: 0 6px; opacity: .6; }
.verified { font-size: .84rem; color: var(--text-muted); font-style: italic; margin-top: 30px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 56px;
               padding: 44px 0 26px; font-size: .9rem; color: var(--text-muted); }
.foot-grid { display: grid; gap: 30px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.foot-grid h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text); margin-bottom: 12px; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; }
.foot-grid li { margin-bottom: 8px; }
.foot-grid a { color: var(--text-muted); }
.foot-bottom { border-top: 1px solid var(--border); margin-top: 30px; padding-top: 20px; font-size: .84rem; }
.age { display: inline-block; border: 2px solid var(--text-muted); border-radius: 6px;
       padding: 2px 9px; font-weight: 700; margin-right: 8px; }

.skip { position: absolute; left: -9999px; background: var(--accent); color: #fff; padding: 10px 16px; z-index: 100; }
.skip:focus { left: 0; }

/* ---------- Playable games ---------- */
.game-shell { max-width: 860px; margin: 0 auto; }

.stat-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 22px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; text-align: center; }
.stat .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.stat .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.hot .v { color: var(--accent); }

.passage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; font-size: 1.12rem; line-height: 2; letter-spacing: .01em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  user-select: none; margin-bottom: 16px; max-height: 260px; overflow-y: auto;
}
.passage span { border-radius: 2px; }
.passage .ok  { color: var(--success); }
.passage .bad { color: #f85149; background: rgba(248,81,73,.15); text-decoration: underline; }
.passage .cur { background: var(--accent); color: #fff; }
.passage .todo { color: var(--text-muted); }

#typeArea {
  width: 100%; min-height: 110px; padding: 14px 16px; font-size: 1.02rem; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; resize: vertical;
}
#typeArea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
#typeArea:disabled { opacity: .6; }

.game-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0; align-items: center; }

.result { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 24px; margin-top: 24px; }
.result h3 { margin-top: 0; }
.big-score { font-size: 3rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; margin: 6px 0 18px; }
.calc { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem;
        background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 14px 0; }
.calc div { padding: 3px 0; }
.calc .eq { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; font-weight: 700; color: var(--accent); }

/* Pattern Recall */
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 340px; margin: 24px auto; }
.pad {
  aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: var(--text-muted); transition: all .12s;
}
.pad:hover:not(:disabled) { border-color: var(--accent); }
.pad.lit { background: var(--accent); color: #fff; border-color: var(--accent); transform: scale(1.04); }
.pad.wrong { background: #f85149; color: #fff; border-color: #f85149; }
.pad:disabled { cursor: default; }
.pad-status { text-align: center; font-size: 1.05rem; min-height: 28px; color: var(--text-muted); margin-top: 8px; }

.demo-note { font-size: .86rem; color: var(--text-muted); border-left: 3px solid var(--accent); padding-left: 14px; margin: 20px 0; }
