/* Basic Reset & Root Variables */
:root {
    --primary-bg: #f8f9fa;
    --secondary-bg: #ffffff;
    --text-color: #212529;
    --border-color: #dee2e6;
    --accent-color: #007bff;
    --button-bg: #007bff;
    --button-text: #ffffff;
    --button-hover-bg: #0056b3;
    --input-bg: #ffffff;
    --input-border: #ced4da;
    --pointer-color: #dc3545;
    --winner-bg: rgba(0, 0, 0, 0.75);
    --winner-text: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --header-bg: var(--secondary-bg);
    --header-border: var(--border-color);
    --tagline-color: #6c757d;

    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Dark Mode Variables */
body.dark-mode {
    --primary-bg: #1a1a1a;
    --secondary-bg: #2c2c2c;
    --text-color: #e0e0e0;
    --border-color: #444444;
    --accent-color: #4dabf7;
    --button-bg: #4dabf7;
    --button-text: #121212;
    --button-hover-bg: #2c9bf5;
    --input-bg: #333333;
    --input-border: #555555;
    --pointer-color: #ff6b6b;
    --winner-bg: rgba(255, 255, 255, 0.85);
    --winner-text: #121212;
    --shadow-color: rgba(255, 255, 255, 0.1);
    --header-bg: var(--secondary-bg);
    --header-border: var(--border-color);
    --tagline-color: #adb5bd;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    background-color: var(--primary-bg);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
}

/* ****** HEADER STYLES ****** */
.app-header {
    background-color: var(--header-bg);
    padding: 0.5rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    position: relative;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.3rem 0;
}

.header-logo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--accent-color);
    transition: transform 0.2s ease;
}
.header-logo-link:hover {
    transform: scale(1.03);
}

.header-logo-icon {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    line-height: 1;
}

.header-logo-text {
    font-size: clamp(1.6rem, 4.5vw, 2.3rem);
    font-weight: 600;
    line-height: 1;
}

.tagline {
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    color: var(--tagline-color);
    margin: 0;
    font-weight: 400;
    width: 100%;
    text-align: center;
    margin-top: -2px;
}

/* Main Navigation */
.main-nav {
    text-align: center;
    padding-top: 0.6rem;
    border-top: 1px solid var(--header-border);
    margin-top: 0.6rem;
}

.main-nav a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 0.8rem;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--button-text);
    background-color: var(--accent-color);
}
body.dark-mode .main-nav a:hover,
body.dark-mode .main-nav a.active {
     color: var(--button-text);
     background-color: var(--accent-color);
}
/* ****** END HEADER STYLES ****** */


.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.controls-panel {
    flex: 1;
    min-width: 300px;
    background-color: var(--secondary-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Controls Panel Sections & Headings */
.controls-panel section {
    margin-bottom: 1rem;
}
.controls-panel section:last-child {
    margin-bottom: 0;
}

.controls-panel h2, .controls-panel h3 {
    margin-bottom: 0.8rem;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
    font-size: 1.3rem;
}
.controls-panel h2 {
     margin-bottom: 0.5rem; /* Less space below H2 */
}

.controls-panel p {
    margin-bottom: 0.8rem; /* More consistent spacing */
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.9;
}
.controls-panel .color-note {
     opacity: 0.7;
     font-size: 0.8rem;
     margin-bottom: 0.3rem; /* Less space below color note */
}

/* Textarea and Inputs */
#entries-input,
.setting-item input[type="number"],
.setting-item input[type="text"] {
    width: 100%;
    padding: 0.7rem;
    margin-bottom: 0.8rem;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

#entries-input {
    min-height: 150px;
}

#entries-input:focus,
.setting-item input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}
body.dark-mode #entries-input:focus,
body.dark-mode .setting-item input:focus {
     box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.25);
}

/* Buttons */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

button {
    padding: 0.7rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--button-text);
    background-color: var(--button-bg);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    text-align: center;
}

