* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: #f8f8f2;
  background: radial-gradient(circle at center, #2d2d46 0%, #161623 70%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}

.hud {
  text-align: center;
  margin-top: 1.5rem;
}

.hud h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
}

.hud p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.8;
}

#game {
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  background: rgba(15, 15, 30, 0.75);
  flex: 1 1 auto;
  width: 100%;
  image-rendering: pixelated;
  align-self: center;
}

.join-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(74, 99, 132, 0.42), transparent 42%),
    rgba(10, 10, 20, 0.88);
  backdrop-filter: blur(8px);
}

.join-screen[hidden] {
  display: none;
}

.join-card {
  display: grid;
  width: min(420px, 100%);
  gap: 12px;
  padding: 30px;
  border: 1px solid rgba(101, 216, 255, 0.45);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(34, 39, 62, 0.98), rgba(18, 19, 34, 0.98));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.join-card__eyebrow {
  margin: 0;
  color: #65d8ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.join-card h1 {
  margin: -4px 0 8px;
  font-size: clamp(34px, 10vw, 52px);
  letter-spacing: 0.04em;
}

.join-card label {
  font-size: 14px;
  font-weight: 700;
}

.join-card input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  outline: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font: 18px/1.3 "Segoe UI", Tahoma, sans-serif;
}

.join-card input:focus {
  border-color: #65d8ff;
  box-shadow: 0 0 0 3px rgba(101, 216, 255, 0.18);
}

.join-card button {
  min-height: 48px;
  margin-top: 4px;
  border: 1px solid rgba(101, 216, 255, 0.8);
  border-radius: 7px;
  color: #06151b;
  background: #65d8ff;
  font: 700 16px/1.2 "Segoe UI", Tahoma, sans-serif;
  cursor: pointer;
}

.join-card button:not(:disabled):hover,
.join-card button:not(:disabled):focus-visible {
  background: #95e7ff;
}

.join-card button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.join-card__error {
  margin: 0;
  color: #ffaaaa;
  font-size: 13px;
}

.debug-menu {
  position: fixed;
  left: 16px;
  bottom: 54px;
  z-index: 20;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 70px);
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  color: #f8f8f2;
  background: rgba(15, 15, 24, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
}

.debug-menu[hidden] {
  display: none;
}

