/* latin-ext */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/outfit-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/outfit-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

: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 {
    height: 60px;
    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;
    padding: 0 2rem;
    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;
}

#molecule-selector,
#difficulty-selector {
    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;
}

#molecule-selector:hover,
#difficulty-selector:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

#molecule-selector option,
#difficulty-selector option {
    background: #1c2128;
    color: var(--text-color);
}

.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);
}

.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);
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

aside {
    width: 280px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    position: relative;
    z-index: 200;
}

#instructions {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

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

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

#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;
}

.zoom-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.zoom-controls span {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
}

.zoom-controls button {
    padding: 4px 10px;
    font-size: 1rem;
}

/* Pool Items */
.pool {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px;
}

/* Draggable Items */
.atom {
    width: 50px;
    height: 50px;
    background: #21262d;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 0 15px rgba(88, 166, 255, 0.2);
    cursor: grab;
    user-select: none;
    position: relative;
    /* Changed from absolute to flow in pool */
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

#canvas .atom {
    position: absolute;
}

.atom:active {
    cursor: grabbing;
}

.trash-zone {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: 150;
    transition: all 0.3s ease;
    min-width: 80px;
    pointer-events: none;
    /* Let drag pass through until we check coordinates */
    opacity: 0.5;
}

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

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

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

.trash-zone.over-trash {
    background: rgba(248, 81, 73, 0.1);
    transform: scale(1.1);
    border-color: var(--error-color);
    box-shadow: 0 0 30px rgba(248, 81, 73, 0.5);
}

.atom.satisfied {
    border-color: var(--success-color);
    box-shadow: 0 0 20px rgba(35, 134, 54, 0.4);
}

.charge-label {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #1c2128;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.charge {
    position: relative;
    background: #1c2128;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: grab;
    user-select: none;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

#canvas .charge {
    position: absolute;
}

.charge:active {
    cursor: grabbing;
}

.bond {
    width: 40px;
    height: 8px;
    background: var(--text-color);
    border-radius: 4px;
    cursor: grab;
    user-select: none;
    position: relative;
    /* Changed from absolute */
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
    transform: rotate(var(--rot, 0deg));
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#canvas .bond {
    position: absolute;
}

/* Feedback Overlay */
#feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(13, 17, 23, 0.9);
    padding: 2rem 3rem;
    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.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

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

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

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

.feedback-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

#feedback.warning {
    border-color: #f1c40f;
}

#feedback.warning #feedback-title {
    color: #f1c40f;
}

.stats {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

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

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.success-pulse {
    animation: pulse 0.5s ease-in-out infinite;
}

/* Solution Ghost Overlay */
.solution-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.solution-image-overlay img {
    max-width: 60%;
    max-height: 60%;
    object-fit: contain;
    opacity: 0.8;
    filter: drop-shadow(0 0 20px rgba(88, 166, 255, 0.4));
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 0.8;
        transform: scale(1);
    }
}

.solution-ghost {
    position: absolute;
    opacity: 0.3;
    pointer-events: none;
    background: transparent !important;
}

.solution-ghost.atom {
    border: 2px dashed rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05) !important;
    color: rgba(255, 255, 255, 0.3);
}

.solution-ghost.bond {
    background: rgba(255, 255, 255, 0.4) !important;
}

.solution-ghost.charge {
    width: 24px;
    height: 24px;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05) !important;
}