:root {
  color-scheme: light;
  --page-bg: #f5f2ed;
  --page-pattern: rgba(255, 157, 109, 0.08);
  --page-stripe: rgba(255, 255, 255, 0.42);
  --panel: #fffdf9;
  --panel-strong: #ffffff;
  --ink: #302a27;
  --muted: #786f69;
  --line: #e7ddd5;
  --accent: #ef774f;
  --accent-strong: #db5d37;
  --accent-soft: #ffeadc;
  --focus: #1468b3;
  --danger: #bd3f3f;
  --shadow: 0 18px 50px rgba(68, 46, 33, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --normal-a: #fff4e7;
  --normal-b: #ffc99e;
  --sr-a: #f8fbff;
  --sr-b: #9ca9b8;
  --ssr-a: #fff4a9;
  --ssr-b: #c99316;
  --capture-bg: linear-gradient(145deg, #fffaf1 0%, #fff 48%, #fff3e9 100%);
  --stage-bg: rgba(255, 255, 255, 0.72);
  --wheel-border: #ffffff;
  --history-bg: rgba(255, 255, 255, 0.78);
  --spin-duration: 4000ms;
  font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--page-bg);
  background-image:
    radial-gradient(circle at 12px 12px, var(--page-pattern) 2px, transparent 2.5px),
    linear-gradient(135deg, transparent 0 49%, var(--page-stripe) 49% 51%, transparent 51% 100%);
  background-size: 28px 28px, 110px 110px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="checkbox"],
input[type="radio"],
summary,
.file-button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.file-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 48%, transparent);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1760px;
  margin: 0 auto;
  padding: 24px clamp(18px, 3vw, 44px) 14px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(1.35rem, 2.2vw, 2.25rem);
  letter-spacing: 0.02em;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.comparison-chip,
.count-chip,
.capture-hint {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.header-theme-control {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 5px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(68, 46, 33, 0.1);
}

.header-theme-control:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.theme-symbol {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: #8a5b00;
  background: #ffd769;
  font-size: 1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(390px, 1.15fr) minmax(360px, 1fr) minmax(280px, 0.78fr);
  gap: clamp(12px, 1.25vw, 20px);
  width: min(1760px, calc(100% - clamp(24px, 5vw, 72px)));
  margin: 0 auto;
  padding-bottom: 20px;
  align-items: start;
}

.capture-module,
.control-panel,
.settings-column {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.capture-module {
  position: sticky;
  top: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(126px, 27%);
  min-width: 0;
  overflow: hidden;
  background: var(--capture-bg);
  isolation: isolate;
}

.capture-module::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 8%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 32%),
    radial-gradient(circle at 92% 72%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 36%);
}

.capture-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 10px;
}

.capture-heading > div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.capture-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-label {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
}

.visual-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(360px, 40vw, 620px);
  margin: 0 18px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  border-radius: calc(var(--radius-xl) - 5px);
  background: var(--stage-bg);
}

.roulette-view,
.slot-view,
.gacha-view,
.empty-stage {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
}

.roulette-view,
.slot-view,
.gacha-view {
  display: grid;
  place-items: center;
}

.wheel-wrap {
  position: relative;
  width: min(80%, 46vh, 520px);
  aspect-ratio: 1;
  filter: drop-shadow(0 18px 24px rgba(50, 30, 20, 0.17));
}

#wheel-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 10px solid var(--wheel-border);
  border-radius: 50%;
  background: var(--panel-strong);
  transition: transform var(--spin-duration) cubic-bezier(0.12, 0.72, 0.16, 1);
}

#wheel-canvas.is-instant {
  transition: none;
}

.pointer {
  position: absolute;
  z-index: 4;
  top: -7px;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 0;
  border-right: 19px solid transparent;
  border-bottom: 48px solid var(--accent-strong);
  border-left: 19px solid transparent;
  filter: drop-shadow(0 5px 2px rgba(34, 22, 18, 0.24));
  transform: translateX(-50%) rotate(180deg);
  transform-origin: center;
}

