@font-face {
  font-family: Classic;
  src: url(assets/classic-game.ttf) format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --pixel: Classic, monospace;
  --shadow: 2px 2px 0 #3f3f3f;
  --dirt: url(assets/menu-dirt.png) repeat 0 0 / 64px 64px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: #fff;
  background: #21170f var(--dirt);
  font: 16px/1.45 var(--pixel);
  font-synthesis: none;
  text-shadow: var(--shadow);
}
h1, h2, h3, p { margin: 0; font-weight: normal; }
a { color: inherit; }
button, input { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.menu-button {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 5px 10px;
  border: 4px solid transparent;
  border-image: url(assets/button-normal.png) 2 fill stretch;
  color: #e0e0e0;
  image-rendering: pixelated;
  text-align: center;
  text-decoration: none;
  text-shadow: 2px 2px 0 #383838;
  cursor: pointer;
}
.menu-button:hover, .menu-button:focus-visible, .menu-button[aria-pressed="true"],
.address-menu[open] > summary {
  color: #ffffa0;
  border-image-source: url(assets/button-hover.png);
  text-shadow: 2px 2px 0 #3f3f28;
}

.title-screen {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
}
.panorama, .title-screen::before {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Six inward-facing cube panels share a camera centered on the viewport. */
.panorama {
  --cube-radius: 650px;
  z-index: -2;
  overflow: hidden;
  perspective: clamp(280px, 65vh, 650px);
  pointer-events: none;
}
.panorama-cube {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-style: preserve-3d;
  animation: panorama-turn 240s linear infinite;
  animation-play-state: paused;
}
.has-begun .panorama-cube { animation-play-state: running; }
.panorama-face {
  position: absolute;
  width: calc(2 * var(--cube-radius) + 1px);
  height: calc(2 * var(--cube-radius) + 1px);
  inset: auto;
  left: calc(-1 * var(--cube-radius));
  top: calc(-1 * var(--cube-radius));
  background-size: 100% 100%;
  transform: rotateY(var(--angle, 0deg)) translateZ(calc(-1 * var(--cube-radius)));
  backface-visibility: hidden;
}
.face-0 { background-image: url(assets/panorama-0.webp); }
.face-1 { --angle: -90deg; background-image: url(assets/panorama-1.webp); }
.face-2 { --angle: 180deg; background-image: url(assets/panorama-2.webp); }
.face-3 { --angle: 90deg; background-image: url(assets/panorama-3.webp); }
.face-4 {
  background-image: url(assets/panorama-4.webp);
  transform: rotateX(-90deg) translateZ(calc(-1 * var(--cube-radius)));
}
.face-5 {
  background-image: url(assets/panorama-5.webp);
  transform: rotateX(90deg) translateZ(calc(-1 * var(--cube-radius)));
}
@keyframes panorama-turn {
  from { transform: translateZ(clamp(280px, 65vh, 650px)) rotateX(8deg) rotateY(0deg); }
  to { transform: translateZ(clamp(280px, 65vh, 650px)) rotateX(8deg) rotateY(360deg); }
}
.title-screen::before {
  content: "";
  z-index: -1;
  background: linear-gradient(#0002, #0002 72%, #0008);
}
.title-menu {
  align-self: center;
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding-block: 52px 28px;
  text-align: center;
}
.title-lockup {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto clamp(38px, 9vh, 86px);
}
.title-lockup img {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.splash {
  position: absolute;
  right: 3%;
  top: 48%;
  color: #ffff00;
  text-shadow: 2px 2px 0 #3f3f00;
  font-size: clamp(18px, 4vw, 30px);
  transform: rotate(-20deg);
  animation: splash-pulse .6s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes splash-pulse {
  to { transform: rotate(-20deg) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .splash { animation: none; }
}
.server-description {
  max-width: 450px;
  margin: 20px auto 14px;
  padding: 6px 10px;
  background: #0008;
  text-wrap: pretty;
}
.menu-stack {
  display: grid;
  gap: 7px;
  width: min(400px, 100%);
  margin-inline: auto;
}
.address-menu summary { list-style: none; }
.address-menu summary::-webkit-details-marker { display: none; }
.address-panel {
  margin-top: 7px;
  padding: 12px;
  border: 2px solid #696969;
  background: #080808ed;
}
.address-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.address-row code { font: inherit; overflow-wrap: anywhere; }
.title-footer {
  padding: 12px 16px;
  text-align: right;
  font-size: 13px;
}

.game-screen { min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; }
.screen-header, .screen-footer { background: #0005; padding: 16px; text-align: center; }
.screen-header h1 { font-size: 24px; }
.screen-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.filters button { font-size: 14px; }
.screen-tools input {
  min-height: 40px;
  max-width: 100%;
  padding: 5px 10px;
  border: 2px solid #a0a0a0;
  border-radius: 0;
  background: #000;
  color: #fff;
}
.list-area {
  background: linear-gradient(#000a, #000a), var(--dirt);
  border-block: 2px solid #080605;
  padding: 14px 0;
}
.screen-width { width: min(760px, calc(100% - 24px)); margin-inline: auto; }
.screen-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.screen-footer .menu-button { width: min(220px, 100%); }

table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 8px; border-bottom: 1px solid #555; }
th { background: #101010; font-weight: normal; color: #e0e0e0; text-shadow: 2px 2px 0 #383838; }
td { background: #0b0b0bd9; }
tr:hover td { background: #222; }
th:last-child, td:last-child { text-align: right; }
td:last-child { white-space: nowrap; }
td > span { display: flex; align-items: center; gap: 9px; overflow-wrap: anywhere; }
.face { width: 32px; height: 32px; flex: none; image-rendering: pixelated; }
.empty { padding: 12px 8px; }

.chronicle { display: grid; gap: 8px; }
.chronicle article { background: #0b0b0bd9; border: 1px solid #747474; padding: 12px; }
.chronicle h3 { font-size: 17px; }
.chronicle time, .chronicle p { color: #aaa; text-shadow: 2px 2px 0 #2a2a2a; }
.chronicle p { margin-top: 4px; }
.event-faces { display: flex; gap: 4px; margin-top: 8px; }
.event-faces .face { width: 24px; height: 24px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 460px) {
  .title-footer, table, .filters button { font-size: 13px; }
  th, td { padding-inline: 5px; }
  td > span { gap: 5px; }
  td .face { width: 24px; height: 24px; }
  .screen-tools input { width: 100%; }
}


.begin-screen {
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: #000;
}
.begin-screen::backdrop { background: #000; }
.begin-screen button {
  width: 100%;
  height: 100%;
  border: 0;
  color: #fff;
  background: #000;
  cursor: pointer;
  text-shadow: var(--shadow);
}
.begin-screen button:focus-visible { outline-offset: -6px; }
.sound-toggle { position: absolute; z-index: 1; top: 10px; left: 10px; }
.sound-toggle[aria-pressed="true"]:not(:hover):not(:focus-visible) {
  color: #e0e0e0;
  border-image-source: url(assets/button-normal.png);
  text-shadow: 2px 2px 0 #383838;
}
.title-menu { padding-top: 70px; }
.has-begun { animation: entrance .8s ease-out both; }
.has-begun .title-menu { animation: menu-enter .7s ease-out both; }
.game-screen { animation: entrance .34s ease-out both; }
.menu-button { transition: filter .16s ease, transform .16s ease; }
.menu-button:hover { filter: brightness(1.1); }
.menu-button:active { transform: translateY(2px); }
.address-menu[open] .address-panel { animation: menu-enter .22s ease-out both; }
td, input { transition: background-color .18s ease; }
@keyframes entrance { from { opacity: 0; } to { opacity: 1; } }
@keyframes menu-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .has-begun .panorama-cube { animation-play-state: paused; }
  .has-begun, .has-begun .title-menu, .game-screen,
  .address-menu[open] .address-panel { animation: none; }
  .menu-button, td, input { transition: none; }
}

.server-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 2px solid #808080;
  background: #000;
  padding: 6px;
  text-align: left;
  margin-bottom: 10px;
}
.server-icon { flex: none; image-rendering: pixelated; }
.server-info { flex: 1; min-width: 0; }
.server-topline { display: flex; justify-content: space-between; flex-wrap: wrap; column-gap: 6px; }
.server-population { color: #aaa; white-space: nowrap; }
.server-motd { color: #aaa; font-size: 13px; }
.signal-bars {
  display: inline-block;
  width: 16px;
  height: 12px;
  background: #55ff55;
  clip-path: polygon(0 100%,0 78%,15% 78%,15% 100%,22% 100%,22% 59%,37% 59%,37% 100%,44% 100%,44% 40%,59% 40%,59% 100%,66% 100%,66% 20%,81% 20%,81% 100%,87% 100%,87% 0,100% 0,100% 100%);
}

[data-page="leaderboards"] .game-screen {
  height: 100svh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.rank-scroll {
  overflow: auto;
  padding-top: 0;
}
.rank-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.game-screen .screen-header { padding-inline: 140px; }
@media (max-width: 650px) {
  body:not(:has(.title-screen)) > .sound-toggle { position: relative; top: auto; left: auto; margin: 5px; min-height: 32px; }
  .game-screen .screen-header { padding-inline: 12px; }
  body:has(> .sound-toggle) .game-screen { height: calc(100svh - 42px); min-height: 0; }
}

.event-faces { flex-wrap: wrap; gap: 8px; }
.event-player { position: relative; display: inline-flex; }
.player-tooltip {
  position: absolute;
  z-index: 3;
  bottom: calc(100% + 5px);
  left: 0;
  display: none;
  padding: 4px 6px;
  border: 1px solid #4d2780;
  background: #100518;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.event-player:hover .player-tooltip, .event-player:focus .player-tooltip { display: block; }
