:root {
  --bg: #0f172a;
  --panel: #111c33;
  --panel-2: #17233d;
  --text: #e5eefc;
  --muted: #9fb0ca;
  --line: #2b3c5f;
  --accent: #8dd6ff;
  --good: #46d39a;
  --warn: #ffd166;
  --bad: #ff7a90;
  --shadow: 0 20px 60px rgba(0,0,0,.25);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
/* The `hidden` attribute must win over class-level `display` rules
   (.login-overlay, .grid-two, .header-actions all set an explicit display,
   which would otherwise override the UA's [hidden]{display:none}). */
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(circle at top left, #1e3a5f, var(--bg) 42%); color: var(--text); }
.app-header { display: flex; justify-content: space-between; gap: 24px; padding: 34px; align-items: flex-end; border-bottom: 1px solid rgba(255,255,255,.08); }
h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 4rem); line-height: 1; letter-spacing: -.04em; }
h2 { font-size: 1.15rem; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-weight: 700; font-size: .75rem; margin: 0 0 8px; }
.subtitle, .hint, footer { color: var(--muted); }
.subtitle { max-width: 760px; margin-bottom: 0; }
main { width: min(1440px, calc(100% - 28px)); margin: 22px auto 60px; display: grid; gap: 18px; }
.panel { background: rgba(17,28,51,.88); border: 1px solid rgba(255,255,255,.08); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.grid-two { display: grid; grid-template-columns: 1.4fr .8fr; gap: 22px; }
button, input, select { font: inherit; }
button { border: 0; background: var(--accent); color: #07111f; font-weight: 800; border-radius: 12px; padding: 11px 14px; cursor: pointer; }
button.secondary { background: #263955; color: var(--text); }
button.danger { background: #613044; color: #fff; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.pick-controls { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }
.pick-card, .tie-box, .match-card, .group-card, .best-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .85rem; font-weight: 700; }
select, input { width: 100%; border: 1px solid var(--line); background: #0b1426; color: var(--text); border-radius: 10px; padding: 10px; }
.metric-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.metric-row:last-child { border-bottom: 0; }
.section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
/* World Six board: on desktop the per-row toggle is just plain text (the
   chevron is hidden and the cards/labels only kick in at the mobile breakpoint). */
.wsx-toggle { all: unset; display: inline-flex; align-items: center; gap: 8px; font: inherit; color: inherit; }
.wsx-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.wsx-chevron { display: none; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: .78rem; font-weight: 800; }
.badge.good { background: rgba(70,211,154,.14); color: var(--good); }
.badge.warn { background: rgba(255,209,102,.14); color: var(--warn); }
.badge.bad { background: rgba(255,122,144,.14); color: var(--bad); }
.badge.neutral { background: rgba(141,214,255,.12); color: var(--accent); }
.best-six { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 12px; }
.best-card strong { display: block; font-size: 1.1rem; margin: 6px 0; }
.best-card .next-label { margin: 10px 0 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.best-card .next-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.best-card .next-list li { font-size: .85rem; }
.matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.match-card .teams { display: grid; grid-template-columns: 1fr 70px 22px 70px 1fr; align-items: center; gap: 8px; margin-top: 10px; }
.match-card input { text-align: center; }
.match-card .right { text-align: right; }
.meta { color: var(--muted); font-size: .8rem; }
/* min(100%, 340px) keeps the column floor from exceeding the viewport, so the
   grid drops to one column instead of overflowing sideways on narrow phones. */
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.group-card h3 { margin-bottom: 8px; }
.group-card table { min-width: 0; font-size: .86rem; }
.group-card th, .group-card td { padding: 8px 6px; }
.result-list { margin-top: 12px; display: grid; gap: 6px; color: var(--muted); font-size: .84rem; }
.result-list span { display: block; padding: 6px 8px; background: rgba(255,255,255,.04); border-radius: 8px; }
footer { width: min(1440px, calc(100% - 28px)); margin: -38px auto 40px; font-size: .86rem; }

/* Editor login overlay */
.login-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(6,12,24,.72); backdrop-filter: blur(6px); z-index: 50; padding: 20px; }
.login-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(380px, 100%); box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card h2 { font-size: 1.3rem; }
.login-error { color: var(--bad); font-size: .85rem; margin: 0; }
.login-actions { display: flex; align-items: center; gap: 14px; }
.login-cancel { color: var(--muted); font-size: .85rem; text-decoration: none; }
.login-cancel:hover { color: var(--text); }

@media (max-width: 900px) {
  .app-header, .section-heading { flex-direction: column; align-items: stretch; }
  .grid-two, .pick-controls, .best-six { grid-template-columns: 1fr; }
  .match-card .teams { grid-template-columns: 1fr 48px 14px 48px 1fr; }

  /* General small-screen polish */
  .app-header { padding: 22px 16px; gap: 10px; }
  .panel { padding: 16px; }
  main, footer { width: min(1440px, calc(100% - 20px)); }
  footer { margin-top: 14px; }
  .group-card table { font-size: .8rem; }
  .group-card th, .group-card td { padding: 7px 4px; }

  /* ---- World Six board -> stacked, tap-to-expand cards ---- */
  .wsx-table { min-width: 0; }                 /* drop the 820px desktop floor */
  .wsx-table thead { display: none; }          /* column headers make no sense per-card */
  .wsx-table, .wsx-table tbody, .wsx-row, .wsx-row td { display: block; }
  .wsx-row { background: var(--panel-2); border: 1px solid var(--line);
             border-radius: 14px; padding: 8px 14px 12px; margin-bottom: 10px; }
  .wsx-row td { border-bottom: 0; padding: 3px 0; }

  .wsx-toggle { display: flex; width: 100%; align-items: center;
                justify-content: space-between; cursor: pointer; padding: 6px 0; }
  .wsx-pot-name { color: var(--muted); text-transform: uppercase;
                  letter-spacing: .08em; font-size: .72rem; font-weight: 800; }
  .wsx-chevron { display: inline-block; color: var(--muted); transition: transform .15s ease; }
  .wsx-chevron::before { content: "\25B8"; }   /* ▸ , rotates to ▾ when open */
  .wsx-row.expanded .wsx-chevron { transform: rotate(90deg); }

  .wsx-pick { font-size: 1.2rem; padding-top: 0 !important; }
  /* R32 % and the switch badge share one line while details are collapsed */
  .wsx-r32, .wsx-signal { display: inline-block; }
  .wsx-r32 { margin-right: 14px; color: var(--text); }
  .wsx-r32::before { content: "R32 "; color: var(--muted); font-weight: 700; }

  .wsx-detail { display: none; }
  .wsx-row.expanded .wsx-detail { display: block; }
  .wsx-detail::before { content: attr(data-label) ": "; color: var(--muted);
                        font-size: .78rem; font-weight: 700; }
}
