/* ============================================================
   Inspiration Dice — style.css
   Playful & Colorful Theme
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  --grad:        linear-gradient(135deg, #6B4DE6 0%, #D855D0 45%, #FF8C42 100%);
  --grad-card:   linear-gradient(135deg, #6B4DE6, #E96BC9);

  --purple:      #6B4DE6;
  --pink:        #E96BC9;
  --orange:      #FF8C42;
  --yellow:      #FFD93D;
  --green:       #6BCB77;
  --blue:        #4D96FF;
  --coral:       #FF6B9D;
  --dark:        #1a0a2e;

  --die-colors:  #FF6B9D, #4D96FF, #6BCB77;   /* used individually in JS */

  --font-display: 'Fredoka One', cursive;
  --font-body:    'Nunito', sans-serif;

  --radius:      20px;
  --radius-sm:   12px;
  --radius-pill: 999px;

  --shadow-card: 0 8px 32px rgba(0,0,0,.13);
  --shadow-lift: 0 16px 48px rgba(0,0,0,.2);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--grad);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--dark);
  overflow-x: hidden;
}


/* ══════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════ */
.site-header {
  text-align: center;
  padding: 60px 20px 44px;
}

.header-logo {
  font-size: 80px;
  display: block;
  margin-bottom: 14px;
  animation: float 3.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.25));
}

.site-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4rem);
  color: #fff;
  text-shadow: 0 4px 20px rgba(0,0,0,.2);
  letter-spacing: 1px;
}

.header-tagline {
  margin-top: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: rgba(255,255,255,.85);
}


/* ══════════════════════════════════════════════════════════════
   SHARED SECTION WRAPPER
══════════════════════════════════════════════════════════════ */
.section {
  max-width: 1060px;
  margin: 0 auto 44px;
  padding: 0 20px;
}

.section-heading {
  font-family: var(--font-display);
  font-size: 2rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,.18);
  margin-bottom: 6px;
  text-align: center;
}

.section-subheading {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,.82);
  margin-bottom: 28px;
}


/* ══════════════════════════════════════════════════════════════
   API SETTINGS
══════════════════════════════════════════════════════════════ */
.api-details {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--radius);
  overflow: hidden;
}

.api-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: #fff;
  font-size: .95rem;
  user-select: none;
  transition: background .2s;
}

.api-details summary::-webkit-details-marker { display: none; }
.api-details summary:hover { background: rgba(255,255,255,.08); }

.summary-chevron {
  font-size: 1.3rem;
  font-weight: 400;
  transition: transform .25s;
  line-height: 1;
}
.api-details[open] .summary-chevron { transform: rotate(90deg); }

.api-body {
  padding: 18px 22px 20px;
  background: rgba(255,255,255,.08);
}

.api-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.api-row label {
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  font-size: .9rem;
}

.api-input-group {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.api-input-group input {
  flex: 1;
  min-width: 0;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 2px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.18);
  color: #fff;
  font-family: var(--font-body);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s, background .2s;
}
.api-input-group input::placeholder { color: rgba(255,255,255,.55); }
.api-input-group input:focus {
  border-color: #fff;
  background: rgba(255,255,255,.28);
}

.btn-save {
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  border: none;
  background: #fff;
  color: var(--purple);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s, box-shadow .15s;
}
.btn-save:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(0,0,0,.2); }

.api-hint {
  font-size: .8rem;
  color: rgba(255,255,255,.72);
}
.api-hint a { color: var(--yellow); text-decoration: underline; }


/* ══════════════════════════════════════════════════════════════
   DICE SETUP
══════════════════════════════════════════════════════════════ */
.dice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
  gap: 20px;
}

/* Individual die card */
.die-card {
  background: rgba(255,255,255,.94);
  border-radius: var(--radius);
  padding: 22px 20px 20px;
  box-shadow: var(--shadow-card);
  border-top: 5px solid var(--die-color, #FF6B9D);
  transition: transform .2s, box-shadow .2s;
}
.die-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
}

.die-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.die-icon { font-size: 1.55rem; flex-shrink: 0; }

