body {
    margin: 0;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background: #151515;
    color: #eee;
}

#overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10;
    text-align: center;
    padding: 2rem;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: rgba(10, 10, 10, 0.7);
    padding: 2rem;
    border-radius: 0.75rem;
    width: min(420px, 90vw);
    pointer-events: auto;
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.35);
}

#start-panel {
    display: flex;
}

.loading-status {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: rgba(30, 30, 30, 0.55);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(-6px);
}

.loading-status.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.loading-visual {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: #3a8bf5;
    animation: loading-spin 1s linear infinite;
    flex-shrink: 0;
}

.loading-details {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 1;
}

.loading-step {
    margin: 0;
    font-size: 0.95rem;
    color: #d8d8d8;
    min-height: 1.2rem;
}

.loading-bar {
    position: relative;
    width: 100%;
    height: 0.5rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
}

.loading-bar-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, #3a8bf5, #7a5cff);
    box-shadow: 0 0 12px rgba(90, 140, 255, 0.65);
    transition: width 0.45s ease;
}

.loading-percent {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #ffffff;
    min-height: 1.2rem;
}

@keyframes loading-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

#pause-panel {
    display: none;
    align-items: flex-start;
    text-align: left;
}

#pause-panel h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 700;
}

#pause-panel p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #d0d0d0;
}

#pause-panel button {
    align-self: center;
}

#pause-menu {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(12, 12, 12, 0.75);
    border-radius: 0.6rem;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

#overlay[data-mode='pause'] #pause-menu,
#overlay[data-mode='start'] #pause-menu {
    display: flex;
    pointer-events: auto;
}

button[data-music-toggle] {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 0.45rem;
    cursor: pointer;
    background: #f57c3a;
    color: #fff;
    transition: background 0.2s ease;
}

button[data-music-toggle]:hover,
button[data-music-toggle]:focus {
    background: #e06925;
}

#start-button,
#resume-button,
#inventory-close,
#object-config-save,
#object-config-cancel {
    padding: 0.8rem 1.6rem;
    font-size: 1rem;
    border: none;
    border-radius: 0.4rem;
    cursor: pointer;
    background: #3a8bf5;
    color: #fff;
    transition: background 0.2s ease;
}

#start-button:hover,
#start-button:focus,
#resume-button:hover,
#resume-button:focus,
#inventory-close:hover,
#inventory-close:focus,
#object-config-save:hover,
#object-config-save:focus,
#object-config-cancel:hover,
#object-config-cancel:focus {
    background: #1e6fd8;
}

#npc-summon-overlay,
#npc-summon-create-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    z-index: 14;
    pointer-events: none;
    padding: 1.5rem;
    overflow-y: auto;
}

#npc-summon-overlay.visible,
#npc-summon-create-overlay.visible {
    display: flex;
    pointer-events: auto;
    scroll-behavior: smooth;
}

#game-over-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.78);
    z-index: 18;
    pointer-events: none;
}

#game-over-overlay.visible {
    display: flex;
    pointer-events: auto;
}

.game-over-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    padding: 2.25rem 2.5rem;
    border-radius: 0.9rem;
    background: rgba(20, 22, 32, 0.92);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
    min-width: min(360px, 85vw);
}

.game-over-modal h2 {
    margin: 0;
    font-size: 2.1rem;
    color: #ff6b6b;
    letter-spacing: 0.05em;
}

.game-over-modal p {
    margin: 0;
    font-size: 1.1rem;
    color: #f8f8f8;
}

.game-over-modal button {
    padding: 0.85rem 1.9rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: #3a8bf5;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.game-over-modal button:hover:not(:disabled),
.game-over-modal button:focus:not(:disabled) {
    background: #1e6fd8;
    transform: translateY(-1px);
}

.game-over-modal button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.npc-summon-modal {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: rgba(15, 15, 18, 0.92);
    border-radius: 1rem;
    padding: 1.75rem;
    width: min(720px, 92vw);
    max-height: min(92vh, 720px);
    overflow-y: auto;
    box-shadow: 0 28px 58px rgba(0, 0, 0, 0.5);
    text-align: left;
}

.npc-summon-modal[hidden] {
    display: none;
}

.npc-summon-modal[data-view="create"] {
    width: min(640px, 92vw);
}

.npc-summon-existing {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 720px) {
    .npc-summon-existing {
        grid-template-columns: minmax(240px, 0.95fr) minmax(280px, 1.05fr);
        align-items: start;
    }
}

.npc-template-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 220px;
}

