* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: #0a0e17;
  color: #f1f5f9;
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 760px;
  height: 100vh;
  max-height: 760px;
  position: relative;
  padding: 8px;
}

#container {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: #111827;
  border-radius: 16px;
  border: 4px solid #1f2937;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 229, 255, 0.15);
  position: relative;
  overflow: hidden;
  max-height: 90vh;
}

/* Table Area */
.table-area {
  position: relative;
  background: #064e3b;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 2px solid #1f2937;
}

canvas {
  background: url("../img/pitch3.png") center center / cover no-repeat;
  display: block;
  max-height: 85vh;
  width: auto;
  height: auto;
  aspect-ratio: 480 / 720;
}

/* Overlays: Start Screen & Game Over */
#startScreen, #gameOverScreen {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#gameOverScreen {
  z-index: -1;
  opacity: 0;
  pointer-events: none;
}

#gameOverScreen.active {
  z-index: 25;
  opacity: 1;
  pointer-events: auto;
}

.screen-content {
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: popIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.brand-badge {
  display: inline-block;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #00e5ff;
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 999px;
  margin-bottom: 12px;
}

#title, #winner-title {
  font-family: 'Teko', sans-serif;
  font-size: 48px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffffff 40%, #00e5ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.subtitle {
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 24px;
}

.team-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 20px;
  margin-bottom: 24px;
  width: 100%;
}

.preview-side {
  display: flex;
  flex-direction: column;
}

.preview-team {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
}

.away-color { color: #38bdf8; }
.home-color { color: #ef4444; }

.preview-name {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
}

.preview-vs {
  font-family: 'Teko', sans-serif;
  font-size: 24px;
  color: #64748b;
}

button#play, button#playagain {
  background: linear-gradient(135deg, #00e5ff, #0284c7);
  color: #0f172a;
  border: none;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 14px 36px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 229, 255, 0.35);
  transition: all 0.2s ease;
  margin-bottom: 20px;
}

button#play:hover, button#playagain:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 30px rgba(0, 229, 255, 0.5);
}

.control-hints {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hint-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #94a3b8;
}

.hint-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  font-size: 10px;
  color: #f1f5f9;
}

.mobile-hint {
  font-size: 11px;
  color: #64748b;
}

.final-score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: 'Teko', sans-serif;
  font-size: 64px;
  line-height: 1;
  color: #f1f5f9;
  margin: 12px 0 6px 0;
}

.score-sep {
  color: #64748b;
}

#over-desc {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 20px;
}

/* Scoreboard Sidebar */
#score {
  background: #0f172a;
  width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px 12px;
  text-align: center;
}

.panel-header .logo-text {
  font-family: 'Teko', sans-serif;
  font-size: 20px;
  letter-spacing: 1px;
  color: #f1f5f9;
}

#timer {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
  width: 100%;
}

.timer-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #64748b;
  margin-bottom: 2px;
}

#countdown {
  font-family: 'Teko', sans-serif;
  font-size: 36px;
  line-height: 1;
  font-weight: 700;
  color: #00e5ff;
}

.teams-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.team-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.team-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.team-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-blue { background: #38bdf8; box-shadow: 0 0 8px #38bdf8; }
.dot-red { background: #ef4444; box-shadow: 0 0 8px #ef4444; }

#blue {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
}

#red {
  font-size: 12px;
  font-weight: 700;
  color: #ef4444;
  text-transform: uppercase;
}

.score-num {
  font-family: 'Teko', sans-serif;
  font-size: 46px;
  line-height: 1;
  font-weight: 700;
  color: #ffffff;
}

.vs-divider {
  font-family: 'Teko', sans-serif;
  font-size: 16px;
  color: #475569;
  margin: -4px 0;
}

#status {
  font-size: 12px;
  font-weight: 700;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00e5ff;
}

.brand-footer {
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.5px;
}

/* In-game floating Goal Banner */
#in-game-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(10, 14, 23, 0.95);
  border: 2px solid #00e5ff;
  border-radius: 16px;
  padding: 16px 28px;
  color: #ffffff;
  font-family: 'Teko', sans-serif;
  font-size: 42px;
  letter-spacing: 2px;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.6);
  pointer-events: none;
  z-index: 10;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#in-game-banner.show {
  transform: translate(-50%, -50%) scale(1);
}

/* Mobile Touch Controls */
#touch-controls {
  display: none;
  width: 100%;
  max-width: 480px;
  gap: 12px;
  margin-top: 10px;
}

.touch-btn {
  flex: 1;
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 12px;
  padding: 14px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #f1f5f9;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease, transform 0.1s ease;
}

.touch-btn:active, .touch-btn.pressed {
  background: #00e5ff;
  color: #0f172a;
  border-color: #00e5ff;
  transform: scale(0.97);
}

.btn-arrow {
  font-size: 18px;
}

.btn-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1px;
}

/* Responsive adjustments */
@media (max-width: 680px), (max-height: 700px) {
  #container {
    flex-direction: column;
    max-height: 82vh;
    border-width: 2px;
  }
  
  .table-area {
    border-right: none;
    border-bottom: 2px solid #1f2937;
  }
  
  canvas {
    max-height: 60vh;
  }

  #score {
    width: 100%;
    flex-direction: row;
    padding: 8px 16px;
    height: auto;
  }

  .panel-header, .brand-footer {
    display: none;
  }

  #timer {
    width: auto;
    padding: 4px 12px;
  }

  #countdown {
    font-size: 24px;
  }

  .teams-container {
    flex-direction: row;
    width: auto;
    gap: 12px;
  }

  .team-card {
    flex-direction: row;
    gap: 8px;
    padding: 4px 10px;
  }

  .score-num {
    font-size: 26px;
  }

  .vs-divider {
    display: none;
  }

  #status {
    min-height: 24px;
    font-size: 11px;
  }

  #touch-controls {
    display: flex;
  }
}