:root {
  --cream: #f4efe1;
  --ink: #4a4038;
  --falu: #9e3b2c;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

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

/* ---------- loading ---------- */

#loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 110%, #e8f1dc 0%, transparent 55%),
    radial-gradient(130% 100% at 50% -20%, #d9e9f5 0%, transparent 60%),
    var(--cream);
  transition: opacity 1.1s ease;
}

#loading.done { opacity: 0; pointer-events: none; }

.loading-card {
  text-align: center;
  user-select: none;
}

.loading-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 6vw, 52px);
  letter-spacing: 0.04em;
  color: var(--falu);
}

.loading-sub {
  margin-top: 2px;
  font-size: 13px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  opacity: 0.62;
}

.loading-track {
  width: min(220px, 56vw);
  height: 3px;
  margin: 26px auto 10px;
  border-radius: 2px;
  background: rgba(74, 64, 56, 0.16);
  overflow: hidden;
}

#load-fill {
  width: 0%;
  height: 100%;
  border-radius: 2px;
  background: var(--falu);
  transition: width 0.35s ease;
}

#load-status {
  font-size: 12px;
  letter-spacing: 0.08em;
  opacity: 0.55;
  min-height: 1.2em;
}

/* ---------- fallback ---------- */

#fallback {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 110%, #e8f1dc 0%, transparent 55%),
    var(--cream);
  text-align: center;
  padding: 24px;
}

.fallback-card p { margin-top: 14px; max-width: 420px; line-height: 1.5; }
.fallback-hint { font-size: 13px; opacity: 0.6; }

/* ---------- HUD ---------- */

#title-chip {
  position: fixed;
  top: 18px;
  left: 22px;
  z-index: 20;
  font-family: Georgia, serif;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 1px 10px rgba(30, 50, 70, 0.55);
  opacity: 0;
  transition: opacity 1.6s ease;
  pointer-events: none;
}
#title-chip.show { opacity: 0.92; }

#hint {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 18px;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(22, 32, 42, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 252, 245, 0.92);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}
#hint.show { opacity: 1; }
#hint b { font-weight: 650; color: #ffe9a8; }
#hint span + span::before {
  content: "\00b7";
  margin-right: 18px;
  opacity: 0.45;
}

@media (max-width: 560px) {
  #hint { gap: 10px; font-size: 11px; padding: 8px 12px; }
  #hint span + span::before { margin-right: 10px; }
}

/* ---------- touch controls (coarse pointers only) ---------- */

#touch-ui {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.stick-wrap {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#wrap-l { left: calc(18px + env(safe-area-inset-left)); }
#wrap-r { right: calc(18px + env(safe-area-inset-right)); }

.stick-zone {
  position: relative;
  width: 128px;
  height: 128px;
  pointer-events: auto;
  touch-action: none;
}

.stick-cap {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 250, 240, 0.75);
  text-shadow: 0 1px 6px rgba(20, 30, 40, 0.6);
}

.stick-base {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: rgba(22, 32, 42, 0.28);
  border: 1.5px solid rgba(255, 250, 240, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 2px 12px rgba(20, 30, 40, 0.35);
  transition: transform 0.05s linear;
}

#stick-l .stick-knob { background: rgba(214, 236, 255, 0.85); }
#stick-r .stick-knob { background: rgba(255, 244, 214, 0.85); }
