:root {
  --bg: #07120d;
  --panel: rgba(9, 18, 15, .72);
  --panel-strong: rgba(9, 18, 15, .88);
  --line: rgba(255, 255, 255, .15);
  --text: #f7fff9;
  --muted: rgba(247, 255, 249, .72);
  --accent: #6cff8d;
  --accent-2: #7cd6ff;
  --danger: #ff5f6d;
  --gold: #ffd76a;
  --shadow: 0 24px 80px rgba(0,0,0,.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.home-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 18%, rgba(108,255,141,.32), transparent 28%),
    radial-gradient(circle at 88% 10%, rgba(124,214,255,.24), transparent 30%),
    linear-gradient(140deg, #06120d 0%, #0a2417 48%, #05100b 100%);
  overflow-x: hidden;
}

.home-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.hero-card {
  position: relative;
  width: min(1120px, 100%);
  padding: clamp(24px, 4vw, 54px);
  border: 1px solid var(--line);
  border-radius: 36px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background:
    linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.035)),
    rgba(5, 12, 8, .68);
}

.hero-bg {
  position: absolute;
  inset: -1px;
  pointer-events: none;
  opacity: .55;
  background:
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 30%, black, transparent 70%);
}

.brand-pill,
.feature-row span,
.glass {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .02em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 26px var(--accent);
}

h1,
h2,
p {
  position: relative;
}

.hero-card h1 {
  max-width: 820px;
  margin: 20px 0 12px;
  font-size: clamp(44px, 8vw, 96px);
  line-height: .88;
  letter-spacing: -.07em;
}

.hero-copy {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.45;
}

.home-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 34px;
}

.glass {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0,0,0,.22);
}

.play-card {
  border-radius: 28px;
  padding: 24px;
}

.play-card h2 {
  margin: 0 0 18px;
  font-size: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

input {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: rgba(0,0,0,.32);
  padding: 0 15px;
  margin-bottom: 14px;
}

input:focus {
  border-color: rgba(108,255,141,.75);
  box-shadow: 0 0 0 4px rgba(108,255,141,.12);
}

.code-input {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 900;
}

.primary-btn,
.secondary-btn,
.mini-btn {
  border: 0;
  border-radius: 18px;
  min-height: 52px;
  padding: 0 20px;
  cursor: pointer;
  color: #06120d;
  font-weight: 950;
  letter-spacing: -.02em;
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #d8ff64);
  box-shadow: 0 14px 34px rgba(108,255,141,.22);
}

.secondary-btn {
  background: linear-gradient(135deg, var(--accent-2), #f0fbff);
  box-shadow: 0 14px 34px rgba(124,214,255,.18);
}

.primary-btn:active,
.secondary-btn:active,
.mini-btn:active {
  transform: scale(.98);
}

.full-btn {
  width: 100%;
}

.feature-row {
  position: relative;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.feature-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
}

.small-note {
  min-height: 20px;
  color: var(--gold);
  font-weight: 800;
}

.game-body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #06120d;
  touch-action: manipulation;
  user-select: none;
}

.three-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.three-root canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.game-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 35%, transparent 0%, rgba(0,0,0,.12) 58%, rgba(0,0,0,.70) 100%),
    linear-gradient(180deg, rgba(0,0,0,.45), transparent 26%, rgba(0,0,0,.45));
}

.game-hud {
  position: fixed;
  z-index: 5;
}

