.gacha-page [hidden],
.gacha-hit-layer[hidden] { display: none !important; }

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

.gacha-simulator-page.gacha-hit-open { overflow: hidden; }

.gacha-simulator-page .update-strip { display: none; }

.gacha-page {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 7px 8px 42px;
  background: #f4f4f1;
}

.gacha-intro {
  padding: 3px 2px 6px;
}

.gacha-intro span,
.gacha-presets__head span,
.gacha-result-heading span,
.gacha-advanced-heading > span {
  display: block;
  color: #806b00;
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.gacha-intro h1 {
  margin: 1px 0 0;
  font-size: clamp(0.98rem, 4.2vw, 1.55rem);
  line-height: 1.2;
}

#gacha-simulator-form {
  display: grid;
  gap: 7px;
}

.gacha-card {
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid #cececa;
  background: var(--th-white);
}

.gacha-presets {
  padding: 7px;
  border: 2px solid var(--th-black);
  box-shadow: 3px 3px 0 var(--th-yellow);
}

.gacha-presets__head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.gacha-presets__head h2 {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.2;
}

.gacha-presets__head > strong {
  flex: 0 0 auto;
  padding: 2px 5px;
  background: var(--th-yellow);
  font-size: 0.57rem;
}

.gacha-preset-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.gacha-preset {
  display: grid;
  min-width: 0;
  min-height: 38px;
  padding: 4px 2px;
  place-content: center;
  border: 1px solid #8f8f8b;
  background: var(--th-white);
  color: var(--th-black);
  cursor: pointer;
  text-align: center;
}

.gacha-preset strong {
  overflow-wrap: anywhere;
  font-size: clamp(0.56rem, 2.4vw, 0.72rem);
  line-height: 1.15;
}

.gacha-preset span { display: none; }
.gacha-preset:hover { background: #fff8c4; }
.gacha-preset:focus-visible { outline: 3px solid #1a73e8; outline-offset: 1px; }

.gacha-preset.is-selected {
  border-color: var(--th-black);
  background: var(--th-yellow);
  box-shadow: 2px 2px 0 var(--th-black);
}

.gacha-preset--custom { background: var(--th-black); color: var(--th-yellow); }
.gacha-preset--custom.is-selected { background: var(--th-yellow); color: var(--th-black); }

.gacha-preset-note {
  margin: 5px 0 0;
  color: var(--th-gray-600);
  font-size: 0.56rem;
  line-height: 1.35;
}

.gacha-results-panel {
  min-width: 0;
  border: 2px solid var(--th-black);
  background: var(--th-white);
}

.gacha-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  padding: 18px;
  place-content: center;
  background: rgba(255, 255, 255, 0.72);
  pointer-events: none;
  text-align: center;
}

.gacha-empty[hidden] { display: none !important; }
.gacha-empty strong { font-size: clamp(0.9rem, 4vw, 1.2rem); }
.gacha-empty span { margin-top: 4px; color: var(--th-gray-600); font-size: 0.58rem; }

#gacha-result-content { padding: 7px; }

.gacha-result-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 7px;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 3px solid var(--th-black);
}

.gacha-result-heading h2 { margin: 0; font-size: 0.85rem; }

.gacha-result-heading > strong {
  flex: 0 0 auto;
  padding: 4px 6px;
  background: var(--th-yellow);
  font-size: 0.65rem;
}

.gacha-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}

.gacha-stat {
  min-width: 0;
  padding: 6px 4px;
  border: 1px solid #cececa;
  background: #fafafa;
}

.gacha-stat span {
  display: block;
  color: var(--th-gray-600);
  font-size: 0.51rem;
  font-weight: 700;
  white-space: nowrap;
}

.gacha-stat strong {
  display: block;
  margin-top: 1px;
  overflow-wrap: anywhere;
  font-size: clamp(0.66rem, 3vw, 1rem);
  line-height: 1.2;
}

