/* ==========================================================================
   bily Design System - Modern, warm, premium
   ========================================================================== */

:root {
  color-scheme: light;
  --color-brand: #ec4899;
  --color-brand-dark: #db2777;
  --color-brand-soft: rgba(236, 72, 153, 0.12);

  --color-bg: #fff5ef;
  --color-bg-end: #fffdf9;
  --color-surface: #fffaf5;
  --color-surface-soft: #fff2ea;
  --color-border: #efd9cf;
  --color-border-strong: #e5cbbd;

  --color-text: #0f172a;
  --color-text-secondary: #6b5b54;
  --color-text-tertiary: #a08f87;
  --color-title: #0b1328;
  --color-label: #6a5a52;
  --color-helper: #9a8a83;
  --color-pill-bg: #fff7f1;
  --color-tile-bg: #fff7f1;
  --color-tile-title: #6b5b54;
  --color-dice-stage-bg: linear-gradient(160deg, #fffaf6, #fff3ee);
  --color-dice-stage-border: #ead2c5;
  --color-panel-bg: rgba(255, 250, 245, 0.98);
  --color-panel-border: rgba(233, 210, 197, 0.92);
  --color-result-border: #d6dfeb;
  --color-result-outline: rgba(236, 72, 153, 0.22);
  --color-result-bg-top: rgba(255, 255, 255, 0.98);
  --color-result-bg-bottom: rgba(250, 251, 255, 0.95);
  --color-result-rule: rgba(71, 85, 105, 0.06);
  --color-result-stamp: #b19a92;
  --color-share-bg: #fff0f6;
  --color-share-border: #f3b0cf;
  --color-share-bg-hover: #ffe2f0;
  --color-secondary-btn-bg: #fff9f4;
  --color-secondary-btn-text: #5e4f48;
  --color-scroll-track: #f6eae3;
  --color-scroll-thumb: #e5cbbd;
  --color-film-bg: #fff8f2;
  --color-roll-btn-bg: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  --color-roll-btn-text: #ffffff;
  --color-roll-btn-border: transparent;
  --color-roll-btn-hover-bg: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));

  --color-active-bg: #111827;
  --color-active-text: #ffffff;

  --shadow-xs: 0 1px 2px rgba(62, 41, 31, 0.08);
  --shadow-sm: 0 8px 18px rgba(62, 41, 31, 0.12);
  --shadow-md: 0 16px 30px rgba(62, 41, 31, 0.16);
  --shadow-brand: 0 12px 26px rgba(236, 72, 153, 0.28);

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --transition-fast: 160ms ease;
  --love-scene-opacity: 0.24;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-bg: #151821;
    --color-surface: #1c2230;
    --color-bg-end: #111723;
    --color-surface-soft: #22293a;
    --color-border: #2f394c;
    --color-border-strong: #3a465d;

    --color-text: #e8ecf5;
    --color-text-secondary: #c1b8b1;
    --color-text-tertiary: #9d918a;
    --color-title: #f4f6fb;
    --color-label: #c8bcb5;
    --color-helper: #a59a93;
    --color-pill-bg: #1d222c;
    --color-tile-bg: #1d222c;
    --color-tile-title: #d4c9c2;
    --color-dice-stage-bg: linear-gradient(160deg, #1f232c, #1a1f28);
    --color-dice-stage-border: #3a312b;
    --color-panel-bg: rgba(30, 26, 24, 0.92);
    --color-panel-border: rgba(68, 58, 52, 0.85);
    --color-result-border: #35435c;
    --color-result-outline: rgba(236, 72, 153, 0.34);
    --color-result-bg-top: rgba(24, 30, 42, 0.98);
    --color-result-bg-bottom: rgba(19, 24, 34, 0.98);
    --color-result-rule: rgba(236, 72, 153, 0.08);
    --color-result-stamp: #b0b9cb;
    --color-share-bg: rgba(236, 72, 153, 0.1);
    --color-share-border: rgba(236, 72, 153, 0.5);
    --color-share-bg-hover: rgba(236, 72, 153, 0.18);
    --color-secondary-btn-bg: #221d1b;
    --color-secondary-btn-text: #e1d7d0;
    --color-scroll-track: #2a2522;
    --color-scroll-thumb: #51443d;
    --color-film-bg: #1f1b19;
    --color-roll-btn-bg: linear-gradient(160deg, rgba(32, 40, 55, 0.96), rgba(28, 35, 49, 0.96));
    --color-roll-btn-text: #f7f3fa;
    --color-roll-btn-border: rgba(236, 72, 153, 0.5);
    --color-roll-btn-hover-bg: linear-gradient(160deg, rgba(40, 49, 66, 0.98), rgba(33, 41, 58, 0.98));
    --color-active-bg: #0d1320;
    --color-active-text: #f3f6fc;

    --shadow-xs: 0 2px 4px rgba(10, 6, 4, 0.6);
    --shadow-sm: 0 10px 22px rgba(10, 6, 4, 0.52);
    --shadow-md: 0 18px 38px rgba(10, 6, 4, 0.55);
    --shadow-brand: 0 0 0 1px rgba(236, 72, 153, 0.45), 0 12px 28px rgba(236, 72, 153, 0.2);
    --love-scene-opacity: 0.2;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #151821;
  --color-surface: #1c2230;
  --color-bg-end: #111723;
  --color-surface-soft: #22293a;
  --color-border: #2f394c;
  --color-border-strong: #3a465d;
  --color-text: #e8ecf5;
  --color-text-secondary: #c1b8b1;
  --color-text-tertiary: #9d918a;
  --color-title: #f4f6fb;
  --color-label: #c8bcb5;
  --color-helper: #a59a93;
  --color-pill-bg: #1d222c;
  --color-tile-bg: #1d222c;
  --color-tile-title: #d4c9c2;
  --color-dice-stage-bg: linear-gradient(160deg, #1f232c, #1a1f28);
  --color-dice-stage-border: #3a312b;
  --color-panel-bg: rgba(30, 26, 24, 0.92);
  --color-panel-border: rgba(68, 58, 52, 0.85);
  --color-result-border: #35435c;
  --color-result-outline: rgba(236, 72, 153, 0.34);
  --color-result-bg-top: rgba(24, 30, 42, 0.98);
  --color-result-bg-bottom: rgba(19, 24, 34, 0.98);
  --color-result-rule: rgba(236, 72, 153, 0.08);
  --color-result-stamp: #b0b9cb;
  --color-share-bg: rgba(236, 72, 153, 0.1);
  --color-share-border: rgba(236, 72, 153, 0.5);
  --color-share-bg-hover: rgba(236, 72, 153, 0.18);
  --color-secondary-btn-bg: #221d1b;
  --color-secondary-btn-text: #e1d7d0;
  --color-scroll-track: #2a2522;
  --color-scroll-thumb: #51443d;
  --color-film-bg: #1f1b19;
  --color-roll-btn-bg: linear-gradient(160deg, rgba(32, 40, 55, 0.96), rgba(28, 35, 49, 0.96));
  --color-roll-btn-text: #f7f3fa;
  --color-roll-btn-border: rgba(236, 72, 153, 0.5);
  --color-roll-btn-hover-bg: linear-gradient(160deg, rgba(40, 49, 66, 0.98), rgba(33, 41, 58, 0.98));
  --color-active-bg: #0d1320;
  --color-active-text: #f3f6fc;
  --shadow-xs: 0 2px 4px rgba(10, 6, 4, 0.6);
  --shadow-sm: 0 10px 22px rgba(10, 6, 4, 0.52);
  --shadow-md: 0 18px 38px rgba(10, 6, 4, 0.55);
  --shadow-brand: 0 0 0 1px rgba(236, 72, 153, 0.45), 0 12px 28px rgba(236, 72, 153, 0.2);
  --love-scene-opacity: 0.2;
}

body {
  margin: 0;
  font-family: "Playfair Display", "Manrope", serif;
  -webkit-font-smoothing: antialiased;
}

.bily-body {
  min-height: 100vh;
  color: var(--color-text);
  background:
    radial-gradient(circle at 12% 14%, rgba(236, 72, 153, 0.12), transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(255, 186, 115, 0.16), transparent 30%),
    radial-gradient(circle at 20% 88%, rgba(255, 221, 193, 0.22), transparent 32%),
    linear-gradient(165deg, var(--color-bg) 0%, var(--color-bg-end) 100%);
}

.bily-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.55), transparent 22%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.45), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  mix-blend-mode: soft-light;
  z-index: 0;
}

