*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-canvas: #050507;
  --bg-surface: rgba(18, 16, 22, 0.9);
  --bg-surface-hover: rgba(34, 29, 40, 0.96);
  --border-subtle: rgba(255, 255, 255, 0.16);
  --text-primary: #f5f0f2;
  --text-secondary: #c4b8be;
  --accent: #f472b6;
  --accent-bg: rgba(244, 114, 182, 0.2);
  --accent-border: rgba(244, 114, 182, 0.62);
  --accent-glow: rgba(244, 114, 182, 0.45);
  --focus-ring: #ffe4e6;
  --radius-pill: 9999px;
  --radius-card: 16px;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  background-color: var(--bg-canvas);
}

#roseCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.fallback-message {
  max-width: 36ch;
  padding: 24px;
  text-align: center;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 20px 12px;
  pointer-events: none;
}

.title-wrap {
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.brand-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.icon-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
}

.control-dock {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  padding: 8px 12px;
  border-radius: 24px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.mode-switch,
.color-picker,
.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
}

.mode-btn,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.mode-btn:hover,
.action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.mode-btn.is-active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--text-primary);
}

.swatch-btn {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.swatch-btn::before {
  content: "";
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--swatch-color);
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.swatch-btn:hover::before {
  transform: scale(1.1);
}

.swatch-btn.is-active::before {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

body.is-ui-hidden .title-wrap,
body.is-ui-hidden .control-dock {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
}

body.is-ui-hidden .title-wrap {
  transform: translateY(-6px);
}

.note-dialog {
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  max-width: min(420px, calc(100vw - 32px));
  color: var(--text-primary);
}

.note-dialog::backdrop {
  background: rgba(5, 5, 7, 0.78);
  backdrop-filter: blur(6px);
}

.note-card {
  padding: 28px 24px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
  background: #121016;
}

.note-title {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-primary);
}

.note-body {
  margin: 0 0 16px;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.note-sign {
  margin: 0 0 24px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.close-note-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 100%;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(244, 63, 94, 0.65);
  background: rgba(244, 63, 94, 0.22);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
}

.close-note-btn:hover {
  background: rgba(244, 63, 94, 0.34);
}

@media (max-width: 720px) {
  .control-dock {
    width: calc(100vw - 20px);
    padding: 8px 10px;
    gap: 4px;
    border-radius: 20px;
  }

  .divider {
    display: none;
  }

  .mode-btn,
  .action-btn {
    padding: 0 12px;
  }
}

@media (min-width: 721px) {
  .control-dock {
    flex-wrap: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .title-wrap,
  .control-dock,
  .icon-btn,
  .mode-btn,
  .action-btn,
  .swatch-btn::before {
    transition: none;
  }
}
