:root {
  --ink: #132018;
  --paper: #fffaf0;
  --panel: rgba(255, 250, 240, 0.94);
  --line: rgba(19, 32, 24, 0.18);
  --shadow: 0 18px 44px rgba(7, 32, 18, 0.32);
  --black: #07120b;
  --grass: #2cc66f;
  --lime: #a7f24b;
  --yellow: #ffd84d;
  --orange: #ff8c32;
  --blue: #28a8ff;
  --red: #f24b5f;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(rgba(5, 18, 9, 0.18), rgba(5, 18, 9, 0.42)),
    url("assets/football-stadium-bg.png") center / cover fixed no-repeat;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
  caret-color: transparent;
  user-select: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 8px;
}

.screen {
  width: min(1840px, 100%);
}

.hidden {
  display: none !important;
}

.start-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 24px;
  align-items: center;
}

.start-copy {
  min-height: 560px;
  display: grid;
  align-content: end;
  padding: clamp(18px, 4vw, 44px);
  color: #fff;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

.kicker {
  width: fit-content;
  margin: 0 0 12px;
  padding: 8px 11px;
  border: 3px solid var(--black);
  border-radius: 8px;
  background: var(--yellow);
  color: #221600;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--black);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 9ch;
  margin-bottom: 18px;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: clamp(3.25rem, 8vw, 7.4rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 5px 5px 0 var(--black), 0 10px 30px rgba(0, 0, 0, 0.42);
}

.intro {
  max-width: 39rem;
  margin-bottom: 0;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 850;
}

.setup-panel,
.result-panel,
.leaderboard-panel,
.coach-panel,
.hud {
  border: 3px solid var(--black);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow), 7px 7px 0 var(--black);
}

.setup-panel {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 3vw, 28px);
}

label {
  display: grid;
  gap: 8px;
  font-weight: 900;
}

input,
select {
  min-height: 48px;
  width: 100%;
  border: 2px solid rgba(7, 18, 11, 0.28);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 750;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 4px solid rgba(255, 216, 77, 0.78);
  outline-offset: 2px;
}

.character-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.character-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  font-weight: 900;
}

.character-card {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 7px;
  justify-items: center;
  padding: 9px 6px;
  border: 2px solid rgba(7, 18, 11, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.05;
}

.character-card input {
  position: absolute;
  inset: 0;
  min-height: 0;
  opacity: 0;
  cursor: pointer;
}

.character-card:has(input:checked) {
  border-color: var(--black);
  background: var(--yellow);
  box-shadow: 4px 4px 0 var(--black);
}

.character-card:has(input:focus-visible) {
  outline: 4px solid rgba(255, 216, 77, 0.78);
  outline-offset: 2px;
}

.character-preview {
  width: 72px;
  height: 74px;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  filter: drop-shadow(0 7px 5px rgba(0, 0, 0, 0.24));
}

.character-boy {
  background-image: url("assets/avatar-boy.png");
}

.character-girl {
  background-image: url("assets/avatar-girl.png");
}

.character-unicorn {
  background-image: url("assets/avatar-unicorn.png");
}

.character-monster {
  background-image: url("assets/avatar-monster.png");
}

.rules {
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.rules p {
  margin: 6px 0 0;
  line-height: 1.45;
}

.start-actions,
.game-over-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--black);
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--black);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-button {
  background: var(--lime);
  color: #07140b;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--black);
}

.game-screen {
  display: grid;
  gap: 8px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) auto;
  gap: 10px;
  padding: 10px;
  align-items: stretch;
}

.hud div,
.result-grid div {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.hud span,
.result-grid span {
  display: block;
  color: rgba(19, 32, 24, 0.72);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.hud strong,
.result-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
}

.sound-button {
  min-height: 100%;
  border: 3px solid var(--black);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--black);
}

.stadium {
  position: relative;
  min-height: clamp(690px, calc(100vh - 190px), 930px);
  overflow: hidden;
  border: 3px solid var(--black);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(3, 30, 12, 0.18)),
    url("assets/football-stadium-bg.png") center 54% / cover no-repeat;
  box-shadow: var(--shadow), 7px 7px 0 var(--black);
}

.stadium::after {
  content: "";
  position: absolute;
  inset: auto 4% 4% 4%;
  height: 45%;
  border: 2px solid rgba(255, 255, 255, 0.44);
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  pointer-events: none;
}

