:root {
    --bg: #0d1117;
    --bg2: #161b22;
    --bg3: #21262d;
    --card-bg: #1c2128;
    --text: #e6edf3;
    --text-sub: #8b949e;
    --border: #30363d;
    --primary: #58a6ff;
    --primary-dark: #388bfd;


}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 520px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg2);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

header {
    text-align: center;
    padding: 22px 20px 18px;
    background: linear-gradient(160deg, #1a2332 0%, #0d1117 100%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.7rem;
    font-weight: 900;
    background: linear-gradient(90deg, #79c0ff, #d2a8ff, #ffa657);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 4px;
}

.logo-icon { -webkit-text-fill-color: initial; }

header p {
    font-size: 0.85rem;
    color: var(--text-sub);
}

main {
    flex: 1;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ─── 画面切り替え ─── */
.screen { display: none; flex-direction: column; align-items: center; width: 100%; }
.screen.active { display: flex; animation: fadeUp 0.4s ease forwards; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── ガチャ待機画面 ─── */
.gacha-machine {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
}

.pod-container {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #2d4a6e, #0d1f33);
    border: 3px solid #30363d;
    box-shadow: 0 0 40px rgba(88, 166, 255, 0.25), inset 0 0 30px rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    animation: float 5s ease-in-out infinite;
    overflow: hidden;
}

.orb-inner {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, rgba(88,166,255,0.15) 25%, transparent 50%);
    animation: spin 4s linear infinite;
}

.orb-shine {
    position: absolute;
    top: 12%;
    left: 14%;
    width: 32%;
    height: 22%;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    filter: blur(4px);
}

.orb-note {
    font-size: 4rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 0 20px rgba(88, 166, 255, 0.8);
    animation: notePulse 2s ease-in-out infinite;
}

@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
@keyframes spin  { to{transform:rotate(360deg)} }
@keyframes notePulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }

.gacha-buttons {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ─── ボタン ─── */
button { cursor: pointer; font-family: inherit; border: none; outline: none; border-radius: 30px; font-weight: 700; transition: all 0.2s ease; }

.primary-btn {
    padding: 14px 32px;
    font-size: 1.05rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(88,166,255,0.35);
    display: flex;
    align-items: center;
    gap: 8px;
}

.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(88,166,255,0.5); }
.primary-btn:active { transform: translateY(1px); }

.btn-ten {
    background: linear-gradient(135deg, #a371f7, #7c3aed);
    box-shadow: 0 4px 14px rgba(163,113,247,0.35);
}
.btn-ten:hover { box-shadow: 0 6px 20px rgba(163,113,247,0.5); }

.btn-icon { font-size: 1.1rem; }

.gacha-note {
    font-size: 0.78rem;
    color: var(--text-sub);
    text-align: center;
}

/* ─── ガチャ演出画面 ─── */
.gacha-animation {
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.capsule {
    width: 56px;
    height: 76px;
    position: relative;
    border-radius: 28px;
    animation: fallBounce 1.6s cubic-bezier(0.28, 0.84, 0.42, 1) forwards;
}

.capsule-top {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 50%;
    background: #ff5252;
    border-radius: 28px 28px 0 0;
    border: 2px solid rgba(255,255,255,0.15);
    z-index: 2;
}
.capsule-bottom {
    position: absolute; bottom: 0; left: 0;
    width: 100%; height: 50%;
    background: #f5f5f5;
    border-radius: 0 0 28px 28px;
    border: 2px solid rgba(0,0,0,0.1);
}
.capsule-shine {
    position: absolute; top: 6px; left: 8px;
    width: 12px; height: 16px;
    background: rgba(255,255,255,0.55);
    border-radius: 50%;
    transform: rotate(-20deg);
    z-index: 3;
}

@keyframes fallBounce {
    0%   { opacity:0; transform:translateY(-180px) rotate(-15deg); }
    55%  { opacity:1; transform:translateY(0) rotate(5deg); }
    68%  { transform:translateY(-30px) rotate(-3deg); }
    80%  { transform:translateY(0) rotate(2deg); }
    90%  { transform:translateY(-8px); }
    100% { transform:translateY(0); }
}

.capsule.open { animation: openCapsule 0.9s ease forwards; }
@keyframes openCapsule {
    0%   { transform:scale(1); opacity:1; }
    60%  { transform:scale(1.3); opacity:0.8; }
    100% { transform:scale(2.5); opacity:0; }
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    animation: blink 1.2s ease infinite alternate;
}
@keyframes blink { from{opacity:0.5} to{opacity:1} }



/* ─── 結果カード ─── */
.result-title {
    font-size: 1.3rem;
    margin-bottom: 18px;
    text-align: center;
}

.card {
    width: 100%;
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 22px;
    transition: box-shadow 0.3s;
}

.thumbnail-container {
    width: 100%;
    height: 195px;
    background: var(--bg3);
    position: relative;
    overflow: hidden;
}
.thumbnail-container img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}
.card:hover .thumbnail-container img { transform: scale(1.04); }

/* 動画埋め込み */
.embed-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    position: relative;
}
.embed-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}



.card-content { padding: 18px; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.artist-badge {
    background: var(--bg3);
    color: var(--text-sub);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}



.song-title {
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1.45;
    margin-bottom: 14px;
    word-break: break-all;
}

.tags-container { display: flex; flex-wrap: wrap; gap: 6px; }
.song-tag {
    background: rgba(88,166,255,0.1);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    border: 1px solid rgba(88,166,255,0.2);
}

/* ─── アクションボタン ─── */
.action-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.btn-row { display: flex; gap: 10px; }
.btn-row .action-btn { flex: 1; }

.action-btn {
    padding: 12px 18px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}
.action-btn:hover { transform: translateY(-2px); }
.action-btn:active { transform: translateY(1px); }
.action-btn.disabled { opacity: 0.4; pointer-events: none; }

.yt-btn     { background:#ff0000; color:#fff; }
.nc-btn     { background:#252525; color:#fff; border: 1px solid #444; }
.vocadb-btn { background:#2e8ece; color:#fff; }
.x-btn      { background:#000; color:#fff; border: 1px solid #333; }
.retry-btn  { background:transparent; color:var(--primary); border:2px solid var(--primary); }
.retry-btn:hover { background:var(--primary); color:#fff; }
.back-btn   { background:transparent; color:var(--text-sub); border:1px solid var(--border); width:100%; }
.back-btn:hover { background:var(--bg3); color:var(--text); }

/* ─── 10連ガチャグリッド ─── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    margin-bottom: 22px;
}

.mini-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.mini-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }

.mini-thumb {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
    background: var(--bg3);
}

.mini-info { padding: 8px 10px; }
.mini-title {
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 5px;
}




footer {
    text-align: center;
    padding: 16px;
    font-size: 0.78rem;
    color: var(--text-sub);
    border-top: 1px solid var(--border);
}
footer a { color: var(--primary); text-decoration: none; }

#confetti-canvas {
    position: fixed; top:0; left:0;
    width:100%; height:100%;
    pointer-events:none; z-index:9999;
}