button:hover {
    background-color: var(--button-hover-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
body.dark-mode button:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

button:active {
    transform: scale(0.98);
    box-shadow: none;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}
body.dark-mode button:disabled {
    background-color: #555555;
}

/* Settings Items */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.setting-item label:not(.switch) {
    flex-shrink: 0;
    font-weight: 500;
}

.setting-item input[type="number"] {
     width: 70px;
     margin-bottom: 0;
     text-align: center;
}
.setting-item.colors-setting {
    flex-direction: column;
    align-items: flex-start;
}
.setting-item input[type="text"]#wheel-colors {
     margin-bottom: 0;
     font-family: monospace;
}


/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--accent-color); }
body.dark-mode input:checked + .slider { background-color: #4CAF50; }
input:focus + .slider { box-shadow: 0 0 1px var(--accent-color); }
body.dark-mode input:focus + .slider { box-shadow: 0 0 1px #4CAF50; }
input:checked + .slider:before { transform: translateX(26px); }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }


/* ****** WHEEL SECTION STYLES (WITH SIZE INCREASE) ****** */
.wheel-section {
    flex: 2;
    min-width: 400px; /* Increased */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: Top;
    padding: 1.5rem;
    background-color: var(--secondary-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
    border: 1px solid var(--border-color);
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.wheel-section h2 { /* Added rule for wheel section H2 */
    margin-bottom: 1rem; /* Space below "3. Spin the Wheel!" */
    color: var(--accent-color);
    font-size: 1.3rem;
    text-align: center;
    width: 100%;
}

#wheel-container {
    position: relative;
    width: clamp(320px, 90vmin, 550px); /* Increased size */
    height: clamp(320px, 90vmin, 550px); /* Increased size */
    margin-bottom: 1.5rem;
	margin-top: 1.5rem;

}

#wheel-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
    border: 3px solid var(--secondary-bg);
    transition: border-color 0.3s ease;
}
body.dark-mode #wheel-canvas {
     border-color: var(--secondary-bg);
}

#wheel-pointer {
    position: absolute;
    top: 0%;
    left: 50%;
    width: 0;
	height: 0;
	border-left: 14px solid transparent; /* Slightly larger pointer */
	border-right: 14px solid transparent;
	border-top: 28px solid var(--pointer-color); /* Pointy top, colored */
    transform: translate(-50%, -115%); /* Adjusted transform */
    z-index: 5;
    transition: border-top-color 0.3s ease;
}

/* Spin Button */
#spin-button {
    padding: 0.9rem 2.8rem;
    font-size: 1.4rem;
    font-weight: 600;
    background-color: #28a745;
    border: none;
    color: white;
    border-radius: 50px;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    margin-top: 1rem;
}
body.dark-mode #spin-button {
    background-color: #58cc73;
    color: #1a1a1a;
    box-shadow: 0 4px 8px rgba(88, 204, 115, 0.3);
}
#spin-button:hover {
    background-color: #218838;
    box-shadow: 0 6px 12px rgba(33, 136, 56, 0.5);
}
body.dark-mode #spin-button:hover {
    background-color: #47b860;
     box-shadow: 0 6px 12px rgba(71, 184, 96, 0.4);
}
#spin-button:active {
    transform: scale(0.97);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

/* Winner Popup Display */
#winner-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background-color: var(--winner-bg);
    color: var(--winner-text);
    padding: 1.5rem 2.5rem;
    border-radius: 10px;
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    font-weight: bold;
    text-align: center;
    z-index: 15;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    max-width: 85%;
    word-wrap: break-word;
}
#winner-display.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 0.4s ease, visibility 0s, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}


/* ****** WINNERS SECTION STYLES ****** */
.winners-section h2 {
    /* Inherits styling from .controls-panel h2 */
     margin-bottom: 0.5rem;
}

.winners-section p {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 0.8rem;
}

.winners-list-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--primary-bg);
    padding: 0.5rem;
    margin-bottom: 0.8rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#winners-list-ol {
    list-style: decimal;
    padding-left: 2rem;
    margin: 0;
}

#winners-list-ol li {
    padding: 0.4rem 0.2rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px dashed var(--border-color);
    color: var(--text-color);
    font-size: 0.95rem;
    word-break: break-word;
    transition: border-color 0.3s ease, color 0.3s ease;
}
#winners-list-ol li:last-child {
    border-bottom: none;
}

#winners-list-ol .placeholder {
    list-style: none;
    color: var(--tagline-color);
    font-style: italic;
    text-align: center;
    padding: 1rem 0;
    border-bottom: none;
}

.winners-controls {
    justify-content: flex-end;
}

#clear-winners-button {
    background-color: #dc3545;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}
body.dark-mode #clear-winners-button {
     background-color: #ff6b6b;
     color: #1a1a1a;
}
#clear-winners-button:hover { background-color: #c82333; }
body.dark-mode #clear-winners-button:hover { background-color: #f74a4a; }
#clear-winners-button:disabled { background-color: #cccccc; opacity: 0.5; }
body.dark-mode #clear-winners-button:disabled { background-color: #555555; opacity: 0.5; }
/* ****** END WINNERS SECTION STYLES ****** */


