* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: rgb(19, 19, 19);
  color: rgb(200, 200, 200);
  font-family: "Open Sans", sans-serif;
  font-size: 1em;
  overflow: hidden;
}

.app-container {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  height: 100vh;
}

.game-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

#canvas1 {
  width: 100%;
  max-width: 1280px;
  aspect-ratio: 16 / 9;
  background: black;
  border: 1px solid rgb(78, 77, 77);
  cursor: pointer;
  image-rendering: crisp-edges;
}

.match-banner {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.4rem 0;
  font-size: 1.1rem;
  color: rgb(180, 180, 180);
  text-align: center;
}

.match-banner p {
  margin: 0;
}

.info-panel {
  width: 320px;
  overflow: hidden;
  background: rgba(30, 30, 30, 0.9);
  border: 1px solid rgb(78, 77, 77);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.scoreboard h2,
.stats h3,
.team-select h2,
.shop h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  color: rgb(160, 160, 160);
}

/* --- Selección de equipo --- */

.team-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.team-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.2rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgb(78, 77, 77);
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.team-btn .team-emoji {
  font-size: 1.1rem;
}

.team-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.team-btn.selected {
  border-color: #ffcc00;
  background: rgba(255, 204, 0, 0.12);
  box-shadow: 0 0 8px rgba(255, 204, 0, 0.3);
}

.credits-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: rgba(255, 200, 0, 0.08);
  border: 1px solid rgba(255, 200, 0, 0.4);
  border-radius: 6px;
  font-size: 0.85rem;
}

.credits-label {
  color: rgb(160, 160, 160);
  text-transform: uppercase;
  font-size: 0.65rem;
}

.credits-value {
  font-size: 1.15rem;
  color: #ffd54f;
  margin-left: auto;
}

/* --- Shop / entrenamiento --- */

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

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.shop-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(140, 140, 140);
  border-bottom: 1px solid rgb(78, 77, 77);
  margin: 0.4rem 0 0.2rem;
  padding-bottom: 0.2rem;
}

.shop-section-title:first-child {
  margin-top: 0;
}

.shop-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 6px;
}

.shop-item:hover {
  border-color: rgb(78, 77, 77);
}

.shop-emoji {
  font-size: 1rem;
}

.shop-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shop-name {
  font-size: 0.8rem;
}

.shop-desc {
  font-size: 0.65rem;
  color: rgb(140, 140, 140);
}

.shop-btn {
  padding: 0.35rem 0.5rem;
  background: rgba(255, 200, 0, 0.2);
  border: 1px solid rgba(255, 200, 0, 0.5);
  color: #ffd54f;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  white-space: nowrap;
}

.shop-btn:hover:not(:disabled) {
  background: rgba(255, 200, 0, 0.35);
}

.shop-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.score-item,
.score-head {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.8fr 0.9fr 0.8fr;
  align-items: center;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  text-align: center;
}

.score-head {
  color: rgb(140, 140, 140);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgb(78, 77, 77);
  margin-bottom: 0.4rem;
}

.score-item span:first-child {
  text-align: left;
}

.score-item {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid;
  border-radius: 4px;
  margin-bottom: 0.4rem;
}

.score-item.rank-0 {
  border-left-color: gold;
}
.score-item.rank-1 {
  border-left-color: silver;
}
.score-item.rank-2 {
  border-left-color: #cd7f32;
}
.score-item.rank-3,
.score-item.rank-4 {
  border-left-color: rgb(100, 100, 100);
}

.stats {
  font-size: 0.85rem;
  line-height: 1.6;
}

.timer-active {
  font-size: 1.2rem;
  color: #ffcc00;
  font-weight: bold;
}

@keyframes timer-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.level-select {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.level-select label {
  font-size: 0.85rem;
  color: rgb(140, 140, 140);
}

.level-select input {
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgb(78, 77, 77);
  color: inherit;
  border-radius: 4px;
}

.level-select button {
  padding: 0.6rem;
  background: rgba(0, 200, 100, 0.7);
  border: none;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.level-select button:hover {
  background: rgba(0, 200, 100, 0.9);
}

@media (max-width: 1024px) {
  body {
    overflow: auto;
  }

  .app-container {
    flex-direction: column;
    height: auto;
  }

  .info-panel {
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
  }

  .shop {
    flex: none;
  }

  .shop-list {
    flex: none;
    max-height: none;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .info-panel {
    max-height: 250px;
    padding: 0.75rem;
  }
}

/* --- Menú de pausa / nueva partida --- */

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: menu-fade 0.15s ease-out;
}

.menu-overlay[hidden] {
  display: none;
}

.menu-modal {
  background: rgb(27, 27, 27);
  border: 1px solid rgb(78, 77, 77);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  min-width: 340px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  animation: menu-pop 0.18s ease-out;
}

@keyframes menu-fade {
  from {
    opacity: 0;
  }
}

@keyframes menu-pop {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
}

.stat-bar-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.9rem 0;
}

.stat-bar-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: center;
  gap: 0.5rem;
}

.stat-bar-label {
  color: rgb(130, 130, 140);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: right;
}

.stat-bar-track {
  display: block;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.menu-modal h2 {
  margin-bottom: 1rem;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.menu-summary {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  color: rgb(190, 190, 190);
  font-size: 0.9rem;
}

.menu-actions {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.menu-btn {
  padding: 0.55rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgb(78, 77, 77);
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.menu-btn.primary {
  border-color: #ffcc00;
  background: rgba(255, 204, 0, 0.12);
  color: #ffcc00;
}

.menu-btn.primary:hover {
  background: rgba(255, 204, 0, 0.22);
}

.team-pick-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.mode-pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.mode-pick-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}

.league-pick-grid {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

.league-pick-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}

.league-pick-grid .team-btn {
  flex-direction: row;
  font-size: 0.8rem;
  padding: 0.5rem 1.2rem;
}

.team-btn.selected {
  border-color: #ffcc00;
  background: rgba(255, 204, 0, 0.12);
  box-shadow: 0 0 8px rgba(255, 204, 0, 0.3);
}

.team-pick-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.team-details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgb(78, 77, 77);
  border-radius: 6px;
  font-size: 0.8rem;
  color: rgb(190, 190, 190);
  min-height: 5.5rem;
}

.team-details-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.team-details-head .team-emoji {
  font-size: 1.1rem;
}

.team-details-head strong {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
}

.team-details-desc {
  color: rgb(150, 150, 150);
  font-size: 0.75rem;
}

.team-details-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.team-details-label {
  min-width: 5rem;
  color: rgb(120, 120, 130);
}

.menu-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

.level-select-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.level-select-menu label {
  font-size: 0.85rem;
  color: rgb(190, 190, 190);
}

.level-input {
  width: 110px;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgb(78, 77, 77);
  border-radius: 6px;
  color: inherit;
  font-size: 0.9rem;
  text-align: center;
}

.menu-hint {
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: rgb(140, 140, 140);
}