.gacha-stat--profit.is-positive strong { color: #bc2118; }
.gacha-stat--profit.is-negative strong { color: #1467a5; }

.gacha-result-card {
  min-width: 0;
  margin: 0;
  padding: 7px;
  border: 1px solid #cececa;
  background: var(--th-white);
}

.gacha-result-card + .gacha-result-card { margin-top: 6px; }

.gacha-result-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.gacha-result-card__head h3 { margin: 0; font-size: 0.75rem; }
.gacha-result-card__head span { color: var(--th-gray-600); font-size: 0.53rem; }

.gacha-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 148px;
  overflow: hidden;
}

#gacha-profit-chart {
  display: block;
  width: 100%;
  height: 148px;
}

.gacha-chart-wrap.is-empty #gacha-profit-chart { opacity: 0.72; }

.gacha-prize-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.gacha-count-chip {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 5px;
  border-left: 4px solid var(--th-yellow);
  background: #f4f4f1;
  font-size: 0.57rem;
}

.gacha-count-chip strong { font-size: 0.69rem; }

.gacha-draw-card { padding: 0; border: 0; background: transparent; }

.gacha-draw-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  padding: 0 2px 4px;
  font-size: 0.61rem;
}

.gacha-draw-meta > span {
  padding: 2px 6px;
  background: var(--th-black);
  color: var(--th-white);
  white-space: nowrap;
}

.gacha-draw-meta b { color: var(--th-yellow); }

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

.gacha-draw-options label { cursor: pointer; }

.gacha-draw-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.gacha-draw-options span {
  display: grid;
  min-height: 38px;
  padding: 3px;
  place-items: center;
  border: 2px solid var(--th-black);
  background: var(--th-white);
  font-size: 0.72rem;
  font-weight: 800;
}

.gacha-draw-options input:checked + span {
  background: var(--th-yellow);
  box-shadow: 2px 2px 0 var(--th-black);
}

.gacha-draw-options input:focus-visible + span { outline: 3px solid #1a73e8; }

.gacha-alert {
  margin: 0;
  padding: 8px 9px;
  border-left: 5px solid #bd1d1d;
  background: #fff0f0;
  color: #7a1111;
  font-size: 0.68rem;
  font-weight: 700;
}

.gacha-alert ul { margin: 0; padding-left: 18px; }

.gacha-alert.is-warning {
  border-left-color: #9a7800;
  background: #fff9d6;
  color: #5f4a00;
}

.gacha-run {
  display: grid;
  width: 100%;
  min-height: 48px;
  padding: 6px 12px;
  place-items: center;
  border: 3px solid var(--th-black);
  background: var(--th-yellow);
  color: var(--th-black);
  box-shadow: 4px 4px 0 var(--th-black);
  cursor: pointer;
}

.gacha-run span { font-size: 0.95rem; font-weight: 900; }
.gacha-run small { font-size: 0.59rem; font-weight: 700; }
.gacha-run:hover { background: #ffe56c; }
.gacha-run:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--th-black); }
.gacha-run:disabled { cursor: wait; opacity: 0.65; }

.gacha-reset {
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  border: 2px solid var(--th-black);
  background: var(--th-white);
  color: var(--th-black);
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 900;
}

.gacha-reset:hover { background: #f0f0ed; }
.gacha-reset:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }

.gacha-session-note {
  margin: 0;
  padding: 5px 7px;
  border-left: 4px solid var(--th-yellow);
  background: var(--th-black);
  color: var(--th-white);
  font-size: 0.57rem;
  line-height: 1.35;
}

.gacha-advanced-toggle {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 44px;
  padding: 6px 42px 6px 10px;
  border: 2px solid var(--th-black);
  background: var(--th-white);
  color: var(--th-black);
  cursor: pointer;
  text-align: left;
}

.gacha-advanced-toggle span { font-size: 0.78rem; font-weight: 900; }
.gacha-advanced-toggle small { color: var(--th-gray-600); font-size: 0.57rem; }

.gacha-advanced-toggle b {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 26px;
  height: 26px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  background: var(--th-yellow);
}

