:root {
  --yellow: #ffdf37;
  --orange: #ff7a24;
  --blue: #226be0;
  --navy: #07162d;
  --green: #29cf65;
  --red: #ff4f43;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  display: grid;
  place-items: center;
  background: #050d1d;
  color: #fff;
  font-family: "Nunito", sans-serif;
  touch-action: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.home-btn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  z-index: 50;
  padding: 9px 13px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(4, 13, 30, 0.82);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
  backdrop-filter: blur(8px);
}

#game-shell {
  position: relative;
  width: min(100vw, 1200px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--navy);
  box-shadow: 0 20px 80px #000;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 18%, rgba(32, 118, 220, 0.28), transparent 42%),
    rgba(5, 15, 34, 0.88);
  backdrop-filter: blur(5px);
}

.menu-card,
.info-card {
  width: min(480px, 94vw);
  max-height: 96%;
  overflow-y: auto;
  padding: clamp(18px, 4vw, 28px);
  border: 3px solid #31588f;
  border-radius: 26px;
  background: linear-gradient(165deg, rgba(17, 49, 91, 0.96), rgba(7, 22, 48, 0.97));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.ball-logo {
  margin-bottom: -2px;
  font-size: clamp(2rem, 7vw, 3.3rem);
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.25));
}

.kicker {
  margin: 0 0 5px;
  color: #9fc8ff;
  font-size: clamp(0.55rem, 1.5vw, 0.72rem);
  font-weight: 900;
  letter-spacing: 0.25em;
}

h1,
h2 {
  margin: 0;
  font-family: "Black Han Sans", sans-serif;
  line-height: 0.88;
  letter-spacing: 0.03em;
}

h1 {
  color: var(--yellow);
  font-size: clamp(2.4rem, 8vw, 4.6rem);
  text-shadow: 0 5px 0 #b74a13, 0 10px 25px rgba(0, 0, 0, 0.45);
}

h1 span {
  color: #fff;
  font-size: 0.73em;
  letter-spacing: 0.13em;
}

h2 {
  color: var(--yellow);
  font-size: clamp(2rem, 7vw, 3.6rem);
  text-shadow: 0 4px 0 #a74618;
}

.tagline {
  margin: 9px 0 13px;
  color: #d8e8ff;
  font-size: clamp(0.68rem, 1.7vw, 0.84rem);
}

.team-picker > p {
  margin: 0 0 7px;
  color: #87adde;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.17em;
}

.teams {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  margin-bottom: 13px;
}

.team-btn {
  min-width: 0;
  padding: 7px 3px;
  border: 2px solid #2c4d7c;
  border-radius: 11px;
  background: #0c2347;
  color: #fff;
  font-size: clamp(1.25rem, 4.5vw, 1.75rem);
}

