@font-face {
  font-family: 'Fredoka';
  src: url('../assets/font/fredoka-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('../assets/font/fredoka-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f1ebe1;
  --ink: #3b2a1e;
  --ink-soft: #8a7563;
  --chip: rgba(255, 255, 255, 0.55);
  --chip-line: rgba(59, 42, 30, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  cursor: default;
}
.ready #scene { opacity: 1; }
#scene.can-grab { cursor: grab; }
#scene.grabbing { cursor: grabbing; }

.top {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  pointer-events: none;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.mark { font-weight: 700; }
.tag { color: var(--ink-soft); text-align: right; }

.hint {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--chip-line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 15px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 1s ease, transform 1s ease;
  animation: hint-in 0.8s 1.6s both ease-out;
}
.hint.gone { opacity: 0; transform: translate(-50%, 8px); }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.tools {
  position: fixed;
  right: 20px;
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
}
.tools button {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--chip);
  border: 1px solid var(--chip-line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s;
}
.tools button:hover { background: rgba(255, 255, 255, 0.9); }
.tools button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* fallback when WebGL is not available */
.fallback {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(80px, 24vw, 340px);
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
}
.no-webgl .fallback { opacity: 1; }
.no-webgl #scene, .no-webgl .hint, .no-webgl .tools { display: none; }
.f-r { color: #e8323c; }
.f-u { color: #d91f26; }
.f-b { color: #18c5f0; text-shadow: 0 0 0.12em #6fe3ff; }
.f-e { color: #d99a2b; }
.f-n { color: #ff7fb8; }

@media (max-width: 600px) {
  .top { left: 16px; right: 16px; font-size: 13px; flex-direction: column; gap: 2px; }
  .tag { text-align: left; }
  .hint { font-size: 13px; bottom: 76px; }
  .tools { right: 50%; transform: translateX(50%); }
}
