/* ===== Avatar World Cup — mobile-first, self-contained (no CDN) ===== */
:root {
  --navy: #0b2240;
  --navy-2: #123156;
  --pitch: #1a7a3c;
  --pitch-dark: #0f4a17;
  --gold: #e8b923;
  --gold-dark: #b8890a;
  --white: #ffffff;
  --line: rgba(255, 255, 255, .85);
  --font-hero: "Arial Black", "Segoe UI Black", Arial, sans-serif;
}

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

html, body {
  margin: 0;
  height: 100%;
  font-family: Arial, "Segoe UI", sans-serif;
  background: var(--navy);
  overflow: hidden;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

.stadium-bg {
  position: absolute;
  inset: 0;
  background: url("../assets/stadium.jpg") center 30% / cover no-repeat;
  z-index: -1;
}
.stadium-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11,34,64,.55) 0%, rgba(11,34,64,.15) 40%, rgba(11,34,64,.55) 100%);
}

/* ================= SCREEN 1 ================= */
.start-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(16px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.wc-header { text-align: center; color: var(--white); }
.wc-trophy { font-size: 44px; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }
.wc-header h1 {
  margin: 6px 0 4px;
  font-family: var(--font-hero);
  font-size: clamp(30px, 9vw, 44px);
  line-height: .95;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--gold-dark), 0 6px 14px rgba(0,0,0,.6);
}
.wc-sub {
  font-family: var(--font-hero);
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--white);
  text-shadow: 0 2px 6px rgba(0,0,0,.7);
}

.panel {
  width: min(400px, 100%);
  background: linear-gradient(180deg, var(--pitch) 0%, var(--pitch-dark) 100%);
  border: 4px solid var(--gold);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
}

.panel-label {
  display: block;
  font-family: var(--font-hero);
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--gold);
  margin: 2px 0 8px;
  text-align: center;
}
.squad-label { margin-top: 16px; }

#player-name {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-hero);
  font-size: 20px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--navy);
  background: var(--white);
  border: 3px solid var(--navy);
  border-radius: 12px;
  outline: none;
}
#player-name:focus { border-color: var(--gold); }

.gender-row { display: flex; gap: 12px; }

.gender-card {
  flex: 1;
  padding: 10px 8px 12px;
  background: var(--white);
  border: 4px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .1s, border-color .15s;
}
.gender-card canvas { width: 100%; height: auto; display: block; }
.gender-card .gender-name {
  display: block;
  margin-top: 6px;
  font-family: var(--font-hero);
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--navy);
}
.gender-card.selected {
  border-color: var(--gold);
  transform: scale(1.03);
  box-shadow: 0 0 0 3px rgba(232,185,35,.35), 0 8px 18px rgba(0,0,0,.35);
}

.btn-gold, .btn-white {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px 12px;
  font-family: var(--font-hero);
  font-size: 17px;
  letter-spacing: 1.5px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn-gold {
  color: var(--navy);
  background: linear-gradient(180deg, #ffd94d 0%, var(--gold) 60%, var(--gold-dark) 100%);
  border: 3px solid var(--gold-dark);
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
}
.btn-white {
  color: var(--navy);
  background: var(--white);
  border: 3px solid var(--navy-2);
}
.btn-gold:active, .btn-white:active { transform: scale(.97); }
.btn-gold:disabled { filter: grayscale(.8) brightness(.8); cursor: not-allowed; }

/* ================= SCREEN 2 : BUILDER ================= */
.builder-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.chip-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  font-size: 20px;
  border-radius: 12px;
  border: 3px solid var(--gold-dark);
  background: linear-gradient(180deg, #ffd94d, var(--gold));
  color: var(--navy);
  cursor: pointer;
}
.chip-btn:active { transform: scale(.94); }

.name-plate {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  font-family: var(--font-hero);
  font-size: 17px;
  letter-spacing: 3px;
  color: var(--white);
  background: var(--navy);
  border: 3px solid var(--gold);
  border-radius: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 3px rgba(0,0,0,.6);
}

.preview-wrap {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
}
#preview {
  max-height: 100%;
  max-width: 88%;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.45));
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  font-family: var(--font-hero);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--white);
  background: rgba(11,34,64,.82);
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 999px;
  cursor: pointer;
}
.tab.active {
  color: var(--navy);
  background: var(--gold);
  border-color: var(--gold-dark);
}

.items {
  flex: 0 0 118px;
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  overflow-x: auto;
  align-items: center;
  background: rgba(11,34,64,.55);
  backdrop-filter: blur(3px);
}
.item {
  flex: 0 0 auto;
  width: 92px;
  height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--white);
  border: 3px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  overflow: hidden;
}
.item img { width: 64px; height: 64px; object-fit: contain; pointer-events: none; }
.item .thumb-fallback { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; font-size: 34px; opacity: .5; }
.item .item-name {
  font-size: 10px;
  font-weight: bold;
  color: var(--navy);
  max-width: 84px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(232,185,35,.5);
}
.item.none-item .none-x { font-size: 30px; color: #b33; font-weight: bold; }

/* Divider marking where girls' skirts begin in the BOTTOMS strip */
.items-divider {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}
.items-divider::before {
  content: "";
  width: 3px;
  align-self: stretch;
  margin: 12px 0;
  background: var(--gold);
  border-radius: 2px;
  opacity: .6;
}
.items-divider span {
  writing-mode: vertical-rl;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
}

.swatch-dot {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid var(--navy-2);
  box-shadow: inset -4px -6px 0 rgba(0,0,0,.12);
}

.actions {
  display: flex;
  gap: 10px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11,34,64,.85);
}
.actions .btn-gold {
  margin-top: 0;
  font-size: 16px;
  padding: 14px 6px;
  flex: 1;
}

/* ================= OVERLAYS ================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 15, 30, .82);
  padding: 24px;
}
.overlay.hidden { display: none; }

.overlay-card {
  width: min(360px, 100%);
  text-align: center;
  background: linear-gradient(180deg, var(--pitch) 0%, var(--pitch-dark) 100%);
  border: 4px solid var(--gold);
  border-radius: 22px;
  padding: 26px 20px;
  color: var(--white);
}
.overlay-emoji { font-size: 54px; }
.overlay-card h2 {
  margin: 8px 0 4px;
  font-family: var(--font-hero);
  font-size: 34px;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--gold-dark);
}
.overlay-card p { margin: 0 0 6px; font-size: 16px; }
.overlay-card .btn-white.hidden { display: none; }

.ball-spinner {
  font-size: 64px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* confetti bits */
.confetti {
  position: fixed;
  top: -40px;
  z-index: 60;
  font-size: 24px;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .9; }
}
