.constitution-typing-game-wrapper {
    font-family: 'Yu Gothic', 'Hiragino Sans', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 20px;
    width: 100% !important;
    max-width: 1000px !important;
    margin: 20px auto !important;
    box-sizing: border-box;
}

.constitution-typing-game-wrapper * {
    box-sizing: border-box;
}

.constitution-typing-game-wrapper .game-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 100%;
}

.constitution-typing-game-wrapper h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
    font-size: 28px;
}

.constitution-typing-game-wrapper h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.constitution-typing-game-wrapper h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.constitution-typing-game-wrapper .tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e9ecef;
    overflow-x: auto;
}

.constitution-typing-game-wrapper .tab {
    padding: 12px 24px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: bold;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.constitution-typing-game-wrapper .tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.constitution-typing-game-wrapper .tab-content {
    display: none;
}

.constitution-typing-game-wrapper .tab-content.active {
    display: block;
}

.constitution-typing-game-wrapper .difficulty-select {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.constitution-typing-game-wrapper .difficulty-btn {
    flex: 1;
    min-width: 150px;
    padding: 20px;
    border: 3px solid #e9ecef;
    border-radius: 15px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.constitution-typing-game-wrapper .difficulty-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.constitution-typing-game-wrapper .difficulty-btn.selected {
    border-color: #667eea;
    background: #f0f4ff;
}

.constitution-typing-game-wrapper .difficulty-title {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
}

.constitution-typing-game-wrapper .difficulty-desc {
    font-size: 13px;
    color: #6c757d;
}

.constitution-typing-game-wrapper .game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.constitution-typing-game-wrapper .info-box {
    background: #f8f9fa;
    padding: 15px 25px;
    border-radius: 10px;
    flex: 1;
    min-width: 120px;
}

.constitution-typing-game-wrapper .info-label {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
}

.constitution-typing-game-wrapper .info-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

.constitution-typing-game-wrapper .combo-display {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
    display: none;
}

.constitution-typing-game-wrapper .combo-display.show {
    display: block;
    animation: ctype-pulse 0.5s ease;
}

@keyframes ctype-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.constitution-typing-game-wrapper .kanji-display {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 10px;
    min-height: 100px;
    font-size: 22px;
    line-height: 1.8;
    letter-spacing: 0.05em;
    color: #333;
    font-weight: 500;
}

.constitution-typing-game-wrapper .text-display {
    background: #fff3e0;
    padding: 25px 30px;
    border-radius: 15px;
    margin-bottom: 10px;
    min-height: 80px;
    font-size: 20px;
    line-height: 1.8;
    letter-spacing: 0.05em;
    color: #555;
}

.constitution-typing-game-wrapper .romaji-display {
    background: #e3f2fd;
    padding: 20px 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    min-height: 60px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.1em;
    color: #1976d2;
    font-weight: bold;
    word-wrap: break-word;
    word-break: break-all;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.6;
}

.constitution-typing-game-wrapper .correct {
    color: #28a745;
}

.constitution-typing-game-wrapper .incorrect {
    color: #dc3545;
    background-color: #ffe6e6;
    animation: ctype-shake 0.3s;
}

@keyframes ctype-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.constitution-typing-game-wrapper .current {
    background-color: #ffc107;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
    animation: ctype-blink 1s infinite;
}

@keyframes ctype-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.constitution-typing-game-wrapper .remaining {
    color: #6c757d;
}

.constitution-typing-game-wrapper .input-area {
    margin-bottom: 20px;
}

.constitution-typing-game-wrapper .input-mode-notice {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: bold;
    color: #856404;
}

.constitution-typing-game-wrapper input[type="text"],
.constitution-typing-game-wrapper input[type="number"] {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.1em;
}

.constitution-typing-game-wrapper input[type="text"]:focus,
.constitution-typing-game-wrapper input[type="number"]:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.constitution-typing-game-wrapper .buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.constitution-typing-game-wrapper button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
}

.constitution-typing-game-wrapper #nextBtn {
    display: none;
}

.constitution-typing-game-wrapper .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.constitution-typing-game-wrapper .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.constitution-typing-game-wrapper .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.constitution-typing-game-wrapper .btn-secondary {
    background: #6c757d;
    color: white;
}

.constitution-typing-game-wrapper .btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.constitution-typing-game-wrapper .btn-share-x {
    background: #000000;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.constitution-typing-game-wrapper .btn-share-x:hover {
    background: #333333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.constitution-typing-game-wrapper .result-display,
.constitution-typing-game-wrapper .total-result-display {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    padding: 30px;
    border-radius: 15px;
    margin-top: 20px;
    display: none;
    color: #333;
}

.constitution-typing-game-wrapper .result-display.show,
.constitution-typing-game-wrapper .total-result-display.show {
    display: block;
    animation: ctype-slideIn 0.5s ease;
}

@keyframes ctype-slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.constitution-typing-game-wrapper .result-item {
    margin-bottom: 10px;
    font-size: 16px;
}

.constitution-typing-game-wrapper .rank-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 20px;
    font-weight: bold;
    margin-left: 10px;
}

.constitution-typing-game-wrapper .rank-s {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.constitution-typing-game-wrapper .rank-a {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.constitution-typing-game-wrapper .rank-b {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.constitution-typing-game-wrapper .rank-c {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.constitution-typing-game-wrapper .rank-d {
    background: #6c757d;
    color: white;
}

.constitution-typing-game-wrapper .progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    display: none;
}

.constitution-typing-game-wrapper .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.constitution-typing-game-wrapper .progress-info {
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
}

.constitution-typing-game-wrapper .total-result-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.constitution-typing-game-wrapper .ranking-display {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
}

.constitution-typing-game-wrapper .ranking-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.constitution-typing-game-wrapper .ranking-table th,
.constitution-typing-game-wrapper .ranking-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.constitution-typing-game-wrapper .ranking-table th {
    background: #667eea;
    color: white;
    font-weight: bold;
}

.constitution-typing-game-wrapper .ranking-table tr:hover {
    background: #f0f4ff;
}

.constitution-typing-game-wrapper .stats-display {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
}

.constitution-typing-game-wrapper .stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #dee2e6;
}

.constitution-typing-game-wrapper .stat-label {
    font-weight: bold;
    color: #667eea;
}

.constitution-typing-game-wrapper .stat-value {
    color: #333;
}

.constitution-typing-game-wrapper .settings-group {
    margin-bottom: 20px;
}

.constitution-typing-game-wrapper .settings-label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #667eea;
}

.constitution-typing-game-wrapper .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    cursor: pointer;
}

.constitution-typing-game-wrapper input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .constitution-typing-game-wrapper .game-container {
        padding: 20px;
    }

    .constitution-typing-game-wrapper h1 {
        font-size: 24px;
    }

    .constitution-typing-game-wrapper .text-display {
        font-size: 20px;
        padding: 20px;
    }

    .constitution-typing-game-wrapper .romaji-display {
        font-size: 16px;
        padding: 15px 20px;
    }

    .constitution-typing-game-wrapper .difficulty-btn {
        min-width: 100%;
    }

    .constitution-typing-game-wrapper .info-box {
        min-width: 100%;
    }
}
/* ===============================================
   ゲームモード・入力モード切替
   =============================================== */
