/**
 * レスポンシブスタイル - 統合terminal.html用
 * PC版横幅制限 + モバイル最適化レイアウト
 */

/* PC版コンテナ横幅制限 - 記事ページと統一 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    min-height: 100vh;
}

/* タブレット・中画面対応 */
@media (min-width: 769px) and (max-width: 1199px) {
    .container {
        padding: 0 2rem;
    }
}

/* 大画面対応 */
@media (min-width: 1200px) {
    .container {
        padding: 0 1rem;
    }
}

/* モバイル専用レイアウト */
@media (max-width: 768px) {
    .container {
        max-width: none;
        margin: 0;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        background: var(--gradient-primary);
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0;
    }
}

/* 共通ヘッダー - PC・モバイル共通スタイル */
.header {
    padding: 0.75rem 1rem;
    height: 60px;
    position: relative;
    z-index: 100;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* モバイル用の追加調整 */
@media (max-width: 768px) {
    .header {
        height: 60px;
    }
}

/* ヘッダーナビゲーション */
.header-nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
}

.logo {
    font-size: 1.1rem;
}

.logo-image {
    height: 40px;
}

/* デスクトップ用メインナビゲーション */
.main-nav {
    display: flex !important; /* デスクトップでメインナビゲーションを表示 */
    align-items: center;
    gap: 1rem;
}

.main-nav .nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.main-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.main-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
}

/* ドロップダウンメニュー */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 250px;
    box-shadow: var(--shadow-lg);
    border-radius: 8px;
    padding: 0.5rem 0;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-0.5rem);
    transition: all 0.3s ease;
}

.dropdown-content a {
    color: var(--text-color) !important;
    padding: 0.5rem 1rem !important;
    text-decoration: none;
    display: block;
    font-weight: normal !important;
}

.dropdown-content a:hover {
    background: var(--bg-light) !important;
}

.dropdown-header {
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-section {
    margin-bottom: 0.5rem;
}

.dropdown-section:last-child {
    margin-bottom: 0;
}

/* ハンバーガーメニュー - PC時は非表示、モバイル時のみ表示 */
.hamburger-menu {
    display: none; /* PC時は非表示 */
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
    position: relative;
}

/* モバイルメニュー - PC時は非表示 */
.mobile-menu,
.mobile-menu-overlay {
    display: none; /* PC時は非表示 */
}

/* モバイル時のナビゲーション切り替え */
@media (max-width: 768px) {
    .main-nav {
        display: none !important; /* モバイルでメインナビゲーション非表示 */
    }

    .hamburger-menu {
        display: flex !important; /* モバイルでハンバーガーメニュー表示 */
        margin-left: auto !important;
        align-self: center !important;
    }

    .mobile-menu,
    .mobile-menu-overlay {
        display: block !important; /* モバイルでモバイルメニュー表示 */
    }
}

.hamburger-line {
    display: block !important;
    width: 100%;
    height: 2px;
    background: white;
    border-radius: 1px;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* ハンバーガーメニューライン強制表示 */
.hamburger-menu .hamburger-line,
.header .hamburger-menu .hamburger-line,
#header-container .hamburger-menu .hamburger-line {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: white !important;
    width: 24px !important;
    height: 2px !important;
}

/* ハンバーガーメニューのアクティブ状態 */
.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

.progress-info {
    display: none; /* モバイルでは進捗情報を非表示 */
}

/* モバイルメニューの表示調整 */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background: white;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 201;
    overflow-y: auto;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 200;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* モバイルメニューコンテンツのスタイル */
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--gradient-primary);
    color: white;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-content {
    padding: 1rem 0;
}

.mobile-nav-section {
    margin-bottom: 2rem;
}

.mobile-nav-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding: 0 1rem;
}

.mobile-nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.mobile-nav-link:hover {
    background: rgba(74, 144, 226, 0.1);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}


/* モバイル用ウェルカムセクション */
.welcome-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1rem;
    margin-bottom: 1rem;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
}

.hero-image {
    order: -1;
    width: 100%;
    max-width: 280px;
}

