/* 年末ジャンボ宝くじシミュレーター - カスタムスタイル */

:root {
    --primary-color: #dc2626;
    --primary-dark: #b91c1c;
    --secondary-color: #fef2f2;
    --accent-color: #facc15;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --hover-bg: #f8fafc;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 0.75rem;
}

body {
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic Medium', Meiryo, sans-serif;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    min-height: 100vh;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-weight: 500;
}

/* 情報バナー */
.info-banner {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--primary-dark);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.info-item {
    text-align: center;
    color: white;
}

.info-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.info-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

/* メインコンテナ */
.main-container {
    display: grid;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* 購入セクション */
.purchase-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.title-icon {
    width: 1.75rem;
    height: 1.75rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.purchase-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.5rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.purchase-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.ticket-select {
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.ticket-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.draw-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.draw-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.purchase-info {
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 1px solid #fca5a5;
}

.info-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.info-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* 抽選アニメーション */
.draw-animation {
    background: white;
    border-radius: var(--border-radius);
    padding: 3rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.draw-animation.hidden {
    display: none;
}

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

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.animation-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 結果セクション */
.result-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.result-section.hidden {
    display: none;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--hover-bg);
    border-radius: var(--border-radius);
}

.summary-item {
    text-align: center;
}

.summary-item.highlight {
    background: var(--accent-color);
    padding: 1rem;
    border-radius: var(--border-radius);
}

.summary-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.summary-item.highlight .summary-label {
    color: #78350f;
}

.summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-item.highlight .summary-value {
    color: #78350f;
}

/* 残り情報 */
.remaining-info {
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #fca5a5;
}

.info-header {
    margin-bottom: 1rem;
}

.info-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.remaining-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.remaining-item {
    text-align: center;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.remaining-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.remaining-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    min-height: 1.5rem;
    line-height: 1.5rem;
}

/* 結果テーブル */
.result-table {
    overflow-x: auto;
    margin-bottom: 2rem;
}

.win-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

.win-table th {
    background: var(--hover-bg);
    padding: 0.875rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.win-table td {
    padding: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.win-table tbody tr:hover {
    background: var(--hover-bg);
}

.win-table tbody tr.has-win {
    background: #fef3c7;
    font-weight: 600;
}

.win-table tbody tr.has-win.big-win {
    background: #fbbf24;
    color: #78350f;
}

/* 当選番号詳細 */
.winning-details {
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #fca5a5;
}

.winning-details.hidden {
    display: none;
}

.details-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.winning-numbers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.winning-number {
    background: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-family: monospace;
    font-size: 0.95rem;
}

.winning-number .grade {
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 0.5rem;
}

/* 結果アクション */
.result-actions {
    display: flex;
    justify-content: center;
}

.reset-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.reset-btn:hover {
    background: #059669;
}

/* 統計セクション */
.stats-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

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

.stat-card {
    background: var(--hover-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.clear-stats-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 auto;
    padding: 0.625rem 1.25rem;
    background: var(--border-color);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-stats-btn:hover {
    background: #cbd5e1;
    color: var(--text-primary);
}

/* 常時表示の残り情報 */
.permanent-remaining-info {
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 1px solid #fca5a5;
}

.permanent-info-header {
    margin-bottom: 1rem;
}

.permanent-info-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.permanent-remaining-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.permanent-remaining-item {
    text-align: center;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.permanent-remaining-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.permanent-remaining-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    min-height: 1.5rem;
    line-height: 1.5rem;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--secondary-color);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.close-modal-btn:hover {
    color: var(--primary-color);
    background: rgba(220, 38, 38, 0.1);
}

.close-modal-btn svg {
    width: 1.5rem;
    height: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--hover-bg);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    gap: 1rem;
}

.draw-again-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
}

.draw-again-btn:hover {
    background: var(--primary-dark);
}

.modal-close-btn {
    padding: 0.875rem 1.5rem;
    background: var(--border-color);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: #cbd5e1;
    color: var(--text-primary);
}

/* モーダル内の要素スタイル調整 */
.modal .result-summary {
    margin-bottom: 1.5rem;
}

.modal .remaining-info {
    margin-bottom: 1.5rem;
}

.modal .result-table {
    margin-bottom: 1.5rem;
}

.modal .winning-details {
    margin-bottom: 0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .draw-again-btn,
    .modal-close-btn {
        width: 100%;
        justify-content: center;
    }
}

/* 確率テーブルセクション */
.probability-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.probability-table {
    overflow-x: auto;
}

.info-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.info-table th {
    background: var(--hover-bg);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.info-table td {
    padding: 0.75rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}

.info-table tbody tr.highlight-row {
    background: #fef3c7;
    font-weight: 600;
}

/* アクションセクション */
.action-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .max-w-7xl {
        padding: 1rem;
    }
    
    .py-20 {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
    
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .purchase-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .ticket-select {
        width: 100%;
    }
    
    .draw-btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .result-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .info-table {
        font-size: 0.8rem;
    }
    
    .info-table th,
    .info-table td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .purchase-section,
    .result-section,
    .stats-section,
    .action-section {
        padding: 1rem;
    }
    
    .section-title {
        font-size: 1.25rem;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* モーダル内の金額表示改善 */
    .modal-content {
        margin: 0.5rem;
    }
    
    .result-summary {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .summary-value {
        font-size: 1.2rem;
        word-break: break-all;
        line-height: 1.3;
    }
    
    .summary-label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    /* モーダル内テーブルの改善 */
    .win-table {
        font-size: 0.75rem;
    }
    
    .win-table th,
    .win-table td {
        padding: 0.375rem 0.25rem;
        word-break: break-all;
    }
    
    /* モーダルヘッダー・フッターの調整 */
    .modal-header {
        padding: 1rem;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
    }

    .draw-again-btn,
    .modal-close-btn {
        width: 100%;
        justify-content: center;
    }
}

/* 関連ツールセクション */
.related-link-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.related-links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.related-link-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s;
}

.related-link-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.related-link-icon {
    font-size: 1.5rem;
}

.related-link-title {
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .related-links-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   無限モード（1等が当たるまで自動抽選）
   ======================================== */

.infinite-mode-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border-color);
    text-align: center;
}

.infinite-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: white;
    border: none;
    border-radius: 9999px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.infinite-mode-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}

.infinite-mode-btn:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

.infinite-mode-hint {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* 無限モード進捗表示 */
.infinite-progress {
    background: linear-gradient(135deg, #4c1d95, #5b21b6);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 1.5rem 0;
    color: white;
    text-align: center;
}

.infinite-progress.hidden {
    display: none;
}

.infinite-progress-content {
    max-width: 600px;
    margin: 0 auto;
}

.infinite-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.infinite-stat {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.infinite-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.infinite-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.infinite-animation {
    margin-bottom: 1.5rem;
}

.infinite-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: infiniteSpin 0.8s linear infinite;
}

@keyframes infiniteSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.infinite-text {
    font-size: 1.2rem;
    font-weight: 500;
    animation: infinitePulse 1.5s ease-in-out infinite;
}

@keyframes infinitePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.stop-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stop-btn:hover {
    background: white;
    color: #5b21b6;
}

/* 無限モード レスポンシブ */
@media (max-width: 768px) {
    .infinite-stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .infinite-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
    }

    .infinite-label {
        margin-bottom: 0;
    }

    .infinite-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .infinite-mode-btn {
        width: 100%;
        justify-content: center;
    }

    .infinite-progress {
        padding: 1.5rem 1rem;
    }
}