/* Webplayer and admin panel in the look of the in-game HUD: chat, tab list and menus over a dim world. Translucent
   black, white text with a hard shadow, chat colours as signals, square corners in 2 px steps. */

@font-face {
  font-family: "Pixelify Sans";
  src: url("/fonts/pixelify-sans.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* The world behind the HUD */
  --world: #30343a;
  /* HUD layers: panel like the chat background, rows like tab list entries */
  --hud: rgb(0 0 0 / 62%);
  --hud-strong: rgb(0 0 0 / 50%);
  --row: rgb(255 255 255 / 7%);
  --row-hover: rgb(255 255 255 / 13%);
  --rule: rgb(255 255 255 / 14%);
  --text: #ffffff;
  --muted: #aaaaaa;
  --shadow: 2px 2px 0 rgb(0 0 0 / 60%);
  /* Chat colours */
  --green: #55ff55;
  --red: #ff5555;
  --yellow: #ffff55;
  --gold: #ffaa00;
  --aqua: #55ffff;
  --hover-text: #ffffa0;
  --pixel: "Pixelify Sans", system-ui, sans-serif;
  --value: 70%;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  scrollbar-color: rgb(255 255 255 / 30%) var(--world);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 100vh;
  padding: 24px 16px;
  background: var(--world);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* The world behind the HUD: a night landscape (tools/make_background.py), pixel-sharp and dimmed like behind the
   pause menu. The hut with the lit window stays in view on narrow screens. */
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  background: url("/background.png") 75% 100% / cover no-repeat;
  filter: brightness(0.72);
  image-rendering: pixelated;
}

::selection {
  background: var(--aqua);
  color: #000;
}

/* --- HUD panel -------------------------------------------------------------------------------- */

.panel {
  width: 100%;
  max-width: 440px;
  padding: 20px;
  background: var(--hud);
}

/* Inner areas are rows of the HUD, not boxes in boxes */
.slot {
  background: var(--row);
}

.masthead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--rule);
}

.note {
  flex: none;
  width: 24px;
  height: 24px;
  fill: var(--gold);
  filter: drop-shadow(2px 2px 0 rgb(0 0 0 / 60%));
}

h1,
h2 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

h1 {
  font-size: 1.75rem;
}

/* Pixel text carries the game's hard shadow */
h1,
h2,
.name,
.title,
.network,
.volume output,
button {
  text-shadow: var(--shadow);
}

.network {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 0.95rem;
}

/* --- Connected player, like an entry of the tab list ------------------------------------------ */

.who {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.head {
  display: grid;
  flex: none;
  place-items: center;
  width: 64px;
  height: 64px;
  background: var(--row);
}

.head img {
  display: block;
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
}

.head-fallback {
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 2rem;
  text-shadow: var(--shadow);
}

.head.loaded {
  background: none;
}

.head.loaded .head-fallback {
  display: none;
}

.who-text {
  min-width: 0;
}

.who-text p {
  margin: 0;
}

.name {
  overflow: hidden;
  font-family: var(--pixel);
  font-size: 1.35rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--yellow);
  font-size: 0.9rem;
}

/* Signal like the ping bars in the tab list: yellow while connecting, green when connected, red on problems */
.status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: currentColor;
  box-shadow: 2px 2px 0 rgb(0 0 0 / 60%);
}

.status.ok {
  color: var(--green);
}

.status.error {
  color: var(--red);
}

section {
  margin-top: 20px;
}

/* --- Buttons: text on translucent black, outlined when selected like in the game menus -------- */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border: 2px solid transparent;
  border-radius: 0;
  background: var(--hud-strong);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--text);
  color: var(--hover-text);
}

button:active:not(:disabled) {
  background: rgb(0 0 0 / 70%);
}

button:disabled {
  cursor: progress;
  color: var(--muted);
}

button.primary {
  color: var(--green);
}

button.danger {
  color: var(--red);
}

button.big {
  width: 100%;
  padding: 14px 20px;
  border-color: rgb(255 255 255 / 25%);
  font-family: var(--pixel);
  font-size: 1.35rem;
}

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: currentColor;
  filter: drop-shadow(2px 2px 0 rgb(0 0 0 / 60%));
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--aqua);
  outline-offset: 2px;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* --- Now playing, like the record line above the hotbar --------------------------------------- */

.now {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
}

.track {
  min-width: 0;
}

.track p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title {
  color: var(--gold);
  font-family: var(--pixel);
  font-size: 1.2rem;
  line-height: 1.3;
}

.artist,
.license {
  color: var(--muted);
  font-size: 0.875rem;
}

.license:empty {
  display: none;
}

.bars {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 4px;
  width: 36px;
  height: 32px;
}

.bars span {
  flex: 1;
  height: 4px;
  background: var(--green);
  box-shadow: 2px 2px 0 rgb(0 0 0 / 60%);
}

.bars.playing span {
  animation: level 0.8s steps(4, jump-none) infinite alternate;
}

.bars.playing span:nth-child(2) {
  animation-delay: -0.5s;
}

.bars.playing span:nth-child(3) {
  animation-delay: -0.2s;
}

.bars.playing span:nth-child(4) {
  animation-delay: -0.65s;
}

.bars.playing span:nth-child(5) {
  animation-delay: -0.35s;
}

@keyframes level {
  from {
    height: 4px;
  }
  to {
    height: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bars.playing span {
    animation: none;
    height: 20px;
  }

  .bars.playing span:nth-child(even) {
    height: 12px;
  }
}

/* --- Volume, like a slider of the options menu ------------------------------------------------ */

.volume {
  display: grid;
  grid-template-columns: auto 1fr 3.5em;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.volume output {
  color: var(--text);
  font-family: var(--pixel);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(var(--gold), var(--gold)) 0 0 / var(--value) 100% no-repeat, rgb(0 0 0 / 55%);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  background: rgb(0 0 0 / 55%);
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  background: var(--gold);
}

input[type="range"]::-webkit-slider-thumb {
  width: 8px;
  height: 20px;
  margin-top: -6px;
  border: 0;
  border-radius: 0;
  background: var(--text);
  box-shadow: 2px 2px 0 rgb(0 0 0 / 60%);
  appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 20px;
  border: 0;
  border-radius: 0;
  background: var(--text);
  box-shadow: 2px 2px 0 rgb(0 0 0 / 60%);
}

input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--hover-text);
}

/* --- Problem and footer ----------------------------------------------------------------------- */

.problem p {
  margin: 0 0 12px;
  color: var(--red);
}

footer {
  max-width: 440px;
  padding: 8px 12px;
  background: rgb(0 0 0 / 55%);
  color: #cccccc;
  font-size: 0.75rem;
  text-align: center;
}

[hidden] {
  display: none !important;
}
