:root {
  --text: #312a24;
  --muted: #786a5e;
  --line: rgba(119, 88, 62, 0.2);
  --accent: #f4b73f;
  --accent-strong: #ff6152;
  --paper: #fff8df;
  --ink: #2c2520;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: #fff4df;
  overflow-x: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.home-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  isolation: isolate;
  overflow: clip;
}

.home-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.home-shell::after {
  z-index: -1;
  inset: auto;
  left: 50%;
  bottom: -280px;
  width: min(1100px, 150vw);
  height: 560px;
  border-radius: 50%;
  background: #f8e8cc;
  transform: translateX(-50%);
}

.gacha-stage {
  position: relative;
  width: min(760px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
}

.gacha-stage[hidden] {
  display: none;
}

.rules-open {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  margin-top: 0.42em;
  border: 1px solid rgba(44, 37, 32, 0.18);
  border-radius: 50%;
  color: #3c2a24;
  background: rgba(255, 255, 255, 0.72);
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(132, 78, 44, 0.14);
}

.rules-open:hover,
.rules-open:focus-visible {
  border-color: rgba(244, 75, 62, 0.45);
  background: rgba(255, 246, 232, 0.96);
}

.home-copy {
  margin-bottom: 1em;
  text-align: center;
}

.home-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
}

.home-copy h1 {
  margin: 0;
  color: #3c2a24;
  font-family: "Mochiy Pop P One", "Hiragino Maru Gothic ProN", "Yu Gothic", ui-rounded, system-ui, sans-serif;
  font-size: clamp(2.25rem, 6vw, 4.4rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow:
    0 4px 0 rgba(255, 255, 255, 0.72),
    0 12px 22px rgba(197, 119, 64, 0.18);
}

.home-title-dot {
  display: inline-block;
  width: 0.92em;
  height: 0.92em;
  margin: 0 0.02em;
  overflow: hidden;
  color: transparent;
  line-height: 1;
  vertical-align: -0.12em;
  background: var(--title-capsule-image) center / contain no-repeat;
  text-shadow: none;
  filter: drop-shadow(0 5px 0 rgba(255, 255, 255, 0.7)) drop-shadow(0 12px 12px rgba(154, 91, 56, 0.2));
}

.home-copy p {
  margin: 10px 0 0;
  color: #6d5a4a;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", ui-rounded, system-ui, sans-serif;
  font-size: clamp(1rem, 2vw, 18px);
  font-weight: 800;
}

.machine-button {
  position: relative;
  --capsule-eject-x: clamp(8px, 2vw, 18px);
  --capsule-eject-mid-y: clamp(42px, 13vw, 74px);
  --capsule-eject-end-y: min(124px, max(32px, calc((100dvh - 640px) * 0.5)));
  width: min(400px, 88vw);
  aspect-ratio: 0.78;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: none;
  filter: drop-shadow(0 18px 16px rgba(132, 78, 44, 0.16));
}

.machine-button:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 8px;
  border-radius: 18px;
}

.machine-glow {
  position: absolute;
  inset: 6% 1% 0;
  z-index: -1;
  border-radius: 42%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 251, 207, 0.92), rgba(255, 185, 89, 0.42) 34%, transparent 68%);
  opacity: 0.54;
  transform: scale(0.9);
  transition: opacity 220ms ease, transform 220ms ease;
}

.machine-button:hover .machine-glow,
.machine-button:focus-visible .machine-glow {
  opacity: 0.9;
  transform: scale(1);
}

.machine-button.is-sequencing .machine-glow {
  animation: machine-flash 2s ease both;
}

.machine-wrap {
  position: absolute;
  inset: 0;
  display: block;
  transform-origin: 50% 74%;
}

.machine-body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 4;
  pointer-events: none;
}

.capsule-field {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  overflow: visible;
  pointer-events: none;
}

.capsule {
  position: absolute;
  width: 20%;
  filter: drop-shadow(0 8px 8px rgba(86, 58, 39, 0.24));
}

