:root {
  --bg: #0f3d2e;
  --bg-deep: #0a2b20;
  --card: #14503a;
  --card-2: #1c6b4e;
  --text: #f4f1e1;
  --muted: #b8c9bd;
  --accent: #e8b64c;
  --accent-dark: #c89a2f;
  --danger: #d96c5f;
  --border: rgba(255, 255, 255, 0.12);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, var(--card) 0%, var(--bg) 45%, var(--bg-deep) 100%);
  min-height: 100vh;
  color: var(--text);
}

.app-header {
  text-align: center;
  padding: 20px 16px 6px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 1px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.85rem;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 16px 60px;
}

.hidden {
  display: none !important;
}

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field .hint {
  font-weight: 400;
  opacity: 0.7;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 1rem;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#player-inputs .player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.player-row .badge {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

#rules-list .rule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.rule-row .round-no {
  flex: 0 0 70px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

.row-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.actions-sticky {
  position: sticky;
  bottom: 12px;
  background: rgba(10, 43, 32, 0.92);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 16px;
  border: 1px solid var(--border);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  transition: transform 0.05s ease, background 0.15s ease;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: transparent;
}

.btn.primary:hover {
  background: #f0c55e;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(217, 108, 95, 0.4);
}

.btn.big {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  margin-top: 6px;
}

/* Round header */
.round-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.round-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.rules-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 14px 0;
}

.rules-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 6px;
}

#round-rules {
  font-size: 1.15rem;
  font-weight: 600;
}

.dealer-tag {
  display: inline-block;
  margin-top: 10px;
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 999px;
}

/* Score entries */
.score-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.score-entry:last-child {
  border-bottom: none;
}

.score-entry .name {
  flex: 1;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.score-entry .total {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.score-entry input {
  width: 110px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.complete-box {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(232, 182, 76, 0.15);
  border: 1px solid var(--accent);
  font-size: 1.05rem;
}

.complete-box strong {
  color: var(--accent);
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

th:first-child, td:first-child {
  text-align: left;
}

thead th {
  color: var(--muted);
  font-weight: 600;
}

tbody tr.clickable {
  cursor: pointer;
}

tbody tr.clickable:hover {
  background: rgba(255, 255, 255, 0.05);
}

tbody tr.current-round {
  background: rgba(232, 182, 76, 0.12);
}

tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--accent);
  border-bottom: none;
}

.giver-tag {
  display: inline-block;
  margin-left: 6px;
  background: var(--accent);
  color: var(--bg-deep);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.muted {
  color: var(--muted);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item .names {
  font-weight: 600;
}

.history-item .meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.history-item .btn {
  font-size: 0.85rem;
  padding: 6px 12px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-deep);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

@media (max-width: 520px) {
  .score-entry input {
    width: 84px;
  }
  .actions-sticky {
    flex-direction: column;
  }
  .actions-sticky .btn {
    width: 100%;
  }
}
