/* ==========================================================================
   G-Test Quiz Modern Glassmorphism Style
   ========================================================================== */

/* 1. 変数定義 & リセット */
:root {
    --bg-color: #080b1a;
    --card-bg: rgba(15, 22, 53, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary-grad: linear-gradient(135deg, #00f0ff 0%, #ab20fd 100%);
    --primary-glow: rgba(171, 32, 253, 0.35);
    
    --color-cyan: #00f0ff;
    --color-purple: #ab20fd;
    --color-correct: #2ed573;
    --color-correct-bg: rgba(46, 213, 115, 0.15);
    --color-incorrect: #ff4757;
    --color-incorrect-bg: rgba(255, 71, 87, 0.15);
    
    --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.2), 0 4px 6px -4px rgb(0 0 0 / 0.2);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
    
    --font-primary: 'Outfit', 'Noto Sans JP', sans-serif;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* 2. 背景装飾（ネオン発光） */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(160px);
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
}

.bg-glow-1 {
    background: var(--color-cyan);
    top: -10%;
    left: -10%;
    animation: pulse 15s infinite alternate ease-in-out;
}

.bg-glow-2 {
    background: var(--color-purple);
    bottom: -10%;
    right: -10%;
    animation: pulse 12s infinite alternate-reverse ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1) translate(0, 0); opacity: 0.12; }
    50% { transform: scale(1.1) translate(50px, 30px); opacity: 0.18; }
    100% { transform: scale(0.9) translate(-20px, -40px); opacity: 0.12; }
}

/* 3. コンテナと基本レイアウト */
.app-container {
    width: 100%;
    max-width: 850px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ヘッダー */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 24px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-accent {
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* 4. コンポーネント: カード (Glassmorphism) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow-lg), inset 0 1px 1px rgba(255, 255, 255, 0.05);
    transition: var(--transition-normal);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* 5. 画面切り替えシステム */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* 6. ダッシュボード画面 */
.welcome-card {
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.welcome-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-cyan);
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

.welcome-card h1 {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.gradient-text {
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-desc {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 90%;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .welcome-card h1 {
        font-size: 1.8rem;
    }
}

/* 設定パネル */
.settings-card h2, .status-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* セレクトボックスのカスタム化 */
.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: "↓";
    font-size: 0.8rem;
    color: var(--text-secondary);
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    appearance: none;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

select:focus {
    border-color: var(--color-cyan);
    background: rgba(255, 255, 255, 0.08);
}

select option {
    background: #0d122b;
    color: var(--text-primary);
}

/* ラジオボタンタイルのカスタム化 */
.radio-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.radio-tile {
    position: relative;
    cursor: pointer;
}

.radio-tile input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.tile-label {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    transition: var(--transition-fast);
}

.radio-tile input:checked + .tile-label {
    background: rgba(171, 32, 253, 0.15);
    border-color: var(--color-purple);
    color: var(--text-primary);
    font-weight: 600;
}

.radio-tile:hover .tile-label {
    border-color: rgba(255, 255, 255, 0.2);
}

/* 進捗ステータス */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-cyan);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.bookmark-status {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 20px;
}

.bookmark-status h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.status-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.bookmark-action-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 10px 14px;
}

.bookmark-count-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bookmark-count-text strong {
    color: var(--text-primary);
    font-size: 1.05rem;
}

/* 7. ボタンの基本設計 */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-family: var(--font-primary);
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
}

.btn-primary {
    background: var(--primary-grad);
    color: #fff;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.btn-icon {
    padding: 10px;
    border-radius: 50%;
    position: relative;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 16px 24px;
    font-size: 1.05rem;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-cyan);
    color: #080b1a;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #080b1a;
}

/* 8. クイズ画面 */
.quiz-progress-container {
    margin-bottom: 24px;
}

.quiz-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.category-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-cyan);
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.15);
    padding: 4px 10px;
    border-radius: 8px;
}

.question-number {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-bar-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-grad);
    border-radius: 99px;
    transition: width var(--transition-normal);
}

.quiz-card {
    margin-bottom: 24px;
}

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

.quiz-accent-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1.5px;
}

