:root {
  --primary: #193d49;
  --primary-dark: #0f2833;
  --accent: #fdb857;
  --mint: #4cbe7d;
  --sky: #a1d8d0;
  --bg: #f1f6f8;
  --card: #ffffff;
  --text: #1f2a30;
  --muted: #4b616b;
  --border: #d3dee2;
  --highlight: #e5f4f1;
  --row-height: 72px;
  --row-gap: 0.5rem;
}

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

body {
  font-family: 'Open Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, rgba(10, 40, 54, 0.65), transparent 60%),
    linear-gradient(180deg, #0f2230 0%, #123647 55%, #0a1a26 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

body.scoreboard-page {
  min-height: 100vh;
  height: 100vh;
  padding: clamp(0.75rem, 4vw, 2.5rem);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

body.scoreboard-page .leaderboard-card {
  flex: 1;
  min-height: 0;
  width: min(90vw, 1300px);
  height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 0.42fr) minmax(0, 0.58fr);
  gap: 2rem;
  align-items: stretch;
  margin: 0 auto;
  background: var(--card);
  border-radius: 28px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  box-shadow: 0 25px 50px rgb(15 23 42 / 0.12);
  border-top: 8px solid var(--accent);
}

h1,
h2,
h3,
.leaderboard-row span.name {
  font-family: 'Oswald', 'Open Sans', sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.leaderboard-hero h2 {
  font-size: clamp(2.2rem, 3.5vw, 3.8rem);
}

.leaderboard-hero .subtitle {
  color: rgb(255 255 255 / 0.75);
  font-size: clamp(1rem, 1.4vw, 1.5rem);
}

.label {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: clamp(0.65rem, 0.8vw, 0.95rem);
  color: var(--sky);
}

.label.accent {
  color: var(--accent);
}

.timer {
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  font-weight: 600;
}

main {
  padding: clamp(1.5rem, 4vw, 4rem);
}

body.scoreboard-page main {
  width: 100%;
  min-height: calc(100vh - clamp(0.5rem, 4vw, 2.5rem) * 2);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: clamp(1rem, 3vw, 2.5rem);
  flex: 1 0 auto;
}


.leaderboard-card {
  margin: 0 auto;
  background: var(--card);
  border-radius: 28px;
  padding: clamp(1.5rem, 5vw, 2.2rem);
  box-shadow: 0 25px 50px rgb(15 23 42 / 0.12);
  border-top: 8px solid var(--accent);
  min-height: clamp(520px, 90vh, 880px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.leaderboard-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #1b5870 55%, rgba(255, 255, 255, 0.08) 100%);
  color: white;
  border-radius: 28px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1.5rem;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15);
}

.leaderboard-hero .label {
  color: rgb(255 255 255 / 0.8);
}

.hero-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

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

.leaderboard-hero .subtitle {
  color: rgb(255 255 255 / 0.75);
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: auto;
}

.countdown-panel {
  align-self: flex-start;
  margin-top: 0.75rem;
  background: rgb(0 0 0 / 0.18);
  border-radius: 22px;
  padding: clamp(0.8rem, 2vw, 1.2rem) clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid rgb(255 255 255 / 0.3);
  box-shadow: inset 0 0 30px rgb(0 0 0 / 0.35);
  width: min(100%, 420px);
}

.timer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.35rem, 1vw, 0.8rem);
  text-align: center;
}

.time-slot {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.time-value {
  font-size: clamp(1.8rem, 4.5vw, 3.2rem);
  font-weight: 700;
  color: white;
  text-shadow: 0 5px 18px rgb(0 0 0 / 0.45);
}

.time-label {
  font-size: clamp(0.55rem, 1vw, 0.85rem);
  letter-spacing: 0.2em;
  color: rgb(255 255 255 / 0.75);
}

.hero-meta strong {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.1;
  color: white;
}

.meta-label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: rgb(255 255 255 / 0.65);
}

.countdown-chip {
  background: rgba(25, 61, 73, 0.08);
  border: 1px solid rgb(25 61 73 / 0.15);
  border-radius: 18px;
  padding: 0.8rem 1.4rem;
  min-width: 220px;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.4);
  backdrop-filter: blur(4px);
  color: var(--text);
}