.debug-menu h2 {
  margin: 0 0 12px;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.debug-tunables {
  display: grid;
  gap: 8px;
}

.debug-tunables > h3 {
  margin: 8px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: #65d8ff;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.debug-tunables > h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.debug-control-panel {
  display: grid;
  gap: 6px;
}

.debug-control-group {
  margin-top: 5px;
  color: rgba(248, 248, 242, 0.58);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.debug-tunable {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 28px;
  padding: 4px 2px;
  cursor: pointer;
}

.debug-tunable--nested {
  min-height: 24px;
  padding-left: 14px;
  color: rgba(248, 248, 242, 0.82);
  font-size: 13px;
}

.debug-tunable:has(input:disabled),
.debug-tunable:has(select:disabled) {
  cursor: default;
  opacity: 0.42;
}

.debug-tunable input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #65d8ff;
  cursor: pointer;
}

.debug-tunable--server {
  min-height: 32px;
  font-size: 13px;
}

.debug-tunable--server > span:first-child {
  min-width: 0;
  line-height: 1.2;
}

.debug-tunable__value {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.debug-tunable input[type="number"],
.debug-tunable input[type="text"],
.debug-tunable select {
  width: 104px;
  min-height: 28px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  color: #f8f8f2;
  background: rgba(255, 255, 255, 0.08);
  font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.debug-tunable input[type="text"] {
  color-scheme: dark;
  color: #f8f8f2;
  background-color: #18252c;
}

.debug-seed-control {
  flex: 1 1 210px;
  min-width: 0;
}

.debug-seed-control input[type="text"] {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
}

.debug-menu__action.debug-seed-control__apply {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
  padding: 6px 8px;
}

.debug-tunable select {
  width: 148px;
  color-scheme: dark;
  color: #f8f8f2;
  background-color: #18252c;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

.debug-tunable select option {
  color: #f8f8f2;
  background-color: #18252c;
}

.debug-tunable select option:checked {
  color: #071218;
  background-color: #65d8ff;
}

.debug-tunable__unit {
  width: 32px;
  color: rgba(248, 248, 242, 0.62);
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.debug-tunable input:disabled,
.debug-tunable select:disabled {
  cursor: default;
}

.debug-menu__action {
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid rgba(101, 216, 255, 0.48);
  border-radius: 5px;
  color: #eafaff;
  background: rgba(30, 87, 108, 0.42);
  font: 600 12px/1.2 "Segoe UI", Tahoma, sans-serif;
  cursor: pointer;
}

.debug-menu__action:not(:disabled):hover,
.debug-menu__action:not(:disabled):focus-visible {
  border-color: rgba(101, 216, 255, 0.9);
  background: rgba(30, 87, 108, 0.68);
}

.debug-menu__action:disabled {
  cursor: default;
  opacity: 0.42;
}

.debug-menu__action--danger {
  border-color: rgba(255, 108, 108, 0.52);
  color: #ffeaea;
  background: rgba(112, 31, 38, 0.48);
}

.debug-menu__action--danger:not(:disabled):hover,
.debug-menu__action--danger:not(:disabled):focus-visible {
  border-color: rgba(255, 125, 125, 0.9);
  background: rgba(142, 38, 48, 0.7);
}

.debug-control-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 6px;
}

.debug-control-status {
  min-height: 16px;
  color: rgba(160, 232, 255, 0.82);
  font-size: 11px;
  line-height: 1.35;
}

.debug-control-status--error {
  color: #ffaaaa;
}

.debug-telemetry-status {
  min-height: 0;
}

.debug-telemetry-panel {
  display: grid;
  gap: 7px;
}

.debug-telemetry-options {
  display: grid;
  gap: 2px;
  padding: 2px 4px 4px;
}

.debug-telemetry-options .debug-control-group {
  margin: 3px 0 1px;
}

.debug-telemetry-action--recording {
  border-color: rgba(255, 188, 92, 0.72);
  color: #fff4df;
  background: rgba(113, 68, 22, 0.58);
}

.debug-telemetry-action--recording:not(:disabled):hover,
.debug-telemetry-action--recording:not(:disabled):focus-visible {
  border-color: rgba(255, 202, 122, 0.95);
  background: rgba(139, 82, 25, 0.76);
}

.debug-readout {
  position: fixed;
  left: 16px;
  bottom: 12px;
  z-index: 20;
  color: rgba(255, 255, 255, 0.72);
  font: 13px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  pointer-events: none;
  user-select: none;
}

.debug-fps {
  margin-bottom: 2px;
  color: #fff;
}

.debug-health {
  max-width: min(520px, calc(100vw - 32px));
  margin-bottom: 3px;
  color: #ff9e9e;
  font-weight: 700;
}

.debug-stats {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  display: grid;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: rgba(248, 248, 242, 0.92);
  background: rgba(10, 10, 18, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font: 11px/1.34 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
  user-select: none;
}

.debug-stats[hidden],
.debug-stats__section[hidden] {
  display: none;
}

.debug-stats__section + .debug-stats__section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.debug-stats__section h2 {
  margin: 0 0 3px;
  color: #65d8ff;
  font: 700 11px/1.3 "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.debug-stats__section--alert h2 {
  color: #ff8f8f;
}

.debug-stats__value--alert {
  color: #ff8f8f;
}

.debug-stats__section pre {
  margin: 0;
  overflow: hidden;
  color: inherit;
  font: inherit;
  white-space: pre;
}

.renderer-error {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 1rem 1.25rem;
  border: 1px solid rgba(255, 100, 100, 0.75);
  border-radius: 8px;
  color: #fff;
  background: rgba(35, 10, 15, 0.95);
  text-align: center;
  z-index: 10;
}
