:root {
  --ink: #fff4dc;
  --dim: #b9b3c9;
  --panel: rgba(10, 10, 28, 0.72);
  --line: rgba(255, 200, 110, 0.28);
  --gold: #ffc14d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: #02030c;
  color: var(--ink);
  font: 14px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#world:active { cursor: grabbing; }

.hud { position: fixed; z-index: 2; }

.title {
  top: calc(16px + env(safe-area-inset-top));
  left: calc(20px + env(safe-area-inset-left));
  right: 20px;
  pointer-events: none;
}
.title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 170, 60, 0.7);
}
.title p { margin: 2px 0 0; color: var(--dim); font-size: 12px; }
.title .signature { color: var(--ink); font-style: italic; letter-spacing: 0.02em; }

.controls {
  left: calc(20px + env(safe-area-inset-left));
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  color: var(--dim);
  font-size: 12px;
  pointer-events: none;
}

button {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  pointer-events: auto;
}

nav { display: flex; flex-wrap: wrap; gap: 6px; }
nav button { min-height: 44px; padding: 8px 12px; }
nav button:hover { background: rgba(70, 40, 10, 0.8); }
#volley { color: var(--gold); }

.hint.touch { display: none; }
@media (pointer: coarse) {
  .hint.mouse { display: none; }
  .hint.touch { display: inline; }
}

.being {
  top: 16px;
  right: 20px;
  width: 290px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.being[hidden] { display: none; }
.being h2 { margin: 0; font-size: 16px; color: var(--gold); }
.being p { margin: 0 0 8px; color: var(--dim); font-size: 12px; }
.being canvas { width: 100%; height: auto; display: block; }

#beingClose {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  font-size: 18px;
}

.legend {
  display: flex;
  gap: 14px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}
.legend .turn { color: #5fd3ff; }
.legend .pace { color: #7dff9a; }
.legend .mood { color: #ff7ac8; }

#error {
  position: fixed;
  inset: 45% 20px auto;
  text-align: center;
  color: var(--gold);
}
#error[hidden] { display: none; }

.touchpad, .risepad { display: none; touch-action: none; }
.touchpad {
  left: calc(20px + env(safe-area-inset-left));
  bottom: calc(112px + env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(10, 10, 28, 0.42);
}
.touchpad span {
  position: absolute;
  inset: 32px;
  border-radius: 50%;
  background: rgba(255, 193, 77, 0.55);
  pointer-events: none;
}
.risepad {
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(112px + env(safe-area-inset-bottom));
  flex-direction: column;
  gap: 8px;
}
.risepad button { width: 52px; height: 52px; touch-action: none; }
@media (pointer: coarse) {
  .touchpad { display: block; }
  .risepad { display: flex; }
}

@media (max-width: 600px) {
  .title { left: 16px; right: 16px; }
  .title h1 { font-size: 18px; }
  .title p { font-size: 11px; }
  .controls { left: 16px; right: 16px; }
  .hint { width: 100%; text-align: center; }
  nav { width: 100%; }
  nav button { flex: 1 1 22%; padding: 8px 4px; font-size: 12px; }
  .being { top: calc(104px + env(safe-area-inset-top)); left: 16px; right: 16px; width: auto; }
  .being canvas { max-height: 80px; }
}

@media (max-height: 460px) {
  .hint { display: none !important; }
  .touchpad, .risepad { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .being { top: 12px; bottom: auto; left: auto; right: 16px; width: 240px; }
  .being canvas { max-height: 90px; }
}
