/* ファミコン風レトロスタイル */

/* Google Fonts - DotGothic16 (日本語対応ファミコン風フォント) + Press Start 2P */
@import url('https://fonts.googleapis.com/css2?family=DotGothic16&family=Press+Start+2P&display=swap');

/* ふりがな（ルビ）のスタイル - サイト全体 */
ruby {
    ruby-align: center;
}

ruby rt {
    font-size: 0.5em;
    font-weight: normal;
    color: inherit;
    opacity: 0.85;
}

/* リセット */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DotGothic16', 'Press Start 2P', cursive;
    line-height: 1.8;
    color: #0f380f;
    background-color: #9bbc0f;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        );
    image-rendering: pixelated;
    font-size: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ナビゲーションバー */
.navbar {
    background: #306230;
    color: #9bbc0f;
    padding: 0.5rem 0;
    border-bottom: 4px solid #0f380f;
    box-shadow: 0 4px 0 #0f380f;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* ナビゲーションバー固定のためのbodyスペース */
body {
    padding-top: 80px;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.4rem;
    font-weight: bold;
    color: #9bbc0f;
    text-decoration: none;
    text-shadow: 2px 2px 0 #0f380f;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
}

.logo-image {
    height: 58px;
    width: auto;
    display: block;
}

.logo:hover {
    color: #fff;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: #9bbc0f;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border: 3px solid #0f380f;
    background: #306230;
    box-shadow: 3px 3px 0 #0f380f;
    transition: all 0.1s;
}

.nav-links a:hover {
    background: #0f380f;
    color: #9bbc0f;
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #0f380f;
}

.user-info {
    background: #0f380f;
    color: #9bbc0f;
    padding: 0.7rem 1.2rem;
    border: 3px solid #306230;
    font-size: 0.7rem;
}

.user-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 4px solid #306230;
    transition: all 0.2s;
    box-shadow: 3px 3px 0 #0f380f;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
    padding: 0;
    text-decoration: none;
}

.user-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-icon:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #0f380f;
    border-color: #8b1e3f;
}

/* メインコンテンツ */
.main-content {
    min-height: calc(100vh - 180px);
    padding: 2rem 0;
}

/* ヒーローセクション */
.hero {
    background: #306230;
    color: #9bbc0f;
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 2rem;
    border: 4px solid #0f380f;
    box-shadow: 8px 8px 0 #0f380f;
}

.hero-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-shadow: 3px 3px 0 #0f380f;
    letter-spacing: 0.1em;
}

.hero-subtitle {
    font-size: 0.9rem;
    margin-bottom: 2rem;
    line-height: 2;
}

.stats-highlight {
    margin: 1.5rem 0;
    padding: 1rem 2rem;
    background: rgba(155, 188, 15, 0.1);
    border: 4px solid #9bbc0f;
    box-shadow: 4px 4px 0 #0f380f;
    display: inline-block;
}

.stats-text {
    font-size: 1rem;
    color: #0f380f;
    margin: 0;
    font-family: 'DotGothic16', 'Press Start 2P', cursive;
}

.stats-text strong {
    color: #9bbc0f;
    font-size: 1.3rem;
    font-weight: bold;
}

.hero-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* 特徴セクション */
.features {
    padding: 2rem 0;
}

.section-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: #0f380f;
    text-shadow: 2px 2px 0 #306230;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: #8bac0f;
    padding: 2rem;
    border: 4px solid #0f380f;
    text-align: center;
    box-shadow: 6px 6px 0 #0f380f;
    transition: all 0.2s;
}

.feature-card:hover {
    transform: translate(3px, 3px);
    box-shadow: 3px 3px 0 #0f380f;
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(2px 2px 0 #0f380f);
}

.feature-card h3 {
    margin-bottom: 1rem;
    color: #0f380f;
    font-size: 1rem;
}

.feature-card p {
    font-size: 0.7rem;
    line-height: 1.8;
    color: #306230;
}

/* 使い方セクション */
.how-to-use {
    background: #8bac0f;
    padding: 2rem;
    margin: 2rem 0;
    border: 4px solid #0f380f;
    box-shadow: 6px 6px 0 #0f380f;
}

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.step {
    text-align: center;
}

.step-number {
    width: 50px;
    height: 50px;
    background: #306230;
    color: #9bbc0f;
    border: 3px solid #0f380f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 auto 1rem;
}

.step h3 {
    margin-bottom: 0.5rem;
    color: #0f380f;
    font-size: 0.9rem;
}

.step p {
    font-size: 0.7rem;
    color: #306230;
    line-height: 1.8;
}

/* CTAセクション */
.cta {
    background: #306230;
    color: #9bbc0f;
    padding: 2rem;
    text-align: center;
    border: 4px solid #0f380f;
    margin: 2rem 0;
    box-shadow: 6px 6px 0 #0f380f;
}

.cta h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 0 #0f380f;
}

.cta p {
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
    line-height: 2;
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 1rem 2rem;
    border: 4px solid #0f380f;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    font-family: 'DotGothic16', 'Press Start 2P', cursive;
    transition: all 0.1s;
    box-shadow: 4px 4px 0 #0f380f;
    font-weight: normal;
}

.btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #0f380f;
}

.btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #0f380f;
}

.btn-primary {
    background: #306230;
    color: #9bbc0f;
}

.btn-primary:hover {
    background: #0f380f;
    color: #9bbc0f;
}

.btn-secondary {
    background: #8bac0f;
    color: #0f380f;
}

.btn-secondary:hover {
    background: #9bbc0f;
}

.btn-danger {
    background: #8b1e3f;
    color: #fff;
}

.btn-danger:hover {
    background: #660e2e;
}

.btn-large {
    padding: 1.5rem 3rem;
    font-size: 1rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 0.6rem 1.2rem;
    font-size: 0.7rem;
}

/* フォーム */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.7rem;
    font-weight: normal;
    color: #0f380f;
    font-size: 0.8rem;
}

.form-control {
    width: 100%;
    padding: 1rem;
    border: 4px solid #0f380f;
    font-size: 0.9rem;
    font-family: 'DotGothic16', 'Press Start 2P', cursive;
    background: #8bac0f;
    color: #0f380f;
    box-shadow: inset 2px 2px 0 #306230;
}

.form-control:focus {
    outline: none;
    background: #9bbc0f;
}

.form-help {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.6rem;
    color: #306230;
    line-height: 1.6;
}

/* 認証ページ */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: #8bac0f;
    padding: 2rem;
    border: 4px solid #0f380f;
    box-shadow: 8px 8px 0 #0f380f;
    width: 100%;
    max-width: 500px;
}

.auth-title {
    text-align: center;
    margin-bottom: 2rem;
    color: #0f380f;
    font-size: 1.5rem;
    text-shadow: 2px 2px 0 #306230;
}

.auth-form {
    margin-bottom: 1rem;
}

.auth-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 3px solid #306230;
    margin-top: 1rem;
}

.auth-footer a {
    color: #0f380f;
    text-decoration: none;
    font-size: 0.7rem;
    border-bottom: 2px solid #0f380f;
}

.auth-footer a:hover {
    color: #306230;
    border-bottom-color: #306230;
}

/* アラート */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 4px solid #0f380f;
    font-size: 0.8rem;
    line-height: 1.8;
}

.alert-success {
    background: #8bac0f;
    color: #0f380f;
}

.alert-error {
    background: #8b1e3f;
    color: #fff;
}

.alert-warning {
    background: #f7b32b;
    color: #0f380f;
}

/* ページヘッダー */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: #8bac0f;
    border: 4px solid #0f380f;
    box-shadow: 6px 6px 0 #0f380f;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #0f380f;
    text-shadow: 2px 2px 0 #306230;
}

.page-header p {
    font-size: 1.1rem;
    color: #306230;
    line-height: 2;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: #0f380f;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border: 3px solid #0f380f;
    background: #8bac0f;
    box-shadow: 3px 3px 0 #0f380f;
}

.back-link:hover {
    background: #9bbc0f;
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #0f380f;
}

/* 学年グリッド */
.grades-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-top: 2rem;
}

.grade-card {
    background: #8bac0f;
    padding: 2rem;
    border: 4px solid #0f380f;
    text-align: center;
    box-shadow: 6px 6px 0 #0f380f;
    text-decoration: none;
    color: #0f380f;
    transition: all 0.2s;
}


.grade-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.grade-card h2 {
    color: #0f380f;
    font-size: 1.2rem;
    text-shadow: 1px 1px 0 #306230;
}

/* 単元グリッド */
.units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.unit-card {
    background: #8bac0f;
    padding: 1.5rem;
    border: 4px solid #0f380f;
    box-shadow: 6px 6px 0 #0f380f;
    text-decoration: none;
    color: #0f380f;
    transition: all 0.2s;
}

.unit-card:hover {
    transform: translate(3px, 3px);
    box-shadow: 3px 3px 0 #0f380f;
    background: #9bbc0f;
}

.unit-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.unit-card h3 {
    color: #0f380f;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.unit-info {
    color: #306230;
    font-size: 0.7rem;
    line-height: 1.8;
}

/* 練習コンテナ */
.practice-container {
    max-width: 800px;
    margin: 0 auto;
}

.progress-bar {
    background: #306230;
    border: 4px solid #0f380f;
    height: 40px;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    background: #9bbc0f;
    height: 100%;
    transition: width 0.3s;
    border-right: 4px solid #0f380f;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: #0f380f;
    font-size: 0.9rem;
    text-shadow: 1px 1px 0 #9bbc0f;
}

.question-card {
    background: #8bac0f;
    padding: 3rem 2rem;
    border: 4px solid #0f380f;
    box-shadow: 8px 8px 0 #0f380f;
    margin-bottom: 2rem;
    text-align: center;
}

.question-number {
    font-size: 0.9rem;
    color: #306230;
    margin-bottom: 1.5rem;
    font-weight: bold;
}

.question-text {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: #0f380f;
    font-weight: bold;
    text-shadow: 2px 2px 0 #306230;
}

