/* ... existing variables ... */
:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.8);
    --border-color: rgba(48, 54, 61, 0.8);
    --text-color: #c9d1d9;
    --accent-color: #58a6ff;
    --success-color: #238636;
    --danger-color: #da3633;
    --glass-blur: 12px;
    --font-main: 'Outfit', sans-serif;
}

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

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

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    min-height: 60px;
    height: auto;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    /* Enable wrapping for small screens */
    padding: 0.5rem 2rem;
    gap: 1rem;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--accent-color);
    text-transform: uppercase;
}

.level-info {
    font-size: 1.1rem;
    font-weight: 300;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

/* Updated Selectors */
select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    padding: 4px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

select option {
    background: #1c2128;
    color: var(--text-color);
}

/* Mode Switch */
.mode-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #21262d;
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-color);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(26px);
    background-color: white;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.rules-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 1rem;
}

button {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s ease;
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
}

.primary-btn:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

#solution-btn {
    border-color: var(--success-color);
    color: var(--success-color);
}

#solution-btn:hover {
    background-color: rgba(35, 134, 54, 0.1);
}

.secondary-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

#toolbar {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    /* Enable wrapping for multiple lines */
    gap: 1.5rem;
    padding: 0.8rem 2rem;
    z-index: 150;
}

.toolbar-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    padding: 4px 0;
}

.toolbar-section h4 {
    margin-bottom: 0;
    min-width: fit-content;
}

main {
    flex: 1;
    display: flex;
    flex-direction: row;
    /* Keep rules on side but maybe make it toggleable? For now just wide canvas */
    overflow: hidden;
}

aside#instructions {
    width: 240px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-left: 1px solid var(--border-color);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    overflow-y: auto;
    position: relative;
    z-index: 200;
    transition: margin-right 0.3s ease, opacity 0.3s ease;
}

aside#instructions.hidden {
    margin-right: -240px;
    opacity: 0;
    pointer-events: none;
}

h3 {
    font-size: 1rem;
    border-bottom: 2px solid var(--accent-color);
    width: fit-content;
    padding-bottom: 3px;
    margin-bottom: 0.4rem;
}

h4 {
    font-size: 0.8rem;
    color: #8b949e;
    text-transform: uppercase;
}

#play-area {
    flex: 1;
    position: relative;
    background-image:
        radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.05) 1px, transparent 0);
    background-size: 40px 40px;
}

#canvas {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: center center;
}

/* Pool Items */
.pool {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

/* Generic Draggable Items */
.draggable-item {
    width: 44px;
    height: 44px;
    background: #21262d;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.draggable-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.draggable-item:active {
    cursor: grabbing;
}

/* Type specific styles */
.draggable-item[data-type="element"] {
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    background: linear-gradient(135deg, #1f6feb 0%, #161b22 100%);
}

.draggable-item[data-type="number"] {
    background: #161b22;
    font-family: monospace;
    font-size: 1.5rem;
    color: #ffd700;
}

.draggable-item[data-type="charge"] {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2da44e;
    font-size: 1rem;
    color: white;
}

.draggable-item[data-type="arrow"] {
    width: 60px;
    background: transparent;
    border: 2px solid var(--text-color);
    font-size: 1.5rem;
}

/* Canvas Items Positioning */
#canvas .draggable-item {
    position: absolute;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Snapping Visualization (Optional) */
.snap-target {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Styles for attached items (indices/charges) */
.attached-index {
    position: absolute;
    bottom: -5px;
    right: -10px;
    font-size: 0.8em;
    width: 20px;
    height: 20px;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.attached-charge {
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 0.7em;
    padding: 2px 5px;
    background: #2da44e;
    color: white;
    border-radius: 10px;
    z-index: 10;
}

/* Trash Zone */
.trash-zone {
    position: absolute;
    top: 2rem;
    /* Moved from bottom to top */
    right: 2rem;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    z-index: 150;
    transition: all 0.3s ease;
    min-width: 70px;
    pointer-events: auto;
    opacity: 0.5;
}

.trash-icon {
    font-size: 1.5rem;
}

.trash-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.trash-zone.active {
    opacity: 1;
    border-color: var(--danger-color);
    box-shadow: 0 0 20px rgba(248, 81, 73, 0.3);
}

.trash-zone.over-trash {
    transform: scale(1.1);
    background: rgba(248, 81, 73, 0.2);
}

/* Feedback Overlay */
#feedback {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 17, 23, 0.95);
    padding: 1.5rem 2.5rem;
    border-radius: 16px;
    border: 1px solid var(--success-color);
    text-align: center;
    z-index: 1000;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#feedback.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -20px) scale(0.9);
}

#feedback-title {
    color: var(--success-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

#feedback.error {
    border-color: var(--danger-color);
}

#feedback.error #feedback-title {
    color: var(--danger-color);
}

.hint {
    font-size: 0.85rem;
    color: #8b949e;
    font-style: italic;
    margin-bottom: 1rem;
}

/* Ghost item for touch dragging on tablet */
.dragging-ghost {
    opacity: 0.8;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transition: none !important;
    background: var(--accent-color);
    color: white;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 600;
}