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

body {
    font-family: "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN", "メイリオ", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    max-width: 800px;
    width: 100%;
    animation: slideIn 0.5s ease-out;
}

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

.title {
    text-align: center;
    font-size: 3.5rem;
    margin-bottom: 40px;
    color: #5a67d8;
    font-weight: bold;
}

.bounce {
    display: inline-block;
    animation: bounce 2s ease-in-out infinite;
}

.bounce:nth-child(1) { animation-delay: 0s; }
.bounce:nth-child(2) { animation-delay: 0.1s; }
.bounce:nth-child(3) { animation-delay: 0.2s; }
.bounce:nth-child(4) { animation-delay: 0.3s; }
.bounce:nth-child(5) { animation-delay: 0.4s; }
.bounce:nth-child(6) { animation-delay: 0.5s; }
.bounce:nth-child(7) { animation-delay: 0.6s; }
.bounce:nth-child(8) { animation-delay: 0.7s; }

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

.grade-selector {
    text-align: center;
    margin-bottom: 30px;
}

.grade-selector label {
    font-size: 1.5rem;
    color: #4a5568;
    display: block;
    margin-bottom: 15px;
    font-weight: bold;
}

.grade-dropdown {
    padding: 15px 30px;
    font-size: 1.2rem;
    border: 3px solid #5a67d8;
    border-radius: 15px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.grade-dropdown:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.grade-dropdown:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.kanji-selection {
    animation: fadeIn 0.5s ease-out;
}

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

.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.selection-header h2 {
    font-size: 1.8rem;
    color: #4a5568;
}

.select-all-btn {
    padding: 10px 20px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-all-btn:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

.kanji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
}

.kanji-item {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7fafc;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.kanji-item:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.kanji-item.selected {
    background: #5a67d8;
    color: white;
    border-color: #5a67d8;
    animation: pop 0.3s ease;
}

@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.start-btn {
    display: block;
    margin: 0 auto;
    padding: 20px 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.start-btn:active {
    transform: translateY(0);
}

.practice-header {
    text-align: right;
    margin-bottom: 30px;
}

.progress {
    font-size: 1.8rem;
    color: #5a67d8;
    font-weight: bold;
    background: #edf2f7;
    padding: 10px 20px;
    border-radius: 10px;
    display: inline-block;
}

.practice-content {
    text-align: center;
    margin-bottom: 50px;
}

.kanji-display {
    font-size: 2.5rem;
    color: #2d3748;
    margin-bottom: 30px;
    min-height: 150px;
    align-items: center;
    justify-content: center;
    animation: zoomIn 0.5s ease-out;
    line-height: 1.8;
    letter-spacing: 0.05em;
}

.kanji-display u {
    text-decoration: underline;
    text-decoration-color: #5a67d8;
    text-decoration-thickness: 3px;
    text-underline-offset: 5px;
    font-weight: bold;
    color: #5a67d8;
    white-space: nowrap;
    display: inline-block;
}

@keyframes zoomIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.instruction {
    font-size: 1.5rem;
    color: #718096;
}

.practice-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.control-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.next-btn {
    background: #48bb78;
    color: white;
}

.next-btn:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

.end-btn {
    background: #f56565;
    color: white;
}

.end-btn:hover {
    background: #e53e3e;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 101, 101, 0.3);
}

.share-btn {
    background: #9f7aea;
    color: white;
}

.share-btn:hover {
    background: #805ad5;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(159, 122, 234, 0.3);
}

.share-btn.copied {
    background: #38a169;
}

.share-btn.copied:hover {
    background: #38a169;
}

.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* スプラッシュスクリーン */
.splash-container {
    text-align: center;
    max-width: 900px;
}

.splash-title {
    font-size: 4.5rem;
    margin-bottom: 50px;
    color: #5a67d8;
    font-weight: bold;
}

.mode-selection {
    margin-bottom: 50px;
}

.mode-selection h2 {
    font-size: 2rem;
    color: #4a5568;
    margin-bottom: 30px;
}

.mode-buttons {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 40px;
}

.mode-btn {
    width: 250px;
    padding: 30px;
    background: white;
    border: 4px solid #e2e8f0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.mode-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.reading-mode:hover {
    border-color: #4299e1;
    background: #ebf8ff;
}

.writing-mode:hover {
    border-color: #48bb78;
    background: #f0fff4;
}

.mode-icon {
    font-size: 3rem;
}

.mode-text {
    font-size: 2rem;
    font-weight: bold;
    color: #2d3748;
}

.mode-desc {
    font-size: 1rem;
    color: #718096;
}

.usage-guide {
    background: #f7fafc;
    border-radius: 20px;
    padding: 30px;
    margin-top: 30px;
}

.usage-guide h3 {
    font-size: 1.5rem;
    color: #4a5568;
    margin-bottom: 20px;
}

.guide-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.guide-number {
    width: 40px;
    height: 40px;
    background: #5a67d8;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    flex-shrink: 0;
}

.guide-item p {
    font-size: 1.1rem;
    color: #4a5568;
    margin: 0;
}

/* 書き練習画面 */
.writing-practice-content {
    text-align: center;
}

.hiragana-display {
    font-size: 4rem;
    color: #2d3748;
    margin-bottom: 30px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease-out;
    background: #f7fafc;
    border-radius: 20px;
    padding: 20px;
    border: 3px dashed #cbd5e0;
}

.writing-area {
    margin: 30px auto;
    max-width: 500px;
}

.paper-effect {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    padding: 50px;
    box-shadow: 
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 10px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    background-image: 
        repeating-linear-gradient(
            0deg,
            #f0f0f0,
            #f0f0f0 1px,
            transparent 1px,
            transparent 30px
        );
}

.paper-effect p {
    font-size: 1.5rem;
    color: #a0aec0;
    margin: 0;
}

.paper-effect::before {
    content: '';
    position: absolute;
    left: 60px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #fc8181;
}

/* 完了画面 */
.completion-container {
    text-align: center;
    max-width: 700px;
}

.completion-celebration {
    margin-bottom: 40px;
}

.completion-title {
    font-size: 3.5rem;
    margin-bottom: 20px;
    animation: celebrationBounce 1s ease-in-out infinite alternate;
}

.celebration-text {
    color: #f6e05e;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes celebrationBounce {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.1);
    }
}

.completion-message {
    font-size: 1.5rem;
    color: #4a5568;
    font-weight: bold;
}

.practiced-kanji-section {
    background: #f7fafc;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
}

.practiced-kanji-section h2 {
    font-size: 1.8rem;
    color: #4a5568;
    margin-bottom: 20px;
}

.practiced-kanji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    justify-items: center;
}

.practiced-kanji-item {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    font-size: 2rem;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: practiceKanjiAppear 0.5s ease-out;
}

@keyframes practiceKanjiAppear {
    from {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.completion-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.restart-btn {
    background: #48bb78;
    color: white;
}

.restart-btn:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

.menu-btn {
    background: #4299e1;
    color: white;
}

.menu-btn:hover {
    background: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(66, 153, 225, 0.3);
}

/* フッター */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px;
    text-align: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.footer p {
    margin: 0;
    font-size: 0.9rem;
    color: #718096;
}

.footer a {
    color: #5a67d8;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #4c51bf;
    text-decoration: underline;
}

/* フッターが重ならないようにbodyに余白を追加 */
body {
    padding-bottom: 60px;
}