/* モダンなモーダルデザインのためのCSS */
.modal {
    font-family: 'Noto Sans Japanese', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.modal__container {
    background-color: #fff;
    width: 85%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    box-sizing: border-box;
    padding: 20px;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 15px;
}

.modal__title {
    margin: 0;
    font-weight: 600;
    font-size: 1.5rem;
    color: #333;
}

.modal__close {
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
}

.modal__close:hover {
    color: #333;
}

.modal__content {
    margin-bottom: 2rem;
    color: #333;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #eaeaea;
    padding-top: 15px;
}

.modal__btn {
    font-size: 1rem;
    padding: 10px 20px;
    background-color: #f0f0f0;
    color: #333;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.modal__btn:hover {
    background-color: #e0e0e0;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.modal__btn-primary {
    background-color: #4a6cf7;
    color: #fff;
}

.modal__btn-primary:hover {
    background-color: #3a5ce6;
}

/* マイスコアダッシュボードのスタイル */
.score-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.score-card {
    background-color: #f9f9f9;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    text-align: center;
    transition: all 0.3s ease;
}

.score-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.score-card__title {
    font-size: 0.9rem;
    color: #666;
    margin: 0 0 10px 0;
}

.score-card__value {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.score-card--correct {
    background-color: #e8f5e9;
}

.score-card--correct .score-card__value {
    color: #2e7d32;
}

.score-card--incorrect {
    background-color: #ffebee;
}

.score-card--incorrect .score-card__value {
    color: #c62828;
}

.score-card--total {
    background-color: #e3f2fd;
}

.score-card--total .score-card__value {
    color: #1565c0;
}

.score-card--ratio {
    background-color: #fff3e0;
}

.score-card--ratio .score-card__value {
    color: #ef6c00;
}

/* 覚えた単語数のスコアカード */
.score-card--learned-words {
    background-color: #e3f2fd;
}

.score-card--learned-words .score-card__value {
    color: #1565c0;
}

/* タブ切り替え */
.tabs {
    display: flex;
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab.active {
    border-bottom: 3px solid #4a6cf7;
    color: #4a6cf7;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* グラフエリア */
.chart-container {
    margin: 20px 0;
    height: 300px;
    position: relative;
}

/* 学習アドバイスエリア */
.learning-advice {
    background: #f1f8e9;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.learning-advice h3 {
    margin-top: 0;
    color: #33691e;
}

.advice-item {
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 5px;
    border-left: 3px solid #8bc34a;
}

/* ランキング表示 */
.ranking-container {
    max-height: 60vh; /* 高さを制限してスクロール可能に */
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 10px;
    background-color: #fdfdfd;
}

#ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#ranking-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

#ranking-list li:last-child {
    border-bottom: none;
}

#ranking-list .rank {
    font-weight: bold;
    font-size: 1.1rem;
    color: #4a6cf7;
    min-width: 30px; /* 順位表示幅 */
    text-align: center;
    margin-right: 15px;
}

#ranking-list .userid {
    flex-grow: 1;
    font-weight: 500;
    color: #333;
    margin-right: 10px;
    /* 長いIDが折り返されるように */
    word-break: break-all;
}

#ranking-list .score {
    font-size: 0.9rem;
    color: #555;
    min-width: 100px; /* スコア表示幅 */
    text-align: right;
}

#ranking-list .score .correct {
    color: #2e7d32;
    font-weight: 600;
}

#ranking-list .score .bad {
    color: #c62828;
}

/* ローディング・エラー表示 (history.css と共通化も検討可) */
#ranking-list li.loading,
#ranking-list li.error {
    justify-content: center;
    color: #888;
    font-style: italic;
    font-weight: normal;
}
#ranking-list li.error {
    color: #c62828;
    font-weight: bold;
}
.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ranking-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

/* ソート・期間ボタングループ */
.ranking-sort-buttons,
.ranking-period-buttons {
    display: flex;
    gap: 5px;
}

