:root {
    --font-main: 'M PLUS Rounded 1c', sans-serif;
    --color-bg: #fdf6e3;
    /* Warm beige */
    --color-primary: #e63946;
    /* Festive Red */
    --color-secondary: #f1faee;
    /* White/Off-white */
    --color-accent: #a8dadc;
    /* Soft Blue */
    --color-gold: #ffd700;
    --color-text: #2b2d42;
    --color-wood: #8d6e63;
    --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hard: 0 8px 15px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: radial-gradient(circle at center, #fff8e1 0%, #ffe0b2 100%);
    /* Subtle radial gradient */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass through to canvas where needed, but buttons need pointer-events: auto */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
}

.title {
    text-align: center;
    font-weight: 900;
    font-size: 3rem;
    color: var(--color-primary);
    text-shadow: 2px 2px 0px #fff, 4px 4px 0px rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
    pointer-events: auto;
}

.controls {
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
    pointer-events: auto;
}

.main-btn {
    background: linear-gradient(135deg, var(--color-primary), #d62828);
    color: white;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1.5rem;
    padding: 1rem 4rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #9d0208, 0 15px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}

.main-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #9d0208, 0 5px 10px rgba(0, 0, 0, 0.2);
}

.icon-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: white;
    border: none;
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    pointer-events: auto;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: scale(1.1) rotate(90deg);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s;
    pointer-events: auto;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-hard);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden .modal-content {
    transform: scale(0.8);
}

.modal-content h2 {
    text-align: center;
    color: var(--color-wood);
    margin-bottom: 1.5rem;
}

/* Settings Grid */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.setting-row {
    display: grid;
    grid-template-columns: 60px 60px 1fr 80px;
    gap: 10px;
    align-items: center;
}

.setting-row.header {
    font-weight: 700;
    color: #666;
    font-size: 0.9rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.setting-row input {
    padding: 0.5rem;
    border: 2px solid #eee;
    border-radius: 8px;
    font-family: var(--font-main);
}

.setting-row input:focus {
    border-color: var(--color-accent);
    outline: none;
}

.ball-color-preview {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin: 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Result Styles */
.result-content {
    text-align: center;
    background: radial-gradient(circle, #fff 0%, #fff8e1 100%);
    border: 4px solid var(--color-gold);
}

#result-rank {
    font-size: 2.5rem;
    color: var(--color-primary);
    margin: 1rem 0;
}

.ball-display {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 1rem auto;
    box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.2), 5px 10px 15px rgba(0, 0, 0, 0.2);
}

.prize-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.secondary-btn {
    background: #eee;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-main);
}

.secondary-btn:hover {
    background: #ddd;
}