:root {
  color-scheme: dark;
  --ink: #071417;
  --panel: rgba(7, 22, 25, 0.93);
  --orange: #f3782c;
  --orange-dark: #9e3e1c;
  --cream: #fff0d0;
  --muted: #a9aaa3;
  --green: #20ef72;
  --red: #ff5252;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background-color: #0a1d21;
  background-image: url('assets/bg_evening.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  color: var(--cream);
  font-family: 'Press Start 2P', monospace;
  image-rendering: pixelated;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 38%, transparent 20%, rgba(3, 13, 16, 0.18) 64%, rgba(2, 8, 10, 0.7) 100%),
    linear-gradient(to bottom, rgba(2, 11, 14, 0.08), rgba(2, 11, 14, 0.3));
  pointer-events: none;
}

button {
  font: inherit;
}

.page-shell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: start center;
  gap: 16px;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(28px, 6vh, 72px) 16px 96px;
}

.status-card {
  position: relative;
  width: min(540px, 100%);
  padding: 34px 36px 22px;
  overflow: visible;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 42%),
    var(--panel);
  border: 2px solid var(--orange);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(29, 7, 2, 0.9),
    0 12px 30px rgba(0, 0, 0, 0.5),
    inset 0 0 34px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.status-card::before,
.status-card::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: #ff9b52;
  pointer-events: none;
}

.status-card::before {
  top: -5px;
  left: -5px;
  border-top: 3px solid;
  border-left: 3px solid;
}

.status-card::after {
  right: -5px;
  bottom: -5px;
  border-right: 3px solid;
  border-bottom: 3px solid;
}

.card-rune {
  position: absolute;
  top: -28px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 56px;
  height: 52px;
  padding-top: 12px;
  color: var(--orange);
  background: var(--ink);
  border: 2px solid var(--orange);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform: translateX(-50%);
  font-size: 25px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(243, 120, 44, 0.55);
}

.server-header {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
}

.side-rune {
  color: var(--orange);
  font-size: 29px;
  opacity: 0.85;
}

.side-rune:last-child {
  transform: scaleX(-1);
}

h1 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--cream);
  font-size: clamp(22px, 5.5vw, 34px);
  line-height: 1.3;
  letter-spacing: 1px;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.65);
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 2px;
}

.status-dot {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 13px currentColor;
}

.is-online .status-line {
  color: var(--green);
}

.is-offline .status-line,
.is-unavailable .status-line {
  color: var(--red);
}

.is-offline .status-dot {
  animation: pulse 1.3s steps(2, end) infinite;
}

.player-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;
}

.player-count {
  font-size: clamp(31px, 7.5vw, 44px);
  line-height: 1.1;
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 #000;
}

.player-label {
  margin-top: 5px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#meatometer {
  position: relative;
  width: min(280px, 80%);
  height: 11px;
  margin: 14px auto 18px;
  overflow: hidden;
  background: #2b1713;
  border: 1px solid rgba(243, 120, 44, 0.75);
  border-radius: 999px;
  box-shadow: inset 0 0 6px #000;
}

#meat-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(to right, #ffb02e, #f04b23);
  transition: width 0.5s ease-in-out, box-shadow 0.3s ease-in-out;
}

#meat-fill.glow {
  box-shadow: 0 0 10px 3px rgba(255, 112, 35, 0.85);
}

#meat-fill-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.connect-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  min-height: 55px;
  margin-bottom: 18px;
  background: rgba(2, 10, 12, 0.62);
  border: 1px solid rgba(243, 120, 44, 0.7);
  border-radius: 7px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.55);
}

.connect-panel code {
  padding: 0 10px;
  overflow: hidden;
  color: var(--cream);
  font-family: inherit;
  font-size: clamp(13px, 4vw, 18px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#copy-address {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--orange);
  background: rgba(243, 120, 44, 0.06);
  border: 2px solid var(--orange);
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

#copy-address:hover,
#copy-address:focus-visible {
  color: var(--cream);
  background: rgba(243, 120, 44, 0.25);
  outline: none;
  transform: translateY(-1px);
}

#copy-address.is-copied {
  color: var(--green);
  border-color: var(--green);
}

.copy-icon {
  font-family: monospace;
  font-size: 24px;
  line-height: 1;
}

.server-details {
  margin: 0;
  padding: 16px 8px;
  border-top: 1px solid var(--orange-dark);
  border-bottom: 1px solid var(--orange-dark);
}

.server-details > div {
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 20px;
  padding: 7px 0;
  text-align: left;
}

.server-details dt,
.server-details dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