.team-btn span {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 0.45rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-btn.selected {
  border-color: var(--yellow);
  background: #254f86;
  box-shadow: 0 0 16px rgba(255, 223, 55, 0.25);
  transform: translateY(-2px);
}

.primary-btn,
.kick-btn {
  border: 0;
  border-bottom: 5px solid #a83f0c;
  border-radius: 15px;
  background: linear-gradient(#ffbe35, var(--orange));
  color: #321701;
  font-weight: 900;
  letter-spacing: 0.07em;
}

.primary-btn {
  width: 100%;
  padding: 13px 18px;
}

.primary-btn:active,
.kick-btn:active {
  transform: translateY(3px);
  border-bottom-width: 2px;
}

.text-btn {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: #9fc8ff;
  font-size: 0.72rem;
  text-decoration: underline;
}

.info-card > p:not(.kicker) {
  color: #d6e6ff;
  font-size: 0.82rem;
  line-height: 1.5;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 20px 0;
}

.steps div {
  padding: 13px 5px;
  border: 2px solid #31588f;
  border-radius: 14px;
  background: #0c2347;
}

.steps b {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0 auto 7px;
  border-radius: 50%;
  background: var(--yellow);
  color: #18223a;
  font-size: 1.1rem;
}

.steps span {
  color: #d9e8ff;
  font-size: clamp(0.52rem, 1.6vw, 0.68rem);
}

kbd {
  padding: 2px 5px;
  border-radius: 4px;
  background: #07162d;
  color: var(--yellow);
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#hud button,
#hud input,
#hud label {
  pointer-events: auto;
}

.scoreboard {
  position: absolute;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  min-width: min(390px, 76vw);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 17px;
  background: rgba(5, 18, 42, 0.9);
  transform: translateX(-50%);
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.3);
}

.side {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  font-size: clamp(1.05rem, 3vw, 1.6rem);
}

.side strong {
  color: var(--yellow);
}

.round {
  min-width: 115px;
  padding: 5px 12px;
  border-inline: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
}

.round small,
.round em {
  display: block;
  color: #8cb3e5;
  font-size: 0.48rem;
  font-style: normal;
  letter-spacing: 0.12em;
}

.round b {
  display: block;
  color: #fff;
  font-size: 0.86rem;
}

.round em {
  color: var(--yellow);
}

.instruction {
  position: absolute;
  top: 19%;
  left: 50%;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(5, 18, 42, 0.78);
  color: var(--yellow);
  font-size: clamp(0.65rem, 2vw, 0.9rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  transform: translateX(-50%);
  text-shadow: 0 2px 4px #000;
}

.callout {
  position: absolute;
  top: 29%;
  left: 50%;
  color: var(--yellow);
  font-family: "Black Han Sans", sans-serif;
  font-size: clamp(2.5rem, 10vw, 6rem);
  transform: translateX(-50%) rotate(-3deg);
  text-shadow: 0 5px 0 #a53c15, 0 9px 22px #000;
  animation: pop 0.25s ease-out;
}

.callout.bad {
  color: #ff8178;
  text-shadow: 0 5px 0 #8b1711, 0 9px 22px #000;
}

@keyframes pop {
  from { transform: translateX(-50%) scale(0.35) rotate(8deg); opacity: 0; }
}

.bottom-controls {
  position: absolute;
  right: 15px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 15px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.curve-control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  width: min(310px, 48vw);
  padding: 10px 13px 13px;
  border-radius: 15px;
  background: rgba(5, 18, 42, 0.84);
  color: var(--yellow);
}

.curve-control input {
  min-width: 0;
  flex: 1;
  accent-color: var(--yellow);
}

.curve-control small {
  position: absolute;
  right: 0;
  bottom: 1px;
  left: 0;
  color: #88a9d6;
  font-size: 0.43rem;
  letter-spacing: 0.16em;
  text-align: center;
}

.kick-btn {
  min-width: min(190px, 34vw);
  min-height: 58px;
  padding: 10px 18px;
  color: #fff;
  background: linear-gradient(#ff6b5f, #d63025);
  border-bottom-color: #84150e;
  font-size: clamp(0.78rem, 2.5vw, 1.1rem);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.power-gauge {
  position: absolute;
  bottom: 105px;
  left: 50%;
  width: min(440px, 78vw);
  height: 25px;
  overflow: visible;
  border: 2px solid #31588f;
  border-radius: 99px;
  background: rgba(5, 18, 42, 0.9);
  transform: translateX(-50%);
}

.power-gauge label {
  position: absolute;
  right: 0;
  bottom: 29px;
  left: 0;
  color: #9fc8ff;
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-align: center;
}

.sweet {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 68%;
  width: 17%;
  border-radius: 99px;
  background: rgba(41, 207, 101, 0.75);
}

.needle {
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: 0;
  width: 6px;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 0 12px #fff;
}

.result-card #trophy {
  font-size: clamp(3rem, 10vw, 6rem);
}

#result-score {
  font-weight: 900;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.result-actions a {
  display: grid;
  place-items: center;
  border: 2px solid #31588f;
  border-radius: 15px;
  color: #cfe2ff;
  font-size: 0.72rem;
  font-weight: 900;
  text-decoration: none;
}

@media (max-height: 560px) {
  .menu-card {
    transform: scale(0.86);
  }
}

@media (max-width: 620px) {
  #game-shell {
    width: 100vw;
  }

  .home-btn {
    font-size: 0;
  }

  .home-btn::after {
    font-size: 1rem;
    content: "←";
  }
}
