:root {
  --bg-1: #efe4cb;
  --bg-2: #e6d8b9;
  --card: rgba(251, 246, 233, 0.82);
  --line: rgba(90, 72, 42, 0.20);
  --text: #2f291d;
  --muted: #76684d;
  --accent: #667547;
  --accent-2: #4d5e34;
  --ok: #3e7b44;
  --warn: #ffcf5c;
  --danger: #b85845;
  --gold: rgba(201, 157, 54, 0.20);
  --silver: rgba(139, 135, 126, 0.16);
  --bronze: rgba(145, 101, 67, 0.18);
  --fourth: rgba(107, 127, 70, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background-image: url('/static/background2.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

body.highscore-page {
  overflow: hidden;
}

body.highscore-page .container {
  padding-top: 16px;
  padding-bottom: 16px;
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    url('/static/glas.png'),
    linear-gradient(rgba(255, 252, 245, 0.22), rgba(255, 252, 245, 0.22)),
    radial-gradient(circle at 22% 20%, rgba(255, 255, 255, 0.2) 0%, transparent 42%),
    radial-gradient(circle at 78% 14%, rgba(255, 255, 255, 0.14) 0%, transparent 38%);
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  background-position: 78% 50%, center, 22% 20%, 78% 14%;
  background-size: auto 70vh, cover, auto, auto;
  opacity: 1;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: grid;
  gap: 16px;
  position: relative;
  z-index: 2;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(2px);
  box-shadow: 0 8px 26px rgba(104, 84, 54, 0.12);
}

.highscore-card {
  background: rgba(251, 246, 233, 0.5);
}

.highscore-card .card-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

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

.brand-logo {
  width: 220px;
  object-fit: contain;
  flex: 0 0 auto;
  justify-self: start;
}

.tournament-title {
  margin: 0;
  line-height: 1.1;
  text-align: center;
}

.title-main,
.title-sub {
  display: block;
}

.title-main {
  font-size: 2.1rem;
}

.title-sub {
  margin-top: 4px;
  font-size: 1.18rem;
  font-weight: 500;
  color: var(--muted);
}

.pill {
  border: 1px solid rgba(86, 101, 55, 0.45);
  color: #4f5f31;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.98rem;
  white-space: nowrap;
  justify-self: end;
}

.table-wrap {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: none;
  box-shadow: inset 0 -1px 0 var(--line);
}

.highscore-card th,
.highscore-card td {
  font-size: 1.45rem;
}

.highscore-card th:nth-child(1), .highscore-card td:nth-child(1) { width: 22%; }
.highscore-card th:nth-child(2), .highscore-card td:nth-child(2) { width: 48%; }
.highscore-card th:nth-child(3), .highscore-card td:nth-child(3) { width: 30%; }

th {
  color: #4a3e2c;
  font-weight: 600;
}

.highscore-card td:last-child,
.highscore-card th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.highscore-card tbody td:nth-child(2) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-icon {
  font-size: 1.12rem;
  width: 1.25rem;
  text-align: center;
}

tbody tr {
  transition: background-color 220ms ease;
}

tbody.page-swap {
  animation: pageSwap 320ms ease;
}

#fixedTableBody tr.prize-1 td,
#fixedTableBody tr.prize-2 td,
#fixedTableBody tr.prize-3 td,
#fixedTableBody tr.prize-4 td {
  box-shadow: inset 0 -1px 0 rgba(84, 66, 40, 0.26);
}

tbody tr.prize-1 { background: var(--gold); }
tbody tr.prize-2 { background: var(--silver); }
tbody tr.prize-3 { background: var(--bronze); }
tbody tr.prize-4 { background: var(--fourth); }

.highscore-card tbody tr.prize-1 td,
.highscore-card tbody tr.prize-2 td,
.highscore-card tbody tr.prize-3 td,
.highscore-card tbody tr.prize-4 td {
  font-weight: 700;
  color: #2a2318;
}

.empty-row td {
  color: rgba(90, 72, 42, 0.45);
}

.admin-block {
  margin-top: 8px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(86, 101, 55, 0.35);
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab-button {
  background: transparent;
  color: #4f5f31;
  border: none;
  border-radius: 0;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-button.active {
  background: rgba(255, 250, 240, 0.65);
  color: #34441f;
  border-bottom-color: #5b6b3a;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel h3 {
  margin-top: 2px;
}

.admin-form-narrow {
  max-width: 360px;
}

.admin-form-inline {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 12px;
}

.admin-form-right {
  justify-content: end;
  margin-bottom: 16px;
}

.actions-cell {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.actions-header {
  text-align: right;
}

.score-editor tr {
  border-bottom: 1px solid var(--line);
}

.score-editor td {
  box-shadow: none;
  border-bottom: none;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.delete-player {
  background: linear-gradient(90deg, #ba6a52, #9f4f3c);
}

.score-editor {
  margin-top: 6px;
}

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

.hidden {
  display: none;
}

.admin-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus {
  border-color: rgba(90, 108, 53, 0.75);
}

select:focus {
  border-color: rgba(90, 108, 53, 0.75);
}

button {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border: none;
  color: #f5f1e5;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

button.danger {
  background: linear-gradient(90deg, #ba6a52, #9f4f3c);
}

.message {
  min-height: 20px;
  color: #5b4a33;
  margin-top: 8px;
}

.message.ok {
  color: var(--ok);
}

.message.err {
  color: #a14d3c;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pageSwap {
  from {
    opacity: 0.15;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 680px) {
  .highscore-card .card-head {
    grid-template-columns: auto 1fr;
    row-gap: 6px;
  }

  .tournament-title {
    text-align: left;
    font-size: 1.05rem;
  }

  .title-main {
    font-size: 1.45rem;
  }

  .title-sub {
    font-size: 1.0rem;
  }

  .pill {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .brand-logo {
    width: 68px;
    height: 68px;
  }

  .admin-form-inline {
    grid-template-columns: 1fr;
  }
}