.love-scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: var(--love-scene-opacity, 0.2);
  z-index: 0;
}

main {
  max-width: 640px;
  margin: 0 auto;
}

.bily-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.bily-layout-left,
.bily-layout-right {
  width: 100%;
}

.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-panel-border);
  background: var(--color-panel-bg);
  box-shadow: var(--shadow-xs);
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-brand);
}

.hero-title {
  margin: 0;
  font-family: "Playfair Display", "Manrope", serif;
  font-size: clamp(2.2rem, 5.6vw, 3.05rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  color: var(--color-title);
}

[data-theme="dark"] .memorial-frame {
  background: #0f0f12;
  border-color: rgba(236, 72, 153, 0.2);
  box-shadow: 0 12px 26px rgba(8, 6, 5, 0.55);
}

@media (max-width: 520px) {
  .hero-top {
    flex-direction: column;
    gap: 10px;
  }

  .hero-text {
    text-align: center;
  }
}

.hero-sub {
  margin: 4px 0 0;
  font-family: "Dancing Script", "Manrope", sans-serif;
  font-size: clamp(1.18rem, 3.2vw, 1.32rem);
  font-weight: 700;
  letter-spacing: 0;
  color: rgba(107, 91, 84, 0.85);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
}

.hero-text {
  text-align: center;
}

.memorial-frame {
  width: min(74px, 20vw);
  margin: 0;
  padding: 1px;
  border-radius: 10px;
  background: #fffaf5;
  border: 1px solid rgba(233, 210, 197, 0.65);
  box-shadow: 0 6px 14px rgba(86, 54, 36, 0.14);
}

.memorial-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.about-memorial {
  display: flex;
  justify-content: flex-start;
}

#aboutDialog .memorial-frame {
  width: min(180px, 60vw);
  padding: 6px;
  border-radius: 14px;
}

