:root {
    /* Light Mode Variables */
    --lotto-ball-yellow: #fbc400;
    --lotto-ball-blue: #69c8f2;
    --lotto-ball-red: #ff7272;
    --lotto-ball-gray: #aaa;
    --lotto-ball-green: #b0d840;
    --text-color-dark: #333;
    --text-color-light: #fff;
    --background-color: #f0f2f5;
    --container-bg-color: #ffffff;
    --button-bg-color: #007bff;
    --button-hover-bg-color: #0056b3;
    --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 8px 20px rgba(0, 0, 0, 0.2);
    --input-border: #ccc;
    --input-bg: #fff;
    --comment-bg: #f9f9f9;
}

[data-theme="dark"] {
    /* Dark Mode Variables */
    --text-color-dark: #e0e0e0;
    --background-color: #121212;
    --container-bg-color: #1e1e1e;
    --button-bg-color: #bb86fc;
    --button-hover-bg-color: #3700b3;
    --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-heavy: 0 8px 20px rgba(0, 0, 0, 0.7);
    --input-border: #444;
    --input-bg: #2c2c2c;
    --comment-bg: #2c2c2c;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    background-color: var(--background-color);
    color: var(--text-color-dark);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

/* Theme Toggle Button */
#theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color-dark);
    padding: 10px;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: none;
}
#theme-toggle:hover {
    background-color: rgba(128, 128, 128, 0.1);
    transform: rotate(15deg);
}

lotto-machine {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--container-bg-color);
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow-heavy);
    width: 100%;
    max-width: 600px;
    text-align: center;
    margin-bottom: 30px;
    transition: background-color 0.3s;
}

h1 {
    color: var(--text-color-dark);
    margin-bottom: 30px;
    font-size: 2.2em;
    font-weight: 700;
}

.lotto-balls-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    min-height: 100px;
    margin-bottom: 30px;
    perspective: 1000px;
}

lotto-ball {
    --ball-size: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: var(--ball-size);
    height: var(--ball-size);
    border-radius: 50%;
    background: var(--lotto-ball-gray);
    color: var(--text-color-light); /* Always light text on balls */
    font-size: 1.8em;
    font-weight: 700;
    box-shadow: var(--shadow-light), inset 0 -3px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
    opacity: 0;
    transform: translateY(50px) scale(0.5);
}

lotto-ball.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Color coding for lotto balls */
lotto-ball.yellow { background: var(--lotto-ball-yellow); color: #333; }
lotto-ball.blue { background: var(--lotto-ball-blue); }
lotto-ball.red { background: var(--lotto-ball-red); }
lotto-ball.gray { background: var(--lotto-ball-gray); }
lotto-ball.green { background: var(--lotto-ball-green); }

button {
    background-color: var(--button-bg-color);
    color: #fff;
    border: none;
    padding: 12px 25px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
    box-shadow: var(--shadow-light);
}

button:hover {
    background-color: var(--button-hover-bg-color);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

/* Comment Section Styles */
comment-section {
    display: flex;
    flex-direction: column;
    background-color: var(--container-bg-color);
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--shadow-heavy);
    width: 100%;
    max-width: 600px;
    box-sizing: border-box;
    transition: background-color 0.3s;
}

.comment-header {
    margin-bottom: 15px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 10px;
}

.comment-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--text-color-dark);
}

.comment-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.nickname-input {
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color-dark);
    width: 150px;
}

.content-input {
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color-dark);
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.comment-item {
    background-color: var(--comment-bg);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: #888;
    margin-bottom: 5px;
}

.comment-content {
    color: var(--text-color-dark);
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve line breaks */
}

/* Responsive adjustments */
@media (max-width: 480px) {
    h1 { font-size: 1.8em; }
    lotto-ball { --ball-size: 50px; font-size: 1.5em; }
    .lotto-balls-container { gap: 10px; }
    button { padding: 10px 20px; font-size: 1em; }
    comment-section { padding: 15px; }
    .nickname-input { width: 100%; }
}