:root {
    /* Light Mode Variables (Default) */
    --bg-color: #fdfaf6;
    --primary-color: #ffb4a2;
    --secondary-color: #ffd166;
    --text-main: #4a4e69;
    --text-light: #9a8c98;
    --card-bg: rgba(255, 255, 255, 0.85);
    --ball-size: 45px;
    --toggle-bg: #e2e8f0;
    --grid-color: #ffd166;
}

[data-theme="dark"] {
    /* Dark Mode Variables */
    --bg-color: #1a1a2e;
    --primary-color: #e94560;
    --secondary-color: #0f3460;
    --text-main: #e6e6e6;
    --text-light: #a0a0a0;
    --card-bg: rgba(30, 30, 40, 0.85);
    --toggle-bg: #2d3748;
    --grid-color: #0f3460;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(var(--grid-color) 1px, transparent 1px);
    background-size: 40px 40px;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
    max-width: 800px;
    width: 100%;
    padding: 3rem;
    text-align: center;
    border: 3px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

/* Theme Toggle Button */
.theme-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--toggle-bg);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s;
    z-index: 10;
}

.theme-btn:hover {
    transform: scale(1.1) rotate(15deg);
}

.theme-btn:active {
    transform: scale(0.95);
}

/* Language Toggle Button */
.lang-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--toggle-bg);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s, color 0.3s;
    z-index: 10;
}

.lang-btn:hover {
    transform: scale(1.1);
}

.lang-btn:active {
    transform: scale(0.95);
}

.hero {
    margin-bottom: 3rem;
}

.image-wrapper {
    width: 250px;
    height: 250px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    padding: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 10px 25px rgba(255, 180, 162, 0.4);
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid #fff;
    transition: transform 0.4s ease;
}

.image-wrapper:hover img {
    transform: scale(1.05) rotate(5deg);
}

h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.highlight {
    color: var(--primary-color);
    position: relative;
}

p {
    font-size: 1.1rem;
    color: var(--text-light);
    line-height: 1.6;
}

.magical-btn {
    background: linear-gradient(45deg, var(--primary-color), #ff9a8b);
    border: none;
    border-radius: 50px;
    padding: 1rem 2.5rem;
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(255, 154, 139, 0.3);
    transition: all 0.3s ease;
    margin-bottom: 2rem;
}

.magical-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 20px rgba(255, 154, 139, 0.4);
    background: linear-gradient(45deg, #ff9a8b, var(--primary-color));
}

.magical-btn:active {
    transform: translateY(1px);
}

.results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.results-container.hidden {
    display: none;
    opacity: 0;
}

.lottery-set {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideUp 0.5s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

.set-label {
    font-weight: 800;
    color: var(--text-light);
    width: 60px;
    text-align: left;
}

.numbers-group {
    display: flex;
    gap: 10px;
}

.ball {
    width: var(--ball-size);
    height: var(--ball-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: scale(0.5);
}

/* Color coding for standard Korean Lotto ranges */
.ball.yellow {
    background: #fbc531;
}

/* 1-10 */
.ball.blue {
    background: #00a8ff;
}

/* 11-20 */
.ball.red {
    background: #e84118;
}

/* 21-30 */
.ball.gray {
    background: #7f8fa6;
}

/* 31-40 */
.ball.green {
    background: #4cd137;
}

/* 41-45 */

/* Comment Section */
.comment-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px dashed rgba(255, 180, 162, 0.5);
    text-align: left;
}

.comment-section h2 {
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 800;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.emoji-picker {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 0.5rem;
}

.emoji-btn {
    font-size: 1.8rem;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
    user-select: none;
}

.emoji-btn:hover {
    transform: scale(1.2);
    background: rgba(255, 180, 162, 0.2);
}

.emoji-btn.selected {
    background: rgba(255, 180, 162, 0.4);
    border-color: var(--primary-color);
}

.input-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.input-wrapper {
    flex: 1;
    min-width: 250px;
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 2px solid var(--toggle-bg);
    border-radius: 10px;
    padding-left: 1rem;
    transition: border-color 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.input-emoji-preview {
    font-size: 1.2rem;
    user-select: none;
    margin-right: 0.5rem;
}

#comment-input {
    flex: 1;
    width: 100%;
    padding: 0.8rem 0.5rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
}

#comment-input:focus {
    outline: none;
}

.submit-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    white-space: nowrap;
}

.submit-btn:hover {
    background: #ff9a8b;
    transform: translateY(-2px);
}

.submit-btn:active {
    transform: translateY(1px);
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom scrollbar for comments list */
.comments-list::-webkit-scrollbar {
    width: 6px;
}

.comments-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.comments-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.comment-item {
    background: var(--card-bg);
    padding: 1.2rem;
    border-radius: 12px;
    border-left: 5px solid var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideUp 0.3s ease forwards;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.comment-emoji {
    font-size: 2rem;
}

.comment-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.comment-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.comment-text {
    color: var(--text-main);
    line-height: 1.4;
    word-break: break-word;
    font-size: 1.05rem;
}

footer {
    margin-top: 3rem;
    font-size: 0.9rem;
    color: #ccc;
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Responsiveness Improvements */
@media (max-width: 600px) {
    .container {
        padding: 2rem 1rem;
        border-width: 2px;
        border-radius: 20px;
    }

    h1 {
        font-size: 1.4rem;
        margin-top: 1rem;
        word-break: keep-all;
        letter-spacing: -0.5px;
    }

    p {
        font-size: 0.95rem;
    }

    .image-wrapper {
        width: 180px;
        height: 180px;
        margin-top: 2.5rem;
        /* Make room for top buttons */
    }

    .magical-btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        width: 100%;
    }

    /* Fix top buttons overlapping on small screens */
    .theme-btn,
    .lang-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        top: 15px;
    }

    .lang-btn {
        left: 15px;
    }

    .theme-btn {
        right: 15px;
    }

    /* Fix Lottery Balls Wrapping */
    .lottery-set {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem 0.5rem;
    }

    .set-label {
        width: auto;
        text-align: center;
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .numbers-group {
        flex-wrap: nowrap;
        justify-content: center;
        gap: 4px;
    }

    .ball {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    /* Fix Comment Section Wrapping */
    .comment-section h2 {
        font-size: 1.3rem;
    }

    .emoji-picker {
        flex-wrap: nowrap;
        gap: 8px;
        justify-content: center;
    }

    .emoji-btn {
        font-size: 1.3rem;
        padding: 5px;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .input-wrapper {
        min-width: 100%;
    }

    .submit-btn {
        width: 100%;
        padding: 1rem;
    }

    .comment-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .comment-emoji {
        font-size: 1.5rem;
    }
}