:root {
  --bg-color: #05070f;
  --panel-bg: rgba(13, 17, 30, 0.74);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --color-primary: #10b981;
  --color-primary-hover: #059669;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-gold: #fbbf24;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

/* Background grid / atmosphere */
.noise {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, transparent 30%, rgba(3, 4, 10, 0.95) 90%);
  z-index: 1;
  pointer-events: none;
}

/* Screen overlays */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background-color: rgba(3, 4, 10, 0.82);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.overlay-screen.active {
  display: flex;
  opacity: 1;
}

/* Panels */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 10px 10px -5px rgba(0, 0, 0, 0.7);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 600px;
  width: 90%;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Splash Screen specific */
.splash-panel {
  max-width: 680px;
}

.logo-area {
  margin-bottom: 2rem;
}

.logo-ball {
  display: block;
  width: 52px;
  height: 52px;
  background: white;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  position: relative;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
  background-image: 
    radial-gradient(circle at 15px 15px, #fff, #bbb),
    repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(0,0,0,0.1) 5px, rgba(0,0,0,0.1) 10px);
}

.logo-area h1 {
  font-size: 2.75rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--color-primary);
  font-weight: 600;
  letter-spacing: 0.2em;
  font-size: 0.85rem;
}

/* Grid layout for settings */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
  margin-bottom: 2rem;
}

