/* 九九マスター - スタイルシート */

/* ==============================
   基本設定
============================== */
:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #FF9800;
    --secondary-dark: #F57C00;
    --accent-color: #2196F3;
    --danger-color: #f44336;
    --success-color: #4CAF50;
    --background-color: #E3F2FD;
    --card-background: #ffffff;
    --text-color: #333333;
    --text-light: #666666;
    --border-radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'メイリオ', Meiryo, sans-serif;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
}

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

/* ==============================
   ヘッダー
============================== */
.header {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: var(--border-radius);
    color: white;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.welcome-header {
    padding: 40px 20px;
}

.train-animation {
    position: relative;
    height: 60px;
    margin-bottom: 20px;
}

.train {
    font-size: 3rem;
    animation: moveRight 3s ease-in-out infinite;
}

.smoke {
    position: absolute;
    top: -10px;
    font-size: 1.5rem;
    opacity: 0.8;
    animation: smokeFloat 2s ease-in-out infinite;
}

@keyframes moveRight {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(30px); }
}

@keyframes smokeFloat {
    0%, 100% { opacity: 0.8; transform: translateY(0); }
    50% { opacity: 0.3; transform: translateY(-10px); }
}

.tagline {
    font-size: 1.3rem;
    opacity: 0.95;
}

.user-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 15px;
}

.user-name {
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
}

/* ==============================
   ボタン
============================== */
.btn {
    display: inline-block;
    padding: 14px 28px;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
}

