#app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.game-layout {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

.sidebar,
.canvas-area { min-height: 0; min-width: 0; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.5rem 1.25rem;
  background: var(--sidebar-bg);
  overflow-y: auto;
}

.sidebar-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  font-size: 2.3rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 0.9;
  margin-bottom: 0.2rem;
}

.sidebar-logo {
  width: auto;
  height: 4.1rem;
  flex-shrink: 0;
}

.sidebar-title-text {
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 0.95rem 1rem;
}

.sidebar-hud {
  display: contents;
}

/* placar */
.score-card { text-align: center; }

.score-line {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.timer {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* títulos de seção */
.sidebar-team h2,
.sidebar-ranking h2 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}

/* torcida + assento */
.team-panel {
  background: #14171c;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  border-left: 3px solid var(--team-accent, var(--accent));
}

.team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.team-identity {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
}

.team-identity .flag-img {
  flex-shrink: 0;
}

.team-seat-badge {
  flex-shrink: 0;
  min-width: 1.5rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--team-accent, var(--accent)) 18%, transparent);
  color: var(--accent-light);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

.team-seats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.team-seats.hidden {
  display: none;
}

.seat-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-light);
  line-height: 1.2;
}

.team-hint {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.team-charges {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--card-border);
}

.team-charges-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.team-charges-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.team-charges-pips {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

/* rankings */
.sidebar-rankings {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-ranking {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ranking-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.ranking-section-head h2 { margin-bottom: 0; }

.ranking-more {
  background: none;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.ranking-more:hover { text-decoration: underline; }

#rank-list,
#season-rank-list {
  list-style: none;
  font-size: 0.86rem;
  margin-top: 0.5rem;
  overflow-y: auto;
}

#rank-list li,
#season-rank-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.42rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#rank-list li > span,
#season-rank-list li > span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#rank-list li strong,
#season-rank-list li strong {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-muted);
}

#rank-list li[data-country-id]:hover,
#season-rank-list li[data-country-id]:hover {
  background: rgba(47, 174, 79, 0.08);
  cursor: pointer;
  border-radius: 6px;
}

#rank-list li.rank-vacant,
#rank-list li.rank-empty,
#season-rank-list li.rank-empty {
  color: var(--text-dim);
  font-style: italic;
}

/* ações */
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.sidebar-actions-row {
  display: flex;
  gap: 0.6rem;
}