.capsule img,
.ejected-capsule img,
.opened-capsule img {
  width: 100%;
  display: block;
}

.capsule-a { left: 5.4%; top: 37.8%; width: 21.5%; z-index: 34; transform: rotate(-24deg); }
.capsule-b { left: 16.8%; top: 39.4%; width: 22.2%; z-index: 38; transform: rotate(15deg); }
.capsule-c { left: 30.2%; top: 37.5%; width: 22.0%; z-index: 39; transform: rotate(-7deg); }
.capsule-d { left: 44.2%; top: 38.2%; width: 22.6%; z-index: 40; transform: rotate(11deg); }
.capsule-e { left: 58.8%; top: 38.0%; width: 22.0%; z-index: 41; transform: rotate(-16deg); }
.capsule-f { left: 73.2%; top: 36.8%; width: 21.2%; z-index: 35; transform: rotate(24deg); }
.capsule-g { left: 8.4%; top: 30.8%; width: 20.5%; z-index: 20; transform: rotate(8deg); }
.capsule-h { left: 21.2%; top: 28.4%; width: 21.2%; z-index: 22; transform: rotate(-19deg); }
.capsule-i { left: 35.8%; top: 29.2%; width: 20.6%; z-index: 24; transform: rotate(17deg); }
.capsule-j { left: 49.2%; top: 28.6%; width: 21.4%; z-index: 23; transform: rotate(-11deg); }
.capsule-k { left: 63.5%; top: 30.5%; width: 20.8%; z-index: 21; transform: rotate(13deg); }
.capsule-l { left: 75.0%; top: 34.2%; width: 20.0%; z-index: 28; transform: rotate(-20deg); }

.capsule.is-jumping img {
  animation: capsule-js-jump 620ms linear both;
}

.capsule { --tumble-delay: 0ms; --tumble-height: -10px; --tumble-sway: 3px; }
.capsule:nth-child(3n + 1) { --tumble-delay: 60ms; --tumble-height: -8px; --tumble-sway: -3px; }
.capsule:nth-child(3n + 2) { --tumble-delay: 120ms; --tumble-height: -14px; }
.capsule:nth-child(4n) { --tumble-delay: 180ms; --tumble-sway: -4px; }

.machine-button.is-handle-turning .capsule img {
  animation: capsule-popcorn calc(var(--handle-turn-duration, 2200ms) - var(--tumble-delay)) linear var(--tumble-delay) both;
}

.handle-turn {
  position: absolute;
  left: 69.8%;
  top: 64.1%;
  width: 14%;
  aspect-ratio: 1;
  z-index: 6;
  border-radius: 50%;
  pointer-events: none;
  transform-origin: 50% 50%;
}

.handle-turn img {
  width: 100%;
  height: 100%;
  display: block;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 8px 8px rgba(88, 47, 25, 0.24));
  transition: transform 220ms ease;
}

.machine-button.is-handle-turning .handle-turn img {
  animation: handle-bar var(--handle-turn-duration, 2200ms) cubic-bezier(0.32, 0, 0.24, 1) both;
}

.ejected-capsule {
  position: absolute;
  left: 35%;
  top: 70%;
  width: 18%;
  z-index: 24;
  opacity: 0;
  transform: translateY(-8px) scale(0.48);
  pointer-events: none;
  filter: drop-shadow(0 18px 16px rgba(104, 62, 38, 0.22));
}

.machine-button.is-capsule-ejecting .ejected-capsule {
  animation: capsule-eject var(--capsule-eject-duration, 950ms) linear both;
}

.spin-scene[hidden],
.spin-result[hidden] {
  display: none;
}

.spin-scene {
  position: fixed;
  inset: 0;
  z-index: 28;
  pointer-events: auto;
}

.spin-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(255, 249, 236, 0.52);
  backdrop-filter: blur(0);
  transition: opacity 320ms ease, backdrop-filter 320ms ease;
}

