:root {
  --bg-color: #f0f9ff; /* Light bright blue/white background */
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(14, 165, 233, 0.15);
  --text-main: #1e293b; /* Dark slate for readability */
  --text-muted: #64748b;
  --accent-color: #0ea5e9; /* Sky blue accent */
  --accent-hover: #0284c7;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --team-a: #0ea5e9;
  --team-b: #f43f5e;
}

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

body {
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background: linear-gradient(135deg, #ffffff 0%, var(--bg-color) 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px;
}

.app-container {
  width: 100%;
  max-width: 800px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeInDown 0.8s ease-out;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-hover);
  margin-bottom: 8px;
}

header p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.courts-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 40px;
}

@media (min-width: 600px) {
  .courts-section {
    flex-direction: row;
  }
}

.court-card {
  flex: 1;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeInUp 0.8s ease-out backwards;
}

.court-card:nth-child(2) {
  animation-delay: 0.1s;
}

.court-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.12);
}

.court-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--card-border);
}

.court-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.status-badge {
  background: #f1f5f9;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}
.status-badge.active {
  background: rgba(14, 165, 233, 0.15);
  color: var(--accent-hover);
}

.start-match-btn {
  width: 100%;
  padding: 16px;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.start-match-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: rgba(14, 165, 233, 0.05);
}

/* Score Board */
.score-board {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.team-score {
  flex: 1;
  text-align: center;
}

.team-score .players {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-main);
  min-height: 44px;
}

.team-a .players { color: var(--team-a); }
.team-b .players { color: var(--team-b); }

.score-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.score-value {
  font-size: 3rem;
  font-weight: 800;
  width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

.score-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #e2e8f0;
  color: var(--text-main);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.score-btn:hover {
  background: var(--text-muted);
  color: #fff;
}

.score-btn:active {
  transform: scale(0.95);
}

.score-divider {
  font-size: 2rem;
  font-weight: 800;
  color: #cbd5e1;
  padding: 0 10px;
}

.match-actions {
  text-align: center;
}

.btn-finish {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.btn-finish:hover {
  background: var(--danger-hover);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}

/* History Section */
.history-section {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.05);
  animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.history-section h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: var(--text-main);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: #f8fafc;
  border-radius: 12px;
  border-left: 4px solid var(--accent-color);
  transition: transform 0.2s;
}

.history-item:hover {
  transform: translateX(4px);
  background: #f1f5f9;
}

.history-item .teams {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 600;
}

.history-item .t-score {
  font-size: 1.5rem;
  font-weight: 800;
  padding: 0 8px;
  color: var(--text-muted);
}

.history-item .t-score.winner {
  color: var(--accent-hover);
}

.history-item .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.btn-edit {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}
.btn-edit:hover {
  background: #e2e8f0;
  color: var(--text-main);
  border-color: #94a3b8;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 32px;
  width: 90%;
  max-width: 500px;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-content h2 {
  margin-bottom: 24px;
  text-align: center;
  color: var(--text-main);
}

.setup-teams, .edit-teams {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.team-setup {
  background: #f8fafc;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.team-setup h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}
.team-a h3 { color: var(--team-a); }
.team-b h3 { color: var(--team-b); }

.edit-score-input {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.player-select {
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 1em;
}

.player-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}
.player-select:last-child {
  margin-bottom: 0;
}

.vs-divider {
  text-align: center;
  font-weight: 800;
  color: #cbd5e1;
}

.modal-actions {
  display: flex;
  gap: 16px;
}

.modal-actions button {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-cancel {
  background: #f1f5f9;
  color: var(--text-muted);
}
.btn-cancel:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-primary {
  background: var(--accent-color);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
