:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --secondary: #6c757d;
    --bg: #f4f6f9;
    --white: #ffffff;
    --text: #333333;
    --border: #dddddd;
    --special-border: #ff9800;
    --special-bg: #fffaf0;
}

/* ================= GLOBALS ================= */
* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

h1, h2, h3 { margin-top: 0; text-align: center; }
h2.align-left {text-align: left}
a { text-decoration: none; }

/* ================= LAYOUT ================= */
.container {
    width: 95%; /* Wider on small screens */
    max-width: 1000px; 
    margin: 20px auto; 
    background: #fff; 
    padding: 20px; 
    box-shadow: 0 0 10px rgba(0,0,0,0.1); 
    border-radius: 8px; 
    box-sizing: border-box; /* Ensures padding doesn't break width */
}

.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

@media (min-width: 600px) {
    .header {
        flex-direction: row;
        justify-content: space-between;
    }
}

.btn-group { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }

/* ================= FORMS ================= */
label { 
	font-weight: 600; 
	color: #555; 
	display: block; 
	margin-bottom: 5px; 
	margin-top: 15px; 
}

input[type="date"], 
input[type="password"],
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
}

/* Responsive Input Grid for Numbers */
.input-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
}

.input-grid input {
    flex: 1 0 18%; /* Fits ~5 per row on desktop */
    min-width: 50px;
    padding: 10px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1.2em;
}

/* Special Numbers (Orange) */
.special-group input {
    border: 2px solid var(--special-border);
    background: var(--special-bg);
}

textarea { height: 200px; font-family: monospace; }

/* ================= BUTTONS ================= */
button, .btn {
    display: inline-block;
    padding: 10px 15px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    color: white;
    transition: opacity 0.2s;
}

button:hover, .btn:hover { opacity: 0.9; }

/* Button Colors */
.btn-primary { background: var(--primary); width: 100%; font-size: 16px; margin-top: 10px; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: #000; }
.btn-info { background: var(--info); }
.btn-secondary { background: var(--secondary); }
.btn-block { 
	display: block; 
	width: 100%; 
	margin-top: 10px; 
}

/* ================= ALERTS ================= */
.alert { 
	padding: 12px; 
	border-radius: 6px; 
	margin-bottom: 15px; 
	text-align: center; 
}
.alert.success { 
	background: #d4edda; 
	color: #155724; 
	border: 1px solid #c3e6cb; 
}
.alert.error { 
	background: #f8d7da; 
	color: #721c24; 
	border: 1px solid #f5c6cb; 
}

/* ================= STATISTICS GRID ================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.stat-box {
    background: #fff;
    border: 1px solid #eee;
    padding: 8px;
    text-align: center;
    border-radius: 8px;
}

.stat-box.active { 
	background: #e3f2fd; 
	border-color: #90caf9; 
}
.stat-num { 
	display: block; 
	font-weight: bold; 
	font-size: 1.2em; 
	color: #333; 
}
.stat-count { 
	font-size: 0.8em; 
	color: #666; 
}

/* ================= HISTORY LIST ================= */
.history-item {
    border-bottom: 1px solid #eee;
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.row-top { 
	display: flex; 
	justify-content: space-between; 
	align-items: center; 
}
.date-badge { 
	background: #e9ecef; 
	color: #333; 
	padding: 4px 8px; 
	border-radius: 4px; 
	font-weight: bold; 
}
.numbers-row { 
	display: flex; 
	flex-wrap: wrap; 
	gap: 5px; 
}
.num-ball { 
    width: 30px; 
	height: 30px; 
    display: flex; 
	align-items: center; 
	justify-content: center;
    border-radius: 50%; 
    background: #fff; 
	border: 1px solid #ddd; 
    font-weight: bold; 
	color: #333; 
	font-size: 0.9em;
}
.num-ball.special { 
	border-color: var(--special-border); 
	color: #e65100; 
	background: var(--special-bg); 
}

/* Pagination */
.pagination { 
	margin-top: 20px; 
	text-align: center; 
}
.page-link { 
	display: inline-block; 
	padding: 8px 12px; 
	margin: 2px; 
	background: white; 
	border: 1px solid #ddd; 
	color: #333; 
	border-radius: 4px; 
}

/* Generator */
.gen-box { 
	text-align: center; 
	padding: 30px; 
	background: #f8f9fa; 
	border-radius: 8px; 
	border: 2px dashed #ccc; 
	margin-top: 20px; 
}
.gen-balls { 
	display: flex; 
	justify-content: center; 
	gap: 10px; 
	flex-wrap: wrap; 
	margin-top: 20px;
}
.big-ball { 
	width: 50px; 
	height: 50px; 
	background: white; 
	border: 2px solid var(--primary); 
	color: var(--primary);
	border-radius: 50%; 
	display: flex; 
	align-items: center; 
	justify-content: center;
	font-size: 1.4em; 
	font-weight: bold; 
	box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
select { 
	padding: 10px; 
	font-size: 16px; 
	border-radius: 6px;
	border: 1px solid #ddd; 
	width: 100%; 
	margin-bottom: 10px; 
}

@media (max-width: 768px) {
	/* Adjust heading sizes */
    h2 { font-size: 1.5em; }
    h3 { font-size: 1.2em; }
    
    /* Login Box Fix */
    .login-box { width: 100%; margin: 50px auto; }
}

/* History Desktop View */
@media (min-width: 600px) {
    .history-item { flex-direction: row; align-items: center; justify-content: space-between; }
    .row-top { width: 120px; flex-shrink: 0; }
    .numbers-row { flex-grow: 1; justify-content: flex-start; margin-left: 10px;}
}