.wheel-hub {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  width: 21%;
  padding: 0;
  aspect-ratio: 1;
  place-items: center;
  border: 8px solid var(--panel-strong);
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(50, 30, 20, 0.2);
  transform: translate(-50%, -50%);
  transition: filter 160ms ease, transform 160ms ease;
}

.wheel-hub span {
  font-size: clamp(0.95rem, 1.7vw, 1.35rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.wheel-hub:hover:not(:disabled) {
  filter: brightness(1.08) saturate(1.08);
  transform: translate(-50%, -50%) scale(1.04);
}

.wheel-hub:disabled {
  opacity: 1;
}

.slot-view[data-spin-trigger],
.gacha-view[data-spin-trigger] {
  cursor: pointer;
}

.empty-stage {
  display: grid;
  max-width: 430px;
  padding: 40px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.result-card {
  position: absolute;
  z-index: 8;
  cursor: pointer;
  top: 50%;
  left: 50%;
  display: flex;
  width: min(78%, 560px);
  min-height: 170px;
  padding: 24px 30px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 9px;
  border: 4px solid var(--panel-strong);
  border-radius: 24px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 60px rgba(35, 23, 18, 0.28);
  text-align: center;
  transform: translate(-50%, -50%) scale(1);
  animation: result-in 520ms cubic-bezier(0.2, 1.25, 0.42, 1) both;
}

.result-card[data-rarity="sr"] {
  border-color: #e8edf3;
  background: linear-gradient(145deg, #ffffff, #d7dee7 52%, #ffffff);
  box-shadow: 0 24px 70px rgba(83, 98, 118, 0.32);
}

.result-card[data-rarity="ssr"],
.result-card[data-rarity="hidden_ssr"] {
  border-color: #fff3a0;
  background: linear-gradient(135deg, #fff9c9, #d49b1f 48%, #fff5a8 77%, #fffdf0);
  box-shadow: 0 24px 80px rgba(181, 126, 8, 0.42);
}

.result-card.is-mystery strong {
  font-size: clamp(2.5rem, 8vw, 5.5rem);
  letter-spacing: 0.12em;
}

.result-kicker {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 1000;
  letter-spacing: 0.16em;
}

.result-card strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(1.3rem, 3vw, 2.4rem);
  line-height: 1.35;
}

.rarity-badge,
.history-rarity,
.import-preview-rarity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 1000;
}

.rarity-normal {
  color: #6b4c36;
  background: var(--normal-a);
}

.rarity-sr {
  color: #4e5c6d;
  background: linear-gradient(135deg, var(--sr-a), var(--sr-b));
}

.rarity-ssr,
.rarity-hidden_ssr {
  color: #6c4900;
  background: linear-gradient(135deg, var(--ssr-a), var(--ssr-b));
}

.history-panel {
  display: flex;
  min-height: 0;
  margin: 14px 18px 18px;
  padding: 17px;
  flex-direction: column;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: var(--radius-lg);
  background: var(--history-bg);
}

.section-title-row,
.compact-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-title-row h2,
.compact-heading h2,
.dialog-heading h2 {
  margin: 2px 0 0;
  font-size: 1.02rem;
}

.section-title-row.compact {
  margin-bottom: 11px;
}

.history-list {
  display: grid;
  min-height: 0;
  max-height: 218px;
  margin-top: 11px;
  overflow: auto;
  gap: 7px;
  scrollbar-color: var(--accent-soft) transparent;
}

.history-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  min-height: 46px;
  padding: 8px 10px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
}

.history-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.returned-label {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

.restore-button,
.text-button,
.delete-candidate {
  border: 0;
  color: var(--accent-strong);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 900;
}

.restore-button,
.delete-candidate {
  padding: 6px 9px;
  border-radius: 9px;
  background: var(--accent-soft);
}

.control-panel {
  min-width: 0;
  padding: 18px;
  background: var(--panel);
}

.settings-column {
  display: grid;
  min-width: 0;
  padding: 18px;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--panel);
}

.set-select {
  width: 100%;
}

.input-heading {
  margin-bottom: 9px;
}

.set-switch-row {
  display: grid;
  margin-bottom: 13px;
  padding-bottom: 13px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  border-bottom: 1px solid var(--line);
}

.set-switch-row button {
  min-height: 40px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--panel);
  font-size: 0.76rem;
  font-weight: 900;
}

.input-section,
.candidate-section {
  margin-bottom: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
}

.danger-quiet {
  color: var(--danger);
}

.add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 106px 104px;
  gap: 7px;
}