.constitution-typing-game-wrapper .mode-select-section {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
}

.constitution-typing-game-wrapper .section-label {
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
    white-space: nowrap;
}

.constitution-typing-game-wrapper .mode-btns,
.constitution-typing-game-wrapper .input-mode-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.constitution-typing-game-wrapper .mode-btn,
.constitution-typing-game-wrapper .input-mode-btn {
    padding: 8px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    color: #6c757d;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.constitution-typing-game-wrapper .mode-btn.active,
.constitution-typing-game-wrapper .input-mode-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

.constitution-typing-game-wrapper .mode-btn:hover:not(.active),
.constitution-typing-game-wrapper .input-mode-btn:hover:not(.active) {
    border-color: #667eea;
    color: #667eea;
    transform: none;
}

/* ===============================================
   章フィルタ
   =============================================== */
.constitution-typing-game-wrapper .chapter-filter-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.constitution-typing-game-wrapper .chapter-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.constitution-typing-game-wrapper .chapter-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.constitution-typing-game-wrapper .chapter-check-label {
    display: flex;
    align-items: center;
    gap: 4px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.constitution-typing-game-wrapper .chapter-check-label:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.constitution-typing-game-wrapper .chapter-check-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #667eea;
}

.constitution-typing-game-wrapper .preamble-toggle {
    font-size: 13px;
    color: #495057;
    margin-top: 6px;
}

.constitution-typing-game-wrapper .btn-tiny {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.constitution-typing-game-wrapper .btn-tiny:hover {
    background: #5a6fd6;
    transform: none;
}

/* ===============================================
   タイムアタック カウントダウン
   =============================================== */
.constitution-typing-game-wrapper .countdown-display {
    text-align: center;
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
    padding: 10px;
    margin-bottom: 15px;
}

.constitution-typing-game-wrapper .countdown-danger {
    color: #dc3545 !important;
}

/* ===============================================
   漢字表示（クリック可能）
   =============================================== */
.constitution-typing-game-wrapper .kanji-display {
    transition: background 0.2s;
}

.constitution-typing-game-wrapper .kanji-display:hover {
    background: #eef1ff;
}

/* ===============================================
   解説モーダル
   =============================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
    animation: ctype-fadeIn 0.2s ease;
}

@keyframes ctype-fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 35px;
    max-width: 640px;
    width: 90%;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    animation: ctype-slideUp 0.3s ease;
}

@keyframes ctype-slideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f8f9fa;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #e9ecef;
    transform: none;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 20px;
    padding-right: 40px;
}

.modal-section {
    margin-bottom: 18px;
}

.modal-label {
    font-size: 13px;
    font-weight: bold;
    color: #6c757d;
    margin-bottom: 6px;
}

.modal-kanji {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #333;
    background: #f8f9fa;
    padding: 14px 18px;
    border-radius: 10px;
}

.modal-kana {
    font-size: 1.0rem;
    line-height: 1.8;
    color: #555;
    background: #fff3e0;
    padding: 12px 18px;
    border-radius: 10px;
}

.modal-hint {
    font-size: 12px;
    color: #adb5bd;
    text-align: center;
    margin-top: 18px;
    margin-bottom: 0;
}

/* ===============================================
   苦手条文リスト
   =============================================== */
.constitution-typing-game-wrapper .weak-high td {
    color: #dc3545;
    font-weight: bold;
}

.constitution-typing-game-wrapper .weak-mid td {
    color: #fd7e14;
}

.constitution-typing-game-wrapper .weak-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    color: #856404;
    margin-top: 8px;
}

/* ===============================================
   スマホ追加対応
   =============================================== */
@media (max-width: 600px) {
    .constitution-typing-game-wrapper .mode-select-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .constitution-typing-game-wrapper .chapter-filter-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .modal-content {
        padding: 24px 18px;
    }
}