#aboutDialog .memorial-image {
  border-radius: 10px;
}

.hero-divider {
  height: 1px;
  margin: 8px auto 0;
  width: 100%;
  max-width: 260px;
  background: linear-gradient(90deg, transparent, rgba(236, 72, 153, 0.38), transparent);
}

.usage-steps {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-tertiary);
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-label);
}

.helper-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-helper);
  transition: opacity 300ms ease, transform 300ms ease;
}

.helper-text.is-hidden {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  height: 0;
  margin: 0;
  overflow: hidden;
}

.helper-nudge {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-align: center;
}

.helper-nudge.is-hidden {
  display: none;
}

.share-format-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-pill-bg);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.share-format-option:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-xs);
}

.share-format-option input {
  margin: 0;
}

.share-format-option:has(input:checked) {
  border-color: var(--color-brand);
  color: var(--color-text);
  background: var(--color-surface-soft);
  box-shadow: var(--shadow-xs);
}

.share-greeting-row {
  display: flex;
  gap: 10px;
}

.share-greeting-row input:first-child {
  max-width: 110px;
}

.share-greeting-row input:last-child {
  flex: 1;
}

.share-progress {
  margin-top: 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.share-progress-track {
  width: 100%;
  height: 8px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.share-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-brand), var(--color-brand-dark));
  transition: width 120ms ease;
}

#shareDialog .share-progress-label {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-align: center;
  letter-spacing: 0.02em;
  width: 100%;
}
.relationship-selector {
  display: flex;
  gap: 8px;
}

.relationship-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-pill-bg);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.relationship-pill:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-xs);
}

.relationship-pill.is-active {
  background: var(--color-active-bg);
  color: var(--color-active-text);
  border-color: var(--color-active-bg);
}

.relationship-pill .pill-emoji {
  font-size: 14px;
  opacity: 0.72;
}

