:root {
  color-scheme: dark;
  --ink: #151714;
  --paper: #f0f0eb;
  --paper-soft: #e8e8e2;
  --line: rgba(21, 23, 20, 0.13);
  --green: #397c3d;
  --green-bright: #b9ff66;
  --blue: #688ee8;
  --coral: #f2775e;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  overflow-x: hidden;
  background: #d2d3ce;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

[hidden] { display: none !important; }

.siteNoise {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

#app {
  width: min(1450px, calc(100% - 34px));
  min-height: calc(100dvh - 34px);
  margin: 17px auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.62);
  border-radius: 30px;
  background:
    radial-gradient(circle at 72% 40%, rgba(255,255,255,.82), transparent 36%),
    var(--paper);
  box-shadow: 0 26px 80px rgba(23, 27, 20, 0.18), inset 0 0 0 1px rgba(18,20,17,.04);
}

.topbar {
  height: 94px;
  padding: 0 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand, .gameBrand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brandMark {
  width: 43px;
  height: 43px;
  filter: drop-shadow(0 7px 12px rgba(18, 20, 17, .18));
}

.wordmark, .gameBrand > span {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.055em;
}

.wordmark span, .gameBrand > span span { color: #72756e; }

.liveStats { display: flex; align-items: center; }

.stat {
  min-height: 42px;
  padding: 0 18px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  border-left: 1px solid var(--line);
  font-size: 12px;
  color: #6e716a;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.stat strong { color: var(--ink); font-size: 16px; letter-spacing: -.03em; }
.liveDot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #65c86b; box-shadow: 0 0 0 4px rgba(101,200,107,.13); }

.landing {
  min-height: calc(100dvh - 130px);
  padding: clamp(55px, 7vw, 105px) 5.8% 38px;
  display: grid;
  grid-template-columns: minmax(390px, .82fr) minmax(520px, 1.18fr);
  align-items: center;
  gap: clamp(40px, 6vw, 100px);
  position: relative;
}

.heroCopy { max-width: 600px; position: relative; z-index: 2; }

.eyebrow {
  margin: 0 0 27px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #62655e;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow span { width: 23px; height: 2px; background: var(--ink); }

h1 {
  margin: 0;
  font-size: clamp(54px, 6.15vw, 99px);
  line-height: .9;
  letter-spacing: -.075em;
  font-weight: 780;
}

h1 em { color: #777a73; font-family: Georgia, "Times New Roman", serif; font-size: .88em; font-weight: 400; letter-spacing: -.06em; white-space: nowrap; }

.heroText {
  max-width: 535px;
  margin: 31px 0 32px;
  color: #646760;
  font-size: 16px;
  line-height: 1.65;
}

.playForm { display: flex; align-items: stretch; gap: 10px; }

.nameField {
  min-width: 0;
  flex: 1;
  padding: 11px 17px 9px;
  display: grid;
  gap: 3px;
  border: 1px solid rgba(21,23,20,.17);
  border-radius: 14px;
  background: rgba(255,255,255,.62);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.nameField:focus-within { border-color: rgba(21,23,20,.5); box-shadow: 0 0 0 4px rgba(21,23,20,.06); }
.nameField span { color: #777a73; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.nameField input { min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; font-weight: 650; }
.nameField input::placeholder { color: #aaa; font-weight: 450; }

.playButton {
  min-width: 174px;
  padding: 0 14px 0 21px;
  border: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 25px rgba(18,20,17,.18);
  transition: transform 140ms var(--ease-out), background-color 180ms ease;
}

.playButton:active { transform: scale(.97); }
.playButton:disabled { cursor: wait; opacity: .7; }
.buttonArrow { width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.12); font-size: 16px; }

.formMessage { min-height: 20px; margin: 10px 2px 0; color: #5d725e; font-size: 12px; }
.formMessage.error { color: #b94b3b; }

.controlHint { margin-top: 26px; display: flex; align-items: center; gap: 9px; color: #777a73; font-size: 11px; }
.controlHint kbd { min-width: 42px; padding: 5px 7px; border: 1px solid rgba(21,23,20,.15); border-bottom-width: 2px; border-radius: 7px; background: rgba(255,255,255,.4); color: #444740; font-size: 10px; text-align: center; }
.controlHint span + kbd { margin-left: 7px; }

.heroVisual { perspective: 1400px; }

.previewCard {
  padding: 17px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 29px;
  background: #181b17;
  color: #e9ece5;
  box-shadow: 0 40px 70px rgba(24,28,22,.28), inset 0 1px rgba(255,255,255,.09);
  transform: rotateY(-4deg) rotateX(1deg);
}

.previewTop, .previewBottom { height: 46px; padding: 0 9px; display: flex; align-items: center; justify-content: space-between; color: #8e9388; font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.previewPulse { color: #9bca84; }
.previewPitch { height: clamp(380px, 42vw, 610px); position: relative; overflow: hidden; border: 1px solid rgba(255,255,255,.18); border-radius: 18px; background: linear-gradient(90deg, rgba(255,255,255,.025) 50%, transparent 50%) 0 0 / 21% 100%, #397c3d; box-shadow: inset 0 0 60px rgba(13,28,14,.27); }
.previewPitch::before { content: ""; position: absolute; inset: 6%; border: 2px solid rgba(255,255,255,.64); }
.previewPitch::after { content: ""; position: absolute; inset: 0; opacity: .08; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='a'%3E%3CfeTurbulence baseFrequency='.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)'/%3E%3C/svg%3E"); }
.previewLine.center { position: absolute; z-index: 1; top: 6%; bottom: 6%; left: 50%; width: 2px; background: rgba(255,255,255,.62); }
.previewCircle { position: absolute; z-index: 1; left: 50%; top: 50%; width: 26%; aspect-ratio: 1; border: 2px solid rgba(255,255,255,.62); border-radius: 50%; transform: translate(-50%,-50%); }
.previewGoal { position: absolute; z-index: 1; top: 36%; width: 8%; height: 28%; border: 2px solid rgba(255,255,255,.7); }
.previewGoal.left { left: -2%; }.previewGoal.right { right: -2%; }
.previewPlayer { position: absolute; z-index: 3; display: grid; justify-items: center; gap: 5px; }
.previewPlayer i { width: 30px; height: 30px; border: 3px solid #121410; border-radius: 50%; box-shadow: inset 8px 8px rgba(255,255,255,.17), 0 8px 14px rgba(0,0,0,.22); }
.previewPlayer b { padding: 3px 7px; border-radius: 6px; background: rgba(14,17,13,.75); color: white; font-size: 10px; }
.previewPlayer.blue i { background: var(--blue); }.previewPlayer.coral i { background: var(--coral); }.previewPlayer.cream i { background: #e8dd9f; }
.previewPlayer.p1 { left: 25%; top: 26%; }.previewPlayer.p2 { right: 22%; bottom: 23%; }.previewPlayer.p3 { left: 42%; bottom: 31%; }
.previewBall { position: absolute; z-index: 4; left: 52%; top: 57%; width: 14px; height: 14px; border: 2px solid #171916; border-radius: 50%; background: #f4f1e8; box-shadow: 0 5px 8px rgba(0,0,0,.23); }
.kickWave { position: absolute; z-index: 2; left: calc(42% + 15px); bottom: calc(31% + 14px); width: 31px; height: 31px; border: 2px solid rgba(255,255,255,.82); border-radius: 50%; animation: previewKick 2.4s var(--ease-out) infinite; }
.previewBottom strong { color: #e9ece5; font-size: 11px; }

@keyframes previewKick { 0%, 58% { transform: scale(.95); opacity: 0; } 64% { opacity: .9; } 86%,100% { transform: scale(3); opacity: 0; } }

.meaning { grid-column: 1 / -1; align-self: end; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 20px; color: #777a73; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.meaning strong { color: var(--ink); }.meaningDivider { color: #b4b6b0; }

/* Game */
body.isPlaying { overflow: hidden; background: #10120f; }
body.isPlaying #app { width: 100%; min-height: 100dvh; margin: 0; border: 0; border-radius: 0; background: #10120f; box-shadow: none; }
body.isPlaying .topbar { display: none; }

.game { height: 100dvh; display: grid; grid-template-rows: 68px minmax(0,1fr); background: #10120f; color: #f4f5f0; }
.gameBar { position: relative; padding: 0 22px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.09); background: rgba(18,20,17,.94); }
.gameBrand img { width: 35px; height: 35px; }.gameBrand > span { font-size: 17px; }
.scoreboard { min-width: 132px; height: 44px; padding: 0 18px; display: flex; align-items: center; justify-content: center; gap: 16px; border: 1px solid rgba(255,255,255,.11); border-radius: 14px; background: #1e211c; font-size: 14px; }
.scoreboard strong { font-size: 20px; font-variant-numeric: tabular-nums; }.scoreboard strong:first-child { color: #87a8ff; }.scoreboard strong:last-child { color: #ff9a82; }
.gameMeta { justify-self: end; padding-right: 88px; display: flex; align-items: center; gap: 16px; color: #989d92; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.gameMeta span { display: inline-flex; align-items: center; gap: 8px; }
.gameMeta .liveDot { width: 6px; height: 6px; }
.leaveButton { position: absolute; right: 22px; height: 34px; padding: 0 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(255,255,255,.05); color: #c8cbc3; font-size: 11px; cursor: pointer; transition: transform 140ms var(--ease-out), background-color 180ms ease; }
.leaveButton:active { transform: scale(.97); }

.gameStage { min-height: 0; position: relative; overflow: hidden; padding: 16px; background: radial-gradient(circle at 50% 42%, #1d241b, #10120f 72%); }
#gameCanvas { width: 100%; height: 100%; display: block; border-radius: 20px; box-shadow: 0 18px 55px rgba(0,0,0,.34); }
.connectionState { position: absolute; left: 50%; top: 30px; z-index: 4; padding: 8px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(17,19,16,.82); color: #e5b986; font-size: 11px; transform: translateX(-50%); backdrop-filter: blur(12px); transition: opacity 180ms ease, transform 180ms var(--ease-out); }
.connectionState.online { color: #a8d598; }.connectionState.hidden { opacity: 0; transform: translate(-50%,-6px); pointer-events: none; }
.gameInstructions { position: absolute; left: 50%; bottom: 30px; z-index: 2; display: flex; gap: 9px; color: rgba(255,255,255,.62); font-size: 11px; transform: translateX(-50%); text-shadow: 0 1px 8px rgba(0,0,0,.4); }

.goalBanner { position: absolute; z-index: 6; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; opacity: 0; transform: scale(.96); }
.goalBanner::before { content: ""; position: absolute; inset: 0; background: rgba(185,255,102,.1); }
.goalBanner small, .goalBanner strong, .goalBanner span { position: relative; }.goalBanner small { margin-bottom: 6px; color: #e9eadf; font-size: 12px; font-weight: 800; letter-spacing: .2em; }.goalBanner strong { font-size: clamp(72px, 12vw, 180px); line-height: .8; letter-spacing: -.08em; text-shadow: 0 18px 50px rgba(0,0,0,.25); }.goalBanner span { margin-top: 22px; color: #fff; font-size: clamp(17px, 2vw, 28px); font-weight: 760; letter-spacing: -.025em; text-shadow: 0 8px 24px rgba(0,0,0,.4); }
.goalBanner.show { animation: goalPop 1200ms var(--ease-out) both; }
@keyframes goalPop { 0% { opacity: 0; transform: scale(.95); } 20%,70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.02); } }

.joystick, .touchShoot { display: none; }

@media (hover: hover) and (pointer: fine) {
  .playButton:hover { background: #292c27; transform: translateY(-1px); }
  .leaveButton:hover { background: rgba(255,255,255,.1); }
}

@media (max-width: 1040px) {
  #app { width: min(100% - 20px, 960px); margin: 10px auto; min-height: calc(100dvh - 20px); }
  .topbar { height: 78px; padding: 0 26px; }
  .landing { padding: 44px 5% 30px; grid-template-columns: 1fr; gap: 48px; }
  .heroCopy { max-width: 720px; }
  h1 { font-size: clamp(58px, 10vw, 92px); }
  .heroText { max-width: 620px; }
  .previewCard { transform: none; }
  .previewPitch { height: min(64vw, 560px); }
  .meaning { margin-top: 0; flex-wrap: wrap; }
}

@media (max-width: 640px) {
  #app { width: 100%; min-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .topbar { height: 70px; padding: 0 18px; }
  .brandMark { width: 36px; height: 36px; }.wordmark { font-size: 18px; }
  .statGoals { display: none; }.stat { padding: 0 0 0 14px; }
  .landing { min-height: calc(100dvh - 70px); padding: 48px 18px 28px; display: block; }
  h1 { font-size: clamp(50px, 16.5vw, 76px); }
  .heroText { margin: 25px 0; font-size: 14px; }
  .playForm { display: grid; }.nameField { min-height: 58px; }.playButton { min-height: 54px; }
  .controlHint { flex-wrap: wrap; }
  .heroVisual { margin-top: 48px; }.previewCard { padding: 11px; border-radius: 21px; }.previewPitch { height: 76vw; min-height: 310px; }
  .meaning { margin-top: 34px; gap: 9px 13px; font-size: 9px; }
  .meaningDivider { display: none; }
  .game { grid-template-rows: 56px minmax(0,1fr); }.gameBar { padding: 0 10px; grid-template-columns: 1fr auto 1fr; gap: 6px; }
  .gameBrand img { width: 30px; height: 30px; }.gameBrand > span { display: none; }
  .scoreboard { min-width: 108px; height: 38px; gap: 12px; padding: 0 12px; }.scoreboard strong { font-size: 17px; }
  .gameMeta { gap: 6px; padding-right: 70px; }.gameMeta #pingLabel { display: none; }.gameMeta #gameOnline { display: none; }
  .leaveButton { right: 10px; }.gameStage { padding: 6px; }.gameInstructions { display: none; }
}

@media (pointer: coarse) {
  html, body, body.isPlaying, body.isPlaying #app, .game { touch-action: none; overscroll-behavior: none; }
  .game { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .gameStage { touch-action: none; }
  .joystick { position: absolute; z-index: 5; left: 0; top: 0; width: 116px; height: 116px; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; display: grid; place-items: center; background: rgba(16,18,15,.3); opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%,-50%) scale(.96); backdrop-filter: blur(5px); transition: opacity 120ms ease, transform 160ms var(--ease-out), visibility 0s linear 160ms; }
  .joystick.active { opacity: 1; visibility: visible; transform: translate(-50%,-50%) scale(1); transition-delay: 0s; }
  .joystickKnob { width: 48px; height: 48px; border: 1px solid rgba(255,255,255,.38); border-radius: 50%; background: rgba(255,255,255,.2); box-shadow: 0 6px 18px rgba(0,0,0,.18); will-change: transform; }
  .touchShoot { position: absolute; z-index: 5; right: max(26px, env(safe-area-inset-right)); bottom: max(30px, env(safe-area-inset-bottom)); width: 88px; height: 88px; border: 1px solid rgba(255,255,255,.46); border-radius: 50%; display: grid; place-content: center; gap: 2px; background: rgba(244,245,239,.86); color: #171916; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; box-shadow: 0 10px 28px rgba(0,0,0,.25); transition: transform 120ms var(--ease-out), background-color 120ms ease; touch-action: manipulation; }
  .touchShoot span { font-size: 22px; line-height: .75; }.touchShoot.pressed, .touchShoot:active { transform: scale(.95); background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
