:root {
  color: #e8e8df;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #020304;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body,
#game,
#viewport {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

canvas { display: block; }

#top-left {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

#hud,
#audio-control,
.hud-button {
  padding: 10px 12px;
  color: #cfd8d5;
  background: rgb(2 6 8 / 65%);
  border: 1px solid rgb(147 189 178 / 20%);
  border-radius: 6px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.hud-button {
  cursor: pointer;
}

#disconnect-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 5;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  color: #fff1e8;
  background: rgb(96 18 14 / 92%);
  border: 1px solid #e78e75;
  border-radius: 7px;
  transform: translateX(-50%);
}

#disconnect-banner button,
.profile-submit {
  padding: 8px 13px;
  border: 0;
  border-radius: 5px;
  color: #17201e;
  background: #d9c99f;
  cursor: pointer;
  font-weight: 700;
}

.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  background: radial-gradient(circle, rgb(17 25 25 / 78%), rgb(0 0 0 / 96%));
  backdrop-filter: blur(7px);
}

.menu-title {
  margin: 0;
  color: #edf4ef;
  font-size: clamp(32px, 6vw, 72px);
  font-weight: 300;
  letter-spacing: 0.18em;
  line-height: 1;
  text-align: center;
}

.modal-card {
  position: relative;
  align-self: center;
  width: min(900px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 34px 18px 18px;
  border: 1px solid rgb(147 189 178 / 45%);
  border-radius: 10px;
  background: #0c1213;
  box-shadow: 0 24px 80px #000;
}

.modal-close { position: absolute; top: 7px; right: 10px; display: flex; gap: 7px; align-items: center; padding: 2px 5px; border: 0; border-radius: 4px; color: #aebbb6; background: none; cursor: pointer; font: 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
.modal-close:hover { color: #fff; background: rgb(255 255 255 / 8%); }
.modal-close-mark { font: 24px/1 system-ui, sans-serif; }
.menu-content { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 16px; align-items: center; }
.identity-panel { display: grid; gap: 10px; align-content: center; }
#player-name { width: 100%; min-width: 0; padding: 8px 10px; color: #f4f5ed; background: #131c1e; border: 1px solid #60716d; border-radius: 5px; font: inherit; }
.form-error { min-height: 1.4em; margin: 0; color: #ffad9d; font-size: 12px; }
.gender-options { display: flex; gap: 8px; }
.gender-option { flex: 1; min-width: 0; padding: 8px 12px; color: #cbd6d2; background: #172022; border: 1px solid #53625e; border-radius: 5px; cursor: pointer; }
.gender-option.selected { color: #1b211f; background: #e4d190; border-color: #e4d190; }
.flare-color-picker { display: grid; gap: 7px; margin-top: 8px; padding-top: 10px; border-top: 1px solid rgb(147 189 178 / 18%); }
.flare-color-label { color: #aebbb6; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.flare-color-options { display: flex; gap: 8px; }
.flare-color-option { flex: 1; min-width: 0; height: 30px; padding: 0; border: 2px solid #253033; border-radius: 5px; background: var(--flare-color); box-shadow: inset 0 0 10px rgb(255 255 255 / 18%); cursor: pointer; }
.flare-color-option.selected { border-color: #f5f0d8; box-shadow: 0 0 0 2px rgb(245 240 216 / 28%), inset 0 0 10px rgb(255 255 255 / 28%); }
.character-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.character-option { position: relative; min-width: 0; padding: 0; overflow: hidden; color: #d8e2de; background: #121a1c; border: 2px solid transparent; border-radius: 7px; cursor: pointer; }
.character-option.selected { border-color: #e4d190; background: #28302c; }
.character-preview { display: grid; place-items: center; width: 100%; padding: 0; aspect-ratio: 2 / 3; color: #7f918c; background: #182021; font-size: 11px; }
.character-option.sprite-ready .character-preview { color: transparent; background-image: var(--sprite-url); background-repeat: no-repeat; background-position: var(--sprite-x) var(--sprite-y); background-size: var(--sprite-size-x) var(--sprite-size-y); }
.character-label { position: absolute; inset: auto 0 0; display: block; padding: 5px 4px 4px; overflow: hidden; color: #f1f4ee; background: linear-gradient(transparent, rgb(0 0 0 / 88%)); text-align: center; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; white-space: nowrap; font-size: 11px; }
.profile-submit { width: 100%; margin-top: 8px; }
.menu-hints { align-self: end; max-width: 100%; color: #9ba5a1; text-align: center; }

@media (max-width: 640px) {
  .modal { padding: 10px; }
  .menu-title { font-size: clamp(25px, 9vw, 42px); }
  .modal-card { padding: 32px 10px 10px; }
  .menu-content { grid-template-columns: minmax(0, 1fr) 120px; gap: 8px; }
  .character-options { gap: 4px; }
  .character-label { font-size: 9px; }
  .gender-option { padding-inline: 8px; }
  .menu-hints { font-size: 10px; }
}

@media (max-height: 760px) {
  .modal { gap: 8px; padding-block: 12px; }
  .menu-title { font-size: clamp(26px, 5vw, 50px); }
  .modal-card { padding-top: 30px; }
  .menu-content { align-items: start; }
  .character-option {
    max-height: clamp(96px, calc((100dvh - 230px) / 2), 220px);
  }
}

#hud {
  pointer-events: none;
}

#audio-control {
  display: grid;
  grid-template-columns: auto minmax(80px, 10vw) 5ch;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

#sound-volume {
  width: 100%;
  accent-color: #91bdb2;
  cursor: pointer;
}

#sound-volume-output {
  color: #ffe8a3;
  text-align: right;
}

#target { color: #ffe8a3; }

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 8px;
  height: 8px;
  margin: -4px;
  border: 1px solid rgb(255 255 255 / 85%);
  border-radius: 50%;
  box-shadow: 0 0 4px #000;
  pointer-events: none;
}

#announcement {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8vw;
  color: #fff4cf;
  background: radial-gradient(circle, rgb(20 28 27 / 30%), transparent 48%);
  font: 700 clamp(42px, 8vw, 112px)/1.05 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 3px 4px #000, 0 0 24px rgb(255 205 105 / 48%);
  pointer-events: none;
}

#announcement > :nth-child(2) {
  margin-top: 0.35em;
  color: #d6e6df;
  font-size: 0.36em;
  font-weight: 500;
  letter-spacing: 0.14em;
}