.die-name-input {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--dark);
  border: none;
  background: transparent;
  outline: none;
  border-bottom: 2px dashed transparent;
  padding: 2px 4px;
  flex: 1;
  min-width: 0;
  transition: border-color .2s;
  cursor: text;
}
.die-name-input:hover,
.die-name-input:focus { border-bottom-color: var(--die-color, #FF6B9D); }

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 38px;
  margin-bottom: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 11px 4px 13px;
  border-radius: var(--radius-pill);
  font-size: .82rem;
  font-weight: 800;
  border: 2px solid var(--die-color, #FF6B9D);
  color: var(--die-color, #FF6B9D);
  background: var(--die-bg, rgba(255,107,157,.1));
  transition: transform .15s, background .15s, color .15s;
}

.tag.highlighted {
  background: var(--die-color, #FF6B9D) !important;
  color: #fff;
  transform: scale(1.03);
}

.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: inherit;
  opacity: .55;
  padding: 0;
  transition: opacity .15s;
  font-weight: 400;
}
.tag-remove:hover { opacity: 1; }

.empty-hint {
  font-size: .8rem;
  color: #bbb;
  font-style: italic;
  align-self: center;
}

.add-tag {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--die-color, #FF6B9D);
}

.add-tag input {
  flex: 1;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 2px solid #e0e0e0;
  font-family: var(--font-body);
  font-size: .85rem;
  color: var(--dark);
  outline: none;
  transition: border-color .2s;
}
.add-tag input:focus { border-color: var(--die-color, #FF6B9D); }

.add-tag button {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--die-color, #FF6B9D);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s, box-shadow .15s;
}
.add-tag button:hover { transform: scale(1.06); box-shadow: 0 4px 12px rgba(0,0,0,.15); }


/* ══════════════════════════════════════════════════════════════
   ROLL SECTION
══════════════════════════════════════════════════════════════ */
.roll-section { text-align: center; }

/* Dice visuals row */
.dice-visuals {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.dice-visual-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dice-face {
  width: 108px;
  height: 108px;
  background: rgba(255,255,255,.95);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 800;
  color: var(--dark);
  text-align: center;
  padding: 10px;
  word-break: break-word;
  line-height: 1.2;
  border: 3px solid var(--die-color, #FF6B9D);
  box-shadow: 0 8px 24px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.9);
  position: relative;
  overflow: hidden;
  transition: transform .1s;
}

/* gloss shine */
.dice-face::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 19px;
  background: linear-gradient(160deg, rgba(255,255,255,.45) 0%, transparent 55%);
  pointer-events: none;
}

.dice-face.spinning {
  animation: diceShake .12s ease-in-out infinite alternate;
}

.dice-placeholder {
  font-size: 2rem;
  opacity: .3;
}

.dice-visual-label {
  font-size: .75rem;
  font-weight: 800;
  color: rgba(255,255,255,.8);
  text-transform: uppercase;
  letter-spacing: .6px;
}

/* Roll button */
.roll-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 52px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--purple);
  background: #fff;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0,0,0,.22), 0 2px 0 rgba(0,0,0,.1);
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
  letter-spacing: .3px;
}
.roll-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,.3), transparent);
  pointer-events: none;
}
.roll-btn:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
}
.roll-btn:active:not(:disabled) {
  transform: translateY(1px) scale(.98);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.roll-btn:disabled { opacity: .65; cursor: not-allowed; }

.roll-icon { display: inline-block; font-size: 1.4rem; }
.roll-btn.rolling .roll-icon { animation: spinFast .18s linear infinite; }

/* Re-roll button variant */
.reroll-btn {
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 2px solid rgba(255,255,255,.5);
  font-size: 1.15rem;
  padding: 14px 40px;
}
.reroll-btn:hover:not(:disabled) { background: rgba(255,255,255,.3); }

.reroll-row { text-align: center; margin-top: 40px; }

/* Rolled results row */
.rolled-results {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
  flex-wrap: wrap;
  animation: fadeInUp .5s ease;
}

.result-badge {
  padding: 7px 20px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-weight: 800;
  font-size: .95rem;
}

.result-connector {
  color: rgba(255,255,255,.65);
  font-size: 1.3rem;
  font-weight: 700;
}


/* ══════════════════════════════════════════════════════════════
   FORTUNE BAGS
══════════════════════════════════════════════════════════════ */
.fortune-section { animation: fadeInUp .6s ease; }

.bags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

/* Each bag uses CSS 3-D card flip */
.fortune-bag {
  height: 290px;
  cursor: pointer;
  perspective: 1100px;
}

.fortune-bag.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

.fortune-bag.disabled .bag-hint {
  color: #999;
}

.bag-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.23, 1, .32, 1);
  border-radius: var(--radius);
}

