/* ===== 神経衰弱 攻略ツール - memory.css ===== */

/* ページ全体 */
.memory-page {
    max-width: 1300px;
    margin: 0 auto;
    padding: 1rem 1.5rem 2rem;
    position: relative;
    z-index: 1;
}

.memory-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center top, rgba(30, 20, 60, 0.5) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
}

.page-title {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
    background: linear-gradient(135deg, #ffd700, #ff9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    text-align: center;
    color: var(--text-sub);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ===== モード切替タブ ===== */
.mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.mode-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.8rem 2rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-sub);
    font-size: 1rem;
    transition: all 0.3s;
    min-width: 180px;
}

.mode-tab:hover {
    border-color: var(--border-highlight);
    color: var(--text-main);
}

.mode-tab.active {
    border-color: var(--accent-gold);
    color: var(--text-main);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 149, 0, 0.05));
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.1);
}

.tab-icon {
    font-size: 1.5rem;
}

.tab-label {
    font-weight: bold;
    font-size: 1rem;
}

.tab-desc {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* ===== モードパネル ===== */
.mode-panel {
    display: none;
}

.mode-panel.active {
    display: block;
}

/* ===== PCモードレイアウト ===== */
.memory-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1000px) {
    .memory-layout {
        grid-template-columns: 1fr;
    }
}

/* セクションヘッダー */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.section-header h2 {
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin: 0;
}

/* ===== キャプチャエリア ===== */
.capture-area {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
}

.capture-controls {
    display: flex;
    gap: 0.5rem;
}

.capture-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #333;
}

.capture-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    text-align: center;
    padding: 1rem;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.placeholder-hint {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 0.3rem;
}

#captureVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

#captureOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

#captureOverlay.calibrating {
    cursor: crosshair !important;
    pointer-events: auto;
}

/* キャリブレーションバー */
.calibration-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.6rem;
    padding: 0.5rem 0.8rem;
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    font-size: 0.85rem;
}

.calibration-status {
    color: var(--text-sub);
}

.calibration-status.detected {
    color: #4caf50;
}

/* ===== 攻略グリッド ===== */
.result-area {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
}

.result-controls {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.detection-count {
    font-size: 0.85rem;
    color: var(--accent-gold);
    font-weight: bold;
}

.result-grid-wrapper {
    background: linear-gradient(135deg, #1a1530 0%, #0f0a1e 100%);
    border-radius: 10px;
    padding: 0.8rem;
    border: 1px solid #2a2545;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
}

/* 個別カード */
.memory-card {
    position: relative;
    aspect-ratio: 0.72;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #3a3555;
    transition: all 0.3s;
    background: #1e1838;
}

.memory-card .card-back {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
}

.memory-card .card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.memory-card.revealed .card-back {
    display: none;
}

.memory-card.revealed .card-face {
    display: block;
}

.memory-card.revealed {
    border-color: #5a55ff;
    box-shadow: 0 0 8px rgba(90, 85, 255, 0.3);
}

/* ペア番号バッジ */
.pair-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: rgba(255, 215, 0, 0.92);
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 50%;
    z-index: 5;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.memory-card .card-label {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.5);
    padding: 1px 0;
}

.memory-card:hover {
    transform: scale(1.05);
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.memory-card.highlighted {
    border-color: #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5) !important;
    animation: highlightPulse 1s ease-in-out infinite;
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.7); }
}

.memory-card.selected {
    border-color: #ff4444 !important;
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.5);
}

/* ペア検索 */
.match-helper {
    margin-top: 0.8rem;
    padding: 0.8rem;
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
}

.match-helper h3 {
    font-size: 0.95rem;
    color: var(--accent-gold);
    margin: 0 0 0.3rem;
}

.match-hint {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin: 0;
}

/* ===== ボタンスタイル ===== */
.btn-primary {
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, var(--accent-gold-dark), var(--accent-gold));
    color: #000;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.btn-primary:disabled {
    opacity: 0.4;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    color: var(--text-sub);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.btn-secondary:hover {
    border-color: var(--border-highlight);
    color: var(--text-main);
}

.btn-secondary:disabled {
    opacity: 0.4;
}

.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

.btn-large {
    padding: 0.9rem 2rem;
    font-size: 1.1rem;
}