.npc-summon-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.npc-summon-header h2 {
    margin: 0;
    font-size: 1.6rem;
}

.npc-summon-header button {
    padding: 0.5rem 0.85rem;
    border: none;
    border-radius: 0.4rem;
    background: rgba(255, 255, 255, 0.08);
    color: #f0f0f0;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.npc-summon-header button:hover,
.npc-summon-header button:focus {
    background: rgba(255, 255, 255, 0.18);
}

.npc-summon-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

#npc-existing-create {
    background: #3a8bf5;
    color: #fff;
}

#npc-existing-create:hover,
#npc-existing-create:focus {
    background: #246ce0;
}

.npc-summon-header button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#npc-create-close {
    background: rgba(255, 255, 255, 0.12);
}

#npc-existing-close {
    background: rgba(255, 255, 255, 0.12);
}

.npc-summon-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.npc-summon-hint {
    margin: 0;
    color: #d0d0d0;
    font-size: 0.95rem;
}

.npc-template-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.npc-template-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.85rem 1rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(30, 32, 42, 0.78);
    color: #f5f5f5;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.npc-template-item:hover,
.npc-template-item:focus {
    border-color: rgba(110, 150, 255, 0.75);
    background: rgba(44, 48, 68, 0.9);
}

.npc-template-item.is-selected {
    border-color: rgba(110, 150, 255, 0.95);
    background: rgba(60, 66, 92, 0.92);
    box-shadow: 0 0 0 1px rgba(110, 150, 255, 0.35);
}

.npc-template-item h4 {
    margin: 0;
    font-size: 1.05rem;
}

.npc-template-item p {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(230, 232, 255, 0.75);
}

.npc-summon-empty {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(240, 240, 240, 0.75);
}

.npc-summon-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.npc-summon-actions button {
    padding: 0.65rem 1.2rem;
    border: none;
    border-radius: 0.45rem;
    cursor: pointer;
    background: #3a8bf5;
    color: #fff;
    font-size: 0.95rem;
    transition: background 0.2s ease;
}

.npc-summon-actions button:hover,
.npc-summon-actions button:focus {
    background: #246ce0;
}

.npc-summon-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.npc-template-detail-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.npc-template-placeholder {
    padding: 1.2rem;
    border-radius: 0.6rem;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    background: rgba(32, 34, 44, 0.6);
    color: rgba(220, 224, 255, 0.75);
    font-size: 0.95rem;
}

.npc-detail-title {
    margin: 0;
    font-style: italic;
    color: rgba(214, 226, 255, 0.85);
}

.npc-detail-sub {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(220, 220, 255, 0.75);
}

.npc-summon-grid {
    display: grid;
    gap: 0.85rem;
    max-height: min(60vh, 520px);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.npc-summon-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #d4d4d4;
}

.npc-summon-grid input,
.npc-summon-grid select,
.npc-summon-grid textarea {
    padding: 0.6rem 0.7rem;
    border-radius: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(24, 26, 34, 0.85);
    color: #f5f5f5;
    font-size: 0.95rem;
    outline: none;
}

.npc-summon-grid input:focus,
.npc-summon-grid select:focus,
.npc-summon-grid textarea:focus {
    border-color: rgba(110, 150, 255, 0.85);
    box-shadow: 0 0 0 2px rgba(110, 150, 255, 0.25);
}

.npc-summon-error {
    min-height: 1.2rem;
    color: #ff6b6b;
    font-size: 0.9rem;
}

#inventory-screen {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    z-index: 12;
    pointer-events: none;
}

#inventory-screen.visible {
    display: flex;
    pointer-events: auto;
}

.inventory-modal {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: rgba(12, 12, 12, 0.85);
    border-radius: 1rem;
    padding: 2rem;
    width: min(760px, 94vw);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

#object-config {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    z-index: 13;
    pointer-events: none;
}

#object-config.visible {
    display: flex;
    pointer-events: auto;
}

.object-config-modal {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(15, 15, 15, 0.9);
    border-radius: 0.9rem;
    padding: 1.75rem;
    width: min(420px, 90vw);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
    text-align: left;
}

.object-config-modal h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.object-config-modal label {
    font-size: 0.9rem;
    color: #d0d0d0;
}