.answer-input-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.answer-input {
    width: 200px;
    padding: 1.2rem;
    font-size: 1.3rem;
    border: 4px solid #0f380f;
    text-align: center;
    font-family: 'DotGothic16', 'Press Start 2P', cursive;
    background: #9bbc0f;
    color: #0f380f;
    box-shadow: inset 2px 2px 0 #306230;
}

.answer-input:focus {
    outline: none;
    background: #fff;
}

.navigation-buttons {
    text-align: center;
}

/* 結果ページ */
.result-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.result-card {
    background: #8bac0f;
    padding: 3rem 2rem;
    border: 4px solid #0f380f;
    box-shadow: 8px 8px 0 #0f380f;
    max-width: 700px;
    width: 100%;
    text-align: center;
}

.result-title {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: #0f380f;
    text-shadow: 2px 2px 0 #306230;
}

.result-score {
    margin-bottom: 2rem;
}

.score-circle {
    display: inline-block;
    width: 200px;
    height: 200px;
    background: #306230;
    color: #9bbc0f;
    border: 4px solid #0f380f;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 6px 6px 0 #0f380f;
}

.score-value {
    font-size: 3.5rem;
    font-weight: bold;
}

.score-total {
    font-size: 1.2rem;
}

.result-percentage {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #0f380f;
    font-weight: bold;
}

.result-message {
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 2;
}

.message-excellent { color: #0f380f; }
.message-great { color: #306230; }
.message-good { color: #8b6220; }
.message-tryagain { color: #8b1e3f; }

.result-info {
    background: #9bbc0f;
    padding: 1.5rem;
    border: 3px solid #0f380f;
    margin-bottom: 2rem;
    text-align: left;
}

.result-info p {
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: #0f380f;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 管理者ページ */
.admin-section {
    background: #8bac0f;
    padding: 2rem;
    border: 4px solid #0f380f;
    box-shadow: 6px 6px 0 #0f380f;
    margin-bottom: 2rem;
}

.admin-section h2 {
    margin-bottom: 1.5rem;
    color: #0f380f;
    font-size: 1.3rem;
    text-shadow: 1px 1px 0 #306230;
}

.inline-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.inline-form input {
    flex: 1;
    min-width: 150px;
}

.inline-form button {
    flex-shrink: 0;
}

.admin-list {
    margin-top: 2rem;
}

.admin-item {
    background: #9bbc0f;
    padding: 1.5rem;
    border: 3px solid #0f380f;
    margin-bottom: 1.5rem;
}

.admin-item h3 {
    color: #0f380f;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.mt-2 {
    margin-top: 1rem;
}

.unit-list {
    margin-top: 1rem;
}

.unit-item {
    background: #8bac0f;
    padding: 1rem;
    border: 3px solid #0f380f;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.problem-form {
    background: #9bbc0f;
    padding: 1.5rem;
    border: 3px solid #0f380f;
}

.code-editor {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.problems-list {
    margin-top: 2rem;
}

.problem-item {
    background: #9bbc0f;
    padding: 1.5rem;
    border: 3px solid #0f380f;
    margin-bottom: 1.5rem;
}

.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.problem-header h3 {
    color: #0f380f;
    margin: 0;
    font-size: 1rem;
}

.problem-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.problem-code {
    background: #306230;
    padding: 1rem;
    border: 3px solid #0f380f;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.problem-code pre {
    margin: 0;
    color: #9bbc0f;
    font-size: 0.7rem;
}

.problem-code code {
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    line-height: 1.8;
}

.problem-edit {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 3px solid #0f380f;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #306230;
    font-size: 0.8rem;
}

/* フッター */
.footer {
    background: #306230;
    color: #9bbc0f;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 4px solid #0f380f;
    font-size: 0.7rem;
}

.footer .footer-links {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer .footer-links a,
.footer .footer-links a:link,
.footer .footer-links a:visited {
    color: #9bbc0f !important;
    text-decoration: none !important;
    padding: 0.3rem 0.8rem;
    border: 1px solid #9bbc0f;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: background 0.2s, color 0.2s;
    background: transparent;
}

.footer .footer-links a:hover,
.footer .footer-links a:active {
    background: #9bbc0f !important;
    color: #0f380f !important;
    text-decoration: none !important;
}

/* レスポンシブ */
@media (max-width: 768px) {
    body {
        font-size: 8px;
    }
    
    .logo-image {
        height: 40px;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.8rem;
    }
    
    .stats-highlight {
        padding: 0.8rem 1.5rem;
    }
    
    .stats-text {
        font-size: 0.8rem;
    }
    
    .stats-text strong {
        font-size: 1.1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
    }
    
    .nav-links {
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-links a {
        font-size: 0.6rem;
        padding: 0.4rem 0.8rem;
    }
    
    .question-text {
        font-size: 1.2rem;
    }
    
    .answer-input-group {
        flex-direction: column;
    }
    
    .answer-input {
        width: 100%;
    }
    
    .inline-form {
        flex-direction: column;
    }
    
    .unit-item {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .grades-grid {
        grid-template-columns: 1fr;
    }
    
    .problem-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