.btn-sidebar {
  flex: 1;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.btn-dark { background: var(--accent-dark); color: #fff; }
.btn-light { background: var(--accent-light); color: #2b330e; }
.btn-sidebar:hover { filter: brightness(1.06); }

.btn-share,
.btn-sidebar-icon {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem 1rem;
  min-width: 0;
  text-decoration: none;
}

.btn-share-icon,
.btn-sidebar-icon-svg {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.btn-sidebar-label {
  white-space: nowrap;
}

.mobile-only { display: none; }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sound-toggle {
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.sound-toggle::after {
  content: '🔊';
  font-size: 0.95rem;
}
.sound-toggle:not(.sound-active) { color: var(--text-dim); }
.sound-toggle:not(.sound-active)::after { content: '🔇'; }

.players-online {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.online-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

/* ===================== STADIUM ===================== */
.canvas-area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-stadium);
  overflow: hidden;
}

.pixel-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  display: flex;
}

#pixel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
}

#pixel-canvas svg { cursor: pointer; }

/* ===================== STADIUM ANIMATIONS ===================== */
@keyframes cup-cloud-drift-left {
  from { transform: translateX(0); }
  to { transform: translateX(-8%); }
}

@keyframes cup-cloud-drift-right {
  from { transform: translateX(-4%); }
  to { transform: translateX(6%); }
}

@keyframes cup-light-pulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

@keyframes cup-grass-shimmer {
  0%, 100% { opacity: 0.04; }
  50% { opacity: 0.07; }
}

@keyframes cup-flag-sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

@keyframes cup-ball-pop {
  0% { transform: scale(0.6) translateY(-4px); opacity: 0.5; }
  70% { transform: scale(1.05) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes cup-confetti-burst {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}
@keyframes cup-light-beam-pulse {
  0%, 100% { opacity: 0.04; }
  50% { opacity: 0.09; }
}

@keyframes cup-truss-led-blink {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

@keyframes cup-seat-flash-lost {
  0%, 100% { stroke: #c4c8d0; }
  25%, 75% { stroke: #dc2626; }
  50% { stroke: #ef4444; }
}

@keyframes cup-seat-shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-3deg); }
  40% { transform: rotate(3deg); }
  60% { transform: rotate(-2deg); }
  80% { transform: rotate(2deg); }
}

@keyframes cup-hover-pulse {
  0%, 100% { stroke-opacity: 0.85; stroke-width: 2.5; }
  50% { stroke-opacity: 1; stroke-width: 3.5; }
}


.svg-stadium.is-live .cup-cloud--left {
  animation: cup-cloud-drift-left 55s linear infinite;
}

.svg-stadium.is-live .cup-cloud--right {
  animation: cup-cloud-drift-right 65s linear infinite;
}

.svg-stadium.is-live .cup-light-bulb {
  animation: cup-light-pulse 3s ease-in-out infinite;
}

.svg-stadium.is-live .cup-light-beam {
  animation: cup-light-beam-pulse 3s ease-in-out infinite;
}

.svg-stadium.is-live .cup-truss-led {
  animation: cup-truss-led-blink 2s ease-in-out infinite;
}

.svg-stadium.is-live .cup-grass-stripe {
  animation: cup-grass-shimmer 6s ease-in-out infinite;
}

.svg-stadium.is-live .cup-flag {
  transform-box: fill-box;
  transform-origin: top center;
  animation: cup-flag-sway 3s ease-in-out infinite;
}

.svg-stadium.is-live .cup-ball-pop {
  transform-box: fill-box;
  transform-origin: center;
  animation: cup-ball-pop 350ms ease-out forwards;
}

.svg-stadium.is-live .cup-confetti-piece {
  transform-box: fill-box;
  transform-origin: center;
  animation: cup-confetti-burst 550ms ease-out forwards;
}

.cup-seat-flash-lost {
  animation: cup-seat-flash-lost 450ms ease-out forwards;
}

.cup-seat-shake {
  transform-box: fill-box;
  transform-origin: center;
  animation: cup-seat-shake 400ms ease-in-out;
}

.cup-seat-group image {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.cup-hover-pulse {
  animation: cup-hover-pulse 1.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .svg-stadium.is-live .cup-cloud--left,
  .svg-stadium.is-live .cup-cloud--right,
  .svg-stadium.is-live .cup-light-bulb,
  .svg-stadium.is-live .cup-light-beam,
  .svg-stadium.is-live .cup-truss-led,
  .svg-stadium.is-live .cup-grass-stripe,
  .svg-stadium.is-live .cup-flag,
  .svg-stadium.is-live .cup-ball-pop,
  .svg-stadium.is-live .cup-confetti-piece,
  .cup-seat-flash-lost,
  .cup-seat-shake,
  .cup-hover-pulse {
    animation: none !important;
  }
}

.stadium-zoom-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(15, 18, 24, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: auto;
}

.stadium-zoom-bar button {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecf4;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.stadium-zoom-bar button:hover {
  background: rgba(255, 255, 255, 0.12);
}

#stadium-zoom-label {
  min-width: 44px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.seat-hover-tip {
  position: absolute;
  z-index: 20;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  min-width: 148px;
  padding: 0.5rem 0.65rem 0.55rem;
  border-radius: 10px;
  background: rgba(15, 18, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, calc(-100% - 12px));
}

.seat-hover-tip.hidden {
  display: none;
  pointer-events: none;
}

.seat-hover-tip .flag-img {
  vertical-align: -2px;
}

.seat-hover-tip-country {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
}

.seat-hover-tip-chance {
  text-align: center;
  color: #fbbf24;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.seat-hover-tip-reason {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.01em;
  margin-bottom: 0.15rem;
}

.seat-hover-tip-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.1rem;
}

.seat-hover-btn {
  flex: 1;
  padding: 0.38rem 0.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.seat-hover-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.seat-hover-btn-attack {
  background: var(--accent);
  color: #fff;
}

.seat-hover-btn-attack:hover:not(:disabled) {
  filter: brightness(1.08);
}

.seat-hover-btn-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
}

.seat-hover-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ===================== AD BAR ===================== */
.bottom-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  max-height: var(--ad-bar-max-height);
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.bottom-ad {
  position: relative;
  min-width: 0;
  height: var(--ad-slot-height);
  max-height: var(--ad-slot-height);
  background: #c9cdd6;
  border-radius: 8px;
  overflow: hidden;
  isolation: isolate;
}

.ad-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.18em;
  pointer-events: none;
  z-index: 0;
}

.bottom-ad .admob-slot {
  position: relative;
  z-index: 1;
  height: 100%;
  max-height: var(--ad-slot-height);
  width: 100%;
  overflow: hidden;
}

.bottom-ad .adsbygoogle {
  display: block;
  width: 100% !important;
  min-height: var(--ad-slot-height) !important;
  height: var(--ad-slot-height) !important;
  max-height: var(--ad-slot-height) !important;
  overflow: hidden !important;
}

.bottom-ad .adsbygoogle iframe,
.bottom-ad .admob-slot iframe {
  display: block;
  width: 100% !important;
  min-height: var(--ad-slot-height) !important;
  height: var(--ad-slot-height) !important;
  max-height: var(--ad-slot-height) !important;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .sidebar {
    max-height: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }
  .sidebar-title {
    width: 100%;
    font-size: 1.25rem;
    margin-bottom: 0;
    flex-direction: row;
    gap: 0.3rem;
  }
  .sidebar-logo { height: 2.4rem; }

  .sidebar-hud {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
  }

  .score-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--card-border);
  }

  .score-card .score-line {
    font-size: 0.82rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .score-card .timer {
    margin-top: 0;
    flex-shrink: 0;
    font-size: 0.72rem;
  }

  .sidebar-team {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.25rem 0.5rem;
    padding: 0.4rem 0.65rem 0.55rem;
    background: transparent;
    border: none;
    border-radius: 0;
  }

  .sidebar-team h2 { display: none; }

  .team-panel {
    display: contents;
    background: none;
    border-left: none;
    padding: 0;
  }

  .team-header { grid-column: 1; grid-row: 1; }

  .team-identity { font-size: 0.78rem; }

  .team-seats { display: none !important; }

  .team-hint {
    grid-column: 1;
    grid-row: 2;
    margin-top: 0;
    font-size: 0.72rem;
    line-height: 1.3;
  }

  .team-charges {
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: center;
    margin: 0;
    padding: 0;
    border: none;
  }

  .team-charges-label { display: none; }

  .sidebar-rankings {
    display: block;
    width: 100%;
    flex: none;
    min-height: 0;
  }

  .sidebar-ranking {
    padding: 0.5rem 0.65rem;
    flex: none;
  }

  .ranking-section-head h2 {
    font-size: 0.68rem;
  }

  .ranking-more {
    font-size: 0.65rem;
  }

  #rank-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.35rem;
    margin-top: 0.35rem;
    padding-bottom: 0.1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #rank-list::-webkit-scrollbar {
    display: none;
  }

  #rank-list li {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem;
    min-width: 5.25rem;
    max-width: 7rem;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: #14171c;
    border-bottom: none;
  }

  #rank-list li > span {
    font-size: 0.68rem;
    gap: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #rank-list li strong {
    font-size: 0.65rem;
    align-self: flex-end;
  }

  .sidebar-actions {
    width: 100%;
    gap: 0.4rem;
    padding-top: 0;
    margin-top: 0;
  }

  .sidebar-actions-row { gap: 0.4rem; }

  .mobile-only { display: block; }

  .btn-sidebar {
    padding: 0.45rem 0.6rem;
    font-size: 0.72rem;
  }

  .btn-icon-only-mobile.btn-sidebar-icon {
    flex: 0 0 auto;
    gap: 0;
    padding: 0.45rem;
    min-width: 2.25rem;
  }

  .btn-icon-only-mobile .btn-sidebar-label {
    display: none;
  }

  .btn-share-icon,
  .btn-sidebar-icon-svg {
    width: 1rem;
    height: 1rem;
  }

  .sidebar-footer { font-size: 0.75rem; }

  .sound-toggle { font-size: 0.72rem; }

  .bottom-bar {
    grid-template-columns: 1fr;
    max-height: 72px;
    padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  }

  .bottom-ad-right { display: none; }

  .bottom-ad {
    contain: layout size style;
  }

  .bottom-ad,
  .bottom-ad .admob-slot,
  .bottom-ad .adsbygoogle,
  .bottom-ad .adsbygoogle iframe,
  .bottom-ad .admob-slot iframe {
    --ad-slot-height: 56px;
    height: 56px;
    max-height: 56px;
  }

  .bottom-ad .adsbygoogle {
    min-height: 56px !important;
    height: 56px !important;
    max-height: 56px !important;
    overflow: hidden !important;
  }

  .bottom-ad .adsbygoogle iframe,
  .bottom-ad .admob-slot iframe {
    min-height: 56px !important;
    height: 56px !important;
    max-height: 56px !important;
    overflow: hidden !important;
  }
}