input,
select,
textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--panel-strong);
}

input,
textarea {
  width: 100%;
  padding: 9px 11px;
}

select {
  padding: 7px 29px 7px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.add-button,
.primary-button {
  border: 0;
  border-radius: 11px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 900;
}

.field-note,
.dialog-note {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.55;
}

.input-footer-row {
  display: grid;
  margin-top: 8px;
  grid-template-columns: minmax(0, 1fr) 106px 104px;
  align-items: center;
  gap: 7px;
}

.input-footer-row .field-note {
  grid-column: 1 / 3;
  margin: 0 2px;
}

.input-footer-row .text-button {
  grid-column: 3;
  justify-self: stretch;
  text-align: center;
}

.candidate-list {
  display: grid;
  max-height: 390px;
  overflow: auto;
  gap: 7px;
}

.candidate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 8px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 62%, transparent);
}

.candidate-row.candidate-rarity-hidden_ssr,
.candidate-row.candidate-rarity-ssr {
  border-color: color-mix(in srgb, #e6b730 78%, var(--line));
  background: color-mix(in srgb, #e6b730 13%, var(--panel-strong));
  box-shadow: inset 4px 0 0 #e6b730;
}

.candidate-row.candidate-rarity-sr {
  border-color: color-mix(in srgb, #aab4c4 76%, var(--line));
  background: color-mix(in srgb, #c7cfda 13%, var(--panel-strong));
  box-shadow: inset 4px 0 0 #aab4c4;
}

.candidate-row.candidate-rarity-hidden_ssr .candidate-text {
  color: color-mix(in srgb, #c99400 84%, var(--ink));
  font-weight: 1000;
  letter-spacing: 0.18em;
  text-align: center;
}

.candidate-row .candidate-text:disabled {
  opacity: 1;
  cursor: not-allowed;
  -webkit-text-fill-color: currentColor;
}

.candidate-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 102px;
  gap: 7px;
}

.candidate-main input,
.candidate-main select {
  min-height: 36px;
  font-size: 0.86rem;
}

.candidate-main input {
  padding: 6px 8px;
}

.settings-panel {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
}

.settings-panel summary {
  display: flex;
  min-height: 54px;
  padding: 13px 15px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 900;
  list-style: none;
}

.settings-panel summary::-webkit-details-marker {
  display: none;
}

.settings-summary-title {
  display: grid;
  gap: 2px;
}

.settings-body {
  display: grid;
  min-height: 0;
  padding: 0 15px 15px;
  gap: 11px;
}

.developer-card {
  display: grid;
  margin: 0 15px 15px;
  padding: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--panel) 76%, transparent);
}

.developer-main-link {
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}

.developer-main-link:hover strong {
  color: var(--accent-strong);
  text-decoration: underline;
}

.developer-icon {
  display: block;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 0;
  object-fit: contain;
}

.developer-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.developer-copy small {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
}

.developer-copy strong {
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.developer-links {
  display: grid;
  gap: 4px;
}

.developer-links a {
  display: flex;
  min-height: 27px;
  padding: 4px 8px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--panel-strong);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.developer-links a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.toggle-row,
.select-row,
.range-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toggle-row + .toggle-row,
.toggle-row + .select-row,
.select-row + .toggle-row,
.range-row + .toggle-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.toggle-row span,
.select-row span {
  display: flex;
  flex-direction: column;
}

.toggle-row small,
.select-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

input[type="checkbox"] {
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.range-row input {
  width: 58%;
  min-height: auto;
  accent-color: var(--accent);
}

.compact-settings-field {
  padding: 8px 11px 9px;
}

.compact-setting-row {
  min-height: 34px;
}

.sound-settings-row {
  display: grid;
  margin-top: 5px;
  padding-top: 7px;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--line);
}

.compact-sound-toggle,
.compact-volume {
  display: flex;
  min-width: 0;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
}

.compact-volume input {
  width: 100%;
  min-width: 58px;
  min-height: auto;
  accent-color: var(--accent);
}

.button-stack {
  display: grid;
  gap: 7px;
}

.help-button-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button-stack button,
.file-button {
  display: grid;
  min-height: 39px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--panel);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.policy-links {
  display: grid;
  margin-top: 9px;
  padding-top: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border-top: 1px solid var(--line);
}

.policy-links a {
  display: grid;
  min-height: 30px;
  padding: 5px 6px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 0.67rem;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
}

.policy-links a:hover {
  text-decoration: underline;
}

.page-about {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--panel) 68%, transparent);
}

.page-about h2 {
  margin: 2px 0 7px;
  font-size: 0.86rem;
}

.page-about h3 {
  margin: 0 0 7px;
  font-size: 0.92rem;
}

.page-about p:not(.section-kicker) {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.55;
}

.legal-document {
  min-height: 100vh;
}

.legal-topbar,
.legal-card {
  width: min(860px, calc(100% - 28px));
  margin-right: auto;
  margin-left: auto;
}

.legal-topbar {
  padding: 22px 0 12px;
}

.legal-back-link {
  color: var(--accent-strong);
  font-weight: 900;
  text-decoration: none;
}

.legal-back-link:hover {
  text-decoration: underline;
}

.legal-card {
  margin-bottom: 36px;
  padding: clamp(20px, 4vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.legal-card h1 {
  margin: 0 0 12px;
  font-size: clamp(1.45rem, 4vw, 2rem);
}

.legal-card h2 {
  margin: 28px 0 8px;
  font-size: 1.08rem;
}

.legal-card h3 {
  margin: 18px 0 6px;
  font-size: 0.96rem;
}

.legal-card p,
.legal-card li {
  font-size: 0.88rem;
  line-height: 1.8;
}

.legal-card ul {
  padding-left: 1.5em;
}

.legal-card a {
  color: var(--accent-strong);
}

.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.status-message {
  min-height: 24px;
  padding: 9px 4px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-message.is-error {
  color: var(--danger);
}

dialog {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-xl);
  color: var(--ink);
  background: var(--panel-strong);
  box-shadow: 0 32px 100px rgba(25, 17, 13, 0.38);
}

dialog::backdrop {
  background: rgba(39, 27, 22, 0.54);
  backdrop-filter: blur(5px);
}

.dialog-card {
  display: grid;
  padding: 23px;
  gap: 12px;
}

.wide-dialog {
  width: min(760px, calc(100% - 28px));
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--panel);
  font-size: 1.4rem;
}

.dialog-actions {
  display: flex;
  margin-top: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-actions button {
  min-height: 42px;
  padding: 8px 17px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--panel);
  font-weight: 900;
}

.dialog-actions .primary-button {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.dialog-actions .danger-button {
  border-color: var(--danger);
  color: #ffffff;
  background: var(--danger);
}

dialog.import-preview-dialog {
  width: min(720px, calc(100% - 28px));
  overflow: hidden;
}

.import-preview-card {
  width: 100%;
  max-height: calc(100vh - 40px);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
}

.import-preview-card > p {
  margin: 0;
  line-height: 1.6;
}

.import-preview-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.import-preview-count {
  display: inline-flex;
  min-height: 28px;
  padding: 4px 10px;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

.import-preview-list {
  display: grid;
  min-height: 110px;
  max-height: min(44vh, 420px);
  padding: 5px;
  overflow-y: auto;
  align-content: start;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--panel) 82%, var(--page-bg));
}

.import-preview-row {
  display: grid;
  min-width: 0;
  padding: 8px 9px;
  grid-template-columns: 2.1rem 5.4rem minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border-radius: 9px;
  background: var(--panel-strong);
}

.import-preview-number {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: right;
}

.import-preview-rarity {
  min-width: 0;
  white-space: nowrap;
}

.import-preview-text {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  line-height: 1.45;
}

.choice-guide {
  display: grid;
  gap: 8px;
}

.choice-guide button {
  display: flex;
  margin: 0;
  padding: 10px 12px;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
}

.choice-guide button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.choice-guide .restore-choice {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--accent-soft);
}

.choice-guide .delete-choice {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--line));
  background: color-mix(in srgb, var(--danger) 9%, var(--panel));
}

