:root {
    --bg: #0f1215;
    --panel: #15181d;
    --line: #2a2e35;
    --text: #e6e6e6;
    --muted: #8d939b;
    --accent: #a5ff8d;
    --gold: #ffbc00;
    --purple: #c27bf0;
    --blue: #6ea8ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Meiryo', sans-serif;
    padding: 72px 16px 48px;
}

[hidden] {
    display: none !important;
}

.home-link {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    padding: 8px 14px;
    background: #1a1e24;
    border: 1px solid #333;
    border-radius: 8px;
    color: #ccc;
    text-decoration: none;
    font-size: 13px;
}

.home-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.app {
    max-width: 980px;
    margin: 0 auto;
}

h1 {
    font-size: 1.5em;
    margin: 0 0 6px;
}

.lead,
.note {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
    margin: 0;
}

/* ===== ガチャの切り替え ===== */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 12px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #bbb;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.tab img,
.tab-star {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #0b0d10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
}

.tab:hover {
    border-color: var(--accent);
}

.tab.on {
    border-color: var(--accent);
    color: #fff;
}

/* ===== ガチャの内容 ===== */
.banner {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #1b1e24, #101216);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.banner-art {
    position: relative;
    min-height: 340px;
    border-radius: 10px;
    overflow: hidden;
    background: #0b0d10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.banner-art > img {
    position: absolute;
    height: 150%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.art-weapons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.art-weapons img {
    width: 110px;
    height: 110px;
    object-fit: contain;
}

.banner-type {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.banner-info h2 {
    margin: 4px 0 2px;
    font-size: 1.5em;
}

.banner-ends {
    margin: 0 0 12px;
    font-size: 12px;
    color: var(--muted);
}

.banner-pickups {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.pickup {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 3px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
}

.pickup img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
}

.pickup.r5 { border-color: rgba(255, 188, 0, 0.6); }
.pickup.r4 { border-color: rgba(194, 123, 240, 0.6); }

.banner-target {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--muted);
}

.chip {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #333;
    background: #1a1e24;
    color: #bbb;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.chip.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    font-weight: bold;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.status {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.status span,
.status small {
    font-size: 11px;
    color: var(--muted);
}

.status b {
    font-size: 15px;
}

.pull-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.pull-btn {
    height: 46px;
    padding: 0 18px;
    border-radius: 10px;
    border: 1px solid #3a3f47;
    background: #1a1e24;
    color: #eee;
    font: inherit;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.pull-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--accent);
}

.pull-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #0b0d10;
}

