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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
    background: white;
    min-height: 100vh;
    padding-top: 58px;
}

:root {
    --brand-500: #FF5704;
    --brand-600: #E04F00;
    --brand-700: #C44700;
    --brand-400: #FF7A33;
    --brand-300: #FFA366;
    --brand-shadow: rgba(255, 87, 4, 0.28);
}

/* ---- ヘッダー ---- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(255, 255, 255, 0.93);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    z-index: 1000;
}

.header-content {
    height: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 0;
}

/* 戻るボタン */
.back-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    border-radius: 8px;
    padding: 6px 10px 6px 6px;
    color: #555;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    line-height: 1;
}

.back-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #111;
}

.back-btn:active {
    background: rgba(0, 0, 0, 0.09);
}

.back-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.back-label {
    font-size: 14px;
}

/* 区切り線 */
.header-divider {
    width: 1px;
    height: 22px;
    background: #e0e0e0;
    flex-shrink: 0;
    margin: 0 14px;
}

/* タイトル・メタ情報 */
.manga-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.manga-title-header {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    margin-bottom: 1px;
}

.manga-meta-header {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* 右側コントロール */
.header-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

/* ページカウンター */
.page-counter {
    background: #f4f4f4;
    border: 1px solid #e8e8e8;
    border-radius: 20px;
    padding: 4px 12px;
    color: #555;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* 更新ボタン（アイコンのみ） */
.refresh-btn {
    background: none;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-size: 18px;
    line-height: 1;
}

.refresh-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #111;
}

.refresh-btn:active {
    background: rgba(0, 0, 0, 0.1);
}

.refresh-btn.refreshing {
    opacity: 0.5;
    pointer-events: none;
}

.refresh-icon {
    display: block;
    transition: transform 0.5s ease;
}

.refresh-btn.refreshing .refresh-icon {
    animation: rotate 1s linear infinite;
}

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

/* ---- プログレスバー ---- */
.progress-bar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(0, 0, 0, 0.06);
    z-index: 999;
}

.progress-fill {
    height: 100%;
    background: var(--brand-500);
    width: 0%;
    transition: width 0.2s ease;
}

/* ---- メインコンテンツ ---- */
.manga-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 58px);
}

.manga-page-wrapper {
    position: relative;
    display: block;
}

.manga-page {
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-bottom: 0;
    display: block;
    border: none;
}

/* ---- 用語解説オーバーレイ ---- */
.glossary-overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 蛍光マーカー風ハイライト */
.glossary-overlay {
    pointer-events: auto;
    position: absolute;
    cursor: pointer;
    border: none;
    padding: 0;
    border-radius: 3px;
    background: rgba(255, 230, 0, 0.30);
    transition: background 0.2s;
}

.glossary-overlay:hover,
.glossary-overlay:focus {
    background: rgba(255, 230, 0, 0.48);
    outline: none;
}

/* ---- ツールチップカード（グラスモーフィズム・白寄り） ---- */
.glossary-tooltip {
    position: fixed;
    z-index: 10000;
    width: 300px;
    max-width: calc(100vw - 24px);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(32px) saturate(1.4);
    -webkit-backdrop-filter: blur(32px) saturate(1.4);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    font-size: 14px;
    line-height: 1.6;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.97);
    transition: opacity 0.25s, visibility 0.25s, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}

.glossary-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.glossary-tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.glossary-tooltip-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255, 87, 4, 0.35);
}

.glossary-tooltip-badge svg {
    width: 16px;
    height: 16px;
    color: #fff;
}

.glossary-tooltip-term {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    line-height: 1.3;
}

.glossary-tooltip-body {
    padding: 12px 16px 16px;
}

.glossary-tooltip-explanation {
    margin: 0;
    color: #333;
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.7;
}

.glossary-tooltip-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 50%;
    cursor: pointer;
    color: #555;
    font-size: 14px;
    line-height: 1;
    transition: background 0.15s;
    padding: 0;
}

.glossary-tooltip-close:hover {
    background: rgba(0, 0, 0, 0.15);
    color: #111;
}

.glossary-tooltip-explanation .glossary-link {
    display: inline-block;
    margin: 8px 8px 0 0;
    padding: 6px 14px;
    background: var(--brand-500);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s;
}

.glossary-tooltip-explanation .glossary-link:hover {
    background: var(--brand-600);
}

/* 背景オーバーレイ（モバイルでカード表示中） */
.glossary-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.glossary-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

/* ---- フッター ---- */
.manga-footer {
    text-align: center;
    padding: 40px 20px;
    background: #f8f8f8;
    margin-top: 20px;
    border-top: 1px solid #e5e5e5;
}

.footer-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.footer-meta {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.footer-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.footer-btn {
    background: var(--brand-500);
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

.footer-btn:hover {
    background: var(--brand-600);
}

.footer-btn.secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.footer-btn.secondary:hover {
    background: #e5e5e5;
}

.footer-btn.cta {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
}

.footer-btn.cta:hover {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-400));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--brand-shadow);
}

.footer-btn.cta::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.footer-btn.cta:hover::before {
    left: 100%;
}