.bookmark-toggle {
    color: var(--text-muted);
}

.bookmark-toggle.active {
    color: var(--color-purple);
    filter: drop-shadow(0 0 6px rgba(171, 32, 253, 0.6));
}

.bookmark-toggle.active svg {
    fill: var(--color-purple);
}

.question-text {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 28px;
    word-break: break-word;
}

/* 選択肢 */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    width: 100%;
    text-align: left;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
}

.option-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-cyan);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 240, 255, 0.05);
}

.option-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* 状態クラス */
.option-btn.correct {
    background: var(--color-correct-bg) !important;
    border-color: var(--color-correct) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(46, 213, 115, 0.15) !important;
}

.option-btn.incorrect {
    background: var(--color-incorrect-bg) !important;
    border-color: var(--color-incorrect) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.15) !important;
    animation: shake 0.4s ease-in-out;
}

.option-btn:disabled {
    cursor: default;
    opacity: 0.6;
}

.option-btn.correct:disabled, .option-btn.incorrect:disabled {
    opacity: 1; /* 正誤判定されたものは薄くしない */
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* 解説カード */
.explanation-card {
    background: rgba(16, 25, 61, 0.8);
    border-color: rgba(255, 255, 255, 0.12);
    margin-top: 24px;
}

.explanation-card.hidden {
    display: none;
}

.explanation-status-header {
    margin-bottom: 16px;
}

.result-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.9rem;
}

.result-badge.correct {
    background: var(--color-correct-bg);
    color: var(--color-correct);
    border: 1px solid var(--color-correct);
}

.result-badge.incorrect {
    background: var(--color-incorrect-bg);
    color: var(--color-incorrect);
    border: 1px solid var(--color-incorrect);
}

.explanation-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.explanation-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 24px;
    white-space: pre-line;
}

.explanation-text p {
    margin-bottom: 12px;
}

.explanation-text strong {
    color: var(--text-primary);
}

.explanation-text h4 {
    color: var(--color-cyan);
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 16px;
    margin-bottom: 8px;
}

.explanation-text ul {
    margin-top: 8px;
    margin-bottom: 16px;
    padding-left: 20px;
}

.explanation-text li {
    margin-bottom: 10px;
    line-height: 1.5;
}

.explanation-actions {
    display: flex;
    justify-content: flex-end;
}

/* 9. リザルト画面 */
.result-card {
    text-align: center;
    padding: 48px 32px;
}

.result-icon-container {
    margin-bottom: 20px;
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.result-card h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.result-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.score-display {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 24px;
    display: inline-block;
    min-width: 200px;
    margin-bottom: 24px;
}

.score-number {
    font-size: 3.5rem;
    font-weight: 900;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
    margin-bottom: 8px;
}

.score-detail {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.result-evaluation {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 80%;
    margin: 0 auto 36px;
    line-height: 1.5;
}

.category-analysis {
    text-align: left;
    margin-bottom: 36px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 24px;
}

.category-analysis h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.category-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.category-bar-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-bar-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
}

.category-bar-name {
    color: var(--text-primary);
}

.category-bar-pct {
    color: var(--color-cyan);
    font-weight: 600;
}

.category-progress-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 99px;
    overflow: hidden;
}

.category-progress-fill {
    height: 100%;
    background: var(--color-purple);
    border-radius: 99px;
    transition: width 1s ease-out;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.result-actions .btn {
    flex: 1;
    max-width: 200px;
}

/* 10. モーダル (ブックマーク) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 6, 15, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 99px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.bookmark-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition-fast);
}

.bookmark-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.bookmark-item-body {
    flex: 1;
}

.bookmark-item-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.bookmark-item-cat {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-cyan);
}

.bookmark-item-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.bookmark-item-delete {
    color: var(--text-muted);
}

.bookmark-item-delete:hover {
    color: var(--color-incorrect);
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 0.9rem;
}

.modal-footer {
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* フッター・免責事項 */
.app-footer {
    margin-top: auto;
    padding-top: 32px;
    text-align: center;
}

.disclaimer {
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--text-muted);
    opacity: 0.6;
    max-width: 650px;
    margin: 0 auto;
}
