/* jiaobei/style.css */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600&family=IM+Fell+English:ital@0;1&display=swap');

:root {
  --ink:        #110b04;
  --parchment:  #fdf3dc;
  --ember:      #b85a22;
  --gold:       #d4a040;
  --gold-light: #eac878;
  --yes-clr:    #6db86d;
  --no-clr:     #c07070;
  --ask-clr:    #d4a040;
  --ff-display: 'IM Fell English', Georgia, serif;
  --ff-hanzi:   'Noto Serif SC', 'SimSun', serif;
  --ff-body:    'Noto Serif SC', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  min-height: 100dvh;
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -5%, #4a2a0a 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 15% 90%, #3e1808 0%, transparent 55%);
  color: var(--parchment);
  font-family: var(--ff-body);
  font-weight: 400;
  overflow-x: hidden;
  position: relative;
}

/* Texture Overlays */
body::before {
  content: '';
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}
body::after {
  content: '';
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 19;
  background: radial-gradient(ellipse 90% 90% at 50% 50%, transparent 40%, rgba(0,0,0,0.3) 100%);
}

canvas#particleCanvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

/* ── Back nav ── */
.back-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: 0.75rem 1.2rem;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(17,11,4,0.72);
  border: 1px solid rgba(212,160,64,0.22);
  border-radius: 999px;
  padding: 0.38rem 0.9rem 0.38rem 0.6rem;
  color: var(--gold-light);
  font-family: var(--ff-display);
  font-style: italic;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:hover { background: rgba(30,18,6,0.88); border-color: rgba(212,160,64,0.42); }
.back-arrow { font-size: 1.1rem; line-height: 1; color: var(--gold); }

.app {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  padding: 4.5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
}

/* Header */
.header { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.hanzi {
  font-family: var(--ff-hanzi);
  font-size: clamp(2.8rem, 11vw, 3.6rem);
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 20px rgba(201,148,58,0.5);
}
h1 {
  font-family: var(--ff-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 5.5vw, 2rem);
  letter-spacing: 0.05em;
  color: var(--parchment);
  line-height: 1;
}
.subtitle {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-light);
  opacity: 0.9;
  margin-top: 0.1rem;
}

.instruction {
  font-family: var(--ff-display);
  font-style: italic;
  font-size: clamp(0.95rem, 3.8vw, 1.05rem);
  color: var(--parchment);
  opacity: 0.85;
  text-align: center;
  line-height: 1.7;
  transition: opacity 0.8s ease;
}
.instruction.faded { opacity: 0.6; }

/* The Stage & Blocks */
.stage {
  display: flex;
  gap: clamp(1.5rem, 6vw, 3rem);
  justify-content: center;
  align-items: flex-end;
  padding: 0.5rem 0;
  flex: 0 0 auto;
}

.block-slot {
  width: clamp(110px, 30vw, 140px);
  height: clamp(170px, 45vw, 210px);
  position: relative;
}
.block-slot svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}

/* Animations */
@keyframes gentle-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-6px); }
}
@keyframes tumble-in {
  0%   { transform: translateY(-90px) rotate(var(--rot, -20deg)) scale(0.85); opacity: 0; }
  50%  { transform: translateY(10px) rotate(calc(var(--rot, -20deg) * -0.25)) scale(1.02); opacity: 1; }
  70%  { transform: translateY(-5px) rotate(3deg) scale(1); }
  85%  { transform: translateY(3px) rotate(-1.5deg); }
  100% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
}

.block-slot.resting svg { animation: gentle-float 4s ease-in-out infinite; }
.block-slot.resting:nth-child(2) svg { animation-delay: -2s; }
.block-slot.casting svg { animation: tumble-in 0.72s cubic-bezier(0.22, 1, 0.36, 1) both; --rot: -22deg; }
.block-slot.casting:nth-child(2) svg { animation-delay: 0.09s; --rot: 18deg; }

/* Result Banner */
.result-banner {
  width: 100%;
  border: 1px solid rgba(201,148,58,0.2);
  border-radius: 3px;
  padding: 2rem 2rem;
  text-align: center;
  display: none;
  flex-direction: column;
  gap: 0.8rem;
  animation: banner-in 0.55s ease both;
}
.result-banner.visible { display: flex; }
@keyframes banner-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result-banner.yes { border-color: rgba(125,184,125,0.35); background: rgba(125,184,125,0.06); }
.result-banner.no  { border-color: rgba(192,112,112,0.35); background: rgba(192,112,112,0.06); }
.result-banner.ask { border-color: rgba(201,148,58,0.4);   background: rgba(201,148,58,0.06); }

.result-verdict {
  font-family: var(--ff-hanzi);
  font-size: clamp(2.2rem, 10vw, 3rem);
  font-weight: 600;
  line-height: 1;
}
.yes .result-verdict { color: var(--yes-clr); }
.no  .result-verdict { color: var(--no-clr);  }
.ask .result-verdict { color: var(--ask-clr); }

.result-name {
  font-size: 1rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
  color: var(--parchment);
}
.result-meaning {
  font-family: var(--ff-display);
  font-size: clamp(1.3rem, 5.5vw, 1.6rem);
  color: var(--parchment);
  line-height: 1.7;
}

/* Cast Button */
.cast-btn {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  cursor: pointer;
  position: relative;
  width: clamp(120px, 38vw, 155px);
  height: clamp(120px, 38vw, 155px);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #9e2a20 0%, #6b1212 50%, #3a0808 100%);
  box-shadow:
    0 0 0 1px rgba(180,80,60,0.35),
    0 0 0 7px rgba(160,50,40,0.1),
    0 10px 36px rgba(0,0,0,0.75),
    inset 0 2px 8px rgba(255,210,130,0.22),
    inset 0 -4px 10px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s, box-shadow 0.16s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}
.cast-btn::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255,160,130,0.15);
  pointer-events: none;
}
.cast-btn:active:not(:disabled) {
  transform: scale(0.92);
  box-shadow: 0 5px 18px rgba(0,0,0,0.7);
}
.cast-btn:disabled { opacity: 0.4; cursor: default; }

.cast-label {
  font-family: var(--ff-hanzi);
  font-size: clamp(1rem, 4vw, 1.15rem);
  font-weight: 600;
  color: var(--parchment);
  letter-spacing: 0.1em;
  text-shadow: 0 1px 5px rgba(0,0,0,0.7);
  user-select: none;
}

/* Tally */
.tally {
  display: none;
  align-items: center;
  gap: 1rem;
  animation: fadeup 0.4s ease both;
}
.tally.visible { display: flex; }
@keyframes fadeup {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tally-item { display: flex; align-items: center; gap: 0.4rem; }
.tally-dot  { width: 6px; height: 6px; border-radius: 50%; }
.dot-yes    { background: var(--yes-clr); }
.dot-no     { background: var(--no-clr); }
.dot-ask    { background: var(--ask-clr); }
.tally-count { font-size: 0.85rem; color: var(--parchment); min-width: 1ch; }
.tally-label { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--parchment); opacity: 0.35; }
.tally-sep  { width: 1px; height: 14px; background: rgba(201,148,58,0.2); }

.footer { margin-top: auto; text-align: center; }
.footer p { font-size: 0.7rem; letter-spacing: 0.12em; color: var(--parchment); opacity: 0.5; }