.btn-info {
    background: linear-gradient(135deg, var(--accent-color), #1976D2);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #D32F2F);
    color: white;
}

.btn-large {
    padding: 18px 40px;
    font-size: 1.3rem;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* ==============================
   レベルカード
============================== */
.menu-title {
    text-align: center;
    margin-bottom: 30px;
}

.menu-title h2 {
    font-size: 1.8rem;
    color: var(--text-color);
}

.level-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.level-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 30px;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border-left: 6px solid;
}

.level-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.level-1 { border-color: #4CAF50; }
.level-2 { border-color: #2196F3; }
.level-3 { border-color: #FF9800; }
.level-4 { border-color: #9C27B0; }

.level-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.level-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.level-card p {
    color: var(--text-light);
    margin-bottom: 15px;
}

.level-features {
    list-style: none;
    font-size: 0.95rem;
}

.level-features li {
    padding: 5px 0;
    padding-left: 25px;
    position: relative;
}

.level-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

/* ==============================
   認証フォーム
============================== */
.auth-form {
    max-width: 450px;
    margin: 0 auto;
    background: var(--card-background);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.auth-form .btn {
    width: 100%;
    margin-top: 10px;
}

.auth-links {
    text-align: center;
    margin-top: 25px;
}

.auth-links a {
    color: var(--accent-color);
    font-weight: bold;
}

.error-message {
    background: #FFEBEE;
    color: var(--danger-color);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.success-message {
    background: #E8F5E9;
    color: var(--success-color);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

/* ==============================
   ウェルカム画面
============================== */
.welcome-screen {
    text-align: center;
}

.welcome-message {
    background: var(--card-background);
    padding: 40px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--primary-dark);
}

.welcome-message p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.welcome-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.features-preview {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.feature {
    background: var(--card-background);
    padding: 25px 35px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.feature-icon {
    font-size: 2.5rem;
}

.feature-text {
    font-weight: bold;
}

/* ==============================
   進捗セクション
============================== */
.progress-section {
    background: var(--card-background);
    padding: 30px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.progress-section h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* ==============================
   学習画面
============================== */
.learning-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    min-height: 600px;
}

@media (max-width: 900px) {
    .learning-container {
        grid-template-columns: 1fr;
    }
}

.problem-area {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.problem-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.problem-text {
    font-size: 4rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--text-color);
}

.problem-text .multiplier {
    color: var(--accent-color);
}

.problem-text .multiplicand {
    color: var(--secondary-color);
}

.answer-display {
    font-size: 3rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 15px;
    padding: 15px 40px;
    margin-bottom: 20px;
    min-width: 150px;
}

.answer-display.correct {
    background: #E8F5E9;
    color: var(--success-color);
}

.answer-display.incorrect {
    background: #FFEBEE;
    color: var(--danger-color);
}

/* テンキー */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 300px;
    margin: 20px auto;
}

.numpad-btn {
    padding: 20px;
    font-size: 1.8rem;
    border: none;
    border-radius: 15px;
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
}

.numpad-btn:hover {
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    transform: scale(1.05);
}

.numpad-btn:active {
    transform: scale(0.95);
}

.numpad-btn.clear {
    background: linear-gradient(135deg, #FFCDD2, #EF9A9A);
}

.numpad-btn.enter {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.numpad-btn.zero {
    grid-column: span 2;
}

/* 九九マップ */
.kuku-map-area {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

.kuku-map-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.kuku-map {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.station {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    border-radius: 25px;
    background: #f5f5f5;
    min-width: 200px;
    transition: all 0.3s ease;
}

.station.current {
    background: linear-gradient(135deg, #FFF9C4, #FFEB3B);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(255, 235, 59, 0.5);
}

.station.completed {
    background: linear-gradient(135deg, #C8E6C9, #81C784);
}

.station.locked {
    opacity: 0.5;
}

.station-icon {
    font-size: 1.5rem;
}

.station-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.track {
    width: 4px;
    height: 30px;
    background: #bdbdbd;
}

.track.completed {
    background: var(--primary-color);
}

/* 九九表 */
.kuku-table-area {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.kuku-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.1rem;
}

.kuku-table th,
.kuku-table td {
    padding: 12px;
    text-align: center;
    border: 2px solid #e0e0e0;
}

.kuku-table th {
    background: var(--accent-color);
    color: white;
    font-weight: bold;
}

.kuku-table td {
    background: #fafafa;
    transition: all 0.3s ease;
}

.kuku-table td.correct {
    background: #C8E6C9;
    color: var(--primary-dark);
    font-weight: bold;
}

.kuku-table td.current {
    background: #FFF9C4;
    font-weight: bold;
}

.kuku-table td.hidden {
    color: transparent;
}

/* ヒントボタン */
.hint-btn {
    margin-top: 15px;
    padding: 12px 25px;
    background: linear-gradient(135deg, #FFF59D, #FFEE58);
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hint-btn:hover {
    transform: scale(1.05);
}

.hint-display {
    margin-top: 15px;
    padding: 15px 25px;
    background: #FFF9C4;
    border-radius: 15px;
    font-size: 1.3rem;
    animation: fadeIn 0.3s ease;
}

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

/* 正解履歴 */
.correct-history {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 15px;
    margin-top: 20px;
    min-height: 60px;
}

.correct-item {
    background: #C8E6C9;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    animation: popIn 0.3s ease;
}

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

/* やめるボタン */
.quit-section {
    text-align: center;
    padding: 30px;
    margin-top: 20px;
}

.quit-btn {
    background: linear-gradient(135deg, #90A4AE, #607D8B);
    color: white;
    padding: 15px 40px;
    border: none;
    border-radius: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(96, 125, 139, 0.4);
}

/* フィードバック */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    z-index: 1000;
    animation: feedbackPop 0.5s ease-out forwards;
}

@keyframes feedbackPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* 選択画面 */
.dan-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.dan-btn {
    padding: 25px 20px;
    border: none;
    border-radius: 15px;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
}

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

.dan-btn.available {
    background: linear-gradient(135deg, var(--accent-color), #1976D2);
    color: white;
}

.dan-btn.completed {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.dan-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 視覚化エリア */
.visualization {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 20px 0;
    box-shadow: var(--shadow);
}

.visualization-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.dots-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    min-height: 100px;
}

.dot-group {
    display: flex;
    flex-wrap: wrap;
    width: 80px;
    gap: 3px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 10px;
    margin: 5px;
}

.dot {
    width: 12px;
    height: 12px;
    background: var(--accent-color);
    border-radius: 50%;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .problem-text {
        font-size: 3rem;
    }
    
    .answer-display {
        font-size: 2.5rem;
    }
    
    .numpad-btn {
        padding: 15px;
        font-size: 1.5rem;
    }
    
    .level-cards {
        grid-template-columns: 1fr;
    }
}

/* アニメーション */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.bounce {
    animation: bounce 0.3s ease;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

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

.modal-content h3 {
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.modal-content p {
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}
