:root {
  --primary: #1b64da;
  --primary-soft: #ebf3ff;
  --ink: #191f28;
  --muted: #4e5968;
  --surface: #f2f4f6;
  --paper: #ffffff;
  --line: #e5e8eb;
  --body-font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 16px/1.6 var(--body-font); -webkit-font-smoothing: antialiased; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; font: inherit; }
a { color: var(--primary); text-underline-offset: 4px; }
a, button { touch-action: manipulation; }
button:disabled { cursor: default; opacity: .6; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; line-height: 1.4; letter-spacing: -.03em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
p, h1, h2, strong, a, code { overflow-wrap: anywhere; }
img { max-width: 100%; object-fit: contain; }
.app-shell { width: 100%; max-width: 480px; min-height: 100dvh; margin: 0 auto; background: var(--surface); }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; background: var(--paper); padding: 12px; min-height: 44px; }
.skip-link:focus { top: 12px; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 20px; background: var(--paper); }
.brand { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; font-size: 20px; font-weight: 800; letter-spacing: -.04em; }
.site-header > span { color: var(--muted); font-size: 12px; }
.page-intro { padding: 16px 20px 14px; }
.page-intro p { margin-top: 4px; font-size: 14px; color: var(--muted); }
.method-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; margin: 0 16px 12px; border-radius: 16px; background: var(--line); }
.method-tabs a { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 12px; text-decoration: none; font-weight: 600; color: var(--muted); }
.method-tabs a[aria-current] { color: var(--primary); background: var(--paper); box-shadow: 0 2px 6px #191f280d; }
.game-shell { min-width: 0; }
.category-filter { padding: 0 20px; background: var(--paper); }
.category-toggle { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 56px; padding: 6px 0; border: 0; background: none; color: var(--muted); text-align: left; }
.category-toggle strong { margin-left: 8px; color: var(--ink); }
.category-toggle > span:last-child { color: var(--primary); font-size: 14px; }
.category-options:not([hidden]) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 8px 0 12px; }
.category-option { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 48px; min-width: 0; padding: 6px 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--muted); font-size: 14px; }
.category-option[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); font-weight: 700; }
.game-scene { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 20px 8px; min-width: 0; }
.result-card { width: 100%; max-width: 340px; height: 216px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; border-radius: 24px; background: var(--paper); box-shadow: 0 8px 24px #191f280a; overflow: hidden; position: relative; text-align: center; }
.result-card > h2, .result-card > p { padding-inline: 16px; }
.result-card h2 { font-size: 20px; }
.result-card p { color: var(--muted); font-size: 14px; }
.result-card .result-menu { font-size: 28px; line-height: 1.4; }
.game-status { min-height: 24px; width: 100%; text-align: center; font-size: 14px; color: var(--muted); line-height: 1.6; }
.game-actions { padding: 12px 20px 16px; }
.primary-button { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 56px; padding: 12px 16px; border: 0; border-radius: 18px; color: var(--paper); background: var(--primary); font: 700 17px/1.5 var(--body-font); text-decoration: none; text-align: center; }
.primary-button:active:not(:disabled) { transform: scale(.98); }
.primary-button:disabled { opacity: .72; }
.storage-alert { margin: 12px 0 0; padding: 14px; border-radius: 14px; background: var(--paper); color: var(--muted); font-size: 14px; }
main > .storage-alert { margin: 0 20px 16px; }
.slot-window { width: 100%; height: 216px; overflow: hidden; position: relative; }
.slot-window::before, .slot-window::after { content: ''; position: absolute; left: 0; right: 0; height: 72px; z-index: 1; pointer-events: none; }
.slot-window::before { top: 0; background: linear-gradient(var(--paper), #ffffff33); }
.slot-window::after { bottom: 0; background: linear-gradient(#ffffff33, var(--paper)); }
.slot-highlight { position: absolute; inset: 72px 0; background: var(--primary-soft); border-block: 1px solid var(--primary); }
.slot-item { display: flex; align-items: center; justify-content: center; height: 72px; padding: 0 12px; color: var(--ink); font-size: 24px; font-weight: 800; overflow-wrap: anywhere; line-height: 1.3; }
.rarity-label { font-weight: 700; color: var(--muted); }
.rarity-label[data-rarity="rare"] { color: var(--primary); }
.rarity-label[data-rarity="legend"] { color: #2143b3; }
.legend-gift { font-size: 48px; line-height: 1; }
.rarity-rates { text-align: center; color: var(--muted); font-size: 14px; }
body[data-game="gacha"] .result-card { border: 2px solid transparent; }
body[data-game="gacha"] .result-card[data-rarity="normal"] { border-color: var(--muted); }
body[data-game="gacha"] .result-card[data-rarity="rare"] { border-color: var(--primary); }
body[data-game="gacha"] .result-card[data-rarity="legend"] { border-color: #2143b3; }
body[data-game="gacha"] .result-card[data-spinning="true"] { animation: card-draw 1200ms cubic-bezier(.2,.8,.2,1); }
.tray-card { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; border-radius: 24px; background: var(--paper); box-shadow: 0 8px 24px #191f280a; }
.tray-slot { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; min-height: 90px; min-width: 0; padding: 10px 8px; border-radius: 18px; background: #f9fafb; text-align: center; }
.tray-slot > span { color: var(--muted); font-size: 14px; }
.tray-slot > strong { font-size: 16px; font-weight: 800; }
.tray-slot > strong[aria-hidden] { font-size: 28px; }
.bottom-tabs { display: flex; gap: 8px; margin: 0 20px 16px; padding: 4px; border: 1px solid var(--line); border-radius: 24px; background: var(--paper); }
.bottom-tabs a { display: flex; justify-content: center; align-items: center; min-height: 44px; flex: 1; border-radius: 20px; color: var(--muted); font-size: 14px; text-decoration: none; }
.bottom-tabs a[aria-current] { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.browse-categories { padding: 16px 20px 24px; border-top: 1px solid var(--line); }
.browse-categories h2 { font-size: 18px; margin-bottom: 12px; }
.category-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.category-links a { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: 12px; background: var(--paper); font-size: 14px; text-decoration: none; }
.site-footer { padding: 16px 20px max(24px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font-size: 14px; }
.article { padding: 24px 20px 32px; }
.article > h1 { margin-bottom: 16px; }
.article > h2 { margin-top: 28px; margin-bottom: 12px; font-size: 20px; }
.article > p { margin: 0 0 16px; color: var(--muted); }
.article p > a { display: inline-flex; min-height: 44px; align-items: center; max-width: 100%; }
.article code { font-size: 14px; }
.article .primary-button { margin-block: 20px; }
.menu-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; padding: 1px; list-style: none; border-radius: 16px; background: var(--line); overflow: hidden; }
.menu-list li { min-width: 0; padding: 12px; background: var(--paper); font-size: 16px; overflow-wrap: anywhere; }
.empty-history { display: flex; flex-direction: column; gap: 12px; align-items: center; padding: 32px 24px; text-align: center; }
.empty-history p { color: var(--muted); }
.empty-history .primary-button { margin-top: 8px; }
.history-summary { padding: 20px; margin: 0 16px 16px; border-radius: 16px; background: var(--paper); }
.history-summary > p:last-child { margin-top: 4px; font-size: 14px; color: var(--muted); }
.list-header { font-size: 16px; color: var(--muted); padding: 16px 20px 8px; }
.history-list { padding: 0; margin: 0 0 8px; list-style: none; background: var(--paper); }
.history-row { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.history-row img { flex-shrink: 0; }
.history-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-text strong { font-size: 16px; font-weight: 600; }
.history-text span, .history-row time { color: var(--muted); font-size: 12px; }
.history-row time { flex-shrink: 0; }
.notice { margin: 16px 20px; padding: 16px; background: var(--paper); border-radius: 16px; font-size: 14px; }
/* Match exit-web: the slot stays in normal layout while loading. Only the
   label and spacing wait for fill; unfilled slots collapse below the CTA. */
.advertisement { margin: 0; padding: 0; border: 0; min-width: 0; max-width: 100%; }
.advertisement > p { display: none; margin: 0 0 6px; color: var(--muted); font-size: 12px; }
/* Keep attribute fallbacks separate: unsupported :has() invalidates a whole
   selector list in older browsers. */
.advertisement[data-filled="true"] { margin-top: 20px; }
.advertisement[data-filled="true"] > p { display: block; }
.advertisement[data-unfilled="true"] { display: none; }
.advertisement:has(ins[data-ad-status="filled"]) { margin-top: 20px; }
.advertisement:has(ins[data-ad-status="filled"]) > p { display: block; }
.advertisement:has(ins[data-ad-status="unfilled"]) { display: none; }
@keyframes card-draw { 0% { transform: perspective(600px) rotateY(0); } 45% { transform: perspective(600px) rotateY(180deg); } 100% { transform: perspective(600px) rotateY(360deg); } }
@media (prefers-reduced-motion: reduce) {
  body[data-game="gacha"] .result-card[data-spinning="true"] { animation: none; }
  .primary-button:active:not(:disabled) { transform: none; }
}