.choice-guide span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

dialog.help-dialog {
  width: min(900px, calc(100% - 28px));
}

dialog.usage-info-dialog {
  width: min(680px, calc(100% - 28px));
}

.usage-info-card {
  width: 100%;
}

.usage-info-card .page-about {
  padding: 16px;
}

.usage-info-card .page-about p:not(.section-kicker) {
  font-size: 0.8rem;
}

.usage-info-card .policy-links {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.usage-info-card .policy-links a {
  min-height: 42px;
  font-size: 0.75rem;
}

.help-dialog-card {
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.help-panel {
  display: grid;
  gap: 14px;
}

.help-lead {
  margin: 0;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--accent-soft);
  font-weight: 800;
  line-height: 1.65;
}

.help-step-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.help-step {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.help-step h3 {
  display: flex;
  margin: 10px 0 5px;
  align-items: center;
  gap: 7px;
  font-size: 0.94rem;
}

.help-step h3 span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.75rem;
}

.help-step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.guide-picture {
  display: flex;
  min-height: 74px;
  padding: 12px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  overflow: hidden;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent-soft) 65%, var(--panel-strong));
}

.guide-select-picture span,
.guide-add-picture span {
  min-width: 0;
  padding: 9px 10px;
  overflow: hidden;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-select-picture b,
.guide-add-picture b {
  padding: 9px 10px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.7rem;
}

.guide-wheel {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 5px solid #ffffff;
  border-radius: 50%;
  background: conic-gradient(#ffc397 0 25%, #e6b730 0 37.5%, #ffe1c6 0 72%, #bdc5cf 0);
  box-shadow: 0 4px 12px rgba(48, 32, 24, 0.16);
}

.guide-wheel b {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.63rem;
}

.guide-history-picture {
  flex-direction: column;
  align-items: stretch;
}

.guide-history-picture span {
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--panel-strong);
  font-size: 0.67rem;
}

.guide-history-picture b {
  align-self: flex-end;
  color: var(--accent-strong);
  font-size: 0.66rem;
}

.help-note-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.help-note-grid > div {
  display: flex;
  padding: 11px 12px;
  flex-direction: column;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}

.help-note-grid span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.streamer-help-inline {
  display: grid;
  margin-top: 4px;
  padding-top: 15px;
  gap: 10px;
  border-top: 2px solid color-mix(in srgb, var(--accent) 38%, var(--line));
}

.streamer-help-inline h3 {
  margin: 0;
  font-size: 1rem;
}

.streamer-help-inline > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.65;
}