/* Info Section */
.info-section h3 { /* Use H3 for this section */
    margin-bottom: 0.8rem;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
    font-size: 1.3rem;
}


/* ****** CONTENT PAGE STYLES ****** */
.content-page main {
    background-color: var(--secondary-bg);
    padding: 2rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
    border: 1px solid var(--border-color);
    max-width: 900px;
    margin: 0 auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.content-page h1 {
    font-size: clamp(1.8rem, 5vw, 2.4rem);
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.content-page h2 {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    color: var(--text-color);
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
}

.content-page p,
.content-page ul,
.content-page li {
    margin-bottom: 1rem;
    line-height: 1.7;
    color: var(--text-color);
    font-size: 1rem;
}

.content-page ul { list-style: disc; margin-left: 1.5rem; }
.content-page a { color: var(--accent-color); text-decoration: none; font-weight: 500; }
.content-page a:hover { text-decoration: underline; }
.content-page strong { font-weight: 600; }
/* ****** END CONTENT PAGE STYLES ****** */


/* ****** FOOTER STYLES ****** */
.app-footer {
    text-align: center;
    margin-top: 2.5rem;
    padding: 1.5rem 1rem;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
    border-top: 1px solid var(--border-color);
    background-color: var(--primary-bg);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.footer-nav { margin-bottom: 0.8rem; }
.footer-nav a { color: var(--text-color); text-decoration: none; margin: 0 0.5rem; font-size: 0.85rem; }
.footer-nav a:hover { text-decoration: underline; color: var(--accent-color); }
.app-footer p { margin: 0; font-size: 0.85rem; }
/* ****** END FOOTER STYLES ****** */


/* ****** RESPONSIVE DESIGN ****** */
@media (max-width: 992px) { /* Medium devices */
    .main-content { flex-direction: column; }
    .controls-panel, .wheel-section { flex: none; width: 100%; }
    #wheel-container { width: clamp(300px, 80vw, 480px); height: clamp(300px, 80vw, 480px); } /* Adjusted size for tablet */
    .app-header { padding: 0.8rem 1rem; border-radius: 8px; }
}

@media (max-width: 576px) { /* Small devices */
     html { font-size: 14px; }
     .app-header { padding: 0.5rem 1rem; }
     .header-logo-icon { font-size: 1.6rem; }
     .header-logo-text { font-size: 1.5rem; }
     .tagline { font-size: 0.75rem; margin-top: -4px; }
     .main-nav { padding-top: 0.5rem; margin-top: 0.5rem; }
     .main-nav a { margin: 0 0.4rem; font-size: 0.85rem; }
     .button-group button { flex-grow: 1; font-size: 0.9rem; padding: 0.6rem 1rem; }
     #spin-button { font-size: 1.2rem; padding: 0.8rem 2rem; }
     #winner-display { padding: 1.2rem 1.8rem; font-size: clamp(1.3rem, 5vw, 1.8rem); }
     .setting-item { flex-direction: column; align-items: flex-start; }
     .setting-item label:not(.switch) { margin-bottom: 0.3rem; }
     .setting-item input[type="number"] { width: 100%; }
     .setting-item .switch { align-self: flex-end; margin-top: -24px; }
     .colors-setting .switch { align-self: flex-start; margin-top: 0.5rem; } /* Reset alignment if needed */
     .content-page main { padding: 1.5rem 1rem; }
     .content-page h1 { font-size: 1.6rem; }
     .content-page h2 { font-size: 1.3rem; }
     .footer-nav a { margin: 0 0.3rem; }
     /* Wheel adjustments for phone */
    #wheel-container { width: clamp(280px, 85vmin, 350px); height: clamp(280px, 85vmin, 350px); }
    .wheel-section { min-width: 300px; }
    #wheel-pointer { border-left-width: 10px; border-right-width: 10px; border-top-width: 20px; transform: translate(-50%, -110%); }
}
/* ****** END RESPONSIVE DESIGN ****** */


/* ****** ACCESSIBILITY ****** */
*:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(0, 123, 255, 0.15);
}
body.dark-mode *:focus-visible {
     outline-color: #6ec6ff;
     box-shadow: 0 0 0 5px rgba(77, 171, 247, 0.2);
}
/* ****** END ACCESSIBILITY ****** */