.server-details dt {
  display: flex;
  gap: 12px;
  color: var(--muted);
}

.server-details dt span {
  color: var(--orange);
}

.server-details dd {
  overflow: hidden;
  color: var(--cream);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.release-notes-link {
  color: inherit;
}

.release-notes-link[href] {
  text-decoration-color: rgba(243, 120, 44, 0.65);
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.release-notes-link[href]::after {
  content: ' \2197';
  color: var(--orange);
  font-family: monospace;
  font-size: 11px;
}

.release-notes-link[href]:hover,
.release-notes-link[href]:focus-visible {
  color: var(--orange);
}

.world-progress {
  padding: 14px 8px 0;
}

.world-progress-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-family: monospace;
}

.world-progress-heading h2 {
  margin: 0;
  color: var(--muted);
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  font-weight: normal;
  text-transform: uppercase;
}

.world-progress-heading strong {
  overflow: hidden;
  color: var(--orange);
  font-size: 11px;
  font-weight: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boss-progress-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
  color: #687371;
  font-family: monospace;
  font-size: 10px;
  text-align: left;
}

.boss-progress-list li {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.boss-progress-list li.is-defeated {
  color: var(--cream);
}

.boss-progress-marker {
  flex: 0 0 auto;
  color: #596260;
}

.is-defeated .boss-progress-marker {
  color: var(--orange);
  text-shadow: 0 0 6px rgba(243, 120, 44, 0.5);
}

.boss-progress-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seed-map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 17px;
  padding: 11px 14px;
  color: var(--orange);
  background: rgba(243, 120, 44, 0.06);
  border: 1px solid rgba(243, 120, 44, 0.7);
  border-radius: 6px;
  font-size: 10px;
  line-height: 1.4;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.seed-map-link:hover,
.seed-map-link:focus-visible {
  color: var(--cream);
  background: rgba(243, 120, 44, 0.2);
  outline: none;
  transform: translateY(-1px);
}

.seed-map-link:focus-visible {
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--orange);
}

.external-link-mark {
  font-size: 14px;
}

.server-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 18px;
}

.server-footer p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--orange);
  font-size: 11px;
  line-height: 1.5;
}

.server-footer .footer-label {
  color: var(--muted);
}

.server-footer strong {
  color: var(--cream);
  font-size: 10px;
}

.footer-divider {
  width: 1px;
  height: 24px;
  background: var(--orange-dark);
}

.age-label {
  margin: 14px 0 0;
  color: #777f7d;
  font-family: monospace;
  font-size: 12px;
}

.activity-card {
  position: relative;
  width: min(570px, 100%);
  padding: 20px 24px 17px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 42%),
    var(--panel);
  border: 2px solid var(--orange);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(29, 7, 2, 0.9),
    0 12px 30px rgba(0, 0, 0, 0.5),
    inset 0 0 34px rgba(0, 0, 0, 0.35);
}

.activity-header {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  padding-bottom: 15px;
  text-align: center;
}

.activity-header h2 {
  margin: 0;
  color: var(--cream);
  font-size: clamp(14px, 3.5vw, 20px);
  line-height: 1.5;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
}

.activity-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-family: monospace;
  font-size: 13px;
  text-transform: uppercase;
}

.activity-section {
  padding: 13px 4px;
  border-top: 1px solid var(--orange-dark);
}

.activity-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
  color: var(--muted);
  font-family: monospace;
  font-size: 13px;
}

.activity-label > span:first-child {
  color: var(--cream);
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.activity-label strong {
  color: var(--orange);
}

.player-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
}

.player-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 8px 10px;
  overflow: hidden;
  color: var(--cream);
  background: rgba(243, 120, 44, 0.08);
  border: 1px solid rgba(243, 120, 44, 0.45);
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-name.is-online::before {
  content: '';
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(32, 239, 114, 0.75);
}

.empty-player-list {
  align-self: center;
  color: #777f7d;
  font-family: monospace;
  font-size: 13px;
}

.leaderboard-wrap {
  overflow-x: auto;
}

.player-leaderboard {
  width: 100%;
  border-collapse: collapse;
  color: var(--cream);
  font-family: monospace;
  font-size: 12px;
  text-align: left;
}

.player-leaderboard th {
  padding: 3px 7px 8px;
  color: var(--muted);
  border-bottom: 1px solid rgba(243, 120, 44, 0.45);
  font-size: 10px;
  font-weight: normal;
  white-space: nowrap;
}

.player-leaderboard th:nth-child(2),
.player-leaderboard th:nth-child(3),
.player-leaderboard td:nth-child(2),
.player-leaderboard td:nth-child(3) {
  text-align: right;
}

