/* ==========================================================================
   キーワード動的ガチャ - デザインシステム & スタイル
   ========================================================================== */

:root {
    --primary-color: #ff9900;
    --primary-glow:  rgba(255, 153, 0, 0.4);
    --accent-color:   #146eb4;
    --bg-dark:        #0a0f1d;
    --bg-card:        rgba(18, 25, 45, 0.85);
    --bg-glass:       rgba(255, 255, 255, 0.05);
    --border-glass:   rgba(255, 255, 255, 0.12);
    --text-main:      #f0f4f8;
    --text-muted:     #8a99ad;
    --ssr-gold:       linear-gradient(135deg, #ffe066, #f5a623, #ff6b00);
    --sr-purple:      #a259ff;
    --r-blue:         #1e90ff;
    --n-silver:       #95a5a6;

    --font-sans:     'Zen Kaku Gothic New', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display:  'Outfit', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* オーブアニメーション背景 */
.background-globes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.globe {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    animation: float 20s infinite ease-in-out alternate;
}

.globe-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
}

.globe-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-color);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.globe-3 {
    width: 300px;
    height: 300px;
    background: #a259ff;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes float {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 80px) scale(1.2); }
}

/* コンテナ */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 540px;
    margin: 0 auto;
    padding: 32px 16px 48px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ヘッダー */
.app-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 12px var(--primary-glow));
}

.logo-title {
    font-family: var(--font-sans);
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* パネル */
.gacha-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 28px 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* キーワード入力エリア (未指定時) */
.keyword-input-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
}

.input-row {
    display: flex;
    gap: 10px;
}

.keyword-field {
    flex: 1;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.25s ease;
}

.keyword-field:focus {
    border-color: var(--primary-color);
}

.keyword-submit-btn {
    padding: 12px 20px;
    background: var(--primary-color);
    color: #111;
    font-weight: 800;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.keyword-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--primary-glow);
}

/* ガチャボタン */
.action-container {
    width: 100%;
    margin-top: 4px;
}

.gacha-trigger-btn {
    position: relative;
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #ff9900 0%, #ff5500 100%);
    color: #ffffff;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 10px 25px var(--primary-glow);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gacha-trigger-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 35px rgba(255, 153, 0, 0.6);
}

.gacha-trigger-btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

.gacha-trigger-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gacha-trigger-btn:hover .btn-glow { opacity: 1; }

.btn-text {
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: 1px;
    z-index: 1;
}

.btn-subtext {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 2px;
    opacity: 0.8;
    z-index: 1;
}

/* トースト・エラー */
.notice-toast, .error-box {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

.notice-toast {
    background: rgba(20, 110, 180, 0.2);
    border: 1px solid rgba(20, 110, 180, 0.4);
    color: #64b5f6;
}

.error-box {
    background: rgba(235, 87, 87, 0.2);
    border: 1px solid rgba(235, 87, 87, 0.4);
    color: #ff6b6b;
}

/* ガチャステージ */
.gacha-stage {
    width: 100%;
}

.gacha-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    gap: 16px;
}

.orb-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
}

.ring-1 {
    width: 80px;
    height: 80px;
    border-top-color: var(--primary-color);
    border-right-color: var(--primary-color);
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.ring-2 {
    width: 60px;
    height: 60px;
    border-bottom-color: #a259ff;
    border-left-color: #a259ff;
    animation: spin 0.9s cubic-bezier(0.5, 0, 0.5, 1) infinite reverse;
}

.ring-3 {
    width: 40px;
    height: 40px;
    border-top-color: #ffffff;
    animation: spin 0.6s linear infinite;
}

.core-spark {
    font-size: 1.5rem;
    animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%   { transform: scale(0.8); opacity: 0.6; }
    100% { transform: scale(1.2); opacity: 1; }
}

.loader-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* 結果カード */
.card-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    position: relative;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

/* レア度バッジ */
.rarity-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 5;
    padding: 6px 14px;
    border-radius: 20px;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rarity-ssr { background: var(--ssr-gold); color: #111111; }
.rarity-sr  { background: var(--sr-purple); color: #ffffff; }
.rarity-r   { background: var(--r-blue);   color: #ffffff; }
.rarity-n   { background: var(--n-silver); color: #222222; }

/* 商品画像 */
.card-image-box {
    position: relative;
    width: 100%;
    height: 220px;
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.image-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.card-image-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.card-image-box:hover img {
    transform: scale(1.05);
}

/* 詳細コンテンツ */
.card-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.brand-tag {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.item-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.45;
    color: #ffffff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rating-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.stars { color: #ffb800; letter-spacing: 2px; }
.rating-num { font-weight: 800; color: #ffffff; }
.review-count { color: var(--text-muted); }

.price-box {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 4px;
}

.price-currency {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-color);
}

.price-amount {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 900;
    color: #ffffff;
}

/* Amazonボタン */
.amazon-buy-btn {
    margin-top: 8px;
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #ffa726 0%, #fb8c00 100%);
    color: #111111;
    font-weight: 800;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s ease;
    box-shadow: 0 6px 16px rgba(255, 153, 0, 0.3);
}

.amazon-buy-btn:hover {
    background: linear-gradient(135deg, #ffb74d 0%, #ffa726 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(255, 153, 0, 0.4);
}

/* もう一度ボタン */
.retry-btn {
    width: 100%;
    padding: 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.retry-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}

/* SNS セクション */
.sns-section { width: 100%; }

.sns-campaign-box {
    background: linear-gradient(135deg, rgba(29, 161, 242, 0.1), rgba(0, 0, 0, 0.2));
    border: 1px solid rgba(29, 161, 242, 0.3);
    border-radius: 24px;
    padding: 28px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.sns-campaign-emoji {
    font-size: 2.4rem;
    animation: pulse 2s ease-in-out infinite;
}

.sns-campaign-title {
    font-size: 1.2rem;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.sns-campaign-text {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-muted);
}

.x-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #000000;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 4px;
}

.x-share-btn:hover {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* フッター */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.disclaimer { opacity: 0.7; }

/* ユーティリティ */
.hidden { display: none !important; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .logo-title { font-size: 1.8rem; }
    .gacha-panel { padding: 20px 16px; }
    .card-image-box { height: 180px; }
}
