@layer base, layout, components, responsive;

@layer base {
  :root {
    color-scheme: light;
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f8fb;
    color: #1c2a38;
    --navy: #11365f;
    --navy-dark: #0a2746;
    --green: #6ea33a;
    --green-dark: #466d24;
    --muted: #5d6c7c;
    --line: #dfe7ee;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body { margin: 0; }
  button, input, select { font: inherit; }
  button, a, select { -webkit-tap-highlight-color: transparent; }
  a { color: inherit; text-decoration: none; }
  h1, h2, h3, p { margin: 0; }
  h1, h2, h3 { color: var(--navy-dark); }
  p { line-height: 1.7; }
  button { cursor: pointer; }
  button:disabled { opacity: .5; cursor: not-allowed; }
  :focus-visible { outline: 3px solid #2d6ba3; outline-offset: 5px; }
  .skip { position: fixed; top: -80px; left: 18px; padding: 15px; background: white; color: var(--navy); z-index: 20; }
  .skip:focus { top: 12px; }
}

@layer layout {
  .site-header { background: white; border-bottom: 1px solid var(--line); }
  .header-inner, main, .footer-inner { width: min(1180px, 92%); margin: auto; }
  .header-inner { min-height: 94px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
  main { padding: 62px 0 65px; min-height: calc(100dvh - 250px); }
  footer { background: #071c32; color: #d3dce5; }
  .footer-inner { padding: 36px 0; display: flex; justify-content: space-between; gap: 25px; }
  .hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .96fr); gap: 65px; align-items: center; }
  .entry-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); gap: 85px; align-items: center; margin-top: 64px; }
  .test-heading { display: flex; gap: 25px; justify-content: space-between; align-items: flex-start; margin-bottom: 35px; }
  .test-layout { display: grid; grid-template-columns: minmax(0, 1.95fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
  .controls { display: grid; gap: 20px; min-width: 0; }
}

@layer components {
  .brand { display: flex; align-items: center; color: var(--navy); font-size: 32px; font-weight: 800; letter-spacing: -1.5px; }
  .brand-mark { background: var(--navy); color: white; border-radius: 10px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; margin-right: 12px; font-size: 29px; position: relative; }
  .brand-mark > span { position: absolute; font-size: 12px; color: #a9d875; right: 3px; bottom: 1px; }
  .wordmark-dot { color: var(--green); }
  nav { display: flex; align-items: center; gap: 26px; font-size: 14px; font-weight: 700; color: var(--navy); }
  nav a:hover, .text-link:hover { text-decoration: underline; text-underline-offset: 4px; }
  .pilot-label { border: 1px solid #cddfc0; background: #f0f6eb; color: var(--green-dark); border-radius: 30px; padding: 9px 14px; font-size: 12px; white-space: nowrap; }
  .eyebrow { color: var(--green-dark); font-size: 11px; font-weight: 800; letter-spacing: .12em; margin-bottom: 18px; line-height: 1.6; }
  h1 { font-size: clamp(44px, 5.5vw, 72px); line-height: 1.03; letter-spacing: -.045em; font-weight: 750; }
  .welcome h1 > span { color: #57842e; }
  .lead { color: var(--muted); font-size: 17px; max-width: 500px; margin-top: 24px; }
  .hero-actions { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-top: 28px; }
  .button-link { border-radius: 8px; min-height: 48px; padding: 14px 20px; font-size: 14px; font-weight: 700; }
  .hero-actions .primary { width: auto; }
  .text-link { color: var(--navy); font-size: 13px; font-weight: 700; min-height: 44px; display: inline-flex; align-items: center; gap: 10px; }
  .hero-note { margin-top: 22px; color: var(--muted); font-size: 12px; }
  .match-visual { background: white; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 60px #11365f12; padding: 24px; transform: rotate(1deg); }
  .match-topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
  .sport-label { color: var(--navy); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
  .illustration-label { color: var(--muted); font-size: 11px; }
  .pitch { background: repeating-linear-gradient(90deg, #416e47 0%, #416e47 12.5%, #3c6542 12.5%, #3c6542 25%); border-radius: 12px; padding: 25px 22px 37px; position: relative; overflow: hidden; }
  .pitch-lines { border: 1.5px solid #ffffffa6; border-radius: 2px; aspect-ratio: 1.65; position: relative; }
  .halfway { position: absolute; left: 50%; height: 100%; border-left: 1.5px solid #ffffffa6; }
  .centre-circle { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #ffffffc4; left: calc(50% - 2px); top: calc(50% - 2px); }
  .shooting-circle { position: absolute; width: 25%; height: 65%; top: 17.5%; border: 1.5px solid #ffffffa6; }
  .shooting-circle.left { left: -1px; border-left: 0; border-radius: 0 100% 100% 0; }
  .shooting-circle.right { right: -1px; border-right: 0; border-radius: 100% 0 0 100%; }
  .goal { position: absolute; width: 8px; height: 20%; top: 40%; border: 2px solid white; }
  .goal.left { left: -8px; } .goal.right { right: -8px; }
  .player { position: absolute; width: 12px; height: 12px; border: 2px solid white; border-radius: 50%; background: #163a68; box-shadow: 0 3px 4px #0003; }
  .player.away { background: #f5c462; }
  .p1 { left: 20%; top: 44%; } .p2 { left: 40%; top: 22%; } .p3 { left: 51%; top: 67%; }
  .p4 { left: 65%; top: 38%; } .p5 { left: 78%; top: 63%; } .p6 { left: 47%; top: 40%; }
  .ball { position: absolute; width: 5px; height: 5px; background: white; border-radius: 50%; left: 52%; top: 46%; }
  .pitch-caption { position: absolute; bottom: 12px; left: 0; right: 0; color: white; font-size: 8px; letter-spacing: .14em; text-align: center; font-weight: 700; }
  .match-caption { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 24px 2px 16px; }
  .match-caption .eyebrow { margin-bottom: 8px; font-size: 9px; }
  .match-caption h2 { font-size: clamp(22px, 2.2vw, 29px); line-height: 1.2; letter-spacing: -.025em; }
  .camera-symbol { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid #d3e4c8; border-radius: 50%; color: var(--green-dark); background: #f1f7ec; font-size: 18px; flex-shrink: 0; }
  .match-status { border-top: 1px solid var(--line); padding-top: 14px; font-size: 11px; color: var(--muted); }
  .sponsor-card { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px 30px; align-items: center; padding: 32px 38px 23px; margin-top: 60px; border: 1px solid #d2e1c6; border-radius: 18px; background: linear-gradient(110deg, #f0f6e9, white 65%); scroll-margin-top: 24px; }
  .sponsor-copy .eyebrow { font-size: 10px; margin-bottom: 10px; }
  .sponsor-copy h2 { font-size: 29px; line-height: 1.2; letter-spacing: -.025em; }
  .sponsor-copy > p:last-child { font-size: 13px; color: var(--muted); margin-top: 10px; }
  .sponsor-logo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 135px; background: var(--navy); color: white; border-radius: 12px; padding: 23px; }
  .sponsor-logo img { display: block; max-width: 100%; height: auto; }
  .sponsor-logo > span { font-size: 12px; font-weight: 700; }
  .sponsor-logo:hover > span { text-decoration: underline; text-underline-offset: 4px; }
  .sponsor-disclaimer { grid-column: 1 / -1; font-size: 11px; color: var(--muted); border-top: 1px solid #dce7d4; padding-top: 13px; }
  .pilot-copy > h2 { font-size: 36px; line-height: 1.15; letter-spacing: -.035em; }
  .step-strip { display: grid; gap: 23px; margin: 30px 0; }
  .step-strip > div { display: flex; gap: 16px; align-items: flex-start; }
  .step-strip b { color: var(--green-dark); background: #eaf2e3; border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
  .step-strip h3 { font-size: 15px; margin-bottom: 5px; }
  .step-strip p { font-size: 13px; color: var(--muted); }
  .scope-note { font-size: 12px; color: var(--muted); border-left: 3px solid var(--green); padding-left: 17px; }
  .join-card { border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 16px; background: white; padding: 32px; box-shadow: 0 12px 30px #11365f08; }
  .card-kicker { display: flex; align-items: center; gap: 9px; color: var(--green-dark); font-size: 10px; font-weight: 700; letter-spacing: .06em; line-height: 1.7; }
  .dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; flex-shrink: 0; }
  .join-card h2 { font-size: 30px; line-height: 1.15; letter-spacing: -.035em; margin: 20px 0 15px; scroll-margin-top: 24px; }
  .join-card > p { color: var(--muted); font-size: 13px; }
  label:not(.check) { display: block; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
  #login-form { margin-top: 25px; }
  input:not([type=checkbox]), select { background: #fbfdff; border: 1px solid #8c9caf; color: var(--navy-dark); width: 100%; border-radius: 8px; padding: 14px; min-height: 48px; }
  input::placeholder { color: #667588; opacity: 1; }
  #access-code { letter-spacing: .13em; font-size: 18px; }
  #code-help { display: block; color: var(--muted); font-size: 11px; line-height: 1.7; margin: 10px 0 20px; }
  button { border-radius: 8px; padding: 13px 17px; min-height: 48px; font-size: 13px; font-weight: 700; line-height: 1.5; }
  .primary { background: var(--green-dark); border: 1px solid var(--green-dark); color: white; display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; }
  .primary:hover:not(:disabled) { background: #36551b; }
  .quiet { color: var(--navy); border: 1px solid #8c9caf; background: white; }
  .quiet:hover { background: #eaf0f6; }
  .stop { background: #fff4f2; border: 1px solid #b1483d; color: #912e24; width: 100%; margin-top: 10px; }
  .full { width: 100%; margin-top: 10px; }
  .message { margin-top: 15px; min-height: 20px; font-size: 12px; color: var(--green-dark); overflow-wrap: anywhere; }
  .message.error { color: #a42c25; }
  .join-foot { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 18px; font-size: 11px; line-height: 1.8; color: var(--muted); display: flex; align-items: flex-start; gap: 9px; }
  .join-foot > span { color: var(--green-dark); font-size: 18px; }
  .test-heading h1 { font-size: clamp(34px, 4.3vw, 55px); }
  .test-heading .eyebrow { margin-bottom: 12px; }
  .test-heading .lead { margin-top: 15px; font-size: 14px; }
  .video-panel { background: white; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-width: 0; }
  .video-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 20px; font-size: 11px; letter-spacing: .04em; color: var(--navy); }
  .state { display: flex; align-items: center; gap: 7px; color: var(--muted); letter-spacing: 0; }
  .state i { width: 7px; height: 7px; border-radius: 50%; background: #778699; flex-shrink: 0; }
  .state.live { color: var(--green-dark); }
  .state.live i { background: var(--green-dark); }
  .state.reconnecting { color: #855400; }
  .video-stage { aspect-ratio: 16/10; background: #0a2138; position: relative; display: grid; place-items: center; min-height: 220px; color: white; }
  #preview { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: contain; }
  .empty-stage { text-align: center; padding: 30px; }
  .empty-stage h2 { color: white; font-size: 22px; letter-spacing: -.025em; margin-bottom: 12px; }
  .empty-stage p { font-size: 13px; color: #c1d0de; max-width: 320px; }
  .viewfinder { display: grid; width: 65px; height: 45px; border: 2px solid #8ab368; border-radius: 8px; place-items: center; margin: 0 auto 25px; }
  .viewfinder i { width: 17px; height: 17px; border: 2px solid #b4d989; border-radius: 50%; }
  .video-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 11px; line-height: 1.7; padding: 16px 20px; color: var(--muted); }
  .video-footer > span:last-child { color: var(--navy); font-size: 10px; letter-spacing: .08em; }
  .control-card { border: 1px solid var(--line); border-radius: 12px; padding: 24px; background: white; }
  .control-card .eyebrow { margin-bottom: 12px; font-size: 10px; }
  .control-card h2 { font-size: 23px; line-height: 1.25; letter-spacing: -.025em; margin-bottom: 23px; }
  .check { display: flex; gap: 10px; font-size: 13px; line-height: 1.6; margin: 20px 0; cursor: pointer; }
  .check input { flex-shrink: 0; accent-color: var(--green-dark); width: 18px; height: 18px; margin-top: 1px; }
  .check small { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; }
  .connection-facts { margin: 22px 0 0; }
  .connection-facts > div { border-top: 1px solid var(--line); padding: 12px 0; display: flex; justify-content: space-between; gap: 15px; font-size: 12px; }
  .connection-facts > div:last-child { padding-bottom: 0; }
  dt { color: var(--muted); }
  dd { margin: 0; font-variant-numeric: tabular-nums; }
  .field-note { border: 1px solid #d2e1c6; border-radius: 10px; background: #edf4e7; padding: 22px; }
  .note-index { font-size: 10px; color: var(--green-dark); letter-spacing: .12em; font-weight: 700; }
  .field-note h3 { font-size: 16px; line-height: 1.5; margin: 14px 0 10px; }
  .field-note p { color: #4b6042; font-size: 12px; margin-top: 10px; }
  .test-boundary { display: flex; gap: 15px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 23px; margin-top: 30px; }
  .test-boundary > span { color: var(--green-dark); font-size: 24px; }
  .test-boundary p { color: var(--muted); font-size: 12px; max-width: 780px; }
  .test-boundary strong { color: var(--navy); }
  footer strong { font-size: 26px; letter-spacing: -1px; color: white; }
  footer p { font-size: 11px; margin-top: 8px; }
  footer a { color: white; font-size: 12px; }
  footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
}

@layer responsive {
  @media (max-width: 980px) {
    main { padding-top: 42px; }
    .hero-grid { gap: 30px; }
    .entry-grid { gap: 35px; }
    .match-visual { padding: 20px; transform: none; }
    .hero-actions { gap: 10px; }
    .test-layout { grid-template-columns: 1fr; }
    .controls { grid-template-columns: 1fr 1fr; align-items: start; }
  }
  @media (max-width: 700px) {
    .header-inner { min-height: 76px; }
    nav { gap: 12px; font-size: 12px; }
    .pilot-label { padding: 7px 10px; font-size: 10px; }
    .brand { font-size: 27px; }
    .brand-mark { width: 32px; height: 34px; font-size: 25px; margin-right: 8px; }
    main { padding: 36px 0 40px; }
    .hero-grid, .entry-grid { grid-template-columns: 1fr; gap: 32px; }
    .welcome h1 { font-size: clamp(42px, 11vw, 68px); }
    .lead { font-size: 15px; margin-top: 20px; }
    .hero-note { margin-top: 15px; }
    .match-visual { max-width: 520px; width: 100%; margin: auto; }
    .match-caption h2 { font-size: 27px; }
    .sponsor-card { grid-template-columns: 1fr; padding: 25px; gap: 22px; margin-top: 36px; }
    .sponsor-copy h2 { font-size: 27px; }
    .sponsor-logo { max-width: 300px; width: 100%; justify-self: start; }
    .sponsor-disclaimer { grid-column: auto; }
    .entry-grid { margin-top: 40px; }
    .pilot-copy > h2 { font-size: 32px; }
    .join-card { padding: 25px; }
    .join-card h2 { font-size: 28px; }
    .test-heading { gap: 15px; margin-bottom: 25px; flex-wrap: wrap; }
    .test-heading .quiet { padding: 10px; min-width: 78px; }
    .test-heading .eyebrow { font-size: 10px; }
    .test-heading h1 { font-size: 36px; }
    .test-heading .lead { font-size: 13px; }
    .controls { grid-template-columns: 1fr; }
    .video-toolbar { padding: 15px; font-size: 10px; gap: 8px; }
    .video-footer { padding: 15px; }
    .empty-stage { padding: 22px; }
    .empty-stage h2 { font-size: 20px; }
    .empty-stage p { font-size: 12px; }
    .video-stage { aspect-ratio: 4/3; }
    .control-card { padding: 22px; }
    .footer-inner { flex-direction: column; gap: 22px; }
  }
  @media (max-width: 650px) {
    body.media-active { padding-bottom: 90px; }
    body.media-active #stop { position: fixed; left: 20px; right: 20px; bottom: max(15px, env(safe-area-inset-bottom)); width: calc(100% - 40px); z-index: 5; box-shadow: 0 0 0 10px #f5f8fbe8, 0 -10px 30px #0a274620; }
  }
  @media (max-width: 480px) { nav > a { display: none; } }
  @media (max-width: 370px) { .header-inner { gap: 10px; } .sponsor-card, .join-card { padding: 20px; } }
  @media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
}