.fortune-bag.opened .bag-inner { transform: rotateY(180deg); }

.bag-front,
.bag-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
}

/* Front face */
.bag-front {
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow-card);
}

/* Float animation — staggered per bag */
.fortune-bag:nth-child(1) .bag-front { animation: float 3.2s ease-in-out infinite 0s; }
.fortune-bag:nth-child(2) .bag-front { animation: float 3.2s ease-in-out infinite -1.1s; }
.fortune-bag:nth-child(3) .bag-front { animation: float 3.2s ease-in-out infinite -2.2s; }
.fortune-bag.opened .bag-front { animation: none; }

.bag-num-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-weight: 800;
  font-size: .88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.bag-emoji {
  font-size: 68px;
  display: block;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.14));
  transition: transform .25s;
}
.fortune-bag:hover:not(.opened) .bag-emoji { transform: scale(1.1) rotate(-6deg); }

.bag-label {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--dark);
  margin-bottom: 5px;
}

.bag-hint {
  font-size: .78rem;
  font-weight: 700;
  color: #aaa;
}

/* Back face */
.bag-back {
  background: var(--grad-card);
  transform: rotateY(180deg);
  color: #fff;
  align-items: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(107,77,230,.45);
  padding: 26px 22px;
  gap: 0;
}

.idea-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--yellow);
  line-height: 1.3;
  margin-bottom: 10px;
}

.idea-body {
  font-size: .88rem;
  line-height: 1.7;
  color: rgba(255,255,255,.93);
  font-weight: 600;
}

/* Loading dots */
.loading-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
  animation: bounce 1.15s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }

.error-msg {
  font-size: .85rem;
  color: #ffcdd2;
  font-weight: 700;
  line-height: 1.5;
}


/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--dark);
  color: #fff;
  padding: 11px 24px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: .9rem;
  opacity: 0;
  transition: opacity .28s, transform .28s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ══════════════════════════════════════════════════════════════
   CONFETTI
══════════════════════════════════════════════════════════════ */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}
.confetti-particle {
  position: fixed;
  top: -20px;
  animation: confettiFall 2s linear forwards;
}


/* ══════════════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════════════ */
.site-footer {
  text-align: center;
  padding: 40px 20px 50px;
  color: rgba(255,255,255,.65);
  font-size: .88rem;
  font-weight: 600;
}
.site-footer strong { color: rgba(255,255,255,.9); }


/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════════ */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-9px); }
}

@keyframes diceShake {
  0%   { transform: rotate(-6deg) scale(.94); }
  100% { transform: rotate(6deg)  scale(1.06); }
}

@keyframes spinFast {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0);    opacity: .5; }
  50%       { transform: translateY(-9px); opacity: 1; }
}

@keyframes confettiFall {
  0%   { top: -20px; transform: rotate(0deg) scaleX(1); opacity: 1; }
  100% { top: 100vh; transform: rotate(720deg) scaleX(-1); opacity: 0; }
}

@keyframes confettiRise {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-400px) scale(0.3); opacity: 0; }
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .site-header { padding: 40px 16px 32px; }
  .header-logo { font-size: 60px; }

  .dice-face { width: 86px; height: 86px; font-size: .8rem; }

  .roll-btn { padding: 15px 36px; font-size: 1.15rem; }

  .fortune-bag { height: 270px; }
  .bag-emoji   { font-size: 54px; }
}

/* 3D Dice Animation */
.dice-cube {
  width: 100px;
  height: 100px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(-30deg);
  transition: transform 0.5s ease-out;
}

.dice-cube.spinning {
  animation: diceSpin 0.8s ease-in-out infinite;
}

