@font-face {
  font-family: "Baloo Paaji";
  src: url("fonts/BalooPaaji.ttf") format("truetype");
}

:root {
  --ground: #37432a;
  /* the HUD's palette: deep slate-blue glass, a steel edge, the slots' blue, a periwinkle accent */
  --panel: rgba(20, 25, 38, 0.94);
  --shadow: #04060e;
  --focus: #5e74c9;
  --accent-light: #a4b4f0;
  --text: #ffffff;
  --edge: #56648a;
  --soft: #ffffff;
  --muted: #8c98b4;
  --field: rgba(34, 52, 92, 0.9);
  --field-focus: #2c4272;
  --button: #364264;
  --button-hot: #485884;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ground);
  font-family: "Baloo Paaji", system-ui, sans-serif;
  color: var(--text);
  user-select: none;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  /* the game focuses the canvas to get the keys; the browser's focus ring would show as a line along the page's edge */
  outline: none;
}

/* A WebGL canvas is black until its first frame: keep it out of sight while the page shows the boot text. */
body:not(.ready) canvas { visibility: hidden; }

#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ground);
  /* a system font: the game's own font is a download, and text set in it stays invisible until it arrives */
  font: 800 34px system-ui, sans-serif;
  letter-spacing: 0.04em;
}

body.ready #boot { display: none; }

#menu {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
}

#menu[hidden], #error[hidden] { display: none; }

#chat[hidden] { display: none; }
#chat {
  position: fixed;
  left: 50%;
  top: calc(50% + 80px);
  transform: translateX(-50%);
  width: min(340px, calc(100vw - 32px));
  padding: 8px 12px;
  border: 3px solid #725126;
  border-radius: 10px;
  background: #392a14;
  box-shadow: 0 4px 0 #251d12;
}
#chat-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: white;
  font: inherit;
  font-size: 20px;
  user-select: text;
}

.menu-panel {
  width: min(100%, 390px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 26px 28px 28px;
  border: 2px solid var(--edge);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 5px 0 rgba(4, 6, 14, 0.4);
}
.menu-header {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(200, 214, 255, 0.13);
}
.menu-header h1 {
  margin: 0;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--text);
}
.menu-header p { margin: 5px 0 0; color: var(--soft); font-size: 16px; line-height: 1.4; }
#join { display: grid; gap: 8px; }
#join label { font-size: 15px; line-height: 1.4; color: var(--soft); }
#join label:not(:first-child) { margin-top: 9px; }
#nickname, #servers {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid rgba(200, 214, 255, 0.13);
  border-radius: 10px;
  background-color: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  outline: none;
  transition: border-color 120ms, background-color 120ms;
}
#nickname { user-select: text; }
#nickname::placeholder { color: var(--muted); opacity: 1; }
#nickname:focus, #servers:focus-visible { border-color: var(--focus); background-color: var(--field-focus); }
#servers {
  appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  font-size: 16px;
}
#servers option { background: #141926; color: var(--text); }
#play {
  width: 100%;
  height: 48px;
  margin-top: 14px;
  padding: 0 24px;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: var(--button);
  box-shadow: 0 4px 0 rgba(4, 6, 14, 0.4);
  color: var(--text);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}
#play:hover, #play:focus-visible { background: var(--button-hot); border-color: var(--focus); outline: none; }
#play:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(4, 6, 14, 0.4); }
#play:disabled { opacity: 0.6; cursor: default; }
#status:empty { display: none; }
#status { margin: 20px 0 0; color: var(--accent-light); font-size: 16px; line-height: 1.5; }
@media (max-height: 480px) {
  .menu-panel { padding: 16px 22px 20px; }
  .menu-header { padding-bottom: 10px; margin-bottom: 12px; }
  .menu-header h1 { font-size: 30px; }
  .menu-header p { display: none; }
}

#error {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ground);
  font: 800 34px system-ui, sans-serif;
  letter-spacing: 0.04em;
}