.relationship-pill:hover .pill-emoji,
.relationship-pill.is-active .pill-emoji {
  opacity: 1;
}

.dice-set-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dice-set-tile {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-pill-bg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dice-set-tile:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-xs);
}

.dice-set-tile.is-active {
  border-width: 1px;
  border-color: var(--color-brand);
  background: var(--color-active-bg);
  color: var(--color-active-text);
  box-shadow: var(--shadow-xs);
}

.dice-set-tile.is-active::after {
  display: none;
}

.dice-set-pill-emoji {
  font-size: 14px;
  opacity: 0.8;
}

.dice-set-tile.is-active .dice-set-pill-emoji,
.dice-set-tile:hover .dice-set-pill-emoji {
  opacity: 1;
}

.dice-set-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.1;
  min-height: 0;
  white-space: nowrap;
}

.dice-set-tile.is-active .dice-set-title {
  color: var(--color-active-text);
}

.dice-panel {
  min-height: 0;
  padding-top: 12px;
  position: relative;
  border: 1px solid rgba(236, 72, 153, 0.22);
  background:
    radial-gradient(circle at 12% 20%, rgba(236, 72, 153, 0.16), transparent 28%),
    radial-gradient(circle at 88% 20%, rgba(168, 85, 247, 0.14), transparent 30%),
    radial-gradient(circle at 20% 88%, rgba(59, 130, 246, 0.12), transparent 32%),
    linear-gradient(155deg, #fff1f8 0%, #fceffe 46%, #eaf4ff 100%);
  box-shadow: 0 14px 30px rgba(236, 72, 153, 0.16), 0 6px 16px rgba(15, 23, 42, 0.1);
}

.dice-panel > * {
  position: relative;
  z-index: 1;
}

.roll-stars {
  position: absolute;
  inset: 50px 10px 20px 10px;
  height: 180px;
  pointer-events: none;
  opacity: 0;
  z-index: 0;
}

.float-emoji {
  position: absolute;
  font-size: 22px;
  color: #fbbf24;
  filter: drop-shadow(0 4px 10px rgba(250, 204, 21, 0.5));
  opacity: 0;
  transform: scale(0.6);
}

.float-emoji.e-1 { top: 6%; left: 18%; }
.float-emoji.e-2 { top: 10%; right: 20%; }
.float-emoji.e-3 { bottom: 8%; left: 22%; }
.float-emoji.e-4 { bottom: 12%; right: 18%; }
.float-emoji.e-5 { top: 48%; left: 4%; transform: translate(-10%, -50%) scale(0.6); }
.float-emoji.e-6 { top: 46%; right: 4%; transform: translate(10%, -50%) scale(0.6); }
.float-emoji.e-7 { top: 20%; left: 6%; }
.float-emoji.e-8 { top: 22%; right: 6%; }
.float-emoji.e-9 { bottom: 20%; left: 46%; }

.dice-panel.is-rolling .roll-stars {
  opacity: 1;
}

.dice-panel.is-rolling .float-emoji {
  animation: rollSparkle 1.05s ease-in-out infinite;
}

.dice-panel.is-rolling .float-emoji.e-2 {
  animation-delay: 0.12s;
}

.dice-panel.is-rolling .float-emoji.e-3 {
  animation-delay: 0.24s;
}

.dice-panel.is-rolling .float-emoji.e-4 {
  animation-delay: 0.18s;
}

.dice-panel.is-rolling .float-emoji.e-5 {
  animation-delay: 0.06s;
}

.dice-panel.is-rolling .float-emoji.e-6 {
  animation-delay: 0.2s;
}

.dice-panel.is-rolling .float-emoji.e-7 {
  animation-delay: 0.14s;
}

.dice-panel.is-rolling .float-emoji.e-8 {
  animation-delay: 0.26s;
}

.dice-panel.is-rolling .float-emoji.e-9 {
  animation-delay: 0.08s;
}

@keyframes rollSparkle {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.55);
  }
  40% {
    opacity: 0.9;
    transform: translateY(0) scale(1);
  }
  70% {
    opacity: 0.6;
    transform: translateY(-6px) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(0.7);
  }
}

