/* Driftworld: the canvas fills the screen, everything else floats on top. */

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1020;
  color: #f3f5fa;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }

#view {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;        /* stop the page scrolling while you drag */
  user-select: none;
  -webkit-user-select: none;
}

button, input, select {
  font: inherit;
  color: inherit;
}
button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(10, 16, 32, 0.6);
  cursor: pointer;
}
button[aria-pressed="true"] { background: #2f6f9f; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #7fd0ff; outline-offset: 2px; }
input {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  width: 100%;
  min-width: 0;
}

/* ---- the bar at the top while you play ---- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  pointer-events: none;       /* taps go through to the world... */
}
#hud nav { display: flex; flex-shrink: 0; gap: 6px; pointer-events: auto; }   /* ...except on buttons */
#hud nav button { padding: 0 10px; }
#seedName {
  flex: 1 1 auto;
  min-width: 0;                /* so a long name shortens with an ellipsis instead of pushing the buttons */
  font-weight: 600;
  text-shadow: 0 1px 3px #000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#compassBox {
  position: fixed;
  left: 50%;
  top: calc(52px + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
#compass { width: 240px; height: 26px; border-radius: 6px; }
#heading { font-size: 12px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px #000; }

#timeBar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 20px));
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(10, 16, 32, 0.55);
}
#timeBar input { min-height: 28px; padding: 0; border: 0; background: none; flex: 1; }
#clock { font-variant-numeric: tabular-nums; }

#crosshair {
  position: fixed;
  left: 50%; top: 50%;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  pointer-events: none;
}

/* The constellation you are looking at, just under the crosshair. */
#skyName {
  position: fixed;
  left: 50%; top: 50%;
  margin: 18px 0 0;
  transform: translateX(-50%);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* The phone joystick appears where your left thumb lands. */
#stick {
  position: fixed;
  width: 110px; height: 110px;
  margin: -55px 0 0 -55px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  pointer-events: none;
}
#knob {
  position: absolute;
  left: 35px; top: 35px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
}

/* Flag labels, placed in 3D by CSS2DRenderer. */
.labels { position: fixed !important; top: 0; left: 0; pointer-events: none; }
.tag {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 13px;
  white-space: nowrap;
}

#minimap {
  position: fixed;
  left: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

#debug {
  position: fixed;
  left: 8px;
  top: calc(52px + env(safe-area-inset-top));
  margin: 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  font: 12px/1.3 ui-monospace, monospace;
  pointer-events: none;
}

#toast {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  text-align: center;
  pointer-events: none;
}

/* ---- start screen, saved picture, dialogs ---- */
.panel {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  padding: 32px 16px;
  background: radial-gradient(circle at 50% 0, #24406a, #0b1020 70%);
}
.panel > * { max-width: 460px; margin-left: auto; margin-right: auto; }
.panel h1 { font-size: 34px; margin-top: 0; margin-bottom: 4px; }
.panel h2 { font-size: 18px; margin-top: 28px; }
#shot { display: flex; flex-direction: column; justify-content: center; }
#shot > * { width: 100%; }
#shotImg { display: block; max-width: 720px; max-height: 55vh; object-fit: cover; border-radius: 8px; background: #000; }
.row { display: flex; gap: 8px; margin-top: 6px; }
.picks { flex-wrap: wrap; gap: 8px 16px; margin: 10px 0 4px; color: #aab3c5; }
.picks label { display: flex; align-items: center; gap: 8px; }
select {
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
}
select option { background: #121a2e; }
.wide { display: block; width: 100%; margin-top: 12px; }
.preview { display: flex; gap: 14px; align-items: flex-start; margin-top: 12px; }
.preview canvas { width: 160px; height: 160px; flex: none; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.25); background: #1b3f66; image-rendering: auto; }
.preview p { margin: 4px 0 10px; }
#worlds { list-style: none; padding: 0; }
#worlds li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
#worlds a { flex: 1; min-width: 0; padding: 8px 0; color: #9fd8ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#worlds button { min-height: 32px; padding: 0 10px; font-size: 13px; color: #aab3c5; }
#worlds button:hover { color: #ffb0a0; border-color: #ffb0a0; }
.muted { color: #aab3c5; }
.error { color: #ffb0a0; }

dialog {
  width: min(380px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: #141b30;
  color: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog label { display: block; margin-bottom: 6px; }
dialog .row { justify-content: flex-end; margin-top: 12px; }
#saveResult { overflow-wrap: anywhere; }

@media (max-width: 420px) {
  #hud nav button { padding: 0 8px; font-size: 14px; }
  #minimap { width: 96px; height: 96px; bottom: calc(64px + env(safe-area-inset-bottom)); }
  #compass { width: 180px; height: 22px; }
}