.streamer-help-inline > p strong {
  color: var(--ink);
}

.capture-example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.capture-example-grid figure {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.capture-example-grid figcaption {
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.mini-app-picture {
  position: relative;
  display: grid;
  min-height: 126px;
  padding: 6px;
  grid-template-columns: 1.2fr 1fr 0.75fr;
  gap: 5px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--line) 45%, transparent);
}

.mini-app-picture::after {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  border: 3px dashed var(--accent);
  border-radius: 10px;
  content: "";
  pointer-events: none;
}

.capture-wheel-only::after { width: calc(40% - 1px); }
.capture-wheel-input::after { width: calc(74% - 2px); }

.mini-app-picture > div {
  display: flex;
  min-width: 0;
  padding: 6px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 7px;
  color: var(--muted);
  background: var(--panel-strong);
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
}

.mini-wheel-column i {
  display: block;
  width: 54px;
  height: 54px;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: conic-gradient(#ffc397 0 35%, #e6b730 0 50%, #ffe1c6 0 78%, #bdc5cf 0);
}

.capture-wheel-only .mini-input-column,
.capture-wheel-only .mini-settings-column,
.capture-wheel-input .mini-settings-column {
  opacity: 0.34;
}


.confirm-card {
  width: min(460px, 100%);
}

.confirm-card > p {
  margin: 2px 0 8px;
  line-height: 1.7;
}

.slot-machine {
  position: relative;
  width: min(76%, 610px);
  padding: clamp(35px, 6vw, 74px) clamp(28px, 5vw, 66px);
  border: 12px solid #ffd54a;
  border-radius: 48px 48px 28px 28px;
  background: linear-gradient(145deg, #f03849, #7d1839 82%);
  box-shadow:
    0 24px 30px rgba(45, 12, 27, 0.28),
    inset 0 0 0 5px #ffef9c;
}

.slot-title {
  margin: 0 0 18px;
  color: #fff7c2;
  font-size: clamp(1rem, 2.5vw, 1.9rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 3px 0 #6a1733;
}

.slot-window {
  display: grid;
  min-height: 170px;
  padding: 16px;
  overflow: hidden;
  place-items: center;
  border: 10px solid #2d1632;
  border-radius: 22px;
  background:
    repeating-linear-gradient(180deg, #fff 0 42px, #f2ecff 42px 44px);
  box-shadow: inset 0 10px 22px rgba(19, 8, 23, 0.25);
}

.slot-item {
  width: 100%;
  padding: 22px 14px;
  overflow: hidden;
  color: #25132e;
  font-size: clamp(1.2rem, 3vw, 2.4rem);
  font-weight: 1000;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-item.is-spinning {
  animation: slot-drop 140ms linear infinite;
}

.slot-lights {
  position: absolute;
  inset: 10px;
  border: 5px dotted #fff4a8;
  border-radius: 30px;
  pointer-events: none;
}

.slot-bar {
  position: absolute;
  right: -44px;
  bottom: 20%;
  width: 34px;
  height: 120px;
  border: 8px solid #ffcf3a;
  border-radius: 18px;
  background: #74223d;
}

.gacha-machine {
  position: relative;
  width: min(68%, 520px);
  padding-bottom: 40px;
}

.gacha-dome {
  position: relative;
  z-index: 2;
  width: 76%;
  margin: 0 auto -35px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 12px solid #ffffff;
  border-radius: 50%;
  background: rgba(184, 235, 255, 0.72);
  box-shadow: inset 0 -28px 0 rgba(70, 162, 207, 0.16), 0 18px 28px rgba(90, 68, 87, 0.18);
}

.gacha-body {
  position: relative;
  z-index: 3;
  min-height: 260px;
  padding-top: 62px;
  border: 10px solid #ffffff;
  border-radius: 45px 45px 72px 72px;
  background: linear-gradient(145deg, #ff96b6, #ffca6c);
  box-shadow: 0 24px 35px rgba(95, 52, 61, 0.22);
  text-align: center;
}

.gacha-body p {
  margin: 0;
  color: #84324f;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.gacha-knob {
  width: 108px;
  height: 108px;
  margin: 20px auto 0;
  border: 13px solid #ffffff;
  border-radius: 50%;
  background: #64c8dc;
  box-shadow: inset 0 -12px 0 rgba(26, 119, 142, 0.18), 0 8px 13px rgba(80, 46, 54, 0.18);
}

.gacha-knob::after {
  display: block;
  width: 72px;
  height: 20px;
  margin: 30px auto;
  border-radius: 999px;
  background: #ffffff;
  content: "";
}

.gacha-exit {
  width: 45%;
  height: 48px;
  margin: 22px auto 0;
  border-radius: 15px 15px 28px 28px;
  background: #7c3851;
  box-shadow: inset 0 10px 0 rgba(50, 15, 28, 0.25);
}

.capsule-ball,
.drop-capsule {
  position: absolute;
  width: 29%;
  aspect-ratio: 1;
  border: 5px solid #ffffff;
  border-radius: 50%;
  box-shadow: inset 0 -10px 0 rgba(86, 37, 62, 0.12);
}

.ball-a { left: 7%; bottom: 4%; background: #ffcc4d; }
.ball-b { left: 35%; bottom: -2%; background: #7ee3d6; }
.ball-c { right: 4%; bottom: 9%; background: #ff7cab; }
.ball-d { left: 18%; bottom: 30%; background: #b69cff; }
.ball-e { right: 18%; bottom: 34%; background: #ff9c64; }

.gacha-machine.is-spinning .gacha-dome {
  animation: gacha-shake 320ms ease-in-out infinite;
}

.gacha-machine.is-spinning .capsule-ball {
  animation: ball-jump 420ms ease-in-out infinite alternate;
}

.gacha-machine.is-spinning .gacha-knob {
  animation: knob-turn 800ms ease-in-out infinite;
}

.drop-capsule {
  z-index: 5;
  right: 8%;
  bottom: -10px;
  width: 86px;
  border-width: 7px;
  background: linear-gradient(180deg, #ffd84d 0 50%, #ff799f 50% 100%);
  opacity: 0;
}

.drop-capsule.is-dropping {
  animation: capsule-drop 720ms cubic-bezier(0.2, 1.2, 0.45, 1) both;
}

.theme-dark {
  color-scheme: dark;
  --page-bg: #12131a;
  --page-pattern: rgba(131, 142, 255, 0.035);
  --page-stripe: rgba(111, 118, 148, 0.055);
  --panel: #1c1e28;
  --panel-strong: #252834;
  --ink: #f3f3f8;
  --muted: #a9abba;
  --line: #383c4d;
  --accent: #7d7ff1;
  --accent-strong: #a381ff;
  --accent-soft: #30314d;
  --focus: #9fcaff;
  --danger: #d95c6a;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
  --normal-a: #34394a;
  --normal-b: #565d76;
  --capture-bg: linear-gradient(145deg, #171924, #202330 55%, #141620);
  --stage-bg: rgba(12, 14, 21, 0.56);
  --wheel-border: #34384a;
  --history-bg: rgba(24, 27, 38, 0.78);
}

.theme-dark .rarity-normal {
  color: #eef0ff;
}

.theme-dark .result-card {
  background: rgba(30, 33, 46, 0.96);
}

.theme-arcade {
  --page-bg: #16101f;
  --page-pattern: rgba(255, 213, 74, 0.08);
  --panel: #261731;
  --panel-strong: #321c3e;
  --ink: #fff7d2;
  --muted: #d6bddc;
  --line: #5b2e69;
  --accent: #f4385a;
  --accent-strong: #ffcc37;
  --accent-soft: #4b213f;
  --focus: #7ee7ff;
  --danger: #ff6174;
  --shadow: 0 18px 60px rgba(13, 2, 20, 0.48);
  --capture-bg: linear-gradient(155deg, #1b0e27, #3f163d 55%, #111329);
  --stage-bg: rgba(15, 7, 25, 0.64);
  --history-bg: rgba(33, 17, 45, 0.84);
}

.theme-pop {
  --page-bg: #fff4f8;
  --page-pattern: rgba(255, 118, 166, 0.09);
  --panel: #fffafd;
  --panel-strong: #ffffff;
  --ink: #55344a;
  --muted: #866f7d;
  --line: #f0d4e0;
  --accent: #ee6b9d;
  --accent-strong: #d34d83;
  --accent-soft: #ffe4ef;
  --focus: #1f83ad;
  --danger: #c54562;
  --shadow: 0 18px 55px rgba(124, 67, 88, 0.16);
  --capture-bg: linear-gradient(145deg, #fff8b9, #fff6fb 40%, #e8fbff 100%);
  --stage-bg: rgba(255, 255, 255, 0.7);
  --history-bg: rgba(255, 255, 255, 0.82);
}

.is-hidden {
  display: none !important;
}

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

@keyframes result-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.78); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes slot-drop {
  from { transform: translateY(-78px); filter: blur(3px); }
  to { transform: translateY(78px); filter: blur(3px); }
}

@keyframes gacha-shake {
  0%, 100% { transform: rotate(-1.2deg); }
  50% { transform: rotate(1.2deg); }
}

@keyframes ball-jump {
  from { transform: translateY(0) rotate(0); }
  to { transform: translateY(-18px) rotate(16deg); }
}

@keyframes knob-turn {
  0%, 20% { transform: rotate(0); }
  70%, 100% { transform: rotate(180deg); }
}

@keyframes capsule-drop {
  0% { opacity: 0; transform: translateY(-100px) rotate(-22deg) scale(0.7); }
  35% { opacity: 1; }
  72% { transform: translateY(2px) rotate(10deg) scale(1); }
  100% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

@media (min-width: 1180px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    width: 100%;
    padding-top: 12px;
    padding-bottom: 9px;
  }

  .topbar h1 {
    font-size: clamp(1.25rem, 1.7vw, 1.8rem);
  }

  .app-shell {
    height: 100%;
    min-height: 0;
    padding-bottom: 12px;
    align-items: stretch;
  }

  .capture-module {
    position: relative;
    top: auto;
    height: 100%;
  }

  .capture-heading {
    padding-top: 12px;
    padding-bottom: 7px;
  }

  .visual-stage {
    min-height: 0;
  }

  .history-list {
    flex: 1;
    max-height: none;
  }

  .input-panel {
    display: flex;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
  }

  .input-panel .candidate-section {
    display: flex;
    min-height: 0;
    margin-bottom: 0;
    flex: 1;
    flex-direction: column;
  }

  .input-panel .candidate-list {
    min-height: 0;
    max-height: none;
    flex: 1;
    grid-auto-rows: 54px;
    align-content: start;
  }

  .settings-column {
    height: 100%;
    min-height: 0;
  }

  .settings-panel {
    display: grid;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .settings-body {
    overflow: auto;
    scrollbar-color: var(--accent-soft) transparent;
  }

  html.legal-document-root,
  html.legal-document-root body {
    height: auto;
    overflow: auto;
  }

  html.legal-document-root body {
    display: block;
  }
}

@media (max-width: 1179px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    width: min(820px, calc(100% - 24px));
  }

  .capture-module {
    position: relative;
    top: auto;
  }

  .visual-stage {
    min-height: min(86vw, 680px);
  }

  .control-panel,
  .settings-column {
    display: contents;
  }

  .input-section,
  .candidate-section,
  .settings-panel,
  .status-message {
    grid-column: 1;
  }

  .input-section { order: 1; }
  .candidate-section { order: 2; }
  .settings-panel { order: 3; }
  .status-message { order: 4; }
}

@media (max-width: 620px) {
  .topbar {
    padding: 17px 13px 10px;
  }

  .topbar h1 {
    font-size: 1.2rem;
  }

  .capture-hint {
    display: none;
  }

  .app-shell {
    width: calc(100% - 16px);
    gap: 10px;
  }

  .capture-module,
  .settings-panel {
    border-radius: 19px;
  }

  .capture-heading {
    padding: 13px 13px 8px;
  }

  .visual-stage {
    min-height: calc(100vw - 42px);
    margin: 0 8px;
    border-radius: 15px;
  }

  .wheel-wrap {
    width: 94%;
  }

  #wheel-canvas {
    border-width: 6px;
  }

  .pointer {
    border-right-width: 13px;
    border-bottom-width: 34px;
    border-left-width: 13px;
  }

  .history-panel {
    margin: 9px 8px 8px;
    padding: 12px;
  }

  .history-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .returned-label {
    display: none;
  }

  .control-panel {
    padding: 0;
  }

  .add-form {
    grid-template-columns: minmax(0, 1fr) 92px;
  }

  .input-footer-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .input-footer-row .field-note {
    grid-column: 1;
  }

  .input-footer-row .text-button {
    grid-column: 2;
  }

  .add-button {
    grid-column: 1 / -1;
    min-height: 40px;
  }

  .candidate-main {
    grid-template-columns: minmax(0, 1fr) 98px;
  }

  .dialog-card {
    padding: 18px;
  }

  .import-preview-row {
    padding: 7px;
    grid-template-columns: 1.7rem 4.8rem minmax(0, 1fr);
    gap: 6px;
  }

  .import-preview-rarity {
    min-width: 0;
    padding-inline: 6px;
  }

  .help-step-grid,
  .help-note-grid,
  .capture-example-grid {
    grid-template-columns: 1fr;
  }


  .slot-machine {
    width: 82%;
    border-width: 7px;
  }

  .slot-window {
    min-height: 118px;
    border-width: 6px;
  }

  .slot-bar {
    display: none;
  }

  .gacha-machine {
    width: 76%;
  }
}
