:root {
  --ink: #1c1916;
  --ink-soft: #3f3a34;
  --paper: rgba(247, 243, 236, 0.88);
  --line: rgba(28, 25, 22, 0.12);
  --bronze: #6b4f3a;
  --bronze-hi: #8a684c;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1c1916;
  color: var(--ink);
  font-family: "Instrument Sans", system-ui, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

canvas#c {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.panel {
  position: absolute;
  top: calc(12px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  width: min(300px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  padding: 16px 16px 14px;
  background: var(--paper);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(28, 25, 22, 0.16);
  pointer-events: auto;
  z-index: 2;
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bronze);
  font-weight: 500;
}

h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 2px 0 10px;
  color: var(--ink);
}

.dims {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.dims strong {
  color: var(--ink);
  font-weight: 600;
}

.note {
  font-size: 11.5px;
  line-height: 1.45;
  color: #6a645c;
  margin-bottom: 12px;
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(28, 25, 22, 0.06);
  padding: 4px;
  border-radius: 10px;
}

.modes button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 500 13px/1 "Instrument Sans", system-ui, sans-serif;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.modes button.active {
  background: var(--ink);
  color: #f7f3ec;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.hint {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.4;
  color: #6a645c;
}

.joystick {
  position: absolute;
  left: calc(18px + var(--safe-l));
  bottom: calc(22px + var(--safe-b));
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.joystick.hidden { display: none; }

.joy-base {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: rgba(247, 243, 236, 0.55);
  border: 1px solid rgba(28, 25, 22, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
  touch-action: none;
}

.joy-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--ink);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.28);
  pointer-events: none;
}

.joy-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f7f3ec;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

@media (max-width: 420px) {
  .panel { padding: 13px 13px 12px; }
  h1 { font-size: 24px; }
}