.object-config-modal textarea {
    min-height: 6rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.55);
    color: #f2f2f2;
    padding: 0.75rem;
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
}

.object-config-modal textarea:focus {
    border-color: #3a8bf5;
    box-shadow: 0 0 0 2px rgba(58, 139, 245, 0.25);
}

.object-config-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

#magic-axe-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    z-index: 14;
    pointer-events: none;
}

#magic-axe-overlay.visible {
    display: flex;
    pointer-events: auto;
}

.magic-axe-modal {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: rgba(15, 15, 15, 0.9);
    border-radius: 1rem;
    padding: 2rem;
    width: min(440px, 92vw);
    box-shadow: 0 28px 52px rgba(0, 0, 0, 0.48);
    text-align: left;
}

.magic-axe-modal h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
}

.magic-axe-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.magic-axe-section h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #f0f0f0;
}

.magic-axe-coordinates {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.magic-axe-coordinates label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #cfcfcf;
}

.magic-axe-coordinates input[type='number'] {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.55);
    color: #f2f2f2;
    font-size: 0.9rem;
    outline: none;
}

.magic-axe-coordinates input[type='number']:focus {
    border-color: #3a8bf5;
    box-shadow: 0 0 0 2px rgba(58, 139, 245, 0.25);
}

.magic-axe-section select {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border-radius: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.6);
    color: #f2f2f2;
    font-size: 0.95rem;
    outline: none;
}

.magic-axe-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.magic-axe-fill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: #f0f0f0;
}

.magic-axe-count {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffd166;
}

.magic-axe-error {
    min-height: 1.2rem;
    margin: 0;
    font-size: 0.85rem;
    color: #ff6b6b;
}

.magic-axe-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

#sorting-hat-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.68);
    z-index: 15;
    pointer-events: none;
}

#sorting-hat-overlay.visible {
    display: flex;
    pointer-events: auto;
}

.sorting-hat-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: rgba(18, 18, 18, 0.92);
    border-radius: 1rem;
    padding: 2.2rem 2.4rem 2rem 2.4rem;
    width: min(460px, 92vw);
    box-shadow: 0 28px 52px rgba(0, 0, 0, 0.5);
    text-align: left;
}

.sorting-hat-modal h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
}

.sorting-hat-progress {
    margin: 0;
    font-size: 0.95rem;
    color: #d0d0d0;
}

.sorting-hat-question {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.45;
    color: #f5f5f5;
}

.sorting-hat-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sorting-hat-option {
    padding: 0.85rem 1rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.5);
    color: #f2f2f2;
    font-size: 0.98rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.sorting-hat-option:hover,
.sorting-hat-option:focus {
    background: rgba(58, 139, 245, 0.25);
    border-color: rgba(58, 139, 245, 0.65);
    outline: none;
}

.sorting-hat-result {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 0.75rem;
    padding: 1rem 1.2rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sorting-hat-result h3 {
    margin: 0 0 0.35rem 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.sorting-hat-result p {
    margin: 0;
    font-size: 0.95rem;
    color: #e0e0e0;
}

.sorting-hat-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.sorting-hat-actions button {
    padding: 0.75rem 1.4rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    background: #3a8bf5;
    color: #fff;
    transition: background 0.2s ease;
}

.sorting-hat-actions button:hover,
.sorting-hat-actions button:focus {
    background: #1e6fd8;
}

.sorting-hat-close {
    position: absolute;
    top: 0.8rem;
    right: 0.9rem;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.35);
    color: #f2f2f2;
    font-size: 1.4rem;
    line-height: 2rem;
    cursor: pointer;
}

.sorting-hat-close:hover,
.sorting-hat-close:focus {
    background: rgba(58, 139, 245, 0.35);
}

#magic-axe-cancel,
#magic-axe-build {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 0.45rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

#magic-axe-cancel {
    background: rgba(255, 255, 255, 0.12);
    color: #f2f2f2;
}

#magic-axe-cancel:hover,
#magic-axe-cancel:focus {
    background: rgba(255, 255, 255, 0.2);
}

#magic-axe-build {
    background: #3a8bf5;
    color: #fff;
}

#magic-axe-build:hover,
#magic-axe-build:focus {
    background: #1e6fd8;
}

.inventory-modal h2 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    text-align: left;
}

.inventory-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.inventory-section h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #d6d6d6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(9, 64px);
    gap: 0.65rem;
    justify-content: center;
}

