:root {
    --bg-color: #0d061a;
    --primary-color: #9c6eff;
    --text-color: #e0d8ff;
    --header-color: #ffffff;
    --border-color: #3d2c6b;
    --accent-gold: #ffd700;
    --font-header: 'Cinzel', serif;
    --font-body: 'Roboto', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image: url('background.png');
    background-size: cover;
    background-attachment: fixed;
    overflow: hidden;
}

#app-container {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100vh;
    gap: 20px;
    padding: 20px;
}

/* LEFT PANEL */
#controls-panel {
    background: rgba(10, 5, 20, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(5px);
}

#controls-panel header {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

#controls-panel h1 {
    font-family: var(--font-header);
    color: var(--header-color);
    font-size: 1.8em;
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
}

#controls-panel h2 {
    font-family: var(--font-header);
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.controls-scroll-container {
    overflow-y: auto;
    padding-right: 10px;
}

/* Scrollbar styling */
.controls-scroll-container::-webkit-scrollbar {
    width: 8px;
}
.controls-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}
.controls-scroll-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}
.controls-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}


fieldset {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
}

legend {
    padding: 0 10px;
    font-family: var(--font-header);
    font-weight: 700;
    color: var(--primary-color);
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: var(--text-color);
}

input[type="text"], textarea, select {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

input[type="text"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
}

textarea {
    resize: vertical;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
    margin-bottom: 15px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 5px var(--primary-color), 0 0 10px var(--primary-color);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 0 5px var(--primary-color), 0 0 10px var(--primary-color);
}

details {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 10px;
}

details summary {
    cursor: pointer;
    font-family: var(--font-header);
    font-weight: 700;
    color: var(--primary-color);
}

.checkbox-group {
    display: flex;
    align-items: center;
    margin-top: 10px;
}
.checkbox-group input {
    margin-right: 10px;
}
.checkbox-group label {
    margin-bottom: 0;
}

.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
}
.toggle-group > label {
    margin: 0;
    user-select: none;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    cursor: pointer;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch .slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 28px;
}
.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.toggle-switch input:checked + .slider {
    background-color: var(--primary-color);
    box-shadow: 0 0 5px var(--primary-color);
}
.toggle-switch input:checked + .slider:before {
    transform: translateX(22px);
}


/* RIGHT PANEL */
#main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#power-meter-container {
    width: 80%;
    max-width: 600px;
    height: 30px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

#power-meter-bar {
    width: 10%;
    height: 100%;
    background: linear-gradient(90deg, #5a5dff, var(--primary-color), var(--accent-gold));
    border-radius: 15px;
    transition: width 0.5s ease-out;
}

#power-meter-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    text-shadow: 0 0 3px black;
}

#arcane-canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1;
    max-height: calc(100vh - 220px);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--primary-color), inset 0 0 20px var(--primary-color);
    animation: canvas-glow 5s infinite alternate;
}

@keyframes canvas-glow {
    from { box-shadow: 0 0 15px var(--primary-color), inset 0 0 15px var(--primary-color); }
    to { box-shadow: 0 0 30px #c5a6ff, inset 0 0 30px #c5a6ff; }
}

#action-buttons, #secondary-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

button {
    font-family: var(--font-header);
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    box-shadow: 0 0 10px var(--primary-color);
}

button:hover {
    background: #b88eff;
    box-shadow: 0 0 20px #b88eff;
}

button:active {
    transform: scale(0.97);
    box-shadow: 0 0 8px #b88eff;
}

#broadcast-button {
    background: #dc143c; /* Crimson */
    box-shadow: 0 0 10px #dc143c;
}
#broadcast-button:hover {
    background: #ff4757; /* Lighter red */
    box-shadow: 0 0 20px #ff4757;
}

#broadcast-button.broadcasting {
    background: #ff4757;
    animation: broadcasting-pulse 1s infinite;
    cursor: wait;
}

@keyframes broadcasting-pulse {
    0% { box-shadow: 0 0 10px #ff4757; }
    50% { box-shadow: 0 0 30px #ff8c8c; }
    100% { box-shadow: 0 0 10px #ff4757; }
}

#secondary-buttons button {
    background: transparent;
    border: 1px solid var(--primary-color);
    box-shadow: none;
}
#secondary-buttons button:hover {
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

#properties-display {
    background: rgba(10, 5, 20, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    margin-top: 15px;
    width: 80%;
    max-width: 600px;
    text-align: center;
}

#properties-display h3 {
    font-family: var(--font-header);
    color: var(--primary-color);
    margin-bottom: 10px;
}
#properties-display p {
    font-size: 0.8em;
    line-height: 1.6;
    color: #c9bcfc;
}

/* MODALS */
dialog {
    background: rgba(10, 5, 20, 0.9);
    border: 1px solid var(--primary-color);
    color: var(--text-color);
    border-radius: 10px;
    box-shadow: 0 0 30px var(--primary-color);
    padding: 20px;
    max-width: 80vw;
    max-height: 80vh;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
dialog[open] {
    opacity: 1;
    transform: scale(1);
}
dialog::backdrop {
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
}
dialog button[id^="close-"] {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 2em;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    box-shadow: none;
}

#presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}
.preset-card {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.preset-card:hover {
    border-color: var(--primary-color);
    background: var(--border-color);
}
.preset-card h4 {
    font-family: var(--font-header);
    color: var(--primary-color);
    margin-bottom: 5px;
}
.preset-card p {
    font-size: 0.8em;
    color: var(--text-color);
}

#manual-modal .manual-content {
    overflow-y: auto;
    max-height: calc(80vh - 80px);
    padding-right: 20px;
}
.manual-content h2, .manual-content h3, .manual-content h4 {
    font-family: var(--font-header);
    color: var(--primary-color);
    margin-top: 20px;
    margin-bottom: 10px;
}
.manual-content p, .manual-content li {
    line-height: 1.6;
    margin-bottom: 10px;
}
.manual-content ul {
    list-style-position: inside;
}

#show-manual-button {
    margin-top: auto;
    background: transparent;
    border: 1px solid var(--primary-color);
    box-shadow: none;
}
#show-manual-button:hover {
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}