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

:root {
  --accent: #7c8cff;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #12132b 0%, #1f2350 100%);
  transition: background 0.8s ease;
  color: #eef0ff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#stage.grabbing { cursor: grabbing; }

header {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 28px;
  pointer-events: none;
  z-index: 10;
}
header h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}
header .accent {
  color: var(--accent);
  transition: color 0.8s ease;
}
header .tagline {
  margin-top: 8px;
  font-size: clamp(0.78rem, 2vw, 0.95rem);
  opacity: 0.55;
  font-weight: 500;
}

.controls {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: 24px;
  display: flex;
  gap: 10px;
  z-index: 10;
}
.controls button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #eef0ff;
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.controls button:hover { background: rgba(255, 255, 255, 0.16); }
.controls button:active { transform: scale(0.92); }
.controls button.muted { opacity: 0.45; }

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 92px);
  transform: translateX(-50%);
  font-size: 0.85rem;
  opacity: 0.5;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  transition: opacity 0.4s;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 10, 25, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 10;
  max-width: calc(100vw - 24px);
}
.dock button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 14px;
  border: none;
  border-radius: 15px;
  background: transparent;
  color: #eef0ff;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, transform 0.15s;
}
.dock button .icon { font-size: 1.5rem; line-height: 1; }
.dock button .label { font-size: 0.68rem; font-weight: 600; opacity: 0.75; }
.dock button:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-3px); }
.dock button.active {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}
.dock button.active .label { opacity: 1; }

footer {
  position: fixed;
  right: 24px;
  bottom: max(16px, env(safe-area-inset-bottom));
  font-size: 0.72rem;
  opacity: 0.35;
  pointer-events: none;
  z-index: 10;
}

.dice-result {
  position: fixed;
  left: 50%;
  top: 16%;
  transform: translateX(-50%) scale(0.7);
  font-size: clamp(1.9rem, 7vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.3s, transform 0.35s cubic-bezier(0.2, 1.7, 0.4, 1);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}
.dice-result.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.motion-btn {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 132px);
  transform: translateX(-50%);
  padding: 13px 24px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #191307;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  z-index: 11;
  box-shadow:
    0 6px 24px color-mix(in srgb, var(--accent) 45%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  animation: motion-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.motion-btn.show { display: block; }
.motion-btn:active { transform: translateX(-50%) scale(0.94); }
@keyframes motion-pop {
  from { transform: translateX(-50%) scale(0.5); opacity: 0; }
}

@media (max-width: 640px) {
  header { left: 18px; }
  .controls { right: 14px; }
  .dock { gap: 2px; padding: 7px; }
  .dock button { padding: 9px 8px; min-width: 46px; }
  .dock button .label { font-size: 0.58rem; }
  footer { display: none; }
  .hint { font-size: 0.75rem; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 86px); }
}

@media (max-width: 430px) {
  .dock button .label { display: none; }
  .dock button { padding: 12px 13px; }
  .dock button .icon { font-size: 1.6rem; }
  header h1 { font-size: 1.7rem; }
  header .tagline { display: none; }
}