.gacha-advanced-toggle[aria-expanded="true"] b { transform: translateY(-50%) rotate(180deg); }
.gacha-advanced-toggle:hover { background: #fffbe3; }

.gacha-advanced-settings {
  padding: 11px;
  border: 3px solid var(--th-black);
  background: #efefec;
}

.gacha-advanced-heading {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 4px solid var(--th-black);
}

.gacha-advanced-heading h2 { margin: 1px 0 0; font-size: 1.05rem; }
.gacha-advanced-heading p { margin: 4px 0 0; color: var(--th-gray-600); font-size: 0.67rem; }

.gacha-settings-grid { display: grid; gap: 10px; }

.gacha-card legend {
  padding: 0 8px 0 0;
  color: var(--th-black);
  font-weight: 800;
}

.gacha-card legend > span {
  display: inline-grid;
  width: 27px;
  height: 27px;
  margin-right: 7px;
  place-items: center;
  background: var(--th-yellow);
}

.gacha-fields { display: grid; gap: 9px; }

.gacha-field,
.gacha-prize-setting label,
.gacha-extra-row label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: #333333;
  font-size: 0.72rem;
  font-weight: 700;
}

.gacha-field small { color: var(--th-gray-600); font-size: 0.64rem; font-weight: 500; }

.gacha-input-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  border: 1px solid #bdbdb8;
  background: var(--th-white);
}

.gacha-input-unit:focus-within { border-color: var(--th-black); box-shadow: 0 0 0 2px var(--th-yellow); }
.gacha-input-unit input { border: 0; }
.gacha-input-unit b { padding: 0 8px; color: #333333; font-size: 0.72rem; }

.gacha-card input:not([type="radio"]),
.gacha-card select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid #bdbdb8;
  border-radius: 0;
  background: var(--th-white);
  color: var(--th-black);
  font: inherit;
  font-size: 0.88rem;
}

.gacha-card input:not([type="radio"]):focus,
.gacha-card select:focus { outline: 2px solid var(--th-yellow); outline-offset: 1px; border-color: var(--th-black); }
.gacha-card input:not([type="radio"]):disabled { background: #eeeeeb; color: #555555; opacity: 1; }

.gacha-help,
.gacha-disclaimer {
  margin: 8px 0 0;
  color: var(--th-gray-600);
  font-size: 0.66rem;
  line-height: 1.5;
}

.gacha-prize-setting {
  display: grid;
  grid-template-columns: 44px minmax(0, 0.7fr) minmax(0, 1fr);
  gap: 7px;
  align-items: end;
  padding: 9px 0;
  border-bottom: 1px solid #ddddda;
}

.gacha-prize-setting label:last-child { grid-column: 2 / -1; }

.gacha-prize-badge {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  align-self: end;
  background: var(--th-black);
  color: var(--th-yellow);
  font-size: 0.84rem;
}

.gacha-catalog-preview { margin-top: 10px; padding-top: 9px; border-top: 3px solid var(--th-black); }

.gacha-catalog-preview__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.gacha-catalog-preview__head strong { font-size: 0.75rem; }
.gacha-catalog-preview__head span { color: var(--th-gray-600); font-size: 0.62rem; }

.gacha-auto-cards { display: grid; gap: 6px; }

.gacha-auto-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 6px;
  border: 1px solid #d4d4d0;
  background: #fafafa;
}

.gacha-card-visual {
  position: relative;
  display: grid;
  width: 42px;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  place-items: center;
  border: 2px solid var(--th-black);
  background: var(--th-black);
  color: var(--th-yellow);
}