.spin-scene[data-stage="result"]::before {
  opacity: 1;
  backdrop-filter: blur(8px);
}

.spin-flash {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18vmax;
  height: 18vmax;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.1);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 1) 0 24%, rgba(var(--capsule-flash-rgb, 244, 185, 34), 0.82) 50%, rgba(255, 255, 255, 0.9) 72%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

.spin-scene.is-flashing .spin-flash {
  animation: center-flash var(--center-flash-duration, 650ms) ease-out both;
}

.spin-scene.is-flashing {
  animation: flash-wash var(--center-flash-duration, 650ms) ease-out both;
}

.spin-result {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100vw - 36px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  animation: result-arrive var(--result-intro-duration, 800ms) cubic-bezier(0.16, 1, 0.3, 1) both;
}

.limit-toast {
  max-width: min(420px, 90vw);
  padding: 12px 16px;
  border: 1px solid rgba(97, 68, 44, 0.12);
  border-radius: 999px;
  color: rgba(49, 42, 36, 0.86);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 24px rgba(143, 91, 54, 0.1);
  backdrop-filter: blur(14px);
  font-weight: 800;
  text-align: center;
}

.limit-toast[hidden] {
  display: none;
}

.hand-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 300px;
  height: 210px;
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) rotate(-9deg) scale(0.78);
  transform-origin: 22% 16%;
  background-image: url("../../gacha sozai/hand2.png");
  background-size: cover;
  background-position: 33% 28%;
  mix-blend-mode: normal;
  filter: drop-shadow(0 20px 18px rgba(126, 73, 43, 0.22));
  transition: opacity 140ms ease, transform 140ms ease;
}

.hand-cursor.is-visible {
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) rotate(-9deg) scale(0.9);
}

.overlay[hidden] {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 53, 61, 0.16);
  backdrop-filter: blur(3px);
}

.overlay.is-dispensing .overlay-backdrop {
  animation: overlay-flash 1.2s ease both;
}

.instruction-sheet {
  position: relative;
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid rgba(70, 46, 28, 0.16);
  border-radius: 6px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(95, 70, 36, 0.06) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, #fffdf2, var(--paper));
  box-shadow: 0 28px 70px rgba(130, 84, 48, 0.24);
}

.overlay.is-dispensing .instruction-sheet {
  animation: sheet-pulse 1.15s ease both;
}

.icon-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(44, 37, 32, 0.2);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.sheet-kicker,
.note-label {
  margin: 0 0 8px;
  color: #93632d;
  font-size: 12px;
  font-weight: 800;
}

.instruction-sheet h2 {
  margin: 0 0 22px;
  font-size: min(20px, 5.2vw);
  line-height: 1.45;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.tab {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(44, 37, 32, 0.2);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.44);
  cursor: pointer;
}

.tab.is-active {
  border-color: rgba(255, 97, 82, 0.58);
  background: rgba(255, 97, 82, 0.14);
}

.share-form label,
.pool-fieldset legend {
  display: block;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.field-help,
.field-rule,
.field-error {
  margin: 0 0 12px;
  color: rgba(44, 37, 32, 0.68);
  font-size: 12px;
  line-height: 1.7;
}

.field-error {
  color: #b3201a;
  font-weight: 700;
}

input[type="text"],
input[type="url"],
textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(44, 37, 32, 0.24);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
}

input[type="text"],
input[type="url"] {
  min-height: 44px;
  margin-bottom: 14px;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.type-panel[hidden] {
  display: none;
}

.upload-dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 118px;
  padding: 14px 16px;
  border: 1px dashed rgba(44, 37, 32, 0.32);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.46);
  cursor: pointer;
  text-align: center;
}

.upload-dropzone.is-dragging,
.upload-dropzone:focus-within {
  border-color: rgba(255, 97, 82, 0.68);
  background: rgba(255, 97, 82, 0.1);
}

.upload-dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-title {
  font-size: 14px;
  font-weight: 900;
}