.hero-main-image {
    width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    animation: mobileHeroImageFloat 3s ease-in-out infinite;
}

.hero-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hero-description {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
    opacity: 0.95;
    max-width: 300px;
}

.hero-features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 250px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    justify-content: flex-start;
}

.feature-icon {
    font-size: 1.25rem;
    min-width: 1.5rem;
}

.get-started-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.875rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.get-started-btn:active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(0.98);
}

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

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

.secondary-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    text-align: center;
}

.secondary-action-btn:hover,
.secondary-action-btn:active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(0.98);
    color: white;
}

.terminal-preview {
    margin-top: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.preview-text {
    text-align: center;
    margin-bottom: 1rem;
}

.preview-text h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.preview-text p {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

.preview-image {
    display: flex;
    justify-content: center;
}

.terminal-demo-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* モバイル用アニメーション */
@keyframes mobileHeroImageFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* モバイル学習開始セクション */
.learning-start-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    color: white;
    padding: 1.5rem 1rem 2rem 1rem;
    margin: 1rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    /* スクロールバーのスタイリング */
    -webkit-overflow-scrolling: touch;
}

.learning-start-section::-webkit-scrollbar {
    width: 4px;
}

.learning-start-section::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.learning-start-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.learning-start-section::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.learning-start-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(255, 255, 255, 0.05) 50%, 
        rgba(255, 255, 255, 0.1) 100%);
    pointer-events: none;
    z-index: 1;
}

.learning-start-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    min-height: 0; /* フレックスアイテムの縮小を許可 */
    height: auto; /* 自動高さ調整 */
}

.learning-start-image {
    width: 100%;
    max-width: 240px;
    order: -1;
}

.learning-start-main-image {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.2);
    animation: mobileLearningFloat 4s ease-in-out infinite;
}

.learning-start-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.learning-start-description {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
    opacity: 0.95;
    max-width: 280px;
}

.learning-start-tips {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 280px;
}

.tip-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    text-align: center;
    width: 100%;
    max-width: 240px;
}

.tip-icon {
    font-size: 1.1rem;
    min-width: 1.3rem;
}

.start-lesson-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.875rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.start-lesson-btn:active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(0.98);
}

/* モバイルお祝いモーダル共通スタイル */
.celebration-overlay,
.levelup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    backdrop-filter: blur(5px);
}

.celebration-modal,
.levelup-modal {
    background: white;
    border-radius: 20px;
    max-width: 350px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: mobileCelebrationSlideIn 0.4s ease-out;
}

.celebration-content,
.levelup-content {
    padding: 2rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.celebration-image,
.levelup-image {
    width: 100%;
    max-width: 200px;
}

.celebration-main-image,
.levelup-main-image {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.celebration-title,
.levelup-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-color);
    margin-bottom: 0.5rem;
}

.celebration-message,
.levelup-message {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.celebration-btn,
.levelup-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--success-color);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.25rem;
    min-width: 120px;
}

.celebration-btn:active,
.levelup-btn:active {
    background: var(--success-hover);
    transform: scale(0.98);
}

.celebration-btn.secondary {
    background: var(--text-muted);
}

.celebration-btn.secondary:active {
    background: #666;
}

.levelup-details {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 1rem;
    margin: 0.5rem 0;
    width: 100%;
    font-size: 0.9rem;
}

/* アニメーション */
@keyframes mobileHeroImageFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

@keyframes mobileLearningFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-5px) rotate(1deg); }
    75% { transform: translateY(-3px) rotate(-1deg); }
}

@keyframes mobileCelebrationSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* モバイルメニュー - 学習データ削除ボタン（PC版と同じ赤背景） */
.reset-btn {
    background: #dc3545 !important;
    border: none;
    color: white !important;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.75rem;
    width: 100%;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 0.5rem 0;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

/* より具体的なセレクター */
#mobileResetProgressBtn.reset-btn {
    color: white !important;
    background-color: #dc3545 !important;
}

.reset-btn:hover,
.reset-btn:active {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}


/* モーダル（PC版と統一） */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    margin: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #495057;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.modal-button {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.modal-button.cancel {
    background: #6c757d;
    color: white;
}