.gacha-card-visual--a { background: #3b3b3b; color: var(--th-white); }

.gacha-card-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gacha-card-visual__placeholder { font-size: 0.8rem; font-weight: 900; }
.gacha-auto-card__copy { display: grid; min-width: 0; }
.gacha-auto-card__copy b { color: #806b00; font-size: 0.6rem; }
.gacha-auto-card__copy strong { overflow-wrap: anywhere; font-size: 0.68rem; line-height: 1.3; }
.gacha-auto-card__copy small { margin-top: 2px; font-size: 0.65rem; font-weight: 800; }
.gacha-auto-cards__empty { grid-column: 1 / -1; margin: 0; padding: 8px; background: #f4f4f1; color: var(--th-gray-600); font-size: 0.68rem; }
.gacha-catalog-preview > p { margin: 6px 0 0; color: var(--th-gray-600); font-size: 0.61rem; line-height: 1.4; }

.gacha-auto-preview { margin-top: 10px; padding: 8px 9px; border: 2px solid var(--th-yellow); background: #fffbe3; }
.gacha-auto-preview strong { display: block; margin-bottom: 2px; font-size: 0.74rem; }
.gacha-auto-preview p { margin: 0; font-size: 0.7rem; }
.gacha-auto-preview.is-error { border-color: #bd1d1d; background: #fff0f0; color: #8e1111; }

.gacha-extra-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr);
  gap: 6px;
  align-items: end;
  padding: 9px 0;
  border-bottom: 1px solid #ddddda;
}

.gacha-extra-slash { align-self: center; padding-top: 18px; text-align: center; font-weight: 800; }
.gacha-extra-text { grid-column: 1 / -1; color: var(--th-gray-600); font-size: 0.68rem; font-weight: 700; }
.gacha-extra-value { grid-column: 1 / span 2; }

.gacha-extra-remove {
  min-height: 42px;
  border: 1px solid #8f8f8b;
  background: var(--th-white);
  color: #8e1111;
  cursor: pointer;
  font-weight: 700;
}

.gacha-add-rule {
  width: 100%;
  min-height: 42px;
  margin-top: 9px;
  border: 2px solid var(--th-black);
  background: var(--th-white);
  cursor: pointer;
  font-weight: 800;
}

.gacha-add-rule:hover { background: #fff8c4; }

.gacha-history-card { margin-top: 4px; }
.gacha-history { display: grid; gap: 6px; }

.gacha-history-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid #ddddda;
}

.gacha-history-row:last-child { border-bottom: 0; }
.gacha-history-badge { display: grid; min-height: 30px; place-items: center; background: var(--th-yellow); font-size: 0.68rem; font-weight: 900; }
.gacha-history-row strong { display: block; font-size: 0.74rem; }
.gacha-history-row p { margin: 3px 0 0; color: var(--th-gray-600); font-size: 0.67rem; line-height: 1.45; }
.gacha-history-empty { margin: 0; padding: 10px; background: #f4f4f1; color: var(--th-gray-600); font-size: 0.7rem; }
.gacha-history-title { display: flex; align-items: center; gap: 7px; }
.gacha-history-title .gacha-card-visual { flex: 0 0 auto; width: 32px; }

.gacha-hit-layer {
  position: fixed;
  z-index: 99999;
  inset: 0;
  display: grid;
  padding: 12px;
  place-items: center;
  overflow: auto;
  background: rgba(0, 0, 0, 0.78);
}

.gacha-hit-dialog {
  position: relative;
  width: min(100%, 620px);
  max-height: calc(100dvh - 24px);
  padding: 18px 14px 14px;
  overflow: auto;
  border: 4px solid var(--th-black);
  background: var(--th-white);
  box-shadow: 8px 8px 0 var(--th-yellow);
  text-align: center;
}

.gacha-hit-close {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 44px;
  height: 44px;
  border: 2px solid var(--th-black);
  background: var(--th-white);
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 900;
}

.gacha-hit-kicker {
  display: inline-block;
  padding: 3px 7px;
  background: var(--th-yellow);
  font-size: 0.59rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.gacha-hit-dialog h2 { margin: 6px 46px 2px; font-size: clamp(1.15rem, 5.5vw, 1.75rem); }
.gacha-hit-dialog > p { margin: 0; color: var(--th-gray-600); font-size: 0.68rem; }

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

.gacha-hit-card {
  display: grid;
  min-width: 0;
  padding: 7px;
  border: 2px solid var(--th-black);
  background: #fafafa;
  text-align: left;
}

.gacha-hit-card .gacha-card-visual { width: 100%; border-width: 0; }
.gacha-hit-card__tier { margin-top: 6px; color: #806b00; font-size: 0.62rem; font-weight: 900; }
.gacha-hit-card strong { overflow-wrap: anywhere; font-size: 0.74rem; line-height: 1.25; }
.gacha-hit-card__value { margin-top: 3px; font-size: 0.8rem; font-weight: 900; }
.gacha-hit-card__count { color: var(--th-gray-600); font-size: 0.62rem; }

.gacha-hit-more { margin-top: 7px !important; font-weight: 800; }

.gacha-hit-pr {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 0 !important;
  padding: 6px 7px;
  border-left: 4px solid var(--th-yellow);
  background: #fff9d9;
  color: var(--th-black) !important;
  font-size: 0.62rem !important;
  line-height: 1.35;
  text-align: left;
}

.gacha-hit-pr strong {
  flex: 0 0 auto;
  padding: 2px 5px;
  background: var(--th-yellow);
  font-size: 0.66rem;
}

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

.gacha-hit-actions button,
.gacha-hit-actions a {
  display: grid;
  min-width: 0;
  min-height: 48px;
  padding: 7px;
  place-items: center;
  border: 2px solid var(--th-black);
  background: var(--th-white);
  color: var(--th-black);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.25;
  text-decoration: none;
}

.gacha-hit-actions .gacha-hit-try { background: var(--th-yellow); }

.gacha-hit-actions .gacha-hit-try.is-disabled {
  border-color: #8b8b87;
  background: #e9e9e6;
  color: #6b6b67;
  cursor: not-allowed;
  pointer-events: none;
}

.gacha-hit-link-note {
  margin: 4px 0 0 !important;
  color: var(--th-gray-600) !important;
  font-size: 0.57rem !important;
  font-weight: 700;
}

.gacha-hit-link-note[hidden] { display: none !important; }

@media (max-width: 350px) {
  .gacha-preset-note,
  .gacha-session-note { display: none; }
  .gacha-summary-grid,
  .gacha-prize-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gacha-chart-wrap { min-height: 122px; }
  #gacha-profit-chart { height: 122px; }
  .gacha-hit-dialog { padding-left: 10px; padding-right: 10px; }
}

@media (max-width: 859px) {
  .gacha-simulator-page .menu-toggle,
  .gacha-preset { min-height: 44px; }
}

@media (min-width: 560px) {
  .gacha-page { padding: 12px 18px 54px; }
  .gacha-preset span { display: block; margin-top: 2px; color: var(--th-gray-600); font-size: 0.55rem; line-height: 1.2; }
  .gacha-preset--custom span { color: #dddddd; }
  .gacha-preset--custom.is-selected span { color: #333333; }
  .gacha-chart-wrap { min-height: 210px; }
  #gacha-profit-chart { height: 210px; }
  .gacha-fields--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gacha-field--wide { grid-column: 1 / -1; }
  .gacha-prize-setting { grid-template-columns: 50px 0.65fr 0.9fr 1.25fr; }
  .gacha-prize-setting label:last-child { grid-column: auto; }
  .gacha-extra-row { grid-template-columns: 0.7fr 12px 0.7fr auto 1.4fr auto; }
  .gacha-extra-text,
  .gacha-extra-value { grid-column: auto; }
  .gacha-auto-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gacha-hit-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 860px) {
  .gacha-intro { padding-top: 7px; }
  .gacha-presets { padding: 10px; }
  .gacha-preset { min-height: 54px; }
  #gacha-result-content { padding: 12px; }
  .gacha-chart-wrap { min-height: 280px; }
  #gacha-profit-chart { height: 280px; }
  .gacha-result-heading h2 { font-size: 1.05rem; }
  .gacha-stat { padding: 9px; }
  .gacha-stat span { font-size: 0.65rem; }
  .gacha-stat strong { font-size: 1.2rem; }
  .gacha-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gacha-settings-grid > :last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .gacha-run:active { transform: none; }
}