.inventory-actions {
    display: flex;
    justify-content: flex-end;
}

#hud {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

#hud-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#health-bar {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.6rem;
    background: rgba(0, 0, 0, 0.45);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

#health-bar[aria-hidden='true'] {
    display: none;
}

.health-heart {
    width: 28px;
    height: 28px;
    image-rendering: crisp-edges;
}

#performance-stats {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.55);
    font-size: 0.9rem;
    font-weight: 600;
    color: #f0f0f0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    align-self: flex-start;
}

#crosshair {
    width: 16px;
    height: 16px;
    margin-top: calc(50vh - 8px);
    border-left: 2px solid #fff;
    border-top: 2px solid #fff;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
}

#magic-axe-tooltip {
    position: absolute;
    top: calc(50vh + 18px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.35rem 0.65rem;
    border-radius: 0.4rem;
    background: rgba(0, 0, 0, 0.7);
    color: #ffd166;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#magic-axe-tooltip.visible {
    opacity: 1;
}

#wand-energy {
    position: absolute;
    top: calc(50vh + 26px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.45rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(12, 18, 36, 0.7);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

#wand-energy.visible {
    opacity: 1;
}

.wand-energy-orb {
    position: relative;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.wand-energy-orb::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(167, 196, 255, 0.95), rgba(79, 124, 255, 0.65));
    opacity: 0;
    transform: scale(0.25);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.wand-energy-orb[data-state='full']::after {
    opacity: 1;
    transform: scale(1);
}

.wand-energy-orb[data-state='charging']::after {
    opacity: 0.9;
    transform: scale(calc(0.25 + var(--orb-progress, 0) * 0.75));
}

#wand-spellbook {
    position: absolute;
    top: 50%;
    left: 2rem;
    transform: translate(-12px, -50%);
    width: min(260px, 32vw);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border-radius: 0.65rem;
    background: rgba(12, 18, 36, 0.72);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.38);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#wand-spellbook.visible {
    opacity: 1;
    transform: translate(0, -50%);
}

#wand-spellbook h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #83b3ff;
}

.wand-spell-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.wand-info-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wand-info-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #83b3ff;
}

.wand-info-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.wand-info-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.wand-info-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.35;
    color: #e4e9ff;
}

.wand-info-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.45rem;
    border-radius: 0.35rem;
    background: rgba(131, 179, 255, 0.18);
    border: 1px solid rgba(131, 179, 255, 0.35);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c8d9ff;
}

.wand-info-description {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #cfd7f3;
}

.wand-spell-item {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 0.5rem;
    background: rgba(18, 26, 48, 0.6);
    transition: background 0.18s ease, transform 0.18s ease;
}

.wand-spell-item.disabled {
    opacity: 0.5;
    filter: grayscale(0.45);
}

.wand-spell-item.triggered {
    animation: wand-spell-trigger 0.28s ease;
}

.wand-spell-item.denied {
    animation: wand-spell-denied 0.28s ease;
}

.wand-spell-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.45rem;
    border-radius: 0.35rem;
    background: rgba(79, 124, 255, 0.25);
    color: #d7e4ff;
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
}

.wand-spell-label {
    font-weight: 600;
    color: #f2f4ff;
}

.wand-spell-cost {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

@keyframes wand-spell-trigger {
    0% {
        transform: scale(1);
        background: rgba(18, 26, 48, 0.6);
    }

    30% {
        transform: scale(1.05);
        background: rgba(79, 124, 255, 0.55);
    }

    100% {
        transform: scale(1);
        background: rgba(18, 26, 48, 0.6);
    }
}

@keyframes wand-spell-denied {
    0% {
        transform: translateX(0);
    }

    30% {
        transform: translateX(-4px);
    }

    60% {
        transform: translateX(4px);
    }

    100% {
        transform: translateX(0);
    }
}

#inventory {
    margin-top: 0;
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: repeat(9, 64px);
    gap: 0.65rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    pointer-events: auto;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.inventory-slot {
    position: relative;
    width: 64px;
    height: 64px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 0.45rem;
    background: rgba(32, 32, 32, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.inventory-slot:hover {
    border-color: rgba(255, 255, 255, 0.55);
    transform: translateY(-2px);
}

#inventory-screen.visible .inventory-slot {
    cursor: grab;
}

#inventory-screen.visible .inventory-slot:active {
    cursor: grabbing;
}

.inventory-slot.filled {
    background: rgba(48, 48, 48, 0.9);
}

.inventory-slot.active {
    border-color: #3a8bf5;
    box-shadow: 0 0 0 2px rgba(58, 139, 245, 0.4);
}

.inventory-slot.dragging {
    opacity: 0.5;
}

.inventory-slot.drag-over {
    border-color: #ffffff;
}

.slot-swatch {
    width: 48px;
    height: 48px;
    border-radius: 0.35rem;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.35);
}

