:root {
  color-scheme: dark;
  --bg-top: #9ec9ff;
  --bg-bottom: #d4f1d0;
  --panel: rgba(12, 24, 37, 0.78);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f4f8fb;
  --muted: rgba(244, 248, 251, 0.72);
  --accent: #ffb84d;
  --accent-2: #57d18f;
  --shadow: 0 24px 80px rgba(9, 18, 29, 0.35);
  --font-display: "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.75), transparent 28%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  position: relative;
}

#game-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.fps-counter {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 3;
  min-width: 88px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(12, 24, 37, 0.76);
  box-shadow: 0 12px 32px rgba(9, 18, 29, 0.24);
  backdrop-filter: blur(10px);
  color: var(--text);
  font: 700 12px/1 var(--font-display);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%);
  pointer-events: none;
}

.compass {
  position: fixed;
  top: 54px;
  left: 50%;
  z-index: 3;
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(12, 24, 37, 0.76);
  box-shadow: 0 12px 32px rgba(9, 18, 29, 0.24);
  backdrop-filter: blur(10px);
  color: var(--text);
  font: 700 12px/1 var(--font-display);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%);
  pointer-events: none;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(6, 12, 18, 0.12), rgba(6, 12, 18, 0.26));
  backdrop-filter: blur(8px);
}

.login-overlay.is-hidden {
  display: none;
}

.login-card,
.panel {
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  animation: settleCard 380ms ease-out;
}

.login-card h1 {
  margin: 0;
  font: 700 44px/1 var(--font-display);
  letter-spacing: 0.03em;
}

.login-card p,
.panel p,
.properties__hint {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.login-status {
  min-height: 22px;
}

.loading-group {
  margin-top: 14px;
}

.loading-group--hidden {
  display: none;
}

.loading-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.loading-bar__fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #ff9654);
  transition: width 120ms ease;
}

.panel {
  position: fixed;
  z-index: 3;
  width: min(320px, calc(100vw - 24px));
  padding: 16px;
  animation: settlePanel 420ms ease-out;
}

.panel--hidden {
  display: none;
}

.panel--left {
  top: 16px;
  left: 16px;
}

.panel--right {
  top: 16px;
  right: 16px;
}

.panel__section + .panel__section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.panel__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel h2 {
  margin: 0 0 10px;
  font: 700 15px/1.1 var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.panel__collapse-button,
.hud-icon-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font: 700 20px/1 var(--font-display);
}

.panel__collapse-button:hover,
.hud-icon-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.panel--collapsed {
  width: 64px;
  padding: 12px;
}

.panel--collapsed .panel__section {
  display: block;
}

.panel--collapsed .properties,
.panel--collapsed p,
.panel--collapsed .panel__section > :not(.panel__heading) {
  display: none;
}

.panel--collapsed .panel__heading {
  justify-content: center;
}

.panel--collapsed .panel__heading h2 {
  display: none;
}

.hud-icon-button {
  position: fixed;
  top: 16px;
  right: 352px;
  z-index: 4;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(9, 18, 29, 0.24);
}

.settings-menu {
  position: fixed;
  top: 62px;
  right: 352px;
  z-index: 4;
  width: 220px;
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(12, 24, 37, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.settings-menu--hidden {
  display: none;
}

.settings-menu__header h2 {
  margin: 0 0 12px;
  font: 700 14px/1 var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.mobile-controls--hidden {
  display: none;
}

.mobile-joystick {
  position: fixed;
  left: 22px;
  bottom: 28px;
  width: 144px;
  height: 144px;
  pointer-events: auto;
  touch-action: none;
}

.mobile-joystick__base,
.mobile-joystick__stick {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.mobile-joystick__base {
  width: 132px;
  height: 132px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 24, 37, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
}

.mobile-joystick__stick {
  width: 62px;
  height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 184, 77, 0.88);
  box-shadow: 0 12px 28px rgba(9, 18, 29, 0.25);
}

.mobile-jump-button {
  position: fixed;
  right: 26px;
  bottom: 36px;
  width: 108px;
  height: 108px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(87, 209, 143, 0.88);
  color: #0d1b14;
  box-shadow: 0 14px 32px rgba(9, 18, 29, 0.28);
  font: 700 20px/1 var(--font-display);
  letter-spacing: 0.04em;
  pointer-events: auto;
  touch-action: none;
}

.mobile-jump-button:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .mobile-controls {
    display: none !important;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.field span,
.property-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.8);
}

input,
button,
select {
  appearance: none;
  border: none;
  border-radius: 14px;
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

input[type="color"] {
  min-height: 46px;
  padding: 6px;
  cursor: pointer;
}

select {
  color: var(--text);
}

select option {
  color: #101820;
  background: #f4f8fb;
}

input:disabled {
  opacity: 0.55;
}

button {
  width: 100%;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--accent), #ff9654);
  color: #101820;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.palette__swatch {
  position: relative;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-align: left;
  cursor: grab;
}

.palette__tone {
  width: 100%;
  height: 18px;
  margin-bottom: 8px;
  border-radius: 999px;
}

.properties {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.property-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.property-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.property-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.property-grid .field {
  margin-bottom: 0;
}

.field--checkbox {
  justify-content: end;
  align-items: flex-start;
}

.field--checkbox-native {
  gap: 10px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.checkbox-row input[type="checkbox"] {
  appearance: auto;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.checkbox-row strong {
  font-size: 14px;
  color: var(--text);
}

.property-readout {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.properties__hint code {
  padding: 1px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

@keyframes settleCard {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes settlePanel {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .panel {
    width: calc(50vw - 18px);
  }

  .hud-icon-button,
  .settings-menu {
    right: calc(50vw + 10px);
  }
}

@media (max-width: 720px) {
  #app {
    overflow-y: auto;
  }

  .panel {
    position: static;
    width: calc(100vw - 24px);
    margin: 12px;
  }

  .hud-icon-button {
    top: 12px;
    right: 12px;
  }

  .settings-menu {
    top: 58px;
    right: 12px;
    width: min(220px, calc(100vw - 24px));
  }

  .property-grid {
    grid-template-columns: 1fr;
  }
}
