/* General Styling */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Roboto', sans-serif;
  background-color: #f8f9fa;
  /* Force full viewport height and prevent scrolling */
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden; 
}

h1 {
  display: none;
}

/* Controls */
.controls {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 5px;
  flex-wrap: wrap;
  background-color: #eee;
  flex-shrink: 0; /* Prevent controls from shrinking */
  z-index: 10;
}

button {
  padding: 6px 10px;
  cursor: pointer;
  border: 1px solid #ccc;
  background-color: white;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.8rem;
}

button:hover {
  background-color: #e2e2e2;
}

.btn-danger {
  background-color: #ffcccc;
  border-color: #ff0000;
  color: #cc0000;
}

/* Headline */
.headline {
  font-size: 1.5rem;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  text-align: center;
  padding: 5px 0;
  border-bottom: 1px dashed transparent;
  flex-shrink: 0; /* Prevent headline from shrinking */
}

.headline:focus {
  border-bottom: 1px dashed #ccc;
  outline: none;
}

/* Wrapper fills the rest of the screen */
.wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Crucial for nested flex scrolling/sizing */
  padding-bottom: 5px;
}

/* Pitch Container takes available space */
.pitch-container {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 0; /* Allows container to shrink if needed */
  padding: 5px;
}

.pitch {
  position: relative;
  background-color: white;
  border: 3px solid #ff0000;
  border-radius: 10px;
  overflow: hidden;
  
  /* Key changes for responsiveness: */
  aspect-ratio: 6 / 10; /* Keep the shape */
  height: 100%; /* Try to fill height */
  width: auto;  /* Let width adjust based on aspect ratio */
  max-width: 100%; /* Don't exceed container width */
  max-height: 100%; /* Don't exceed container height */
}

/* Field Markings */
.center-line {
  position: absolute;
  width: 100%;
  height: 3px;
  background-color: #ff0000;
  top: 50%;
  transform: translateY(-50%);
}

.center-circle {
  position: absolute;
  width: 15%;
  aspect-ratio: 1;
  border: 2px solid #ff0000;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.goal-area {
  position: absolute;
  width: 50%;
  height: 15%; /* Reduced slightly for visual balance */
  border: 2px solid #ff0000;
  left: 50%;
}

.goal-area.top {
  top: 0;
  border-radius: 0 0 50% 50%;
  border-top: 0;
  transform: translate(-50%, -50%);
}

.goal-area.bottom {
  bottom: 0;
  border-radius: 50% 50% 0 0;
  border-bottom: 0;
  transform: translate(-50%, 50%);
}

.goal-circle {
  position: absolute;
  width: 20%;
  aspect-ratio: 1;
  border: 2px solid #ff0000;
  border-radius: 50%;
}

.goal-area.top .goal-circle.left {
  left: 25%;
  top: 93%;
  transform: translate(-50%, -50%);
}

.goal-area.top .goal-circle.right {
  right: 25%;
  top: 93%;
  transform: translate(50%, -50%);
}

.goal-area.bottom .goal-circle.left {
  left: 25%;
  top: 7%;
  transform: translate(-50%, -50%);
}

.goal-area.bottom .goal-circle.right {
  right: 25%;
  top: 7%;
  transform: translate(50%, -50%);
}

/* Player Circle */
.player {
  position: absolute;
  width: 14%; /* Slightly smaller to fit better on mobile */
  aspect-ratio: 1;
  border-radius: 50%;
  background-color: red;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  color: white;
  font-weight: bold;
  transform: translate(-50%, -50%);
  transition: top 0.5s ease, left 0.5s ease;
  z-index: 5;
}

.player-name {
  font-size: 0.7rem;
  color: black;
  text-align: center;
  white-space: nowrap;
  position: absolute;
  bottom: -18px; /* Tighter spacing */
  cursor: text;
  background-color: rgba(255,255,255,0.8); /* Readability */
  padding: 0 2px;
  border-radius: 3px;
}
.player-position {
  cursor: text;
}

/* Bench Section */
.bench-container {
  width: 100%;
  text-align: center;
  /* Fixed height area for bench, does not grow */
  height: 15vh; 
  min-height: 80px;
  flex-shrink: 0;
  overflow-y: auto;
  border-top: 1px solid #ddd;
  padding-top: 5px;
  background-color: #f0f0f0;
}

.bench-container h2 {
  font-size: 1rem;
  font-weight: bold;
  margin: 0 0 15px 0;
}

.bench {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 20px;
}

.bench-player {
  position: relative;
  width: 35px; /* Smaller on bench */
  height: 35px;
  border-radius: 50%;
  background-color: red;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  color: white;
  font-weight: bold;
  flex-shrink: 0;
}

.bench-player-name {
  position: absolute;
  bottom: -15px;
  color: black;
  white-space: nowrap;
  font-size: 0.6rem;
  width: 150%;
  text-align: center;
}

.bench-player .remove-button {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: white;
  color: red;
  border: 1px solid #ccc;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  width: 16px;
  height: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
}