:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --accent-color: #e67e22;
    --accent-dark: #d35400;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #ecf0f1;
    --header-bg: #ffffff;
    --header-shadow: rgba(0,0,0,0.05);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-main: #f0f0f0;
    --text-muted: #b0b0b0;
    --border-color: #404040;
    --header-bg: #2d2d2d;
    --header-shadow: rgba(0,0,0,0.3);
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

/* Header & Navigation */
header {
    background: var(--header-bg);
    box-shadow: 0 2px 10px var(--header-shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-main);
}

.logo span {
    color: var(--primary-color);
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 700;
    transition: color 0.3s;
}

nav a.active, nav a:hover {
    color: var(--primary-color);
}

.theme-toggle-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    width: 40px;
    height: 40px;
}

.theme-toggle-btn:hover {
    background-color: var(--border-color);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #3498db, #8e44ad);
    color: #fff;
    padding: 4rem 1.5rem;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 900;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content Wrapper */
.content-wrapper {
    max-width: 1000px;
    margin: -3rem auto 3rem;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
    padding: 0 1.5rem;
}

@media (max-width: 768px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        margin-top: 1.5rem;
    }
}

/* Cards */
section[class*="-card"] {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: background-color 0.3s, box-shadow 0.3s;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.badge {
    background: var(--primary-color);
    color: #fff;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

/* Lotto Board */
.lotto-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 2rem;
}

.number-btn {
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-main);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.number-btn:hover:not(:disabled) {
    background-color: var(--border-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.number-btn.selected {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
    transform: scale(1.1);
}

.number-btn:disabled {
    cursor: default;
    opacity: 0.6;
}

/* Ball Styling */
.ball-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 40px;
    margin-top: 0.5rem;
}

.ball {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.ball.range-1 { background: #fbc400; }
.ball.range-11 { background: #69c8f2; }
.ball.range-21 { background: #ff7272; }
.ball.range-31 { background: #aaa; }
.ball.range-41 { background: #b0d840; }

/* Buttons */
.btn-group {
    display: flex;
    gap: 10px;
    margin: 2rem 0;
}

button:not(.theme-toggle-btn):not(.number-btn) {
    padding: 1rem;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
}

.primary-btn:hover:not(:disabled) {
    background-color: var(--accent-dark);
}

.primary-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.secondary-btn {
    background-color: var(--border-color);
    color: var(--text-muted);
}

.text-btn {
    background: none !important;
    color: var(--text-muted) !important;
    font-size: 0.9rem !important;
    margin-top: 1rem !important;
    text-decoration: underline !important;
    padding: 0 !important;
    flex: none !important;
}

/* Results Section */
.result-area {
    margin-top: 2rem;
    text-align: center;
}

.hidden { display: none; }

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

.result-summary {
    margin-top: 1.5rem;
}

.match-text {
    font-size: 1.2rem;
    font-weight: 700;
}

.rank-text {
    font-size: 1.8rem;
    color: #e74c3c;
    font-weight: 900;
    margin-top: 0.5rem;
}

/* History Card */
.history-list {
    margin-top: 1.5rem;
}

.history-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.history-item .date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.history-item .result {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item .rank {
    margin-left: auto;
    font-weight: 900;
    color: var(--primary-color);
}

/* Analysis Section */
.side-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.analysis-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.data-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.stat-group {
    margin-bottom: 1.5rem;
}

.stat-group h3 {
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
    color: var(--text-main);
}

.mini-ball-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mini-ball {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.accent-btn {
    background-color: #9b59b6;
    color: #fff;
}

.accent-btn:hover {
    background-color: #8e44ad;
}

footer {
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 1000px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
}