.crowd-ribbon {
  position: absolute;
  inset: 0 0 auto;
  height: 28%;
  background: linear-gradient(180deg, rgba(11, 14, 24, 0.08), transparent);
  pointer-events: none;
}

.target-card {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  padding: 12px 16px;
  border: 3px solid var(--black);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.96);
  text-align: center;
  box-shadow: 5px 5px 0 var(--black);
}

.target-card span {
  display: block;
  color: rgba(19, 32, 24, 0.72);
  font-size: 0.82rem;
  font-weight: 950;
  text-transform: uppercase;
}

.target-card strong {
  display: block;
  color: #0f641e;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1;
  text-transform: lowercase;
}

.goal-area {
  position: absolute;
  z-index: 3;
  top: 22%;
  left: 50%;
  width: min(430px, 29vw);
  aspect-ratio: 2.7 / 1;
  transform: translateX(-50%);
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.word-options {
  position: absolute;
  z-index: 6;
  inset: 50% 7% 15%;
}

.word-button {
  position: absolute;
  min-width: 112px;
  max-width: 190px;
  min-height: 52px;
  border: 3px solid var(--black);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  font-size: clamp(1rem, 2vw, 1.28rem);
  font-weight: 950;
  line-height: 1.05;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--black);
  transition: transform 150ms ease, background 150ms ease;
}

.word-button:hover {
  transform: translateY(-4px);
  background: #e8fbff;
}

.word-button.correct {
  background: var(--lime);
}

.word-button.wrong {
  background: var(--red);
  color: #fff;
}

.sprite {
  position: absolute;
  z-index: 4;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  filter: drop-shadow(0 12px 10px rgba(0, 0, 0, 0.3));
}

.player {
  left: 7%;
  bottom: 3%;
  width: clamp(190px, 19vw, 285px);
  aspect-ratio: 907 / 992;
  background-image: url("assets/avatar-boy.png");
  animation: player-idle 1.65s ease-in-out infinite;
}

.player[data-character="boy"] {
  aspect-ratio: 907 / 992;
  background-image: url("assets/avatar-boy.png");
}

.player[data-character="girl"] {
  aspect-ratio: 922 / 986;
  background-image: url("assets/avatar-girl.png");
}

.player[data-character="unicorn"] {
  width: clamp(178px, 18vw, 255px);
  aspect-ratio: 892 / 1165;
  background-image: url("assets/avatar-unicorn.png");
}

.player[data-character="monster"] {
  width: clamp(180px, 18vw, 260px);
  aspect-ratio: 953 / 1170;
  background-image: url("assets/avatar-monster.png");
}

.keeper {
  left: 52%;
  bottom: 4%;
  width: clamp(105px, 8vw, 145px);
  aspect-ratio: 1612 / 626;
  transform: translateX(-50%);
  background-image: url("assets/goalkeeper-dive.png");
}

.ball {
  z-index: 5;
  --ball-left: 28%;
  --ball-bottom: 15%;
  left: var(--ball-left);
  bottom: var(--ball-bottom);
  width: clamp(42px, 5vw, 68px);
  aspect-ratio: 1;
  background-image: url("assets/ball.png");
}

.ball[data-character="boy"] {
  --ball-left: 28%;
  --ball-bottom: 15%;
}

.ball[data-character="girl"] {
  --ball-left: 29%;
  --ball-bottom: 15%;
}

.ball[data-character="unicorn"] {
  --ball-left: 27%;
  --ball-bottom: 16%;
}

.ball[data-character="monster"] {
  --ball-left: 28%;
  --ball-bottom: 15%;
}

.trophy {
  position: static;
  display: inline-block;
  width: 64px;
  aspect-ratio: 1;
  background-image: url("assets/trophy.png");
  vertical-align: middle;
}

.ball.shoot-goal {
  animation: ball-goal 760ms cubic-bezier(0.2, 0.82, 0.25, 1) forwards;
}

.ball.shoot-save {
  animation: ball-save 720ms cubic-bezier(0.2, 0.82, 0.25, 1) forwards;
}

.keeper.save {
  animation: keeper-save 720ms ease-out;
}

.player.kick {
  animation: player-kick 680ms ease-out;
}

.goal-effect,
.save-effect {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 27%;
  transform: translate(-50%, -50%) scale(0.65);
  opacity: 0;
  padding: 10px 18px;
  border: 4px solid var(--black);
  border-radius: 8px;
  color: #fff;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: clamp(3rem, 8vw, 6rem);
  letter-spacing: 0;
  text-shadow: 4px 4px 0 var(--black);
  pointer-events: none;
}

