:root {
  color-scheme: dark;
  font-family: Pretendard, "Noto Sans KR", system-ui, sans-serif;
  --panel: rgba(25, 20, 42, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --pink: #ff4f92;
  --gold: #ffd15c;
}

* { box-sizing: border-box; }
body { margin: 0; color: #fff; }
button, input, textarea, select { font: inherit; }

.admin-body {
  min-height: 100vh;
  background: radial-gradient(circle at 12% 8%, #48265f, transparent 34%), linear-gradient(145deg, #120e20, #21142d);
}

.admin-shell { width: min(1100px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 70px; }
header { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 46px); }
h2 { font-size: 19px; }
.eyebrow { margin-bottom: 6px; color: var(--gold); font-weight: 900; letter-spacing: 0.15em; font-size: 12px; }
#saveStatus { color: #d9cce6; }
.admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: 0 18px 45px rgba(0,0,0,.22); }
.panel.wide { grid-column: 1 / -1; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading h2 { margin-bottom: 0; }
label { display: grid; gap: 7px; margin: 14px 0; color: #d9cce6; font-size: 13px; }
label.check { display: flex; align-items: center; }
input, textarea, select { min-width: 0; padding: 11px 13px; color: #fff; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.25); }
select option { color: #111; background: #fff; }
textarea { resize: vertical; line-height: 1.55; }
.url-row, .actions { display: flex; gap: 10px; }
.url-row input { flex: 1; }
.actions.wrap { flex-wrap: wrap; }
button { padding: 10px 15px; border: 0; border-radius: 10px; color: #17101e; background: var(--gold); font-weight: 900; cursor: pointer; }
button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button.danger { color: #fff; background: #7d3150; }
.result-table { display: grid; gap: 9px; padding: 0; list-style: none; }
.result-table li { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 12px; background: rgba(255,255,255,.06); }
.result-table b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: #17101e; background: var(--gold); }
.result-table span { font-size: 18px; font-weight: 900; }
.probability-grid { display: grid; gap: 7px; margin: 12px 0 18px; }
.probability-grid label { display: grid; grid-template-columns: minmax(0, 1fr) 84px 54px; gap: 8px; align-items: center; margin: 0; }
.probability-grid input { width: 84px; padding: 8px 10px; text-align: right; }
.probability-grid b { color: var(--gold); text-align: right; }
.hint, .status-line { margin-bottom: 0; color: #bfb1cc; font-size: 13px; line-height: 1.6; }
.status-line { margin-bottom: 15px; color: #fff; }
.signature-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.event-log { display: grid; gap: 8px; }
.event-log > div { display: grid; grid-template-columns: 160px 1fr 100px 110px 50px; gap: 12px; align-items: center; padding: 11px 13px; border-radius: 10px; background: rgba(255,255,255,.05); }
.event-log time, .event-log small { color: #aa9ab9; }
.event-log b { color: var(--gold); }
.donation-log .donation-status { color: #74e7bd; }
.empty { color: #aa9ab9; }

.overlay-body { width: 100vw; height: 100vh; overflow: hidden; background: transparent; }
.overlay-stage { display: grid; place-items: center; width: 100%; height: 100%; padding: 5vh 5vw; }
.impact-scene {
  position: relative;
  width: min(1100px, 94vw);
  height: min(700px, 90vh);
  opacity: 0;
  transform: translateY(45px) scale(.85);
  pointer-events: none;
}
.impact-scene.show { animation: sceneIn .48s cubic-bezier(.15,.85,.2,1.15) forwards; }
.impact-scene::before {
  content: "";
  position: absolute;
  inset: 6% 0 0;
  border-radius: 48%;
  background: radial-gradient(ellipse, rgba(63,28,84,.92) 0 27%, rgba(19,10,30,.74) 54%, transparent 72%);
  filter: blur(2px);
}
.back-rays {
  position: absolute;
  inset: -12%;
  opacity: .35;
  background: repeating-conic-gradient(from 4deg, rgba(255,216,106,.6) 0 2deg, transparent 2deg 13deg);
  -webkit-mask-image: radial-gradient(circle, #000 0 10%, transparent 63%);
  mask-image: radial-gradient(circle, #000 0 10%, transparent 63%);
  animation: raySpin 16s linear infinite;
}
.character-frame {
  position: absolute;
  z-index: 4;
  left: 1%;
  bottom: 0;
  width: auto;
  height: 94%;
  aspect-ratio: 1 / 2;
  overflow: hidden;
  filter: drop-shadow(0 22px 26px rgba(0,0,0,.55));
}
.ion-character {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: url("assets/ion-character-semi-real-v5.png") 0 center / 300% 100% no-repeat;
  transition: filter .16s ease;
}
.ion-character.pose-ready { background-position: 0 center; }
.ion-character.pose-throw { background-position: 50% center; }
.ion-character.pose-drink { background-position: 100% center; }
.show .character-frame { animation: characterEnter .62s cubic-bezier(.18,.82,.22,1.2) both; }
.throwing .character-frame { animation: characterThrow .62s ease both; }
.drinking .character-frame { animation: drunkenSway .58s ease-in-out infinite alternate; }
.dice-wrap {
  position: absolute;
  z-index: 5;
  right: 12%;
  top: 16%;
  width: min(270px, 25vw);
  aspect-ratio: 1;
  filter: drop-shadow(0 22px 25px rgba(0,0,0,.48));
  perspective: 900px;
}
.result-die {
  position: absolute;
  inset: 0;
  border: 10px solid #fff;
  border-radius: 26%;
  background: linear-gradient(145deg, #fffdf2 0 43%, #e5d9ee 100%);
  box-shadow: 0 0 0 7px #4a285e, 0 0 55px rgba(255,210,91,.92), inset -22px -24px 36px rgba(71,36,88,.22);
  transform: scale(.72);
  opacity: 0;
  transform-style: preserve-3d;
}
.show .result-die { animation: dieAppear .45s .35s ease both; }
.rolling .result-die, .result-die.shuffle { animation: dieSpin .22s linear infinite; opacity: 1; transform: scale(1); }
.settled .result-die { animation: dieLand .72s cubic-bezier(.12,.9,.2,1.25) both; opacity: 1; }
.result-die::before {
  content: "DRINK";
  position: absolute;
  left: 50%;
  top: 13%;
  color: #9a7cab;
  font-size: 18px;
  font-weight: 1000;
  letter-spacing: .22em;
  transform: translateX(-50%);
}
.result-die > i { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #ff5796; box-shadow: 0 0 12px rgba(255,64,139,.7); }
.result-die > i:nth-child(1) { left: 18%; top: 18%; }
.result-die > i:nth-child(2) { right: 18%; top: 18%; }
.result-die > i:nth-child(3) { left: 18%; bottom: 18%; }
.result-die > i:nth-child(4) { right: 18%; bottom: 18%; }
.result-die b {
  position: absolute;
  inset: 27%;
  display: grid;
  place-items: center;
  border: 5px solid #e1c9eb;
  border-radius: 22%;
  color: #3b2048;
  background: #fff;
  font-size: 92px;
  box-shadow: 0 7px 16px rgba(0,0,0,.2), inset 0 0 15px rgba(255,92,157,.14);
}
.flying-token {
  position: absolute;
  z-index: 8;
  left: 43%;
  top: 42%;
  display: grid;
  place-items: center;
  width: 76px;
  aspect-ratio: 1;
  opacity: 0;
  color: #fff;
  background: linear-gradient(135deg, #bff5ff, #8873ff 45%, #ff82d0);
  clip-path: polygon(50% 0, 92% 28%, 82% 78%, 50% 100%, 17% 78%, 7% 28%);
  font-size: 34px;
  font-weight: 1000;
  box-shadow: 0 0 30px #fff, 0 0 65px #ffd35d;
}
.flying-token.fly { animation: tokenFly .78s cubic-bezier(.12,.62,.22,1) forwards; }
.result-copy {
  position: absolute;
  z-index: 10;
  right: 0;
  bottom: 7%;
  display: grid;
  justify-items: center;
  width: 57%;
  text-align: center;
}
.viewer-text { margin-bottom: 8px; color: #fff; font-size: clamp(22px, 2.7vw, 38px); font-weight: 900; text-shadow: 0 4px 12px #000; }
.result-copy strong { color: var(--gold); font-size: clamp(66px, 9vw, 126px); line-height: 1; -webkit-text-stroke: 3px #6f2845; text-shadow: 0 7px 0 #6f2845, 0 0 22px #fff, 0 0 60px #ff5b9c, 0 15px 30px #000; }
.result-copy small { min-height: 28px; margin-top: 20px; padding: 5px 18px; border-radius: 999px; background: rgba(20,10,30,.78); font-size: 22px; font-weight: 900; }
.settled .result-copy strong { animation: resultPop .7s cubic-bezier(.12,.85,.2,1.3); }
.drinking .result-copy strong::after { content: "  짠!"; font-size: .34em; -webkit-text-stroke-width: 1px; }
.blank-result .result-copy strong { color: #bff4ff; text-shadow: 0 7px 0 #315074, 0 0 28px #fff, 0 0 66px #5bbfff; }
.question-result .result-copy strong { max-width: 720px; color: #bff4ff; font-size: clamp(48px, 6vw, 88px); line-height: 1.12; }
.question-result .result-copy strong::after { content: "  ?"; color: #ffd15c; }
.question-result .character-frame { animation: questionBounce .72s ease-in-out infinite alternate; }
.spark-field { position: absolute; z-index: 9; inset: 0; opacity: 0; }
.settled .spark-field { opacity: 1; }
.spark-field i { position: absolute; width: 18px; height: 18px; background: #fff3a5; clip-path: polygon(50% 0,61% 39%,100% 50%,61% 61%,50% 100%,39% 61%,0 50%,39% 39%); animation: sparkle 1s ease-in-out infinite alternate; filter: drop-shadow(0 0 10px #ffd34d); }
.spark-field i:nth-child(1) { left: 15%; top: 13%; }
.spark-field i:nth-child(2) { left: 8%; top: 52%; animation-delay: -.4s; }
.spark-field i:nth-child(3) { left: 38%; top: 7%; animation-delay: -.7s; }
.spark-field i:nth-child(4) { left: 53%; top: 29%; animation-delay: -.2s; }
.spark-field i:nth-child(5) { right: 7%; top: 8%; animation-delay: -.8s; }
.spark-field i:nth-child(6) { right: 3%; top: 56%; animation-delay: -.3s; }
.spark-field i:nth-child(7) { left: 45%; bottom: 8%; animation-delay: -.6s; }
.spark-field i:nth-child(8) { right: 19%; bottom: 4%; animation-delay: -.1s; }

@keyframes sceneIn { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes raySpin { to { transform: rotate(360deg); } }
@keyframes characterEnter { from { opacity: 0; transform: translateX(-24%) scale(.82); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes characterThrow { 0% { transform: translateX(0) rotate(0); } 42% { transform: translateX(3%) rotate(-4deg) scale(1.06); } 100% { transform: translateX(0) rotate(0); } }
@keyframes drunkenSway { from { transform: rotate(-3deg) translateY(0); } to { transform: rotate(4deg) translateY(-10px); } }
@keyframes dieAppear { from { opacity: 0; transform: translateY(-80px) rotate(-35deg) scale(.45); } to { opacity: 1; transform: translateY(0) rotate(0) scale(1); } }
@keyframes dieSpin { 0% { transform: rotateX(0) rotateY(0) rotateZ(0) scale(.88); } 100% { transform: rotateX(360deg) rotateY(540deg) rotateZ(180deg) scale(1.04); } }
@keyframes dieLand { 0% { transform: translateY(-90px) rotate(520deg) scale(.8); } 62% { transform: translateY(18px) rotate(-8deg) scale(1.14); } 100% { transform: translateY(0) rotate(0) scale(1); } }
@keyframes tokenFly { 0% { opacity: 1; transform: translate(0,0) rotate(0) scale(.7); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(320px,-190px) rotate(620deg) scale(1.25); } }
@keyframes resultPop { 0% { opacity: 0; transform: scale(.35); } 70% { transform: scale(1.16); } 100% { opacity: 1; transform: scale(1); } }
@keyframes sparkle { from { opacity: .3; transform: scale(.5) rotate(0); } to { opacity: 1; transform: scale(1.6) rotate(90deg); } }
@keyframes questionBounce { from { transform: translateY(0); } to { transform: translateY(-12px) rotate(-1deg); } }

@media (max-width: 820px) {
  .admin-grid { grid-template-columns: 1fr; }
  .panel.wide { grid-column: auto; }
  .event-log > div { grid-template-columns: 1fr 1fr; }
  .event-log time { grid-column: 1 / -1; }
}
