* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #101418;
  color: #f4f6f8;
  touch-action: manipulation;
}

button, input, textarea, select { font: inherit; }

button {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  background: #26313a;
  color: #fff;
  cursor: pointer;
  min-height: 52px;
}

button:active { transform: scale(0.98); }

button.selected {
  outline: 4px solid #f5c542;
  background: #3d4b55;
}

.primary { background: #1f8f5f; }
.warning { background: #b07a17; }
.danger { background: #a63d3d; }

.small {
  padding: 10px 12px;
  min-height: 42px;
  font-size: 14px;
}

.app {
  max-width: 1366px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.topbar h1 { margin: 0; font-size: 28px; }
.topbar p { margin: 4px 0 0; color: #aab4bd; }

.screen { display: none; }
.screen.active { display: block; }

.card {
  background: #172029;
  border: 1px solid #2a3540;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.setup-card {
  max-width: 720px;
  margin: 20px auto;
}

label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  color: #cdd6dd;
}

input, textarea, select {
  width: 100%;
  border: 1px solid #33414d;
  background: #0f151b;
  color: #fff;
  border-radius: 12px;
  padding: 13px;
}

textarea { resize: vertical; }

.hint {
  margin: 0 0 6px;
  color: #9da8b0;
  font-size: 14px;
}

.match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.match-header h2 { margin: 0; font-size: 30px; }
.match-header p { margin: 6px 0 0; color: #aab4bd; }

.clock-box {
  text-align: center;
  min-width: 360px;
}

#periodLabel {
  font-weight: bold;
  color: #f5c542;
}

#clock {
  font-size: 58px;
  font-weight: bold;
  letter-spacing: 2px;
  margin: 4px 0 8px;
}

.clock-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.live-layout {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr 0.9fr;
  gap: 12px;
}

.panel h3 { margin-top: 0; }
.panel h4 { margin: 18px 0 8px; color: #cdd6dd; }

.button-grid {
  display: grid;
  gap: 8px;
}

.event-btn, .player-btn {
  text-align: left;
  font-weight: bold;
}

.selection-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  background: #0f151b;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
  color: #dce3e8;
}

.court {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: min(100%, 430px);
  aspect-ratio: 1 / 2;
  height: auto;
  min-height: 420px;
  margin: 0 auto;
  background:
    repeating-linear-gradient(
      90deg,
      #9b6136 0px,
      #9b6136 46px,
      #8b5630 46px,
      #8b5630 92px
    );
  border: 5px solid #f2e5d8;
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
}

.court-markings {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.center-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 3px solid rgba(255,255,255,0.85);
}

.center-circle {
  position: absolute;
  width: 125px;
  height: 125px;
  border: 3px solid rgba(255,255,255,0.85);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.goal-area {
  position: absolute;
  width: 210px;
  height: 95px;
  border: 3px solid rgba(255,255,255,0.85);
  left: 50%;
  transform: translateX(-50%);
}

.goal-area.top {
  top: -3px;
  border-top: 0;
  border-radius: 0 0 80px 80px;
}

.goal-area.bottom {
  bottom: -3px;
  border-bottom: 0;
  border-radius: 80px 80px 0 0;
}

.penalty {
  position: absolute;
  width: 8px;
  height: 8px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  left: 50%;
  transform: translateX(-50%);
}

.penalty.top { top: 120px; }
.penalty.bottom { bottom: 120px; }

.zone-btn {
  position: relative;
  z-index: 2;
  background: rgba(0,0,0,0.06);
  border-radius: 0;
  border: 1px solid rgba(255,255,255,0.32);
  font-size: 30px;
  font-weight: bold;
  color: rgba(255,255,255,0.92);
}

.zone-btn span {
  background: rgba(0,0,0,0.28);
  padding: 8px 12px;
  border-radius: 12px;
}

.zone-btn.selected {
  outline: none;
  box-shadow: inset 0 0 0 8px #f5c542;
  background: rgba(0,0,0,0.22);
}

.save-status {
  min-height: 42px;
  margin-top: 12px;
  padding: 12px;
  background: #0f151b;
  border-radius: 12px;
  color: #cdd6dd;
}

.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.players-list {
  display: grid;
  gap: 8px;
  max-height: 600px;
  overflow-y: auto;
}

.feed-card { margin-top: 12px; }

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.event-feed {
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
}

.event-row {
  display: grid;
  grid-template-columns: 80px 1.1fr 1.5fr 1fr;
  gap: 10px;
  background: #0f151b;
  border-radius: 12px;
  padding: 12px;
  color: #e7edf2;
  align-items: center;
}

.event-row strong {
  font-size: 16px;
}

.event-player {
  display: grid;
  gap: 2px;
}

.event-player small {
  color: #aab4bd;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
  width: min(560px, 100%);
}

.modal h2 { margin-top: 0; }

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.choice-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.choice-grid.two {
  grid-template-columns: 1fr 1fr;
}

.choice-btn.selected {
  outline: 4px solid #f5c542;
}

@media (max-width: 1000px) {
  .live-layout { grid-template-columns: 1fr; }
  .clock-box { min-width: auto; }
  .match-header { flex-direction: column; gap: 12px; align-items: stretch; }
}


.setup-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.squad-box {
  margin: 12px 0 16px;
  background: #0f151b;
  border: 1px solid #33414d;
  border-radius: 14px;
  padding: 12px;
}

.squad-title {
  display: flex;
  justify-content: space-between;
  color: #dce3e8;
  margin-bottom: 10px;
}

.squad-selection-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 330px;
  overflow-y: auto;
}

.squad-player {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #172029;
  border-radius: 12px;
  padding: 10px;
  min-height: 46px;
}

.squad-player input {
  width: 24px;
  height: 24px;
}

.squad-player span {
  font-weight: bold;
}


.file-note {
  margin-top: 8px;
  color: #aab4bd;
  font-size: 14px;
}

.locked-message {
  color: #f5c542;
  font-weight: bold;
}


.player-position {
  color: #f5c542;
  font-weight: normal;
}

@media (max-width: 1000px) {
  .court {
    width: min(100%, 390px);
    min-height: 560px;
  }
}