.slot-swatch.has-icon {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    box-shadow: none;
}

.slot-label {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #f2f2f2;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    text-align: center;
}

.slot-count {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.slot-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.45rem;
    background: rgba(8, 12, 24, 0.68);
    color: #f0f4ff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    pointer-events: none;
    overflow: hidden;
}

.slot-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    transform-origin: bottom;
    transform: scaleY(var(--cooldown-progress, 1));
    background: linear-gradient(180deg, rgba(79, 124, 255, 0.55), rgba(12, 20, 40, 0.85));
    transition: transform 0.12s linear;
}

.slot-overlay-text {
    position: relative;
    z-index: 1;
}

canvas {
    display: block;
}

#chat-container {
    position: absolute;
    left: 1.5rem;
    bottom: 6rem;
    width: 24rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    pointer-events: none;
    font-size: 0.85rem;
}

#chat-log {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 12rem;
    overflow: hidden;
}

#chat-history {
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 9rem;
    overflow-y: auto;
    padding: 0.4rem;
    border-radius: 0.4rem;
    background: rgba(8, 8, 8, 0.85);
    scrollbar-width: thin;
    pointer-events: none;
}

#chat-history.visible {
    display: flex;
}

.chat-history-entry {
    display: flex;
    gap: 0.45rem;
    font-size: 0.8rem;
    line-height: 1.2;
    color: #f5f5f5;
}

.chat-history-name {
    font-weight: 600;
    white-space: nowrap;
}

.chat-history-text {
    flex: 1;
    word-break: break-word;
    color: rgba(255, 255, 255, 0.85);
}

.chat-message {
    background: rgba(0, 0, 0, 0.55);
    padding: 0.35rem 0.5rem;
    border-radius: 0.35rem;
    line-height: 1.2;
    pointer-events: none;
    transition: opacity 0.25s ease;
    opacity: 0.95;
}

.chat-message.fade {
    opacity: 0;
}

.chat-text {
    color: #f5f5f5;
    word-break: break-word;
}

#chat-input {
    display: none;
    padding: 0.45rem 0.6rem;
    border-radius: 0.35rem;
    border: none;
    outline: none;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    pointer-events: auto;
    font-size: 0.9rem;
}

#chat-input.visible {
    display: block;
}

#start-panel h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.6rem;
    font-weight: 700;
}

#start-panel label {
    text-align: left;
    font-size: 0.9rem;
    color: #d0d0d0;
}

#start-panel input[type="text"] {
    padding: 0.6rem 0.75rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.55);
    color: #f2f2f2;
    font-size: 1rem;
    outline: none;
}

#start-panel input[type="text"]:focus {
    border-color: #3a8bf5;
    box-shadow: 0 0 0 2px rgba(58, 139, 245, 0.25);
}

#start-panel input[type="color"] {
    width: 100%;
    height: 2.5rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
    padding: 0;
    outline: none;
}

#start-panel input.invalid {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.25);
}

.chat-name {
    font-weight: 600;
    margin-right: 0.4rem;
}
#overlay::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.6));
    z-index: -1;
}

.panel {
    background: rgba(20, 20, 30, 0.85);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border-radius: 18px;
    padding: 32px 36px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: clamp(320px, 30vw, 480px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel h1 {
    margin: 0;
    font-size: 2.8rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #ffd166;
}

.world-name {
    margin: 0;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
}

.start-tips {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
}

.panel label {
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.panel input[type="text"],
.panel input[type="color"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #f9f9f9;
    font-size: 1rem;
}

.panel button:not([data-music-toggle]) {
    margin-top: 12px;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #ff6b6b, #ffd166);
    color: #151826;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel button:not([data-music-toggle]):hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(255, 210, 102, 0.35);
}

#world-name {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 2px;
}

@media (max-width: 768px) {
    .panel {
        width: 90vw;
        padding: 28px;
    }

    .panel h1 {
        font-size: 2.2rem;
    }
}
