:root {
  --panel: rgba(14, 16, 22, 0.78);
  --line: rgba(255, 255, 255, 0.14);
  --text: #e9ecf1;
  --dim: #9aa3b2;
  --accent: #ffb454;
  --bad: #ff6b5e;
  --good: #6fdc8c;
  font-family: system-ui, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #0b0d12;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
}

body.playing #crosshair {
  opacity: 1;
}

#panel {
  position: fixed;
  left: 16px;
  top: 16px;
  width: 250px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  transition:
    opacity 0.3s,
    transform 0.25s;
}

body.playing #panel,
body.playing #panel-fold {
  opacity: 0.35;
}

/* The panel folds away to the left; its tab stays. */
body.folded #panel {
  transform: translateX(calc(-100% - 20px));
}

#panel-fold {
  position: fixed;
  left: 266px;
  top: 16px;
  width: 22px;
  height: 40px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  background: var(--panel);
  border-left: none;
  border-radius: 0 8px 8px 0;
  backdrop-filter: blur(8px);
  transition:
    opacity 0.3s,
    left 0.25s;
}

body.folded #panel-fold {
  left: 0;
}

h1 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 4px;
  color: var(--dim);
}

.row output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}

#lighting {
  margin: 8px 0 4px;
  color: var(--dim);
}

#lighting summary {
  cursor: pointer;
}

.tune {
  display: grid;
  grid-template-columns: 82px 1fr 34px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
}

.tune output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#reach-row,
#fog-row {
  grid-template-columns: 82px 1fr 52px;
  color: var(--dim);
}

#lighting-reset {
  margin: 4px 0 2px;
}

.row[hidden] {
  display: none;
}

input[type='text'] {
  font: inherit;
  color: var(--text);
  background: #1b1e26;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  width: 150px;
}

select {
  font: inherit;
  color: var(--text);
  background: #1b1e26;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  max-width: 170px;
}

button:hover {
  background: rgba(255, 255, 255, 0.14);
}

button.active {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

#chat {
  position: fixed;
  left: 16px;
  bottom: 16px;
  width: 360px;
  pointer-events: none;
}

#chat-log {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#chat-log li {
  margin: 2px 0;
  transition: opacity 1s;
}

#chat-log li.old {
  opacity: 0;
}

#chat-log b {
  color: var(--accent);
  font-weight: 600;
}

#chat-input {
  pointer-events: auto;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  opacity: 0.35;
}

#chat-input:focus {
  opacity: 1;
  outline: none;
  border-color: var(--accent);
}

#status {
  margin: 12px 0 0;
  color: var(--dim);
}

.help {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  line-height: 1.6;
  font-size: 12.5px;
}

.help b {
  color: var(--text);
  font-weight: 600;
}

.links {
  display: flex;
  justify-content: space-between;
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--dim);
}

a {
  color: var(--accent);
}

#search {
  position: relative;
  margin: 8px 0 4px;
}

#search[hidden] {
  display: none;
}

#search-input {
  width: 100%;
}

#search-results {
  position: absolute;
  left: 0;
  right: -90px;
  top: 100%;
  z-index: 2;
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  max-height: 320px;
  overflow-y: auto;
  background: #14171f;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#search-results li {
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
}

#search-results li.active,
#search-results li:hover {
  background: rgba(255, 255, 255, 0.1);
}

#search-results li.none {
  color: var(--dim);
  cursor: default;
}

#search-results small {
  display: block;
  color: var(--dim);
}

#parcel-card {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(640px, 90vw);
  padding: 8px 14px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

#parcel-card b {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

#parcel-card span {
  color: var(--dim);
  font-size: 12.5px;
}

#minimap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 230px;
  height: 230px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #183a53;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

#minimap[hidden] {
  display: none;
}

#minimap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

#minimap.large {
  right: auto;
  bottom: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1100px, 92vw);
  height: min(820px, 88vh);
  z-index: 5;
}

#minimap.large canvas {
  cursor: grab;
  touch-action: none;
}

.map-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-tools button {
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 1;
  color: #1f2522;
  background: rgba(250, 250, 246, 0.92);
  border: 1px solid #b9c2ba;
}

.map-tools button:hover {
  background: #ffffff;
}

#minimap:not(.large) [data-map='me'],
#minimap:not(.large) .map-hint {
  display: none;
}

.map-hint {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  margin: 0;
  padding: 5px 12px;
  white-space: nowrap;
  color: #eef1ec;
  background: rgba(22, 27, 24, 0.85);
  border-radius: 14px;
  font-size: 12.5px;
  pointer-events: none;
}

#mine {
  margin: 10px 0 6px;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
}

#mine[hidden] {
  display: none;
}

#mine span {
  display: block;
  color: var(--dim);
  font-size: 12px;
}

#mine b {
  display: block;
  margin: 2px 0 8px;
  font-weight: 600;
}

.buttons.two {
  grid-template-columns: 1fr 1fr;
}

#mine a.button {
  display: block;
  padding: 4px 10px;
  text-align: center;
  text-decoration: none;
  color: #12151c;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
}

/* Phones and tablets: no settings, a cross to move, a finger on the picture to look around. */
body.mobile #panel,
body.mobile #panel-fold,
body.mobile #chat-input {
  display: none;
}

body.mobile #view {
  touch-action: none;
}

body.mobile #crosshair {
  opacity: 1;
}

body.mobile #chat {
  left: 12px;
  top: 12px;
  bottom: auto;
  width: min(300px, 55vw);
}

body.mobile #minimap:not(.large) {
  right: 12px;
  top: 12px;
  bottom: auto;
  width: 120px;
  height: 120px;
}

body.mobile #parcel-card {
  bottom: 12px;
  left: auto;
  right: 12px;
  transform: none;
  max-width: calc(100vw - 200px);
}

#touch-pad {
  position: fixed;
  left: 18px;
  bottom: 18px;
  width: 150px;
  height: 150px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 3;
}

#touch-pad i {
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-size: 20px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  pointer-events: none;
}

#touch-pad i.on {
  background: rgba(255, 180, 84, 0.55);
}

#touch-pad [data-pad='up'] {
  grid-area: 1 / 2;
  border-radius: 10px 10px 0 0;
}

#touch-pad [data-pad='left'] {
  grid-area: 2 / 1;
  border-radius: 10px 0 0 10px;
}

#touch-pad [data-pad='hub'] {
  grid-area: 2 / 2;
}

#touch-pad [data-pad='right'] {
  grid-area: 2 / 3;
  border-radius: 0 10px 10px 0;
}

#touch-pad [data-pad='down'] {
  grid-area: 3 / 2;
  border-radius: 0 0 10px 10px;
}

/* The avatar gallery (app/picker.js). */
#look {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#avatar-picker {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

#avatar-picker[hidden] {
  display: none;
}

#avatar-picker .sheet {
  width: min(760px, 100%);
  max-height: min(640px, 100%);
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
}

#avatar-picker header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

#avatar-picker h2 {
  margin: 0;
  font-size: 15px;
  flex: 1;
}

#avatar-picker .styles {
  display: flex;
  gap: 4px;
}

#avatar-picker button.active {
  border-color: var(--accent);
  color: var(--accent);
}

#avatar-picker .close {
  font-size: 18px;
  line-height: 1;
  padding: 2px 9px;
}

#avatar-picker .looks {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

#avatar-picker .looks button {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
}

#avatar-picker .looks .thumb {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}

#avatar-picker .looks span {
  font-size: 12px;
}

#avatar-picker .chosen button {
  border-color: var(--accent);
  background: rgba(255, 180, 84, 0.15);
}

#avatar-picker .credit {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--dim);
}