.modal-button.cancel:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.modal-button.confirm {
    background: #dc3545;
    color: white;
}

.modal-button.confirm:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* モバイル統計マスコット */
.stats-mascot {
    text-align: center;
    margin: 1rem 0;
    padding: 0.5rem;
}

.stats-penguin-image {
    max-width: 60px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    animation: mobileStatsFloat 3s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.stats-penguin-image:active {
    transform: scale(1.1);
}

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

/* モバイル バッジ獲得華やか演出 */
.badge-celebration {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    text-align: center;
    color: white;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    max-width: 350px;
    width: 90%;
    margin: 0 auto;
}

.badge-celebration::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
}

.badge-image-container {
    position: relative;
    z-index: 2;
    margin-bottom: 1.5rem;
}

.badge-achievement-image {
    max-width: 200px;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    animation: badgeImageFloat 2s ease-in-out infinite;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.badge-content {
    position: relative;
    z-index: 2;
}

.badge-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.badge-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    backdrop-filter: blur(5px);
}

.badge-icon {
    font-size: 3rem;
    min-width: 3rem;
}

.badge-details {
    text-align: left;
}

.badge-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.badge-description {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
    line-height: 1.4;
}

.badge-close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.badge-close-btn:active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(0.98);
}

/* バッジ獲得アニメーション */
@keyframes badgeImageFloat {
    0%, 100% {
        transform: translateY(0px) scale(1);
    }
    50% {
        transform: translateY(-8px) scale(1.05);
    }
}

@keyframes badgeCelebrationIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes badgeCelebrationOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
}

/* 課題選択タブエリア */
.tabs {
    display: flex;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
    z-index: 50;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    min-width: 80px;
}

.tab:hover {
    color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
    background: rgba(74, 144, 226, 0.1);
}

/* 課題説明パネル（折りたたみ） */
.challenge-panel {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 40;
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    user-select: none;
}

.challenge-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}


.challenge-content {
    padding: 0 1rem 1rem 1rem;
    opacity: 1;
}

.challenge-description {
    color: var(--text-color);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.challenge-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.challenge-hint {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.85rem;
    color: #856404;
}

/* モバイル版ヒント機能 */
.hint-container {
    margin: 1rem 0;
    padding: 0;
}

.hint-button {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    width: 100%;
    -webkit-tap-highlight-color: rgba(74, 144, 226, 0.2);
    touch-action: manipulation;
}

.hint-button:hover,
.hint-button:active {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hint-content {
    margin-top: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    font-style: italic;
    color: #8B4513;
    line-height: 1.6;
    border-left: 4px solid #ffa500;
    font-size: 0.85rem;
}

.hint-content .hint-message {
    margin: 0;
    padding: 0;
    font-weight: 500;
    color: #8B4513;
    font-style: normal;
}

/* ターミナルエリア（メイン） */
.terminal-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--gradient-primary);
    position: relative;
    z-index: 30;
    min-height: 0; /* flexboxでの高さ計算を正しく行う */
}

.terminal-area {
    flex: 1;
    min-height: 0; /* flexboxでの高さ計算を正しく行う */
}

/* モバイル版ターミナル出力の左寄せ */
#mobileTerminal {
    text-align: left !important;
}

#mobileTerminalOutput {
    text-align: left !important;
    line-height: 1.4;
    padding-left: 0 !important;
    margin-left: 0 !important;
}

#mobileTerminalOutput span {
    display: block;
    text-align: left !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* ツールバー */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid var(--border-color);
    height: 50px;
    position: relative;
    z-index: 50;
}

.toolbar-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-btn {
    padding: 0.5rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
}

