* {
  box-sizing: border-box;
}

:root {
  --panel: rgba(7, 17, 34, 0.92);
  --panel-soft: rgba(16, 31, 54, 0.82);
  --line: rgba(255, 255, 255, 0.15);
  --text: #f8fbff;
  --muted: #aebfd3;
  --accent: #ffd23f;
  --good: #65e38c;
  --bad: #ff6676;
  --blue: #49a8ff;
  --purple: #9b7aff;
}

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

body {
  padding: 18px;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, #315f96 0%, #14213a 38%, #060a14 100%);
  font-family: Inter, "Noto Sans Devanagari", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.game-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.topbar,
.score-panel,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  min-height: 70px;
  padding: 8px 4px 15px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-ball {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  font-size: 28px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.15rem, 3vw, 1.65rem);
  line-height: 1.1;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.icon-btn {
  width: 43px;
  height: 43px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
  transition: 0.18s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.score-panel {
  min-height: 82px;
  margin-bottom: 12px;
  padding: 10px clamp(12px, 4vw, 35px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
}

.team-card {
  display: flex;
  min-width: 170px;
  align-items: center;
  gap: 18px;
}

.team-card strong {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.opponent-team {
  justify-content: flex-end;
}

.team-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.user-team strong {
  color: var(--blue);
}

.opponent-team strong {
  color: var(--bad);
}

.match-center {
  text-align: center;
}

.timer {
  font-size: clamp(1.35rem, 4vw, 2.15rem);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.match-meta {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 5px;
}

.match-meta span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 210, 63, 0.12);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.11em;
}

.match-meta span:first-child {
  background: rgba(73, 168, 255, 0.13);
  color: #8ccaff;
}

.stadium-wrap {
  position: relative;
  min-height: 660px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background: #0d3024;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 660px;
  touch-action: none;
}

.scene-label,
.connection-pill {
  position: absolute;
  z-index: 5;
  top: 15px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(5, 12, 25, 0.72);
  color: #deedff;
  font-size: 0.72rem;
  font-weight: 800;
  backdrop-filter: blur(9px);
}

.scene-label {
  left: 15px;
}

.connection-pill {
  right: 15px;
}

.connection-pill.live {
  border-color: rgba(101, 227, 140, 0.5);
  color: #8bf0a9;
}

.connection-pill.warning {
  border-color: rgba(255, 210, 63, 0.5);
  color: #ffe27b;
}

.typing-hud {
  position: absolute;
  z-index: 4;
  top: 64px;
  left: 50%;
  width: min(680px, calc(100% - 30px));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.instruction {
  margin: 0 0 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 12px #000;
}

.target-word {
  min-height: 65px;
  color: #fff;
  font-size: clamp(2.35rem, 8vw, 4.5rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  line-height: 1.05;
  text-transform: uppercase;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, 0.3),
    0 0 24px rgba(255, 255, 255, 0.35),
    0 8px 25px rgba(0, 0, 0, 0.8);
}

.typed-word {
  min-height: 30px;
  margin-top: 5px;
  color: var(--accent);
  font-size: clamp(1.1rem, 4vw, 1.55rem);
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 3px 10px #000;
}

.character-meter {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 7px;
}

.character-meter span {
  width: 28px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.character-meter span.filled {
  background: var(--accent);
}

.message-stack {
  position: absolute;
  z-index: 8;
  top: 220px;
  left: 50%;
  display: grid;
  width: min(460px, calc(100% - 30px));
  transform: translateX(-50%);
  justify-items: center;
  gap: 7px;
  pointer-events: none;
}

.floating-message {
  padding: 9px 17px;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 34, 53, 0.9);
  font-size: clamp(0.78rem, 2.7vw, 1rem);
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.3);
  animation: float-message 1.15s ease forwards;
}

.floating-message.goal {
  background: rgba(30, 159, 83, 0.93);
}

.floating-message.miss {
  background: rgba(203, 54, 69, 0.93);
}

.floating-message.opponent {
  background: rgba(56, 82, 134, 0.94);
}

@keyframes float-message {
  0% { opacity: 0; transform: translateY(8px) scale(0.95); }
  16% { opacity: 1; transform: translateY(0) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px) scale(0.98); }
}

.mobile-type-btn {
  display: none;
  position: absolute;
  z-index: 10;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 13px 20px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: white;
  background: rgba(5, 14, 29, 0.88);
  font-weight: 900;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.mobile-input {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 8, 18, 0.76);
  backdrop-filter: blur(8px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(640px, 100%);
  max-height: calc(100% - 20px);
  overflow-y: auto;
  padding: clamp(22px, 5vw, 38px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 26px;
  background: linear-gradient(150deg, rgba(25, 44, 73, 0.98), rgba(7, 17, 34, 0.98));
  text-align: center;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.5);
}

.overlay-card h2 {
  margin: 8px 0 12px;
  font-size: clamp(1.7rem, 6vw, 2.55rem);
}

.overlay-card p {
  color: #c6d4e4;
  line-height: 1.55;
}

.large-ball {
  font-size: 58px;
  filter: drop-shadow(0 9px 14px rgba(0, 0, 0, 0.4));
}

.lead {
  max-width: 560px;
  margin: 0 auto 20px;
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  margin: 18px 0;
}

.mode-option {
  position: relative;
  cursor: pointer;
}

.mode-option input,
.difficulty-picker input {
  position: absolute;
  opacity: 0;
}

.mode-option span {
  display: grid;
  min-height: 122px;
  place-content: center;
  gap: 5px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.055);
  transition: 0.2s ease;
}

.mode-option b {
  font-size: 1.8rem;
}

.mode-option small,
.difficulty-picker small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.mode-option input:checked + span,
.difficulty-picker input:checked + span {
  border-color: var(--accent);
  background: rgba(255, 210, 63, 0.11);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 63, 0.35);
}

.language-picker {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  text-align: left;
}

.language-picker label {
  color: #fff;
  font-weight: 950;
}

.language-picker select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
  color: white;
  font: inherit;
  font-weight: 850;
}

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