.setting-item {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.setting-item label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.setting-item select {
  background: rgba(10, 12, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: white;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.setting-item select:focus {
  border-color: var(--color-primary);
}

/* Controls guide */
.controls-guide {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 2rem;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.controls-guide h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--color-gold);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  font-size: 0.85rem;
}

@media (min-width: 520px) {
  .guide-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.guide-grid div {
  display: flex;
  align-items: center;
}

.guide-grid kbd {
  background-color: #374151;
  border-bottom: 2px solid #1f2937;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-family: monospace;
  font-size: 0.8rem;
  margin-right: 0.25rem;
  color: white;
}

.guide-grid span {
  margin-left: 0.5rem;
  color: var(--text-secondary);
}

.gamepad-info {
  margin-top: 0.85rem;
  font-size: 0.75rem;
  color: var(--color-primary);
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-block;
  width: 100%;
  padding: 0.9rem;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  outline: none;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-secondary {
  background-color: #374151;
  color: white;
  margin-top: 0.75rem;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-danger {
  background-color: var(--color-danger);
  color: white;
  margin-top: 0.75rem;
}

.btn-danger:hover {
  background-color: var(--color-danger-hover);
}

/* Pause screen modifications */
.pause-panel {
  max-width: 400px;
}

.pause-panel h2 {
  font-size: 1.75rem;
  margin-bottom: 2rem;
  letter-spacing: 0.1em;
}

.pause-actions {
  width: 100%;
}

/* End Game screen */
.end-panel h2 {
  font-size: 2rem;
  color: var(--color-gold);
  margin-bottom: 1.5rem;
  letter-spacing: 0.1em;
}

.end-scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.team-score-big {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.team-score-big span {
  font-size: 1.25rem;
  color: var(--text-secondary);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.team-score-big strong {
  font-size: 4rem;
  font-weight: 900;
  color: white;
}

.end-scoreboard .separator {
  font-size: 2.5rem;
  color: var(--text-secondary);
  font-weight: 300;
}

.end-msg {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.5;
}

/* Goal screen overlay styling */
.goal-overlay {
  background-color: rgba(3, 4, 10, 0.65);
  backdrop-filter: blur(2px);
  z-index: 15;
}

.goal-text-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: goalPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.goal-banner {
  font-size: 7rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 0 30px rgba(16, 185, 129, 0.8), 0 0 60px rgba(16, 185, 129, 0.4);
  margin-bottom: 1rem;
  animation: goalShake 0.4s ease-in-out infinite alternate;
}

.goal-team {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--color-gold);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  text-transform: uppercase;
}

@keyframes goalPop {
  0% { transform: scale(0.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes goalShake {
  0% { transform: rotate(-2deg); }
  100% { transform: rotate(2deg); }
}

/* Game layout containing canvas and HUD */
.game-layout {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* HUD elements overlapping the canvas */
.ui-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none; /* Let clicks pass to canvas if needed, HUD inputs handled by keyboard */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
}

/* Top Scoreboard */
.scoreboard {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  height: 52px;
  align-self: center;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-size: 1.1rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.score-team {
  display: flex;
  align-items: center;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.team-badge {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid white;
}

.score-team.home .team-badge {
  margin-right: 0.65rem;
}

.score-team.away .team-badge {
  margin-left: 0.65rem;
}

.score-box {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  padding: 0.2rem 0.8rem;
  margin: 0 1rem;
  display: flex;
  align-items: center;
  font-weight: 900;
  color: white;
}

.score-box .separator {
  color: var(--text-secondary);
  margin: 0 0.25rem;
}

.match-time-box {
  border-left: 1px solid rgba(255,255,255,0.15);
  padding-left: 1rem;
  margin-left: 0.5rem;
  display: flex;
  align-items: center;
}

#hudMatchTime {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 50px;
}

.half-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--color-gold);
  background: rgba(251, 191, 36, 0.15);
  border-radius: 4px;
  padding: 0.08rem 0.3rem;
  margin-left: 0.5rem;
}

/* Bottom HUD elements */
.hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
}

/* Player Card Info */
.player-indicator-hud {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  width: 210px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.hud-player-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hud-player-number {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--color-gold);
  line-height: 1;
}

.hud-player-info {
  display: flex;
  flex-direction: column;
}

.hud-player-info strong {
  font-size: 1rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.hud-player-info small {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Power bar for shooting/long passes */
.power-bar-container {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  height: 8px;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}

.power-bar {
  background: linear-gradient(to right, var(--color-primary), var(--color-gold), var(--color-danger));
  width: 0%;
  height: 100%;
  transition: width 0.05s linear;
}

/* 2D Radar styling */
.radar-container {
  background: rgba(13, 17, 30, 0.82);
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  border-radius: 10px;
  overflow: hidden;
  width: 224px;
  height: 146px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#radarCanvas {
  display: block;
}

/* Right helper */
.action-help-hud {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  width: 210px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.gamepad-status {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.gamepad-status.offline {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.gamepad-status.online {
  color: white;
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid var(--color-primary);
  animation: pulse 1.5s infinite;
}

.hud-controls-hint {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.hud-controls-hint kbd {
  background: rgba(255,255,255,0.1);
  padding: 0 0.25rem;
  border-radius: 3px;
  color: white;
}

@keyframes pulse {
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}

/* Match stats styling */
.match-stats-table {
  width: 100%;
  max-width: 420px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 0.45rem;
}

.stat-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.stat-val {
  font-weight: 800;
  width: 50px;
}

.stat-val:first-child {
  text-align: left;
}

.stat-val:last-child {
  text-align: right;
}

.stat-label {
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-grow: 1;
}

/* Card overlay screens */
.card-overlay {
  background-color: rgba(3, 4, 10, 0.55);
  backdrop-filter: blur(2px);
  z-index: 15;
}

.card-text-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: goalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.card-banner {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 0 20px rgba(0,0,0,0.5);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.card-sub {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--color-gold);
  text-transform: uppercase;
}

.yellow-card {
  width: 90px;
  height: 130px;
  background-color: #fbbf24;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.8);
  transform: rotate(-10deg);
  animation: cardSwing 0.5s ease-in-out infinite alternate;
}

.red-card {
  width: 90px;
  height: 130px;
  background-color: #ef4444;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
  transform: rotate(-10deg);
  animation: cardSwing 0.5s ease-in-out infinite alternate;
}

@keyframes cardSwing {
  0% { transform: rotate(-12deg) translateY(0); }
  100% { transform: rotate(-8deg) translateY(-5px); }
}