.btn-file {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

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

.btn-cancel {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 1.3rem;
    padding: 0.2rem 0.5rem;
    transition: color 0.2s;
}

.btn-cancel:hover {
    color: #ff4444;
}

/* ===== 設定パネル ===== */
.settings-panel {
    margin-top: 1rem;
}

.settings-panel details {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.settings-panel summary {
    padding: 0.8rem 1rem;
    color: var(--text-sub);
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.3s;
}

.settings-panel summary:hover {
    color: var(--text-main);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.setting-item label {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.setting-item select,
.setting-item input[type="range"] {
    padding: 0.4rem;
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.85rem;
}

.setting-item input[type="range"] {
    accent-color: var(--accent-gold);
}

/* ===== スマホモード - ステップカード ===== */
.mobile-steps {
    max-width: 600px;
    margin: 0 auto;
}

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    display: none;
    align-items: flex-start;
    gap: 1rem;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.step-card.active {
    display: flex;
    opacity: 1;
}

.step-card.completed {
    display: flex;
    opacity: 0.6;
    border-color: #4caf50;
}

.step-number {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: linear-gradient(135deg, var(--accent-gold-dark), var(--accent-gold));
    color: #000;
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.step-card.completed .step-number {
    background: linear-gradient(135deg, #2e7d32, #4caf50);
    color: #fff;
}

.step-content {
    flex: 1;
}

.step-content h3 {
    margin: 0 0 0.3rem;
    font-size: 1rem;
    color: var(--text-main);
}

.step-content p {
    margin: 0 0 0.8rem;
    font-size: 0.85rem;
    color: var(--text-sub);
}

.upload-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-sub);
    display: flex;
    gap: 1rem;
}

/* キャリブレーション */
.calibrate-canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid #333;
}

.calibrate-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
}

.calibrate-markers {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.calibrate-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* 動画シークバー */
.video-seek-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.4rem;
    padding: 0.3rem 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

.video-seek-bar input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.video-seek-bar input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-gold, #ffd700);
    border: 2px solid rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.video-seek-bar span {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    min-width: 7em;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* プログレスバー */
.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.progress-track-lg {
    flex: 1;
    height: 12px;
    background: #2a2545;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-lg {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-gold-dark), var(--accent-gold));
    border-radius: 6px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--accent-gold);
    min-width: 3em;
    text-align: right;
}

.analyze-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-sub);
}

/* PiP コントロール */
.pip-controls {
    text-align: center;
    margin: 1.5rem 0 1rem;
}

.pip-hint {
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-top: 0.5rem;
}

/* スマホ結果グリッド */
.mobile-result .result-grid {
    max-width: 500px;
    margin: 0 auto;
}

/* ===== ガイドセクション ===== */
.guide-section {
    margin-top: 2rem;
}

.guide-section details {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.guide-title {
    padding: 1rem 1.2rem;
    font-size: 1rem;
    color: var(--accent-gold);
    cursor: pointer;
    transition: color 0.3s;
}

.guide-title:hover {
    color: #fff;
}

.guide-content {
    padding: 0 1.2rem 1.2rem;
}

.guide-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 700px) {
    .guide-columns {
        grid-template-columns: 1fr;
    }
}

.guide-column h3 {
    font-size: 1rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.guide-column ol {
    padding-left: 1.3rem;
    margin: 0;
}

.guide-column li {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-bottom: 0.4rem;
    line-height: 1.5;
}

/* ===== モーダル ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent-gold);
}

.modal-body {
    padding: 1.2rem;
}

.modal-body p {
    margin: 0 0 0.8rem;
    font-size: 0.9rem;
    color: var(--text-sub);
}

.calib-canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.8rem;
    border: 1px solid #333;
}

.calib-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair !important;
}

.calib-info {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-sub);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--border-color);
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .memory-page {
        padding: 0.5rem 0.8rem 1.5rem;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .page-subtitle {
        font-size: 0.8rem;
    }

    .mode-tab {
        padding: 0.6rem 1rem;
        min-width: 140px;
    }

    .tab-icon {
        font-size: 1.2rem;
    }

    .tab-label {
        font-size: 0.85rem;
    }

    .result-grid {
        gap: 4px;
    }

    .memory-card {
        border-width: 1px;
    }

    .capture-area,
    .result-area {
        padding: 0.8rem;
    }

    .section-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .mode-tabs {
        flex-direction: column;
        gap: 0.3rem;
    }

    .mode-tab {
        flex-direction: row;
        gap: 0.5rem;
        min-width: unset;
        padding: 0.6rem 1rem;
    }

    .tab-desc {
        display: none;
    }

    .result-grid {
        gap: 3px;
    }

    .memory-card .card-label {
        font-size: 0.45rem;
    }

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