/* Domino Counter — Mobile-First Responsive CSS */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --border: #334155;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

h2 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--text);
}

h3 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Forms */
input, select, button {
  font-family: inherit;
  font-size: 1rem;
  border-radius: var(--radius);
}

input[type="text"],
input[type="number"],
select {
  padding: 10px 12px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
}

.form-row input {
  flex: 1;
}

.form-row button {
  white-space: nowrap;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn:hover {
  background: #475569;
  text-decoration: none;
}

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

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

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: #d97706;
  color: white;
  border-color: #d97706;
}

.btn-warning:hover {
  background: #b45309;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-card);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover {
  background: rgba(59, 130, 246, 0.1);
}

.ranking tr:first-child {
  background: rgba(255, 215, 0, 0.1);
  font-weight: bold;
}

.target-reached {
  background: rgba(34, 197, 94, 0.15) !important;
  font-weight: bold;
}

/* Round form */
.round-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 1rem;
}

.pair-input {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.pair-input strong {
  min-width: 120px;
  font-size: 0.95rem;
}

.pair-input input {
  max-width: 120px;
}

/* Team input boxes */
.team-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.team-box.vs {
  justify-content: center;
  background: transparent;
  padding: 4px;
}

.vs-badge {
  font-weight: bold;
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
  padding: 4px 12px;
  border-radius: 20px;
}

.team-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: var(--bg-input);
  padding: 4px 8px;
  border-radius: 4px;
}

.team-names {
  flex: 1;
  font-size: 1rem;
}

.team-box input {
  max-width: 100px;
}

/* Round totals row */
.totals-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.total-box {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
}

.total-box.vs-total {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  padding: 0 4px;
}

.total-score {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent);
  margin-top: 8px;
}

.target-reached-bg {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 24px;
  background: var(--bg-input);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  color: #fff;
  min-width: fit-content;
  padding: 0 8px;
  transition: width 0.3s ease;
}

/* Hand (partida) form */
.hand-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.winner-select {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.winner-select label {
  flex: 1;
  display: block;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.winner-select label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.2);
}

.winner-select input[type="radio"] {
  margin-right: 4px;
}

.puntos-input {
  display: flex;
  gap: 8px;
}

.puntos-input input {
  flex: 1;
  max-width: 150px;
}

.puntos-input button {
  flex: 1;
}

/* Round win banner */
.champion-banner {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1e293b;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  font-size: 1.3rem;
  margin: 1rem 0;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.champion-banner strong {
  font-size: 1.5rem;
}

.round-win {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  color: #86efac;
  margin-bottom: 1rem;
}

/* Partidas table */
.partidas {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.partidas th {
  text-align: left;
  padding: 6px 8px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
}

.partidas td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Actions */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.actions form {
  flex: 1;
  min-width: 120px;
}

.actions .btn {
  width: 100%;
}

/* Home actions */
.home-actions {
  display: flex;
  gap: 12px;
  margin: 1.5rem 0;
}

.home-actions .btn {
  flex: 1;
  text-align: center;
  font-size: 1.1rem;
  padding: 14px 20px;
}

.score-rules {
  list-style: disc;
  padding-left: 1.5rem;
}

.score-rules li {
  border: none;
  padding: 4px 0;
}

/* Navigation */
.nav {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* List */
ul {
  list-style: none;
  padding: 0;
}

li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

li a {
  flex: 1;
}

/* Session list */
.session-list li {
  padding: 12px 0;
}

.session-list li:hover {
  background: rgba(59, 130, 246, 0.05);
  padding-left: 8px;
  border-radius: var(--radius);
}

/* Session title */
.session-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Error message */
.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 1rem;
  color: #fca5a5;
}

.banner-active {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 1rem;
  color: #86efac;
  font-size: 0.9rem;
}

.text-dim {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Labels */
label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

label input, label select {
  margin-top: 4px;
}

/* Section separator */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* Responsive: Small screens */
@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  h1 {
    font-size: 1.3rem;
  }

  .pair-input {
    flex-direction: column;
    align-items: stretch;
  }

  .pair-input input {
    max-width: 100%;
  }

  .team-box {
    flex-wrap: wrap;
  }

  .team-box input {
    max-width: 100%;
    width: 100%;
  }

  .team-names {
    width: 100%;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 8px 4px;
  }

  .actions {
    flex-direction: column;
  }

  .totals-row {
    flex-direction: column;
  }

  .hand-form {
    padding: 12px;
  }

  .winner-select {
    flex-direction: column;
    gap: 8px;
  }

  .puntos-input {
    flex-direction: column;
  }

  .puntos-input input {
    max-width: 100%;
  }
}