.result-stars {
  position: absolute;
  inset: 10px 12px 12px 12px;
  height: 80%;
  pointer-events: none;
  opacity: 0.6;
  z-index: 0;
}

.result-card > :not(.result-stars) {
  position: relative;
  z-index: 1;
}

.result-stars .float-emoji {
  opacity: 0.65;
  transform: scale(0.9);
  animation: resultSparkle 3.6s ease-in-out infinite;
}

.result-stars .e-2 {
  animation-delay: 0.4s;
}

.result-stars .e-3 {
  animation-delay: 0.9s;
}

.result-stars .e-4 {
  animation-delay: 0.6s;
}

.result-stars .e-5 {
  animation-delay: 1.2s;
}

.result-stars .e-6 {
  animation-delay: 1.5s;
}

.result-stars .e-7 {
  animation-delay: 0.2s;
}

.result-stars .e-8 {
  animation-delay: 0.8s;
}

.result-stars .e-9 {
  animation-delay: 1.1s;
}

@keyframes resultSparkle {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(2px) scale(0.85);
  }
  50% {
    opacity: 0.85;
    transform: translateY(-4px) scale(1.05);
  }
}

.dice-stage {
  width: 100%;
  max-width: 226px;
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid var(--color-dice-stage-border);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.95), rgba(255, 248, 242, 0.7)),
    linear-gradient(160deg, #fffaf6, #ffeede);
  padding: 8px;
  box-shadow: 0 10px 22px rgba(86, 54, 36, 0.18);
}

#diceCanvas {
  display: block;
  margin: 0 auto;
  cursor: pointer;
  width: 100%;
  max-width: 190px;
  aspect-ratio: 1;
  touch-action: manipulation;
  transition: transform var(--transition-fast);
}

#diceCanvas:hover {
  transform: scale(1.02);
}

#diceCanvas:active {
  transform: scale(0.985);
}

.bily-roll-btn {
  width: 100%;
  max-width: 228px;
  padding: 10px 18px;
  border: 1px solid var(--color-roll-btn-border);
  border-radius: 12px;
  background: var(--color-roll-btn-bg);
  box-shadow: var(--shadow-brand);
  color: var(--color-roll-btn-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
}

.bily-roll-btn:hover {
  transform: translateY(-1px);
  background: var(--color-roll-btn-hover-bg);
  box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.6), 0 14px 24px rgba(236, 72, 153, 0.22);
  filter: saturate(1.05);
}

.bily-roll-btn:active {
  transform: translateY(0);
}

.result-card {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(236, 72, 153, 0.24);
  background:
    radial-gradient(circle at 12% 18%, rgba(236, 72, 153, 0.14), transparent 28%),
    radial-gradient(circle at 86% 22%, rgba(168, 85, 247, 0.12), transparent 30%),
    radial-gradient(circle at 22% 88%, rgba(59, 130, 246, 0.1), transparent 30%),
    linear-gradient(155deg, #fff1f8 0%, #fceffe 46%, #eaf4ff 100%);
  box-shadow: 0 14px 30px rgba(236, 72, 153, 0.16), 0 6px 16px rgba(15, 23, 42, 0.1);
  padding: 18px 16px 14px;
  text-align: center;
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(236, 72, 153, 0.28);
  border-radius: 10px;
  pointer-events: none;
}


.result-eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #7c8aa0;
}

.result-heading {
  margin: 8px 0 0;
  font-family: "Playfair Display", "Manrope", serif;
  font-size: clamp(1.02rem, 3.2vw, 1.22rem);
  font-weight: 600;
  color: #5b667a;
}

.result-dice-stage {
  margin: 10px auto;
  width: min(56vw, 152px);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(236, 72, 153, 0.2);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 255, 0.96));
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

#resultDiceCanvas {
  display: block;
  width: min(50vw, 136px);
  height: min(50vw, 136px);
  margin: 0 auto;
}