.top-hud {
  top: max(14px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-link {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: var(--text);
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(14px);
}

.score-card {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(14px);
}

.team {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.team-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.team strong {
  font-size: 32px;
  line-height: 1;
}

.align-right {
  text-align: right;
}

.match-center {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 92px;
  padding: 7px 10px;
  border-radius: 16px;
  background: rgba(255,255,255,.08);
}

.match-center span {
  font-weight: 950;
  letter-spacing: .12em;
}

.match-center small {
  color: var(--muted);
  font-weight: 800;
}

.status-panel {
  top: calc(max(14px, env(safe-area-inset-top)) + 70px);
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-radius: 24px;
  padding: 14px 16px;
}

.status-panel h1 {
  margin: 0;
  font-size: clamp(17px, 4vw, 26px);
  letter-spacing: -.03em;
}

.status-panel p {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 720;
}

.mini-btn {
  min-height: 42px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.10);
}

.controls-shell {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(720px, calc(100vw - 24px));
  transform: translateX(-50%);
}

.control-card {
  display: none;
  border-radius: 28px;
  padding: 16px;
}

.control-card.is-active {
  display: block;
  animation: floatIn .24s ease both;
}

@keyframes floatIn {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.control-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.control-heading strong {
  font-size: 18px;
}

.control-heading span,
#waitText,
.result-card span {
  color: var(--muted);
  font-weight: 760;
  font-size: 13px;
}

.goal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.goal-grid button {
  min-height: 54px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255,255,255,.08);
  font-weight: 900;
  cursor: pointer;
}

.goal-grid button.selected {
  color: #06120d;
  background: linear-gradient(135deg, var(--accent), #fff27d);
  box-shadow: 0 0 0 4px rgba(108,255,141,.14);
}

.power-label {
  margin: 4px 0 12px;
}

.power-label strong {
  color: var(--accent);
}

input[type="range"] {
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
}

#waitControls {
  text-align: center;
  padding: 22px;
}

.loader-ball {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 28%, transparent 29%),
    conic-gradient(#111 0 12%, #fff 12% 22%, #111 22% 34%, #fff 34% 48%, #111 48% 62%, #fff 62% 76%, #111 76% 88%, #fff 88%);
  animation: spin 1s linear infinite;
  box-shadow: 0 12px 28px rgba(0,0,0,.28);
}

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

.result-card {
  text-align: center;
}

.result-card strong {
  display: block;
  font-size: 22px;
  margin-bottom: 3px;
}

.result-card .primary-btn {
  margin-top: 12px;
}

.join-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(14px);
}

.join-overlay.is-active {
  display: grid;
}

.join-box {
  width: min(420px, 100%);
  border-radius: 30px;
  padding: 24px;
}

.join-box h2 {
  margin: 0 0 8px;
  font-size: 30px;
}

.join-box p {
  color: var(--muted);
}

.plain-link {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

@media (max-width: 760px) {
  .home-shell {
    padding: 14px;
  }

  .hero-card {
    border-radius: 28px;
    padding: 22px;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .play-card {
    padding: 18px;
  }

  .feature-row span {
    font-size: 13px;
  }

  .status-panel {
    top: auto;
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 248px);
    padding: 12px;
  }

  .controls-shell {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .control-card {
    border-radius: 24px;
    padding: 12px;
  }

  .goal-grid {
    gap: 7px;
  }

  .goal-grid button {
    min-height: 48px;
    padding: 6px;
    font-size: 12px;
  }

  .score-card {
    border-radius: 19px;
  }

  .team strong {
    font-size: 26px;
  }

  .match-center {
    min-width: 76px;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .status-panel {
    display: none;
  }

  .controls-shell {
    width: min(560px, calc(100vw - 110px));
    right: 14px;
    left: auto;
    transform: none;
  }

  .goal-grid button {
    min-height: 40px;
  }
}


/* ===== V2: matchmaking + WhatsApp + mobile polish ===== */

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

.card-copy {
  margin: -8px 0 16px;
  color: var(--muted);
  font-weight: 720;
  line-height: 1.35;
}

.spotlight-card {
  position: relative;
  overflow: hidden;
}

.spotlight-card::before {
  content: "";
  position: absolute;
  inset: -80px;
  background:
    radial-gradient(circle at 50% 0%, rgba(108,255,141,.24), transparent 38%),
    radial-gradient(circle at 90% 20%, rgba(124,214,255,.16), transparent 34%);
  pointer-events: none;
}

.whatsapp-btn {
  border: 0;
  border-radius: 18px;
  min-height: 52px;
  padding: 0 20px;
  cursor: pointer;
  color: #06120d;
  font-weight: 950;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #25d366, #b8ff72);
  box-shadow: 0 14px 34px rgba(37, 211, 102, .20);
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}

.whatsapp-btn:active {
  transform: scale(.98);
}

#createWhatsappBtn {
  margin-top: 10px;
}

.pulse-btn {
  position: relative;
  isolation: isolate;
}

.pulse-btn::after {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: 22px;
  background: rgba(108,255,141,.32);
  animation: pulseOnline 1.6s ease infinite;
}

@keyframes pulseOnline {
  0%, 100% {
    transform: scale(.98);
    opacity: .28;
  }
  50% {
    transform: scale(1.05);
    opacity: .7;
  }
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.whatsapp-mini {
  color: #06120d;
  border: 0;
  background: linear-gradient(135deg, #25d366, #b8ff72);
}

.invite-row {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.compact-btn {
  min-height: 46px;
  border-radius: 16px;
}

@media (max-width: 1180px) {
  .home-grid-v2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .status-panel .hud-actions {
    display: flex;
  }

  .status-panel {
    gap: 8px;
  }

  .mini-btn {
    min-height: 38px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 14px;
  }

  .status-panel p {
    font-size: 12px;
  }

  .status-panel h1 {
    font-size: 17px;
  }
}

@media (max-width: 420px) {
  .hud-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .mini-btn {
    min-height: 32px;
  }
}