.upload-note,
.upload-file {
  color: rgba(44, 37, 32, 0.66);
  font-size: 12px;
  line-height: 1.6;
}

.upload-file {
  font-weight: 800;
}

.upload-preview {
  width: min(180px, 100%);
  max-height: 140px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(77, 48, 32, 0.16);
}

.pool-fieldset {
  margin: 22px 0;
  padding: 0;
  border: 0;
}

.pool-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.pool-options label {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(44, 37, 32, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.38);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.pool-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pool-options label:has(input:checked) {
  border-color: rgba(255, 97, 82, 0.58);
  background: rgba(255, 97, 82, 0.14);
  color: #583026;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
}

.primary-action {
  color: #241714;
  background: linear-gradient(180deg, #ffd965, #ffad28);
  box-shadow: 0 9px 0 #b45b25;
}

.primary-action:disabled {
  cursor: default;
  opacity: 0.68;
}

.secondary-action {
  margin-top: 18px;
  color: var(--paper);
  background: #3a2a21;
}

.result-panel {
  text-align: center;
  animation: result-arrive 360ms ease both;
}

.spin-result .opened-capsule {
  position: absolute;
  left: 50%;
  top: 112px;
  z-index: 1;
  width: 154px;
  margin: 0;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 18px 18px rgba(83, 54, 34, 0.22));
}

.result-panel .opened-capsule {
  width: 130px;
  margin: 0 auto 16px;
  animation: capsule-open 680ms ease both;
}

.paper-note {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 22px;
  border: 1px dashed rgba(44, 37, 32, 0.25);
  border-radius: 4px;
  text-align: left;
  background: rgba(255, 255, 255, 0.58);
}

.spin-result .paper-note {
  margin-top: 176px;
  padding-top: 34px;
  transform-origin: 50% 0;
  animation: note-unfold var(--result-intro-duration, 800ms) cubic-bezier(0.16, 1, 0.3, 1) both;
  background:
    linear-gradient(90deg, rgba(95, 70, 36, 0.06) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, rgba(255, 253, 242, 0.96), var(--paper));
  box-shadow: 0 28px 70px rgba(130, 84, 48, 0.24);
}

.note-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.note-header .note-label {
  margin: 0;
}

.note-date {
  color: rgba(44, 37, 32, 0.52);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.result-actions {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.chance-status {
  position: relative;
  z-index: 3;
  margin: 12px 0 0;
  color: rgba(44, 37, 32, 0.66);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.question-response {
  position: relative;
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(44, 37, 32, 0.14);
  border-radius: 0;
  background: transparent;
}

.question-response textarea {
  min-height: 88px;
  resize: vertical;
}

.question-response .primary-action,
.question-response .secondary-action {
  min-height: 42px;
  border-radius: 6px;
}

.question-response[hidden] {
  display: none;
}

.question-response label {
  font-size: 12px;
  font-weight: 900;
}

.question-response .secondary-action {
  margin-top: 0;
}

.paper-note p[data-result-text] {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.9;
}

.result-title {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.5;
}

.result-link {
  display: block;
  margin-top: 12px;
  overflow-wrap: anywhere;
  color: #2f6f9f;
  font-size: 0.92rem;
  font-weight: 800;
}

.result-image {
  display: block;
  width: 100%;
  max-height: 220px;
  margin: 10px 0 14px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(77, 48, 32, 0.16);
}

.result-image[hidden] {
  display: none;
}

.result-extra {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(44, 37, 32, 0.14);
  border-radius: 6px;
  color: rgba(44, 37, 32, 0.72);
  background: rgba(255, 255, 255, 0.42);
  font-size: 0.9rem;
  line-height: 1.6;
}

.result-reactions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
}

.reaction-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 58px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid rgba(44, 37, 32, 0.18);
  border-radius: 999px;
  color: rgba(44, 37, 32, 0.78);
  background: rgba(255, 255, 255, 0.52);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}

.reaction-button:hover,
.reaction-button:focus-visible,
.reaction-button.is-selected {
  border-color: rgba(255, 97, 82, 0.68);
  background: rgba(255, 235, 218, 0.74);
}

.reaction-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.result-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
}

.paper-note footer {
  margin: 0;
  color: rgba(44, 37, 32, 0.58);
  font-size: 0.9rem;
}

.shared-result-page[hidden] {
  display: none;
}

.shared-result-page {
  position: fixed;
  inset: 0;
  z-index: 27;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.shared-result-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 249, 236, 0.58);
  backdrop-filter: blur(8px);
}