.result-outcome {
  margin: 10px auto 0;
  max-width: 92%;
  font-family: "Playfair Display", "Manrope", serif;
  font-size: clamp(1.4rem, 4.8vw, 1.95rem);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.result-subheading {
  margin-top: 9px;
  font-size: clamp(0.88rem, 2.8vw, 0.98rem);
  font-weight: 500;
  color: #475569;
}

.result-timestamp {
  margin-top: 12px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8da0bc;
}

.result-actions {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats-panel {
  text-align: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 20%, rgba(236, 72, 153, 0.12), transparent 38%),
    radial-gradient(circle at 88% 24%, rgba(59, 130, 246, 0.1), transparent 40%),
    linear-gradient(155deg, rgba(255, 248, 242, 0.96), rgba(247, 249, 255, 0.96));
}

.stats-title {
  display: block;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.stats-pill-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  align-items: stretch;
}

@media (min-width: 640px) {
  .stats-pill-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stats-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 16px;
  border: 1px solid rgba(236, 72, 153, 0.28);
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255, 236, 247, 0.95), rgba(234, 242, 255, 0.95));
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.stats-pill-icon {
  width: 44px;
  height: 44px;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-size: 22px;
}

.stats-pill-meta {
  text-align: left;
}

.stats-pill-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-label);
}

.stats-pill-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 2px;
}

.stats-copy {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.btn-share,
.btn-secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-share {
  border: 1px solid var(--color-share-border);
  background: var(--color-share-bg);
  color: var(--color-brand-dark);
}

.btn-share:hover {
  border-color: var(--color-brand);
  background: var(--color-share-bg-hover);
}

.btn-secondary {
  border: 1px solid var(--color-border-strong);
  background: var(--color-secondary-btn-bg);
  color: var(--color-secondary-btn-text);
}

.btn-secondary:hover {
  border-color: var(--color-brand);
  color: var(--color-brand-dark);
  background: var(--color-brand-soft);
}

.btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.btn-text:hover {
  background: var(--color-surface-soft);
  color: var(--color-text);
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.footer-link {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--color-brand);
}

.footer-link:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Keep share modal light even when device/browser is dark mode */
#shareDialog {
  color-scheme: light;
}

#shareDialog .modal-box {
  background: #ffffff;
  color: #0f172a;
  border-color: var(--color-border);
}

#shareDialog .modal-backdrop {
  background: rgba(15, 23, 42, 0.42);
}

#shareDialog .input,
#shareDialog .select {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

#shareDialog .input::placeholder {
  color: #94a3b8;
}

#shareDialog .input:focus,
#shareDialog .select:focus {
  outline: 2px solid rgba(236, 72, 153, 0.28);
  outline-offset: 0;
  border-color: #ec4899;
}

.is-ios #shareFormatBlock {
  display: none !important;
}

.film-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.film-strip::-webkit-scrollbar {
  height: 5px;
}

.film-strip::-webkit-scrollbar-track {
  background: var(--color-scroll-track);
  border-radius: 999px;
}

.film-strip::-webkit-scrollbar-thumb {
  background: var(--color-scroll-thumb);
  border-radius: 999px;
}

.film-tile {
  min-width: 146px;
  max-width: 164px;
  flex-shrink: 0;
  padding: 9px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-film-bg);
  scroll-snap-align: start;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.film-tile:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}

.film-tile-label {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}

.history-dice-canvas {
  width: 64px;
  height: 64px;
  display: block;
  margin: 5px auto;
}

.film-tile-heading {
  margin: 0;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--color-text-secondary);
}

.film-tile-outcome {
  margin: 3px 0 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

.film-tile-subheading {
  margin: 2px 0 0;
  font-size: 9px;
  color: var(--color-text-tertiary);
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.975);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes press {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.97);
  }
}

.animate-scale-in {
  animation: scale-in 220ms ease-out;
}

.animate-press {
  animation: press 150ms ease-out;
}

@media (max-width: 460px) {
  .relationship-pill {
    font-size: 13px;
  }

  .dice-set-title {
    font-size: 13px;
  }

  .result-actions-row {
    grid-template-columns: 1fr;
  }
}

.relationship-pill:focus-visible,
.dice-set-tile:focus-visible,
.bily-roll-btn:focus-visible,
.btn-share:focus-visible,
.btn-secondary:focus-visible,
.btn-text:focus-visible,
.film-tile:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}
