:root {
    --primary-color: #7c3aed;
    --primary-dark: #6d28d9;
    --secondary-color: #f5f3ff;
    --accent-color: #facc15;
    --success-color: #10b981;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

body { background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); min-height: 100vh; }
.subtitle { text-align: center; color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 2rem; }

.info-banner {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 12px; padding: 1.5rem; margin-bottom: 2rem; color: white;
}
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; text-align: center; }
.info-label { font-size: 0.85rem; opacity: 0.9; }
.info-value { font-size: 1.25rem; font-weight: 700; }

.selection-section, .purchase-section, .result-section, .stats-section, .probability-section, .action-section {
    background: white; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.section-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin-bottom: 1rem; }

.number-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.number-btn {
    aspect-ratio: 1; border: 2px solid var(--border-color); border-radius: 50%;
    background: white; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.number-btn:hover { border-color: var(--primary-color); background: var(--secondary-color); }
.number-btn.selected { background: var(--primary-color); border-color: var(--primary-color); color: white; }

.selection-info { text-align: center; font-size: 1.1rem; font-weight: 600; color: var(--primary-color); margin-bottom: 1rem; }
.action-buttons { display: flex; gap: 1rem; justify-content: center; }
.quick-btn { padding: 0.75rem 1.5rem; background: var(--primary-color); color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; }
.quick-btn:hover { background: var(--primary-dark); }
.clear-btn { padding: 0.75rem 1.5rem; background: var(--border-color); color: var(--text-secondary); border: none; border-radius: 8px; font-weight: 600; cursor: pointer; }

.purchase-grid { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: end; }
.control-label { font-weight: 600; color: var(--text-primary); margin-bottom: 0.5rem; display: block; }
.ticket-select { width: 100%; padding: 0.75rem; border: 2px solid var(--border-color); border-radius: 8px; font-size: 1rem; }
.draw-btn {
    padding: 0.75rem 2rem; background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white; border: none; border-radius: 8px; font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.draw-btn:hover { transform: translateY(-2px); }
.draw-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.draw-animation { text-align: center; padding: 3rem; }
.draw-animation.hidden { display: none; }
.lottery-balls { display: flex; justify-content: center; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.ball {
    width: 45px; height: 45px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 700;
}
.ball.rolling { animation: roll 0.5s ease-in-out infinite; }
@keyframes roll { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.animation-text { font-size: 1.25rem; font-weight: 600; color: var(--text-primary); }

.result-section.hidden { display: none; }
.winning-numbers { text-align: center; padding: 1.5rem; background: var(--secondary-color); border-radius: 12px; margin-bottom: 1.5rem; }
.numbers-label { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1rem; }
.numbers-display { display: flex; justify-content: center; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.winning-ball {
    width: 45px; height: 45px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 700;
}
.winning-ball.matched { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); }
.bonus-numbers { margin-top: 1rem; }
.bonus-label { font-size: 0.85rem; color: var(--text-secondary); margin-right: 0.5rem; }
.bonus-ball {
    display: inline-flex; width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white; align-items: center; justify-content: center; font-weight: 700; margin: 0 0.25rem;
}

.result-details { margin-top: 1rem; }
.result-card { padding: 1rem; border-radius: 8px; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; }
.result-card.win-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #78350f; }
.result-card.win-2, .result-card.win-3 { background: #fef3c7; }
.result-card.win-4, .result-card.win-5, .result-card.win-6 { background: #ecfdf5; }
.result-card.no-win { background: #f8fafc; color: var(--text-secondary); }
.result-grade { font-weight: 700; }
.result-amount { font-weight: 700; font-family: monospace; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: #f8fafc; border-radius: 8px; padding: 1rem; text-align: center; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.stat-value { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.clear-stats-btn { display: block; margin: 0 auto; padding: 0.5rem 1rem; background: var(--border-color); color: var(--text-secondary); border: none; border-radius: 6px; cursor: pointer; }

.probability-table { overflow-x: auto; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.info-table th { background: #f8fafc; font-weight: 600; }
.info-table .highlight-row { background: #fef3c7; }

.related-link-section { margin-bottom: 1.5rem; }
.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); }
.related-link-icon { font-size: 1.5rem; }
.related-link-title { font-weight: 600; color: var(--text-primary); }

/* 全結果表示ボタン */
.show-all-btn {
    display: block; width: 100%; margin-top: 1rem; padding: 0.75rem;
    background: var(--primary-color); color: white; border: none; border-radius: 8px;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.show-all-btn:hover { background: var(--primary-dark); }

/* モーダル */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); }
.modal-content {
    position: relative; background: white; border-radius: 16px; width: 90%; max-width: 600px;
    max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-color);
}
.modal-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.modal-close { background: none; border: none; font-size: 1.75rem; color: var(--text-secondary); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }

.modal-winning {
    padding: 1rem 1.5rem; background: var(--secondary-color);
    display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap;
}
.modal-winning-numbers { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.modal-winning-numbers .winning-ball { width: 36px; height: 36px; font-size: 0.9rem; }
.modal-bonus { display: flex; align-items: center; gap: 0.5rem; }
.bonus-ball.small { width: 32px; height: 32px; font-size: 0.85rem; }

.modal-body { flex: 1; overflow-y: auto; padding: 1rem 1.5rem; }
.modal-result-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 0.5rem;
}
.modal-result-item.win { background: #fef3c7; }
.modal-result-item.lose { background: #f8fafc; }
.modal-result-numbers { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.modal-result-numbers .num {
    width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600;
}
.modal-result-numbers .num.match { background: var(--success-color); color: white; }
.modal-result-numbers .num.bonus-match { background: #f59e0b; color: white; }
.modal-result-numbers .num.no-match { background: #e2e8f0; color: var(--text-secondary); }
.modal-result-status { font-weight: 600; font-size: 0.9rem; text-align: right; }
.modal-result-status.win { color: #b45309; }
.modal-result-status.lose { color: var(--text-secondary); }

.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); }
.modal-close-btn {
    width: 100%; padding: 0.75rem; background: var(--border-color); color: var(--text-primary);
    border: none; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.modal-close-btn:hover { background: #cbd5e1; }

/* 無限モード */
.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, #dc2626, #b91c1c);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.infinite-mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

.infinite-mode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.infinite-mode-btn .btn-icon { font-size: 1.25rem; }

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

.infinite-progress {
    margin-top: 1.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-radius: 16px;
    color: white;
}

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

.infinite-progress-content { text-align: center; }

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

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

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

.infinite-stat { text-align: center; }

.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-searching {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.stop-btn {
    padding: 0.75rem 2rem;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* 無限モード結果 */
.infinite-result {
    margin-top: 1.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: 16px;
    text-align: center;
}

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

.infinite-result-title {
    font-size: 2rem;
    font-weight: 700;
    color: #78350f;
    margin-bottom: 1rem;
}

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

.infinite-result-stat {
    background: rgba(255,255,255,0.5);
    padding: 1rem;
    border-radius: 8px;
}

.infinite-result-label {
    font-size: 0.85rem;
    color: #92400e;
}

.infinite-result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #78350f;
}

@media (max-width: 768px) {
    .info-grid { grid-template-columns: 1fr; gap: 0.5rem; }
    .number-grid { grid-template-columns: repeat(7, 1fr); }
    .purchase-grid { grid-template-columns: 1fr; }
    .draw-btn { width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .related-links-grid { grid-template-columns: 1fr; }
    .modal-content { width: 95%; max-height: 85vh; }
    .modal-result-numbers .num { width: 24px; height: 24px; font-size: 0.7rem; }
    .infinite-stats { grid-template-columns: 1fr; gap: 0.5rem; }
    .infinite-result-stats { grid-template-columns: 1fr; }
}