.shared-result-page > * {
  position: relative;
}

.shared-result-capsule {
  z-index: 1;
  width: 128px;
  margin-bottom: -42px;
}

.shared-result-note {
  width: min(430px, 100%);
  min-height: 250px;
  padding-top: 34px;
}

.shared-result-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed rgba(44, 37, 32, 0.18);
}

.shared-result-source span {
  color: rgba(44, 37, 32, 0.68);
  font-weight: 900;
}

.shared-result-source a {
  color: #2f6f9f;
  font-weight: 800;
  text-decoration: none;
}

.shared-result-source a:hover,
.shared-result-source a:focus-visible {
  text-decoration: underline;
}

.shared-result-error {
  width: min(430px, 100%);
  margin-top: 14px;
  text-align: center;
}

.shared-result-cta {
  width: min(430px, 100%);
  margin-top: 14px;
  color: #2b190d;
  text-align: center;
  text-decoration: none;
}

.admin-panel[hidden] {
  display: none;
}

.rules-panel[hidden] {
  display: none;
}

.rules-panel,
.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: 18px;
}

.rules-backdrop,
.admin-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 35, 28, 0.42);
  backdrop-filter: blur(8px);
}

.rules-sheet,
.admin-sheet {
  position: relative;
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid rgba(70, 46, 28, 0.16);
  border-radius: 6px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(95, 70, 36, 0.06) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, #fffdf2, var(--paper));
  box-shadow: 0 28px 70px rgba(45, 32, 22, 0.32);
}

.rules-sheet h2,
.admin-sheet h2 {
  margin: 0 0 12px;
  font-size: min(20px, 5.2vw);
  line-height: 1.45;
}

.rules-content {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.rules-section {
  padding: 14px;
  border: 1px solid rgba(44, 37, 32, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.48);
}

.rules-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.rules-section ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.2em;
  color: rgba(44, 37, 32, 0.74);
  font-size: 13px;
  line-height: 1.7;
}

.admin-status {
  margin: 16px 0;
  padding: 10px 12px;
  border-radius: 6px;
  color: rgba(44, 37, 32, 0.76);
  background: rgba(255, 255, 255, 0.52);
  font-size: 12px;
  font-weight: 800;
}