.pull-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* ===== 結果・履歴 ===== */
.panel {
    margin-top: 14px;
    padding: 14px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.panel h3 {
    margin: 0;
    font-size: 15px;
}

.panel h3 small {
    color: var(--muted);
    font-weight: normal;
    font-size: 11px;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.plain-btn,
.panel select {
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #0f1215;
    color: #bbb;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.plain-btn:hover {
    border-color: #ff8a80;
    color: #ff8a80;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #20242a;
    font-size: 13px;
}

.stat span {
    color: var(--muted);
    font-size: 12px;
}

.history {
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow-y: auto;
}

.hist {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 2px;
    border-bottom: 1px solid #20242a;
    font-size: 13px;
}

.hist img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #0b0d10;
}

.hist.r5 .hist-name { color: var(--gold); font-weight: bold; }
.hist.r4 .hist-name { color: var(--purple); }

.hist-meta {
    margin-left: auto;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.tag {
    font-size: 10px;
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 4px;
    color: #000;
    background: var(--gold);
}

.tag.lost {
    background: #6b7078;
    color: #fff;
}

.rules summary {
    cursor: pointer;
    font-size: 14px;
}

.rules ul {
    margin: 10px 0 0;
    padding-left: 18px;
    font-size: 12px;
    color: #aaa;
    line-height: 1.8;
}

/* ===== 演出 ===== */
body.stage-open {
    overflow: hidden;
}

.stage {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: radial-gradient(ellipse at 50% 50%, #151a28 0%, #07080c 72%);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.stage-fx {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.stage-skip {
    position: absolute;
    top: 18px;
    right: 20px;
    z-index: 5;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.5);
    color: #eee;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.stage-skip:hover {
    border-color: #fff;
}

.stage-body {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* --- 1つずつの登場 --- */
.stage-body.reveal {
    background:
        linear-gradient(0deg, rgba(var(--glow), 0.42), transparent 46%),
        radial-gradient(ellipse at 56% 46%, rgba(var(--glow), 0.2), transparent 60%),
        linear-gradient(115deg, rgba(6, 7, 11, 0.92) 18%, transparent 62%);
}

/* 斜めに走る光の帯 */
.st-band {
    position: absolute;
    left: -30%;
    right: -30%;
    top: 58%;
    height: 16vh;
    transform: rotate(-9deg);
    background: linear-gradient(90deg, transparent, rgba(var(--glow), 0.34) 26%, rgba(var(--rank), 0.5) 50%, transparent 84%);
    filter: blur(1px);
    animation: band-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

@keyframes band-in {
    from { transform: rotate(-9deg) translateX(-60%); opacity: 0; }
}

.st-halo {
    position: absolute;
    left: 56%;
    top: 46%;
    width: min(78vh, 90vw);
    height: min(78vh, 90vw);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(var(--glow), 0.45);
    box-shadow: 0 0 60px rgba(var(--glow), 0.35), inset 0 0 70px rgba(var(--glow), 0.25);
    animation: halo-in 0.7s ease-out backwards;
}

@keyframes halo-in {
    from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
}

.st-art {
    position: absolute;
    left: 56%;
    top: 46%;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 0 26px rgba(var(--glow), 0.75));
    animation: art-in 0.6s cubic-bezier(0.16, 0.9, 0.24, 1) backwards;
}

.st-art.char {
    height: 112vh;
    max-width: none;
}

.st-art.weapon {
    width: min(58vh, 74vw);
    animation: art-in 0.6s cubic-bezier(0.16, 0.9, 0.24, 1) backwards, float 4.2s 0.6s ease-in-out infinite;
}

@keyframes art-in {
    from { opacity: 0; transform: translate(-42%, -50%) scale(1.06); filter: brightness(4) blur(6px); }
}

@keyframes float {
    50% { transform: translate(-50%, -52.5%); }
}

.st-burst {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    pointer-events: none;
    animation: burst 0.42s ease-out forwards;
}

.reveal.r3 .st-burst {
    background: rgba(255, 255, 255, 0.35);
}

@keyframes burst {
    to { opacity: 0; }
}

.st-caption {
    position: absolute;
    left: clamp(20px, 6vw, 88px);
    bottom: clamp(70px, 16vh, 150px);
    padding-left: 18px;
    border-left: 4px solid rgb(var(--rank));
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95);
}

.st-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(30px, 5.2vw, 62px);
    font-weight: bold;
    letter-spacing: 0.04em;
    color: #fff;
    animation: cap-in 0.45s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.st-element {
    width: clamp(36px, 5vw, 60px);
    height: clamp(36px, 5vw, 60px);
    filter: drop-shadow(0 0 8px rgba(var(--glow), 0.9));
}

@keyframes cap-in {
    from { opacity: 0; transform: translateX(-26px); }
}

.st-star-row {
    min-height: 40px;
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.st-star {
    font-size: clamp(24px, 3vw, 34px);
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 188, 0, 0.9);
    animation: star-pop 0.28s cubic-bezier(0.3, 1.8, 0.5, 1) backwards;
}

@keyframes star-pop {
    from { opacity: 0; transform: scale(2.6) rotate(-30deg); }
}

.st-tag {
    display: inline-block;
    margin-bottom: 8px;
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    color: #000;
    background: var(--gold);
    text-shadow: none;
    animation: cap-in 0.4s 0.1s ease-out backwards;
}

.st-tag.lost {
    background: #6b7078;
    color: #fff;
}

.reveal.radiance .st-tag {
    background: linear-gradient(90deg, #ff9a9a, #ffd35c, #8df0a0, #7fd8ff, #d9a5f5);
}

.st-progress {
    position: absolute;
    left: clamp(20px, 6vw, 88px);
    top: 22px;
    font-size: 14px;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.65);
}

.st-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    text-align: center;
    font-size: 13px;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.7);
    animation: hint 1.8s ease-in-out infinite;
}

@keyframes hint {
    50% { opacity: 0.35; }
}

/* --- 結果一覧 --- */
.st-summary {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    width: min(980px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.st-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    width: 100%;
}

.st-grid.n1 {
    grid-template-columns: minmax(0, 220px);
    justify-content: center;
}

.st-tile {
    --c: 110, 168, 255;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding-bottom: 10px;
    border-radius: 12px;
    border: 1px solid rgba(var(--c), 0.55);
    background: #12151c;
    overflow: hidden;
    animation: tile-in 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.st-tile.r4 { --c: 194, 123, 240; }
.st-tile.r5 {
    --c: 255, 188, 0;
    box-shadow: 0 0 24px rgba(255, 188, 0, 0.4);
}

@keyframes tile-in {
    from { opacity: 0; transform: translateY(18px) scale(0.94); }
}

.st-tile-art {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 12px 10px 6px;
    background: linear-gradient(170deg, rgba(var(--c), 0.5), rgba(var(--c), 0.06));
}

.st-tile img {
    width: 100%;
    max-width: 104px;
    aspect-ratio: 1;
    object-fit: contain;
}

.st-tile .st-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    margin: 0;
    font-size: 10px;
    padding: 1px 6px;
    animation: none;
}

.st-stars {
    font-size: 11px;
    color: var(--gold);
}

.st-name {
    padding: 0 6px;
    font-size: 12px;
    text-align: center;
    color: #eee;
}

.st-back {
    font-size: 13px;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.7);
    animation: hint 1.8s ease-in-out infinite;
}

@media (max-width: 760px) {
    .banner { grid-template-columns: 1fr; }
    .banner-art { min-height: 240px; }
    .st-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .st-band, .st-halo, .st-burst, .st-art, .st-art.weapon, .st-title, .st-star, .st-tag, .st-hint, .st-back, .st-tile {
        animation: none;
    }

    .st-burst {
        display: none;
    }
}