.player-leaderboard th:last-child,
.player-leaderboard td:last-child {
  text-align: right;
}

.player-leaderboard td {
  padding: 9px 7px;
  border-bottom: 1px solid rgba(158, 62, 28, 0.45);
  white-space: nowrap;
}

.player-leaderboard tbody tr:last-child td {
  border-bottom: 0;
}

.player-leaderboard tbody tr.is-online {
  background: rgba(32, 239, 114, 0.055);
}

.player-leaderboard tbody tr.is-online td:last-child {
  color: var(--green);
  text-shadow: 0 0 8px rgba(32, 239, 114, 0.4);
}

.player-leaderboard td:first-child {
  min-width: 125px;
}

.leaderboard-rank {
  display: inline-block;
  width: 24px;
  color: var(--orange);
  font-size: 10px;
}

.playtime-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 7px;
  vertical-align: middle;
}

.playtime-rank img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.75));
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-empty td {
  display: table-cell !important;
  color: #777f7d;
  text-align: center !important;
}

.activity-note {
  margin: 4px 0 0;
  color: #777f7d;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@media (max-width: 600px) {
  .page-shell {
    padding: 28px 10px 92px;
  }

  .status-card {
    padding: 30px 18px 18px;
  }

  .activity-card {
    padding: 18px 14px 15px;
  }

  .activity-header {
    grid-template-columns: 18px minmax(0, 1fr) 18px;
  }

  .server-header {
    grid-template-columns: 18px minmax(0, 1fr) 18px;
    gap: 4px;
  }

  .side-rune {
    font-size: 20px;
  }

  .server-details > div {
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 12px;
  }

  .server-footer {
    align-items: stretch;
    gap: 10px;
  }

  .server-footer p {
    flex: 1;
    flex-wrap: wrap;
    justify-content: center;
  }

  .activity-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .boss-progress-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .world-progress-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .player-leaderboard thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .player-leaderboard,
  .player-leaderboard tbody,
  .player-leaderboard tr,
  .player-leaderboard td {
    display: block;
    width: 100%;
  }

  .player-leaderboard tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding-block: 7px;
    border-bottom: 1px solid rgba(158, 62, 28, 0.45);
  }

  .player-leaderboard td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 7px;
    border: 0;
    text-align: right !important;
  }

  .player-leaderboard td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
  }

  .player-leaderboard td:first-child {
    grid-column: 1 / -1;
    justify-content: flex-start;
    min-width: 0;
    padding-bottom: 7px;
    font-size: 14px;
  }

  .player-leaderboard td:first-child::before {
    content: none;
  }

  .player-leaderboard td:last-child {
    grid-column: 1 / -1;
  }

  .leaderboard-empty {
    display: block !important;
  }

  .leaderboard-empty td {
    padding-block: 10px;
  }

  .leaderboard-empty td::before {
    content: none;
  }

  .footer-label {
    display: none;
  }
}

@media (max-width: 390px) {
  .status-card {
    padding-inline: 13px;
  }

  .side-rune {
    display: none;
  }

  .server-header {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 1250px) and (min-width: 601px) {
  .page-shell {
    gap: 12px;
    padding-top: 26px;
    padding-bottom: 72px;
  }

  .status-card {
    padding: 27px 32px 14px;
  }

  .status-line {
    margin-top: 4px;
  }

  .player-summary {
    margin-top: 5px;
  }

  #meatometer {
    margin-block: 9px 12px;
  }

  .connect-panel {
    min-height: 49px;
    margin-bottom: 12px;
  }

  .server-details {
    padding-block: 10px;
  }

  .server-details > div {
    padding-block: 4px;
  }

  .server-footer {
    padding-top: 11px;
  }

  .seed-map-link {
    margin-top: 11px;
    padding-block: 8px;
  }

  .age-label {
    margin-top: 8px;
  }

  .activity-card {
    padding: 14px 20px 12px;
  }

  .activity-header {
    padding-bottom: 8px;
  }

  .activity-header p {
    margin-top: 2px;
  }

  .activity-section {
    padding-block: 9px;
  }

  .activity-label {
    margin-bottom: 7px;
  }

  .player-name {
    padding: 6px 9px;
  }
}

@media (max-height: 700px) and (min-width: 601px) {
  .page-shell {
    padding-top: 30px;
  }

  .status-card {
    padding-top: 27px;
    padding-bottom: 14px;
  }

  #meatometer {
    margin-block: 8px 12px;
  }

  .server-details {
    padding-block: 10px;
  }

  .server-footer {
    padding-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