.admin-login {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.admin-login[hidden],
.admin-review[hidden] {
  display: none;
}

.admin-login .primary-action {
  margin-top: 4px;
}

.admin-logout,
.admin-close {
  margin: 0 0 12px;
  min-height: 40px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 12px;
}

.admin-tab {
  min-height: 36px;
  border: 1px solid rgba(44, 37, 32, 0.18);
  border-radius: 6px;
  color: rgba(44, 37, 32, 0.72);
  background: rgba(255, 255, 255, 0.6);
  font-weight: 900;
  cursor: pointer;
}

.admin-tab.is-active {
  border-color: rgba(255, 97, 82, 0.72);
  color: #3c2a24;
  background: rgba(255, 235, 218, 0.82);
}

.admin-close {
  margin: 16px 0 0;
  width: 100%;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-card {
  padding: 14px;
  border: 1px solid rgba(44, 37, 32, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.56);
}

.admin-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.admin-card p {
  margin: 0;
  color: rgba(44, 37, 32, 0.74);
  font-size: 12px;
  line-height: 1.7;
}

.admin-preview-image {
  display: block;
  width: 100%;
  max-height: 220px;
  margin: 10px 0;
  border-radius: 6px;
  object-fit: cover;
}

.admin-preview-link {
  display: block;
  margin: 10px 0;
  overflow-wrap: anywhere;
  color: #2f6f9f;
  font-size: 12px;
  font-weight: 800;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.admin-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgba(44, 37, 32, 0.18);
  border-radius: 6px;
  color: #3c2a24;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 900;
}

.admin-actions button:hover:not(:disabled) {
  border-color: rgba(244, 75, 62, 0.45);
  background: rgba(255, 246, 232, 0.94);
}

.admin-actions button:disabled {
  color: rgba(44, 37, 32, 0.38);
  cursor: wait;
}

.admin-metric {
  margin-top: 8px;
  font-weight: 900;
}

.admin-action-note {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border: 1px solid rgba(44, 37, 32, 0.18);
  border-radius: 6px;
  color: rgba(44, 37, 32, 0.52);
  background: rgba(255, 255, 255, 0.54);
  font-weight: 800;
}

@keyframes capsule-js-jump {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  0% { animation-timing-function: cubic-bezier(0.2, 0.65, 0.35, 1); }
  30% { transform: translate(2px, -9px) rotate(3deg); animation-timing-function: cubic-bezier(0.55, 0, 0.85, 0.4); }
  56% { transform: translate(0, 0) rotate(-2deg); animation-timing-function: ease-out; }
  74% { transform: translate(-1px, -3px) rotate(1deg); animation-timing-function: ease-in; }
}

@keyframes capsule-popcorn {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  0%, 30%, 64% { animation-timing-function: ease-out; }
  16% { transform: translate(var(--tumble-sway), var(--tumble-height)) rotate(5deg); animation-timing-function: ease-in; }
  30% { transform: translate(0, 0) rotate(-3deg); }
  46% { transform: translate(calc(var(--tumble-sway) * -1), calc(var(--tumble-height) * 0.65)) rotate(-4deg); animation-timing-function: ease-in; }
  64% { transform: translate(0, 0) rotate(2deg); }
  78% { transform: translate(var(--tumble-sway), calc(var(--tumble-height) * 0.25)) rotate(1deg); animation-timing-function: ease-in; }
  92% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes handle-ring {
  0% { transform: rotate(0deg) scale(0.8); }
  44% { transform: rotate(180deg) scale(1.08); }
  56% { transform: rotate(180deg) scale(1.04); }
  100% { transform: rotate(360deg) scale(0.88); }
}

@keyframes handle-bar {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes capsule-eject {
  0% { opacity: 0; transform: translate(0, -14px) scale(0.42) rotate(-20deg); animation-timing-function: ease-out; }
  12% { opacity: 1; transform: translate(2px, 0) scale(0.68) rotate(8deg); animation-timing-function: cubic-bezier(0.45, 0, 0.85, 0.5); }
  52% { opacity: 1; transform: translate(var(--capsule-eject-x), var(--capsule-eject-end-y)) scale(1.04, 0.94) rotate(100deg); animation-timing-function: ease-out; }
  69% { opacity: 1; transform: translate(calc(var(--capsule-eject-x) * 1.15), var(--capsule-eject-mid-y)) scale(0.98, 1.02) rotate(132deg); animation-timing-function: ease-in; }
  84% { opacity: 1; transform: translate(calc(var(--capsule-eject-x) * 1.3), var(--capsule-eject-end-y)) scale(1) rotate(154deg); animation-timing-function: ease-out; }
  92% { opacity: 1; transform: translate(calc(var(--capsule-eject-x) * 1.35), calc(var(--capsule-eject-end-y) - 4px)) scale(1) rotate(160deg); }
  100% { opacity: 0; transform: translate(calc(var(--capsule-eject-x) * 1.4), var(--capsule-eject-end-y)) scale(1) rotate(166deg); }
}

@keyframes machine-flash {
  0% { opacity: 0.62; transform: scale(0.92); }
  46% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 0.15; transform: scale(1.22); }
}

@keyframes center-flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.1); }
  26% { opacity: 1; transform: translate(-50%, -50%) scale(1.35); }
  72% { opacity: 0.92; transform: translate(-50%, -50%) scale(7); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(9); }
}