.toolbar-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.toolbar-btn.secondary {
    background: var(--light-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.toolbar-btn.secondary:hover {
    background: #e9ecef;
}


/* レッスンリスト（タブ内コンテンツ） */
.lesson-list {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.95);
    max-height: 400px;
    overflow-y: auto;
    border-bottom: 1px solid var(--border-color);
}

.lesson-list.active {
    display: flex;
}

/* レッスンリスト レスポンシブ対応 */
/* PC・タブレット向け (769px以上) */
@media (min-width: 769px) {
    .lesson-list {
        max-height: 450px;
    }
}

/* スマートフォン向け (768px以下) */
@media (max-width: 768px) {
    .lesson-list {
        max-height: 350px;
    }
}

/* 大画面向け (1200px以上) */
@media (min-width: 1200px) {
    .lesson-list {
        max-height: 500px;
    }
}

.lesson-item {
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.lesson-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.lesson-item.active,
.lesson-item.selected {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
}

.lesson-item.selected {
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.lesson-item.completed {
    background: rgba(40, 167, 69, 0.05);
    border-color: rgba(40, 167, 69, 0.3);
}

/* 完了済みの課題が選択されている場合も緑色を優先 */
.lesson-item.completed.selected,
.lesson-item.completed.active {
    background: rgba(40, 167, 69, 0.1);
    border-color: rgba(40, 167, 69, 0.5);
}

.lesson-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.lesson-difficulty {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* アニメーション */
.slide-up {
    animation: mobileSlideUp 0.3s ease-out;
}

@keyframes mobileSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.fade-in {
    animation: mobileFadeIn 0.2s ease-in-out;
}

@keyframes mobileFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* タッチ操作最適化 */
.tab,
.lesson-item,
.toolbar-btn,
.challenge-header {
    -webkit-tap-highlight-color: rgba(74, 144, 226, 0.2);
    touch-action: manipulation;
}

/* セーフエリア対応（iPhone X以降） */
@supports (padding-top: env(safe-area-inset-top)) {
    .toolbar {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
        height: calc(50px + env(safe-area-inset-bottom));
    }
}

/* ==========================================================================
   UI/UX改善: モバイル用学習コンテンツカード & モーダル
   ========================================================================== */

/* モバイル版学習コンテンツカード */
.learning-content-cards {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem 1rem;
    margin: 1rem 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.learning-content-cards h2 {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.content-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.content-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary-color);
    text-align: center;
}

.content-card:active {
    transform: scale(0.98);
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.content-card h3 {
    color: var(--text-color);
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.content-card p {
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.content-card a,
.content-card button {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(74, 144, 226, 0.2);
}

.content-card a:active,
.content-card button:active {
    transform: scale(0.95);
}

/* モバイル版カード別カラー */
.guide-card {
    border-left-color: var(--info-color);
}

.practice-card {
    border-left-color: var(--success-color);
}

.recommended-card {
    border-left-color: var(--warning-color);
}

/* モバイル版初回訪問者モーダル機能は削除済み */

/* 必要なモーダルスタイル（正解モーダル等で使用） */
.mobile-modal-content {
    background: white;
    padding: 2rem 1.5rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.mobile-modal-content h2,
.mobile-modal-content h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.mobile-modal-content p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
    font-size: 0.9rem;
}

.mobile-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-modal-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    font-size: 1rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(74, 144, 226, 0.2);
}

.mobile-modal-button:active {
    transform: scale(0.98);
}

.mobile-modal-button.secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

/* モバイル版記事レコメンドトースト */
.article-recommendation {
    position: fixed;
    bottom: 70px; /* ツールバー上 */
    right: 10px;          /* 右寄せ */
    left: auto;           /* 左は自動（横幅いっぱいを解除） */
    max-width: 350px;     /* 最大幅を制限 */
    min-width: 280px;     /* 最小幅を確保 */
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    border-top: 4px solid var(--info-color);
    transform: translateY(100px);
    transition: transform 0.3s ease;
    z-index: 900;
}

.article-recommendation.show {
    transform: translateY(0);
}

.recommendation-content {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.recommendation-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.recommendation-text {
    flex: 1;
    line-height: 1.4;
    font-size: 0.9rem;
}

.recommendation-text strong {
    color: var(--text-color);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
}

.recommendation-text a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.recommendation-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.recommendation-close:active {
    background-color: var(--light-color);
}

/* iPhone X以降の安全エリア対応 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .article-recommendation {
        bottom: calc(70px + env(safe-area-inset-bottom));
    }
}