/* ===== リセット & ベーススタリング ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: #0f172a;
    /* ダークブルー背景 */
    color: #f8fafc;
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 24px;
    background-color: #1e293b;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}

/* ===== ヘッダー ===== */
header h1 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

header p {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-bottom: 32px;
}

/* ===== 入力エリア ===== */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.input-section label {
    font-size: 1rem;
    font-weight: 700;
    color: #cbd5e1;
}

input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1rem;
    border-radius: 8px;
    border: 2px solid #334155;
    background-color: #0f172a;
    color: #fff;
    outline: none;
    transition: all 0.3s ease;
}

input[type="text"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* ===== ボタン共通 ===== */
.btn {
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn:active {
    transform: scale(0.98);
}

.primary-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.secondary-btn {
    background-color: #334155;
    color: white;
}

.secondary-btn:hover {
    background-color: #475569;
}

.x-btn {
    background-color: #000000;
    color: white;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.x-btn:hover {
    background-color: #27272a;
}

.x-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.text-btn {
    background: transparent;
    color: #94a3b8;
    padding: 8px;
    text-decoration: underline;
    font-size: 0.9rem;
}

.text-btn:hover {
    color: #cbd5e1;
}

/* ===== 実績解除カード領域 (画像化対象) ===== */
.achievement-card {
    background: linear-gradient(to bottom right, #1a1a2e, #16213e);
    border: 2px solid #fbbf24;
    border-radius: 12px;
    padding: 24px 16px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(251, 191, 36, 0.2);
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 擬似要素で神々しい光を演出 */
.achievement-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent 0%, rgba(251, 191, 36, 0.1) 25%, transparent 50%);
    animation: rotate-light 10s linear infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes rotate-light {
    100% {
        transform: rotate(360deg);
    }
}

.card-inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    width: 100%;
    gap: 16px;
}

.icon-area {
    font-size: 3rem;
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.5));
}

.text-area {
    text-align: left;
    flex-grow: 1;
}

.achievement-label {
    font-family: 'Oswald', sans-serif;
    color: #fbbf24;
    font-size: 0.8rem;
    letter-spacing: 2px;
    margin-bottom: 4px;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.title {
    font-size: 1.4rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 4px;
    word-break: break-all;
    line-height: 1.3;
}

/* 文字数が多い場合にフォントサイズをJSで調整するためのクラス */
.title.long-text {
    font-size: 1.1rem;
}

.title.super-long {
    font-size: 0.9rem;
}

.title.ultra-long {
    font-size: 0.75rem;
}

.action {
    font-size: 1rem;
    color: #cbd5e1;
    word-break: break-all;
    line-height: 1.4;
    max-height: 80px;
    /* 長すぎる場合は高さを制限して画像化時の崩れを防ぐ */
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    /* CSSで3行までに省略 */
}

.rarity-badge {
    position: absolute;
    top: -12px;
    right: -8px;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #fff;
    font-size: 0.7rem;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* レアリティ別の装飾 */
.rarity-N .achievement-card {
    border-color: #64748b;
    box-shadow: none;
}

.rarity-N .achievement-label {
    color: #cbd5e1;
}

.rarity-N .rarity-badge {
    background: #64748b;
}

.rarity-N .achievement-card::before {
    display: none;
}

.rarity-R .achievement-card {
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.rarity-R .achievement-label {
    color: #60a5fa;
}

.rarity-R .rarity-badge {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.rarity-SR .achievement-card {
    border-color: #db2777;
    box-shadow: 0 0 30px rgba(219, 39, 119, 0.4);
}

.rarity-SR .achievement-label {
    color: #f472b6;
}

.rarity-SR .rarity-badge {
    background: linear-gradient(135deg, #db2777, #be185d);
}

.rarity-SSR .achievement-card {
    border-color: #fbbf24;
    box-shadow: 0 0 40px rgba(251, 191, 36, 0.6), inset 0 0 20px rgba(251, 191, 36, 0.3);
}

/* SSRは煌めきアニメーションを追加 */
.rarity-SSR .title {
    background: linear-gradient(to right, #fbbf24, #fff, #fbbf24);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 2s linear infinite;
}

@keyframes shine {
    to {
        background-position: 200% center;
    }
}


/* ===== リザルト＆アクションエリア ===== */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sub-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.sub-actions .btn {
    flex: 1;
}

/* トースト通知 */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #10b981;
    /* エメラルドグリーン */
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translate(-50%, 20px);
    pointer-events: none;
}

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

/* ローディングスピナー */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin: 32px 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #334155;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 登場アニメーション */
.fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

footer {
    margin-top: 32px;
    font-size: 0.8rem;
    color: #475569;
}

.footer-links {
    margin-bottom: 12px;
}

.footer-links a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #94a3b8;
    text-decoration: underline;
}

.separator {
    margin: 0 8px;
    color: #334155;
}

/* ===== レスポンシブ対応 (スマホ向け) ===== */
@media screen and (max-width: 480px) {
    body {
        padding: 12px;
        /* 画面端の余白を少し減らす */
    }

    .container {
        padding: 24px 16px;
        /* スマホでは横のpaddingを狭くしてコンテンツ幅を確保 */
        border-radius: 12px;
    }

    header h1 {
        font-size: 1.5rem;
        /* タイトルを少し小さく */
    }

    header p {
        font-size: 0.85rem;
        margin-bottom: 24px;
    }

    .input-section label {
        font-size: 0.95rem;
    }

    input[type="text"] {
        padding: 12px 14px;
        font-size: 1rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.95rem;
        flex-wrap: wrap;
        /* 長いボタンテキストの折り返しを許可 */
    }

    /* 実績カードの中身をスマホ最適化 */
    .achievement-card {
        padding: 20px 12px;
        gap: 12px;
        flex-direction: column;
        /* アイコンを上に、テキストを下に配置 */
        text-align: center;
    }

    .card-inner {
        flex-direction: column;
        gap: 8px;
    }

    .text-area {
        text-align: center;
    }

    .icon-area {
        font-size: 2.5rem;
    }

    .achievement-label {
        font-size: 0.75rem;
    }

    .title {
        font-size: 1.25rem;
    }

    .title.long-text {
        font-size: 1.1rem;
    }

    .title.super-long {
        font-size: 0.95rem;
    }

    .action {
        font-size: 0.9rem;
    }

    /* サブボタンを縦並びに */
    .sub-actions {
        flex-direction: column;
        gap: 8px;
    }

    /* トースト通知 */
    .toast {
        width: 90%;
        max-width: 320px;
        font-size: 0.85rem;
        padding: 10px 16px;
        bottom: 16px;
    }
}