.dice-cube-face {
  position: absolute;
  width: 100px;
  height: 100px;
  background: linear-gradient(145deg, #fff 0%, #f0f0f0 100%);
  border: 2px solid var(--die-color, #FF6B9D);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--die-color, #FF6B9D);
  text-align: center;
  padding: 8px;
  word-break: break-word;
  box-shadow: inset 0 0 20px rgba(255,255,255,0.8), 0 4px 12px rgba(0,0,0,0.15);
}

.dice-cube-face.front  { transform: translateZ(50px); }
.dice-cube-face.back   { transform: rotateY(180deg) translateZ(50px); }
.dice-cube-face.right  { transform: rotateY(90deg) translateZ(50px); }
.dice-cube-face.left   { transform: rotateY(-90deg) translateZ(50px); }
.dice-cube-face.top    { transform: rotateX(90deg) translateZ(50px); }
.dice-cube-face.bottom { transform: rotateX(-90deg) translateZ(50px); }

@keyframes diceSpin {
  0% { transform: rotateX(-20deg) rotateY(-30deg) rotateZ(0deg); }
  25% { transform: rotateX(160deg) rotateY(90deg) rotateZ(90deg); }
  50% { transform: rotateX(-160deg) rotateY(-90deg) rotateZ(180deg); }
  75% { transform: rotateX(20deg) rotateY(170deg) rotateZ(270deg); }
  100% { transform: rotateX(-20deg) rotateY(-30deg) rotateZ(360deg); }
}

/* Mobile adjust */
@media (max-width: 480px) {
  .dice-cube, .dice-cube-face {
    width: 70px;
    height: 70px;
  }
  .dice-cube-face { transform: translateZ(35px); }
  .dice-cube-face.front  { transform: translateZ(35px); }
  .dice-cube-face.back   { transform: rotateY(180deg) translateZ(35px); }
  .dice-cube-face.right  { transform: rotateY(90deg) translateZ(35px); }
  .dice-cube-face.left   { transform: rotateY(-90deg) translateZ(35px); }
  .dice-cube-face.top    { transform: rotateX(90deg) translateZ(35px); }
  .dice-cube-face.bottom { transform: rotateX(-90deg) translateZ(35px); }
}

/* 3D Realistic Dice */
.dice-cube {
  width: 90px;
  height: 90px;
  position: relative;
  transform-style: preserve-3d;
  perspective: 600px;
}

.dice-cube-face {
  position: absolute;
  width: 90px;
  height: 90px;
  background: linear-gradient(145deg, #ffffff 0%, #e8e8e8 50%, #d0d0d0 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--die-color, #FF6B9D);
  text-align: center;
  padding: 8px;
  word-break: break-word;
  box-shadow: 
    0 4px 8px rgba(0,0,0,0.15),
    inset 0 2px 4px rgba(255,255,255,0.9),
    inset 0 -2px 4px rgba(0,0,0,0.05);
  backface-visibility: hidden;
  transition: transform 0.5s ease-out;
}

.dice-cube-face.front {
  transform: translateZ(45px);
}
.dice-cube-face.back {
  transform: rotateY(180deg) translateZ(45px);
}
.dice-cube-face.right {
  transform: rotateY(90deg) translateZ(45px);
}
.dice-cube-face.left {
  transform: rotateY(-90deg) translateZ(45px);
}
.dice-cube-face.top {
  transform: rotateX(90deg) translateZ(45px);
}
.dice-cube-face.bottom {
  transform: rotateX(-90deg) translateZ(45px);
}

/* Glossy overlay */
.dice-cube-face::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 8px;
  right: 40%;
  height: 30%;
  background: linear-gradient(160deg, rgba(255,255,255,0.7) 0%, transparent 100%);
  border-radius: 10px 10px 40% 40%;
  pointer-events: none;
}

.dice-cube.spinning {
  animation: diceFloat 1.5s ease-in-out infinite;
}

@keyframes diceFloat {
  0% { transform: rotateX(-15deg) rotateY(25deg) translateY(0); }
  50% { transform: rotateX(15deg) rotateY(-25deg) translateY(-15px); }
  100% { transform: rotateX(-15deg) rotateY(25deg) translateY(0); }
}

/* Mobile */
@media (max-width: 480px) {
  .dice-cube, .dice-cube-face {
    width: 65px;
    height: 65px;
    border-radius: 10px;
  }
  .dice-cube-face { transform: translateZ(32px); }
  .dice-cube-face.front { transform: translateZ(32px); }
  .dice-cube-face.back { transform: rotateY(180deg) translateZ(32px); }
  .dice-cube-face.right { transform: rotateY(90deg) translateZ(32px); }
  .dice-cube-face.left { transform: rotateY(-90deg) translateZ(32px); }
  .dice-cube-face.top { transform: rotateX(90deg) translateZ(32px); }
  .dice-cube-face.bottom { transform: rotateX(-90deg) translateZ(32px); }
}

/* Emoji Dice */
.dice-emoji {
  font-size: 80px;
  display: inline-block;
  animation: diceFloat 3.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.25));
  transition: transform 0.3s ease;
  cursor: default;
}

.dice-emoji.spinning {
  animation: diceSpin 0.15s ease-in-out infinite;
}

@keyframes diceFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
}