.sort-button,
.period-button {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #f2f2f2;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sort-button:hover,
.period-button:hover {
    background-color: #e0e0e0;
}

.sort-button.active,
.period-button.active {
    background-color: #4a6cf7;
    color: white;
    border-color: #4a6cf7;
}

.ranking-filter select {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #333;
    background-color: white;
}

.refresh-btn {
    background-color: #f2f2f2;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background-color: #e0e0e0;
}

.refresh-btn i {
    color: #555;
}

.refresh-btn.loading i {
    animation: spin 1s infinite linear;
}

.modern-ranking-list {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    position: relative;
    min-height: 200px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ranking-item:hover {
    background-color: #f5f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    z-index: 1;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-position {
    font-size: 1.25rem;
    font-weight: bold;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 18px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.ranking-item:hover .ranking-position {
    transform: scale(1.08);
}

.position-1 {
    background: linear-gradient(135deg, #ffd700, #f9a825);
    box-shadow: 0 2px 8px rgba(249, 168, 37, 0.3);
}

.position-2 {
    background: linear-gradient(135deg, #c0c0c0, #9e9e9e);
    box-shadow: 0 2px 8px rgba(158, 158, 158, 0.3);
}

.position-3 {
    background: linear-gradient(135deg, #cd7f32, #8d6e63);
    box-shadow: 0 2px 8px rgba(141, 110, 99, 0.3);
}

.position-default {
    background: linear-gradient(135deg, #4a6cf7, #3a5ce6);
    box-shadow: 0 2px 4px rgba(74, 108, 247, 0.3);
}

.ranking-info {
    flex-grow: 1;
    overflow: hidden;
}

.ranking-user {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-stats {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #666;
}

.stat-item {
    display: flex;
    align-items: center;
}

.stat-item i {
    margin-right: 6px;
    font-size: 0.9rem;
}

.stat-item.correct i {
    color: #4caf50;
}

.stat-item.incorrect i {
    color: #f44336;
}

.stat-item.accuracy i {
    color: #2196f3;
}

.stat-item.learned-words i {
    color: #4caf50;
}

.stat-item.learned-words i {
    color: #4caf50;
}

/* 強調表示のスタイル */
.stat-item.highlight {
    font-weight: bold;
    color: #333;
    background-color: rgba(74, 108, 247, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin: -4px 0;
}

.stat-item.highlight i {
    color: #4a6cf7;
}

.stat-item.correct.highlight {
    background-color: rgba(76, 175, 80, 0.15);
}

.stat-item.correct.highlight i {
    color: #2e7d32;
}

.stat-item.accuracy.highlight {
    background-color: rgba(33, 150, 243, 0.15);
}

.stat-item.accuracy.highlight i {
    color: #1976d2;
}

.stat-item.total.highlight {
    background-color: rgba(0, 0, 0, 0.1);
}

.progress-bar-container {
    height: 4px;
    background-color: #f0f0f0;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    transition: width 0.3s ease;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 2;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

/* レスポンシブ対応 */
@media screen and (max-width: 600px) {
    .ranking-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .ranking-controls {
        margin-top: 10px;
        width: 100%;
    }

    .ranking-filter {
        flex-grow: 1;
    }

    .ranking-filter select {
        width: 100%;
    }

    .ranking-stats {
        flex-direction: column;
        gap: 4px;
    }
}

/* シェア機能 */
.share-area {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eaeaea;
    text-align: center;
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.share-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-button:hover {
    transform: scale(1.1);
}

.share-twitter {
    background-color: #1da1f2;
}

.share-facebook {
    background-color: #1877f2;
}

.share-line {
    background-color: #00b900;
}

/* アニメーション */
@keyframes mmfadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes mmfadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes mmslideIn {
    from {
        transform: translateY(10%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes mmslideOut {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10%);
    }
}

.micromodal-slide {
    display: none;
}

.micromodal-slide.is-open {
    display: block;
}

.micromodal-slide[aria-hidden="false"] .modal__overlay {
    animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="false"] .modal__container {
    animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__overlay {
    animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__container {
    animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide .modal__container,
.micromodal-slide .modal__overlay {
    will-change: transform;
}

/* アカウント管理スタイル */

.account-section {
    margin-bottom: 25px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.account-section h4 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.account-section input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.account-section button {
    background-color: #4a6cf7;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.account-section button:hover {
    background-color: #3a5ce6;
}

/* スマートフォン対応 */
@media screen and (max-width: 600px) {
    .modal__container {
        width: 100%;
        height: 93vh;
        max-height: none;
        padding: 15px;
        border-radius: 12px 12px 0px 0px;
        position: absolute;
        bottom: 0;
    }

    .ranking-header {
        display: block;
    }

    .score-dashboard {
        grid-template-columns: 1fr 1fr;
    }

    .score-card__value {
        font-size: 1.5rem;
    }

    .tab {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* アニメーション */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
