:root {
  --ink: #fbfff7;
  --muted: #bdd4cd;
  --panel: rgba(5, 14, 17, 0.78);
  --panel-strong: rgba(4, 9, 12, 0.94);
  --line: rgba(255, 255, 255, 0.2);
  --gold: #ffd659;
  --red: #ed4e3b;
  --cyan: #55d7e6;
  --grass: #187c4c;
  --deep: #071015;
  --shadow: rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  overflow: hidden;
  background: #071015;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: 0;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid rgba(255, 214, 89, 0.95);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 480px;
  overflow: hidden;
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #123d2c;
  touch-action: none;
}

.top-hud {
  position: absolute;
  inset: max(10px, env(safe-area-inset-top)) 10px auto;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.brand-lockup,
.score-tile,
.shot-panel,
.field-readout,
.final-copy {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(4, 10, 12, 0.9), rgba(21, 42, 38, 0.72));
  box-shadow: 0 16px 42px var(--shadow);
  backdrop-filter: blur(10px);
}

.brand-lockup {
  width: min(340px, 43vw);
  padding: 12px 14px;
}

.brand-lockup span,
.score-tile span,
.shot-panel span,
.final-copy span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.brand-lockup h1 {
  margin: 4px 0 0;
  font-size: clamp(1.12rem, 2.2vw, 1.8rem);
  line-height: 1.02;
  text-wrap: balance;
}

.score-strip {
  display: grid;
  grid-template-columns: minmax(70px, 92px) minmax(116px, 172px) minmax(70px, 92px);
  gap: 8px;
}

.score-tile {
  min-height: 66px;
  padding: 10px 12px;
  text-align: center;
}

.score-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 1.26rem;
  line-height: 1.05;
  white-space: nowrap;
}

.home-score strong {
  color: var(--red);
}

.away-score strong {
  color: var(--cyan);
}

.possession-tile strong {
  font-size: 1rem;
  text-transform: uppercase;
}

.field-readout {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 3;
  width: min(440px, calc(100vw - 28px));
  min-height: 86px;
  transform: translate(-50%, -50%);
  padding: 16px 18px;
  text-align: center;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.field-readout.is-quiet {
  opacity: 0.2;
  transform: translate(-50%, -50%) scale(0.97);
}

.field-readout p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.45rem, 4.1vw, 2.35rem);
  font-weight: 950;
  line-height: 1.02;
  text-wrap: balance;
}

.field-readout span {
  display: block;
  min-height: 21px;
  margin-top: 6px;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 850;
  line-height: 1.15;
}

.shot-panel {
  position: absolute;
  right: 10px;
  top: min(126px, 20vh);
  z-index: 3;
  display: grid;
  width: 116px;
  gap: 8px;
  padding: 10px;
  pointer-events: none;
}

.shot-panel div {
  min-height: 42px;
}

.shot-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
  line-height: 1;
}

.control-dock {
  position: absolute;
  inset: auto 0 max(12px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right));
  pointer-events: none;
}

.stick-zone {
  position: relative;
  width: clamp(96px, 23vw, 146px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 214, 89, 0.15), transparent 54%),
    rgba(4, 10, 12, 0.34);
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.35), 0 18px 48px var(--shadow);
}

.stick-zone span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.13);
  transform: translate(-50%, -50%);
}

.action-cluster {
  display: grid;
  grid-template-columns: minmax(124px, 174px) 76px 76px 48px 48px;
  align-items: end;
  gap: 8px;
  pointer-events: auto;
}

.round-button,
.start-button {
  display: grid;
  place-items: center;
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(18, 45, 51, 0.96), rgba(5, 15, 18, 0.96));
  box-shadow: 0 14px 32px var(--shadow);
  cursor: pointer;
}

.round-button img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  pointer-events: none;
}

.start-button {
  padding: 0 16px;
  background: linear-gradient(180deg, #ef6048, #c83228);
  color: #fff9e8;
  font-size: 0.98rem;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.32);
  white-space: normal;
}

.kick-button {
  min-height: 76px;
  background: linear-gradient(180deg, #ffe37b, #d8821d);
}

.sprint-button {
  min-height: 70px;
  background: linear-gradient(180deg, #4bd9e8, #1d6fa3);
}

.kick-button img,
.sprint-button img {
  width: 44px;
  height: 44px;
}

.small-button {
  min-height: 44px;
  align-self: start;
}

.small-button img {
  width: 24px;
  height: 24px;
}

button:disabled {
  cursor: default;
  filter: grayscale(0.82);
  opacity: 0.58;
}

.final-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.final-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.final-copy {
  width: min(420px, calc(100vw - 36px));
  padding: 22px;
  text-align: center;
}

.final-copy strong {
  display: block;
  margin: 8px 0 18px;
  font-size: clamp(1.7rem, 6vw, 3.1rem);
  line-height: 1.02;
}

.final-copy .start-button {
  width: min(220px, 100%);
  margin: 0 auto;
}

@media (max-width: 760px) {
  .app-shell {
    min-height: 430px;
  }

  .brand-lockup {
    width: min(210px, 46vw);
    padding: 10px 11px;
  }

  .brand-lockup h1 {
    font-size: 1rem;
  }

  .score-strip {
    grid-template-columns: 62px minmax(92px, 124px) 62px;
    gap: 6px;
  }

  .score-tile {
    min-height: 58px;
    padding: 8px 7px;
  }

  .score-tile span,
  .shot-panel span,
  .brand-lockup span {
    font-size: 0.63rem;
  }

  .score-tile strong {
    font-size: 1rem;
  }

  .possession-tile strong {
    font-size: 0.78rem;
  }

  .shot-panel {
    top: 92px;
    right: 8px;
    width: 96px;
    padding: 8px;
  }

  .shot-panel div {
    min-height: 34px;
  }

  .field-readout {
    top: 39%;
    min-height: 74px;
    padding: 12px;
  }

  .field-readout span {
    font-size: 0.82rem;
  }

  .action-cluster {
    grid-template-columns: minmax(104px, 130px) 62px 62px 42px 42px;
    gap: 6px;
  }

  .round-button,
  .start-button {
    min-height: 48px;
  }

  .kick-button {
    min-height: 64px;
  }

  .sprint-button {
    min-height: 58px;
  }

  .round-button img {
    width: 28px;
    height: 28px;
  }

  .kick-button img,
  .sprint-button img {
    width: 36px;
    height: 36px;
  }
}

@media (orientation: portrait) {
  .top-hud {
    display: grid;
    grid-template-columns: 1fr;
  }

  .brand-lockup {
    width: min(340px, calc(100vw - 20px));
  }

  .score-strip {
    width: min(340px, calc(100vw - 20px));
  }

  .shot-panel {
    top: auto;
    right: 10px;
    bottom: 132px;
  }

  .control-dock {
    align-items: center;
  }

  .stick-zone {
    width: clamp(88px, 28vw, 120px);
  }

  .action-cluster {
    grid-template-columns: 64px 70px 46px;
    grid-template-areas:
      "start kick sound"
      "reset sprint sound";
    max-width: 218px;
  }

  #startButton {
    grid-area: start;
    min-width: 64px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  #kickButton {
    grid-area: kick;
  }

  #sprintButton {
    grid-area: sprint;
  }

  #soundButton {
    grid-area: sound;
  }

  #resetButton {
    grid-area: reset;
  }
}