@keyframes diceSpin {
  0% { transform: rotate(-15deg) scale(1.1); }
  50% { transform: rotate(15deg) scale(1.1); }
  100% { transform: rotate(-15deg) scale(1.1); }
}

/* Mobile */
@media (max-width: 480px) {
  .dice-emoji { font-size: 60px; }
}

.dice-word {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--die-color, #FF6B9D);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

.dice-word.show {
  opacity: 1;
}

/* 3D Dice with Word */
.dice-cube {
  width: 90px;
  height: 90px;
  position: relative;
  transform-style: preserve-3d;
  perspective: 600px;
}

.dice-cube-face {
  position: absolute;
  width: 90px;
  height: 90px;
  background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--die-color, #FF6B9D);
  text-align: center;
  padding: 6px;
  word-break: break-word;
  line-height: 1.2;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.9);
}

.dice-cube-face.front { transform: translateZ(45px); }
.dice-cube-face.back { transform: rotateY(180deg) translateZ(45px); }
.dice-cube-face.right { transform: rotateY(90deg) translateZ(45px); }
.dice-cube-face.left { transform: rotateY(-90deg) translateZ(45px); }
.dice-cube-face.top { transform: rotateX(90deg) translateZ(45px); }
.dice-cube-face.bottom { transform: rotateX(-90deg) translateZ(45px); }

.dice-cube.spinning {
  animation: diceSpin 0.8s ease-in-out infinite;
}

@keyframes diceSpin {
  0% { transform: rotateX(0) rotateY(0) rotateZ(0); }
  25% { transform: rotateX(90deg) rotateY(180deg) rotateZ(45deg); }
  50% { transform: rotateX(180deg) rotateY(270deg) rotateZ(90deg); }
  75% { transform: rotateX(270deg) rotateY(360deg) rotateZ(135deg); }
  100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(180deg); }
}

@media (max-width: 480px) {
  .dice-cube, .dice-cube-face {
    width: 65px;
    height: 65px;
    font-size: 0.5rem;
  }
  .dice-cube-face { transform: translateZ(32px); }
  .dice-cube-face.front { transform: translateZ(32px); }
  .dice-cube-face.back { transform: rotateY(180deg) translateZ(32px); }
  .dice-cube-face.right { transform: rotateY(90deg) translateZ(32px); }
  .dice-cube-face.left { transform: rotateY(-90deg) translateZ(32px); }
  .dice-cube-face.top { transform: rotateX(90deg) translateZ(32px); }
  .dice-cube-face.bottom { transform: rotateX(-90deg) translateZ(32px); }
}

/* Emoji Dice with Word */
.dice-face {
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,.95);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--die-color, #FF6B9D);
  box-shadow: 0 8px 24px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.9);
  position: relative;
  overflow: hidden;
  transition: transform .1s;
  flex-direction: column;
  gap: 4px;
}