.leaderboard-hero .countdown-panel {
  border-color: rgb(255 255 255 / 0.35);
}

.leaderboard-table {
  display: flex;
  flex-direction: column;
  gap: var(--row-gap);
  min-height: 0;
  height: 100%;
}

.leaderboard-body {
  display: flex;
  flex-direction: column;
  gap: var(--row-gap);
  overflow-y: auto;
  max-height: calc(
    var(--row-height) * var(--visible-row-count, 5) +
      (var(--visible-row-count, 5) - 1) * var(--row-gap)
  );
  padding-right: 0.25rem;
  flex: 1 1 auto;
  min-height: 0;
}

.leaderboard-body::-webkit-scrollbar {
  width: 6px;
}

.leaderboard-body::-webkit-scrollbar-thumb {
  background: rgb(25 61 73 / 0.2);
  border-radius: 999px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 80px 1fr 130px;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  background: linear-gradient(120deg, var(--highlight), #ffffff);
  font-size: clamp(1rem, 2.2vw, 1.4rem);
  color: var(--primary);
  border: 1px solid rgb(25 61 73 / 0.05);
  box-shadow: 0 5px 15px rgb(25 61 73 / 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
  min-height: var(--row-height);
}

.move-up {
  animation: slide-up 0.45s ease;
}

.move-down {
  animation: slide-down 0.45s ease;
}

.leaderboard-row.heading {
  font-size: 0.85rem;
  color: var(--muted);
  background: transparent;
  border: none;
  box-shadow: none;
}

.leaderboard-row span:last-child {
  text-align: right;
}

.leaderboard-row:not(.heading):hover {
  transform: none;
  box-shadow: 0 5px 15px rgb(25 61 73 / 0.08);
}

.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 1rem;
}

.leaderboard-body .placeholder {
  margin: auto;
}

@media (max-width: 1024px) {
  body.scoreboard-page .leaderboard-card {
    width: min(94vw, 1000px);
    grid-template-columns: 1fr;
    height: auto;
  }

  .leaderboard-table {
    height: auto;
  }

  .leaderboard-body {
    max-height: calc(var(--row-height) * 5 + 0.5rem * 4);
  }
}

@media (max-width: 600px) {
  body.scoreboard-page {
    padding: 0;
    background: var(--card);
    align-items: flex-start;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  body.scoreboard-page main {
    width: 100%;
    min-height: 100vh;
    padding: 0;
  }

  body.scoreboard-page .leaderboard-card {
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    max-width: none;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .leaderboard-body {
    max-height: none;
    flex: 1;
    overflow-y: visible;
  }

  .leaderboard-hero {
    border-radius: 20px;
    flex-direction: column;
    margin-bottom: 1rem;
  }

  .leaderboard-table {
    flex: 1;
  }
}

.row-updated {
  animation: pulse 0.9s ease;
  box-shadow: 0 8px 24px rgb(76 190 125 / 0.35);
  position: relative;
  z-index: 1;
}

.row-decreased {
  animation: pulse-down 0.9s ease;
  box-shadow: 0 8px 24px rgb(214 69 69 / 0.35);
  position: relative;
  z-index: 1;
}

@keyframes pulse {
  0% {
    background: linear-gradient(120deg, rgba(76, 190, 125, 0.5), #ffffff);
    transform: scale(1.02);
  }
  100% {
    background: linear-gradient(120deg, var(--highlight), #ffffff);
    transform: scale(1);
  }
}

@keyframes pulse-down {
  0% {
    background: linear-gradient(120deg, rgba(253, 88, 88, 0.45), #ffffff);
    transform: scale(1.02);
  }
  100% {
    background: linear-gradient(120deg, var(--highlight), #ffffff);
    transform: scale(1);
  }
}

@keyframes slide-up {
  0% {
    transform: translateY(12px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes slide-down {
  0% {
    transform: translateY(-12px);
  }
  100% {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .row-updated,
  .row-decreased {
    animation: none;
    box-shadow: none;
  }
}

.page-footer {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

/* Admin pagina */
.admin-page {
  background: var(--bg);
}

.admin-main {
  display: grid;
  gap: 2rem;
  padding: clamp(1.5rem, 4vw, 4rem);
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 1.2rem 1.6rem;
  box-shadow: 0 15px 35px rgb(20 37 46 / 0.12);
 border: 1px solid rgb(25 61 73 / 0.08);
}

.admin-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.scoreboard-link {
  text-decoration: none;
  padding: 0.8rem 1.6rem;
  border-radius: 999px;
  font-weight: 600;
  color: #1c1917;
  background: linear-gradient(120deg, var(--accent), #ffc86f);
  box-shadow: 0 15px 25px rgb(253 184 87 / 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.scoreboard-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 30px rgb(253 184 87 / 0.5);
}

.panel {
  background: var(--card);
  border-radius: 22px;
  padding: 1.8rem;
  box-shadow: 0 25px 45px rgb(20 37 46 / 0.12);
  border: 1px solid rgb(25 61 73 / 0.08);
}

#login-panel .subtitle {
  margin-bottom: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.logo-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo.small {
  width: 90px;
  height: auto;
  filter: drop-shadow(0 6px 10px rgb(0 0 0 / 0.2));
}

.name-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.name-text {
  font-weight: 600;
}

.name-actions {
  display: flex;
  gap: 0.4rem;
}

.name-edit {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field span {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  letter-spacing: 0.03em;
}

input,
button,
select {
  font: inherit;
}

input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fdfefe;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgb(25 61 73 / 0.15);
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 2rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button.primary,
.primary.phone {
  background: linear-gradient(120deg, var(--accent), #ffc86f);
  color: #1c1917;
  box-shadow: 0 15px 25px rgb(253 184 87 / 0.45);
}

button.primary:hover,
.primary.phone:hover {
  transform: translateY(-2px);
}

button.ghost {
  background: transparent;
  border: 2px solid rgb(255 255 255 / 0.4);
  color: white;
  padding: 0.65rem 1.5rem;
}

.admin-page button.ghost {
  border-color: var(--border);
  color: var(--primary);
}

button.ghost:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgb(25 61 73 / 0.15);
}

button.danger {
  background: #d64545;
  color: #fff;
  box-shadow: 0 10px 20px rgb(214 69 69 / 0.35);
}

button.danger:hover {
  transform: translateY(-2px);
}

button.small {
  padding: 0.4rem 1.1rem;
  border-radius: 10px;
  font-size: 0.85rem;
}

.inline-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.panel-header .inline-form {
  margin-bottom: 0;
  justify-content: flex-end;
}

.panel-header .inline-form .field {
  flex: 0 0 220px;
}

.header-actions {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-actions .search-field {
  flex: 0 0 220px;
  margin-bottom: 0;
}

.table-wrapper {
  overflow-x: auto;
}

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

thead {
  text-align: left;
  color: var(--muted);
}

td,
th {
  padding: 0.9rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

table td:first-child,
table th:first-child {
  width: 70px;
  text-align: center;
}

table td:nth-child(3),
table th:nth-child(3) {
  text-align: center;
}

.edit-zone {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.alert {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: rgb(253 184 87 / 0.15);
  color: #8b4a00;
  border: 1px solid rgb(253 184 87 / 0.5);
  margin-bottom: 1rem;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.alert.success {
  background: rgb(76 190 125 / 0.15);
  color: #0f5132;
  border: 1px solid rgb(76 190 125 / 0.45);
}

.alert.fade-out {
  opacity: 0;
  transform: translateY(-5px);
}

@media (max-width: 700px) {
  .countdown-chip {
    width: 100%;
  }

  .leaderboard-row {
    grid-template-columns: 50px 1fr 80px;
    font-size: 1rem;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
}
table td:nth-child(3),
table th:nth-child(3) {
  text-align: center;
}