.goal-effect {
  background: var(--orange);
}

.save-effect {
  background: var(--blue);
}

.goal-effect.active,
.save-effect.active {
  animation: effect-pop 880ms ease-out;
}

.coach-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.feedback,
.bonus-label {
  margin: 0;
  font-weight: 900;
  line-height: 1.35;
}

.feedback.good {
  color: #117739;
}

.feedback.bad {
  color: #b51f34;
}

.bonus-label {
  width: fit-content;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 216, 77, 0.32);
}

.game-over-screen {
  display: grid;
  grid-template-columns: minmax(300px, 0.86fr) minmax(0, 1.14fr);
  gap: 18px;
  align-items: start;
}

.result-panel,
.leaderboard-panel {
  padding: clamp(16px, 3vw, 24px);
}

.result-panel h2 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.new-highscore {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px;
  border: 3px solid var(--black);
  border-radius: 8px;
  background: var(--yellow);
  font-weight: 950;
  box-shadow: 4px 4px 0 var(--black);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.leaderboard-panel h3,
.dialog-top h2 {
  margin-bottom: 14px;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(19, 32, 24, 0.12);
  text-align: left;
  vertical-align: top;
}

.leaderboard-table th {
  background: #123c24;
  color: #fff;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.empty-board {
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  font-weight: 850;
}

.leaderboard-dialog {
  width: min(900px, calc(100% - 24px));
  border: 3px solid var(--black);
  border-radius: 8px;
  padding: 18px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow), 7px 7px 0 var(--black);
}

.leaderboard-dialog::backdrop {
  background: rgba(5, 18, 9, 0.64);
}

.dialog-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 3px solid var(--black);
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

@keyframes player-idle {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-7px);
  }
}

@keyframes player-kick {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  45% {
    transform: translateY(-12px) rotate(-7deg) scale(1.06);
  }
}

@keyframes ball-goal {
  0% {
    left: var(--ball-left);
    bottom: var(--ball-bottom);
    transform: translate(0, 0) scale(1) rotate(0deg);
  }

  100% {
    left: 50%;
    bottom: 70%;
    transform: translateX(-50%) scale(0.28) rotate(760deg);
  }
}

@keyframes ball-save {
  0% {
    left: var(--ball-left);
    bottom: var(--ball-bottom);
    transform: translate(0, 0) scale(1) rotate(0deg);
  }

  100% {
    left: 48%;
    bottom: 68%;
    transform: translateX(-50%) scale(0.42) rotate(520deg);
  }
}

@keyframes keeper-save {
  0%,
  100% {
    transform: translateX(-50%) translateY(0) rotate(0deg);
  }

  45% {
    transform: translateX(-92%) translateY(-8px) rotate(-15deg) scale(1.06);
  }
}

@keyframes effect-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55) rotate(-3deg);
  }

  20%,
  72% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(2deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.18) rotate(0deg);
  }
}

@media (max-width: 940px) {
  .start-screen,
  .game-over-screen,
  .coach-panel {
    grid-template-columns: 1fr;
  }

  .start-copy {
    min-height: 360px;
  }

  .hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .word-options {
    inset: 50% 4% 18%;
  }
}

@media (max-width: 580px) {
  .app {
    padding: 6px;
  }

  .start-copy {
    padding: 10px 4px;
    min-height: 300px;
  }

  h1 {
    font-size: clamp(3rem, 17vw, 5rem);
  }

  .hud,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stadium {
    min-height: 660px;
  }

  .target-card {
    top: 10px;
  }

  .goal-area {
    top: 24%;
    width: 52vw;
  }

  .word-options {
    inset: 50% 3% 16%;
  }

  .word-button {
    min-width: 96px;
    max-width: 136px;
    min-height: 48px;
    padding: 7px 9px;
  }

  .player {
    left: 1%;
    width: 165px;
  }

  .player[data-character="unicorn"],
  .player[data-character="monster"] {
    width: 154px;
  }

  .ball {
    --ball-left: 29%;
    --ball-bottom: 15%;
  }

  .ball[data-character="unicorn"],
  .ball[data-character="monster"] {
    --ball-left: 27%;
    --ball-bottom: 16%;
  }

  .leaderboard-panel {
    overflow-x: auto;
  }

  .leaderboard-table {
    min-width: 720px;
  }

  .character-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