.dice-emoji {
  font-size: 48px;
  display: block;
  animation: diceFloat 3.2s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.dice-word {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--die-color, #FF6B9D);
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

.dice-word.show {
  opacity: 1;
}

@keyframes diceFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.dice-face.spinning .dice-emoji {
  animation: diceShake 0.1s ease-in-out infinite;
}

@keyframes diceShake {
  0% { transform: rotate(-10deg) scale(1.1); }
  50% { transform: rotate(10deg) scale(1.1); }
  100% { transform: rotate(-10deg) scale(1.1); }
}

@media (max-width: 480px) {
  .dice-face { width: 75px; height: 75px; }
  .dice-emoji { font-size: 36px; }
  .dice-word { font-size: 0.55rem; padding: 2px 8px; }
}

/* Login UI */
.login-section {
  position: absolute;
  top: 20px;
  right: 20px;
}

.user-section {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.9);
  padding: 8px 16px;
  border-radius: 30px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  height: 44px;
  box-sizing: border-box;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.signout-btn {
  background: #ff6b9d;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
}

.signout-btn:hover {
  background: #e85a8a;
}

/* Hide content when not logged in */
.content-wrapper.logged-out .dice-setup-section,
.content-wrapper.logged-out .roll-section,
.content-wrapper.logged-out .fortune-section {
  display: none;
}

.login-required-msg {
  text-align: center;
  padding: 40px;
  color: white;
  font-size: 1.2rem;
}

/* 3D CSS Cube - 和 inspiration2 一样 */
.dice-visuals { display: flex; justify-content: center; gap: 60px; margin-bottom: 40px; flex-wrap: wrap; }
.dice-visual-item { display: flex; flex-direction: column; align-items: center; gap: 0; }
.cube-scene { width: 90px; height: 90px; perspective: 550px; perspective-origin: 50% 50%; }
.dice-visual-label { display: none; }
.cube { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transform: rotateX(-18deg) rotateY(24deg); transition: transform .15s ease; }
.cube.landing { transition: transform .9s cubic-bezier(.15, 1.2, .35, 1); }
.cube.tumbling { transition: transform .07s linear; }
.cube-face { position: absolute; width: 90px; height: 90px; display: flex; align-items: center; justify-content: center; border-radius: 16px; backface-visibility: visible; background: linear-gradient(145deg, #f3e8ff 0%, #ede9fe 55%, #e9d5ff 100%); border: none; box-shadow: 5px 5px 12px rgba(168, 85, 247, .08), -3px -3px 10px rgba(255, 255, 255, .8), inset 0 2px 5px rgba(168, 85, 247, .08), inset 0 -2px 3px rgba(255, 248, 255, .9), inset 2px 0 4px rgba(168, 85, 247, .05), inset -2px 0 4px rgba(168, 85, 247, .05); font-family: 'Nunito', sans-serif; font-size: .72rem; font-weight: 900; color: #7c3aed; text-align: center; padding: 8px; line-height: 1.15; word-break: break-word; overflow: hidden; text-transform: uppercase; letter-spacing: .8px; text-shadow: 0 1px 0 rgba(255, 255, 255, .95), 0 -1px 1px rgba(168, 85, 247, .18), 1px 0 1px rgba(168, 85, 247, .06), -1px 0 1px rgba(168, 85, 247, .06); }
.cube-face::before { content: ''; position: absolute; inset: 0; border-radius: 16px; background: linear-gradient(155deg, rgba(255,255,255,.32) 0%, transparent 40%); pointer-events: none; }
.cube-face::after { content: ''; position: absolute; width: 60px; height: 60px; border-radius: 50%; border: 1px dashed rgba(168, 85, 247, .15); pointer-events: none; }
.cube-face.face-front { transform: rotateY(0deg) translateZ(45px); }
.cube-face.face-back { transform: rotateY(180deg) translateZ(45px); }
.cube-face.face-right { transform: rotateY(90deg) translateZ(45px); }
.cube-face.face-left { transform: rotateY(-90deg) translateZ(45px); }
.cube-face.face-top { transform: rotateX(90deg) translateZ(45px); }
.cube-face.face-bottom { transform: rotateX(-90deg) translateZ(45px); }
.cube-face .dice-placeholder { font-size: 1.8rem; opacity: .22; color: var(--dark); text-shadow: none; text-transform: none; }

/* ── Pricing Modal ── */
.remaining-rolls {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0 10px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.remaining-rolls:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.pricing-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.pricing-modal-content {
  background: white;
  border-radius: 24px;
  padding: 40px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.pricing-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  color: #999;
  cursor: pointer;
}

.pricing-close:hover {
  color: #333;
}

.pricing-modal-content h2 {
  font-size: 1.8rem;
  color: #333;
  margin-bottom: 8px;
}

.pricing-subtitle {
  color: #666;
  margin-bottom: 30px;
}

.pricing-options {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.pricing-card {
  border: 2px solid #eee;
  border-radius: 16px;
  padding: 25px;
  width: 180px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pricing-card.selected {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
  transform: scale(1.02);
}

.pricing-card.featured {
  position: relative;
}

.pricing-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

.pricing-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.pricing-card h3 {
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 8px;
}

.pricing-price {
  font-size: 1.8rem;
  font-weight: 800;
  color: #667eea;
  margin-bottom: 5px;
}

.pricing-desc {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 15px;
}

.pricing-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.pricing-btn:hover {
  transform: scale(1.05);
}

.pricing-note {
  margin-top: 20px;
  color: #999;
  font-size: 0.85rem;
}


/* ── Separate Rolls Container (left of user section) ── */
.rolls-container {
  position: absolute;
  top: 20px;
  right: 210px;
  z-index: 100;
  display: flex;
  align-items: center;
  height: 44px;
}

.rolls-container .remaining-rolls {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 6px 14px;
  border-radius: 25px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  height: 44px;
  line-height: 32px;
  display: inline-flex;
  align-items: center;
}
.rolls-container .remaining-rolls:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}