.difficulty-picker legend {
  width: 100%;
  margin-bottom: 10px;
  color: #fff;
  font-weight: 950;
}

.difficulty-picker label {
  position: relative;
  cursor: pointer;
}

.difficulty-picker span {
  display: grid;
  min-height: 89px;
  place-content: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.055);
  transition: 0.2s ease;
}

.rule-box {
  display: grid;
  gap: 9px;
  margin: 20px 0;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: #dfebf7;
  text-align: left;
}

.rule-icon {
  display: inline-grid;
  width: 23px;
  height: 23px;
  margin-right: 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--good);
  color: #062514;
  font-weight: 1000;
}

.rule-icon.miss {
  background: var(--bad);
  color: #32080c;
}

.primary-btn,
.secondary-btn {
  min-width: 175px;
  padding: 13px 22px;
  border-radius: 13px;
  font-weight: 950;
}

.primary-btn {
  border: 0;
  color: #1b1605;
  background: linear-gradient(135deg, #ffdc42, #f4aa16);
  box-shadow: 0 10px 25px rgba(244, 169, 20, 0.23);
}

.secondary-btn {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  background: rgba(255, 255, 255, 0.07);
}

.keyboard-note {
  margin: 15px 0 0 !important;
  font-size: 0.75rem;
}

.compact-card {
  width: min(420px, 100%);
}

.radar {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto 12px;
  overflow: hidden;
  border: 2px solid rgba(101, 227, 140, 0.48);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(101, 227, 140, 0.2) 0 2px, transparent 3px),
    repeating-radial-gradient(circle, transparent 0 14px, rgba(101, 227, 140, 0.18) 15px 16px);
}

.radar::before,
.radar::after {
  position: absolute;
  content: "";
  background: rgba(101, 227, 140, 0.22);
}

.radar::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
}

.radar::after {
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
}

.radar span {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 72%, rgba(101, 227, 140, 0.65) 100%);
  animation: radar-spin 1.7s linear infinite;
}

@keyframes radar-spin {
  to { transform: rotate(360deg); }
}

.search-countdown {
  display: grid;
  width: 150px;
  margin: 18px auto;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.search-countdown strong {
  color: var(--accent);
  font-size: 2.1rem;
  font-variant-numeric: tabular-nums;
}

.search-countdown span {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.search-status {
  min-height: 24px;
  font-size: 0.82rem;
}

.countdown-number {
  color: white;
  font-size: clamp(6rem, 25vw, 12rem);
  font-weight: 1000;
  line-height: 0.9;
  text-shadow: 0 0 45px rgba(255, 210, 63, 0.65);
  animation: countdown-pop 0.75s ease both;
}

#countdownOverlay p {
  color: white;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@keyframes countdown-pop {
  0% { opacity: 0; transform: scale(1.5); }
  35% { opacity: 1; transform: scale(0.94); }
  100% { opacity: 1; transform: scale(1); }
}

.result-kicker {
  margin-bottom: 0 !important;
  color: var(--accent) !important;
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.2em;
}

.final-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 4vw, 28px);
  margin: 22px 0;
  font-weight: 900;
}

.final-score span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.final-score strong {
  font-size: 3.2rem;
}

.final-score b {
  color: var(--muted);
  font-size: 2rem;
}

.final-score em {
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
  letter-spacing: 0.1em;
}

.match-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 25px;
}

.match-stats div {
  padding: 13px 7px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.match-stats strong,
.match-stats span {
  display: block;
}

.match-stats strong {
  font-size: 1.25rem;
}

.match-stats span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.game-footer {
  gap: 20px;
  padding: 13px 6px 0;
  color: var(--muted);
  font-size: 0.76rem;
}

@media (max-width: 720px) {
  body {
    padding: 8px;
  }

  .topbar {
    min-height: 60px;
  }

  .brand p {
    display: none;
  }

  .brand-ball {
    width: 40px;
    height: 40px;
    font-size: 23px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .score-panel {
    min-height: 68px;
    padding: 8px 10px;
    border-radius: 14px;
  }

  .team-card {
    min-width: 92px;
    gap: 7px;
  }

  .team-card strong {
    font-size: 2rem;
  }

  .team-label {
    max-width: 60px;
    overflow: hidden;
    font-size: 0.56rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stadium-wrap {
    min-height: 610px;
    border-radius: 17px;
  }

  #gameCanvas {
    height: 610px;
  }

  .typing-hud {
    top: 55px;
  }

  .scene-label,
  .connection-pill {
    top: 9px;
    padding: 6px 9px;
    font-size: 0.62rem;
  }

  .scene-label {
    left: 9px;
  }

  .connection-pill {
    right: 9px;
  }

  .message-stack {
    top: 195px;
  }

  .mode-picker,
  .difficulty-picker {
    grid-template-columns: 1fr;
  }

  .mode-option span,
  .difficulty-picker span {
    min-height: 65px;
  }

  .mobile-type-btn {
    display: block;
  }

  .game-footer {
    display: none;
  }
}