@keyframes flash-wash {
  0% { background: rgba(255, 255, 255, 0); }
  46% { background: rgba(var(--capsule-flash-rgb, 244, 185, 34), 0.36); }
  76% { background: rgba(255, 255, 255, 0.96); }
  100% { background: rgba(255, 255, 255, 0); }
}

@keyframes overlay-flash {
  0%, 72% { opacity: 1; }
  88% { opacity: 0.28; }
  100% { opacity: 1; }
}

@keyframes sheet-pulse {
  0%, 72% { transform: scale(1); }
  86% { transform: scale(0.98); filter: brightness(1.12); }
  100% { transform: scale(1); }
}

@keyframes capsule-open {
  from { opacity: 0; transform: translateY(-18px) scale(0.7) rotate(-18deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}

@keyframes capsule-open-behind {
  from { opacity: 0; transform: translate(-50%, -68%) scale(0.72) rotate(-14deg); }
  to { opacity: 1; transform: translate(-50%, -58%) scale(1) rotate(0deg); }
}

@keyframes result-arrive {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media (max-width: 820px) {
  .home-shell {
    padding: 18px 16px 24px;
  }

  .gacha-stage {
    width: 100%;
    gap: 10px;
  }

  .machine-button {
    --capsule-eject-x: clamp(6px, 1.8vw, 12px);
    --capsule-eject-mid-y: clamp(30px, 9vw, 54px);
    --capsule-eject-end-y: clamp(48px, 14vw, 82px);
    width: min(340px, 72vw);
  }

  .limit-toast {
    margin-top: -4px;
  }

  .hand-cursor {
    display: none;
  }
}

@media (max-width: 520px) {
  .overlay {
    align-items: start;
    padding: 14px 12px max(28px, env(safe-area-inset-bottom));
  }

  .home-shell {
    padding-right: 8px;
    padding-left: 8px;
  }

  .home-copy h1 {
    font-size: clamp(2rem, 11vw, 2.8rem);
  }

  .home-title-row {
    gap: 6px;
  }

  .rules-open {
    width: 32px;
    height: 32px;
    margin-top: 0.36em;
    font-size: 15px;
  }

  .home-copy p {
    font-size: 0.98rem;
  }

  .machine-button {
    width: min(220px, 52vw);
    filter: drop-shadow(0 18px 20px rgba(132, 78, 44, 0.22));
  }

  .instruction-sheet {
    padding: 22px 18px 34px;
    max-height: calc(100dvh - 32px);
  }

  .upload-dropzone {
    min-height: 48px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px 12px;
    border-style: solid;
    background: rgba(255, 255, 255, 0.62);
  }

  .upload-title {
    width: 100%;
  }

  .upload-file {
    width: 100%;
    line-height: 1.3;
  }

  .upload-preview {
    width: min(104px, 34vw);
    max-height: 76px;
  }

  .spin-result[data-result-type="question"] {
    width: calc(100vw - 28px);
    max-height: calc(100dvh - 96px);
    overflow: auto;
  }

  .spin-result[data-result-type="question"] .opened-capsule {
    top: 88px;
    width: 118px;
  }

  .spin-result[data-result-type="question"] .paper-note {
    margin-top: 140px;
    padding: 20px 16px;
  }

  .spin-result[data-result-type="question"] .paper-note p[data-result-text] {
    max-height: 5.8em;
    overflow: auto;
    font-size: 1rem;
    line-height: 1.65;
  }

  .spin-result[data-result-type="question"] .question-response textarea {
    min-height: 76px;
  }

  .spin-result[data-result-type="question"] .result-actions {
    margin-top: 10px;
  }

  .pool-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