/* ---- CTA説明文 ---- */
.cta-description {
    text-align: center;
    margin: 24px auto 20px auto;
    padding: 0 20px;
    max-width: 720px;
}

.cta-title {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.cta-subtitle {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

/* ---- NFTパネル ---- */
.nft-section {
    position: relative;
    overflow: hidden;
    border-radius: 32px;
    padding: 32px 16px;
}

.nft-panel {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    background: linear-gradient(#fff, #fff) padding-box,
                linear-gradient(135deg, rgba(255, 87, 4, 0.35), rgba(255, 138, 61, 0.35)) border-box;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid transparent;
    overflow: hidden;
    transition: background 0.3s ease;
}

.nft-panel:hover {
    background: linear-gradient(#fff, #fff) padding-box,
                linear-gradient(135deg, rgba(255, 87, 4, 0.7), rgba(255, 138, 61, 0.7)) border-box;
}

.nft-panel-content {
    padding: 40px;
    position: relative;
    z-index: 1;
}

.nft-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 51px;
    height: auto;
    display: block;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
    pointer-events: none;
}

.nft-panel-header {
    text-align: center;
    margin-bottom: 40px;
}

.nft-title {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    animation: fadeInScale 0.8s ease-out;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

.nft-subtitle {
    font-size: 16px;
    color: #64748b;
    font-weight: 500;
}

.nft-panel-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
    margin-bottom: 30px;
}

.nft-cover-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nft-cover-wrapper {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.nft-cover-wrapper:hover {
    transform: translateZ(0);
}

.nft-cover {
    width: auto;
    height: auto;
    max-width: 260px;
    max-height: 312px;
    object-fit: contain;
    border-radius: 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2),
                0 10px 20px rgba(99, 102, 241, 0.2);
    position: relative;
    z-index: 2;
}

.nft-cover-wrapper::before {
    content: '';
    position: absolute;
    inset: -10px;
    background: linear-gradient(45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%);
    border-radius: 0;
    transform: translateX(-100%);
    animation: hologram 3s ease-in-out infinite;
}

@keyframes hologram {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.nft-qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.nft-qr-wrapper {
    position: relative;
    padding: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.9));
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1),
                inset 0 1px 1px rgba(255, 255, 255, 0.9);
}

.nft-qr {
    width: 200px;
    height: 200px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.scan-animation {
    position: absolute;
    left: 0;
    right: 0;
    top: -20%;
    height: 40%;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(16, 185, 129, 0.45) 50%,
        rgba(255, 255, 255, 0) 100%);
    opacity: 0.9;
    animation: scanMove 2.4s ease-in-out infinite;
    will-change: transform;
    z-index: 5;
    pointer-events: none;
}

@keyframes scanMove {
    0%   { transform: translateY(-120%); }
    100% { transform: translateY(220%); }
}

.qr-instructions {
    text-align: center;
    font-size: 14px;
    color: #64748b;
    max-width: 250px;
}

.nft-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 40px;
}

.nft-btn {
    position: relative;
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.nft-btn-primary {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    color: white;
    box-shadow: 0 10px 20px var(--brand-shadow);
}

.nft-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px var(--brand-shadow);
}

.nft-btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.nft-btn-primary:active::before {
    width: 300px;
    height: 300px;
}

.nft-btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--brand-500);
    border: 2px solid rgba(255, 87, 4, 0.2);
    backdrop-filter: blur(10px);
}

.nft-btn-secondary:hover {
    background: rgba(255, 87, 4, 0.08);
    border-color: rgba(255, 87, 4, 0.4);
    transform: translateY(-2px);
}

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

.nft-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 30px;
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(16, 185, 129, 0.1));
    border-radius: 50px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

.status-text {
    font-size: 14px;
    color: #16a34a;
    font-weight: 600;
}

/* ---- レスポンシブ ---- */
@media (max-width: 600px) {
    .header-content {
        padding: 0 12px;
        gap: 0;
    }

    .back-label {
        display: none;
    }

    .back-btn {
        padding: 6px 8px;
    }

    .header-divider {
        margin: 0 10px;
    }

    .manga-info {
        display: block;
    }

    .manga-title-header {
        font-size: 13px;
    }

    .manga-meta-header {
        display: none;
    }

    .page-counter {
        font-size: 11px;
        padding: 3px 9px;
    }

    .refresh-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .manga-container {
        padding: 0;
    }

    .nft-panel-content {
        padding: 30px 20px;
    }

    .nft-panel-body {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .nft-title {
        font-size: 24px;
    }

    .nft-subtitle {
        font-size: 14px;
    }

    .nft-actions {
        flex-direction: column;
    }

    .nft-btn {
        width: 100%;
        justify-content: center;
    }

    .footer-actions {
        flex-direction: column;
        align-items: center;
    }

    .footer-btn {
        width: 100%;
        max-width: 200px;
    }
}

/* ---- ローディング ---- */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 18px;
    color: #666;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #007AFF;
    border-top: 2px solid transparent;
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 1s linear infinite;
}

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

/* ---- エラー表示 ---- */
.error {
    text-align: center;
    padding: 40px 20px;
    color: #FF3B30;
    font-size: 16px;
}

.error-title {
    font-size: 24px;
    margin-bottom: 10px;
}
