@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Share+Tech+Mono&display=swap');

:root {
    --black:        #000000;
    --white:        #ffffff;
    --gray-950:     #060606;
    --gray-900:     #0d0d0d;
    --gray-800:     #161616;
    --gray-700:     #222222;
    --gray-600:     #333333;
    --gray-500:     #4a4a4a;
    --gray-400:     #666666;
    --gray-300:     #888888;
    --gray-200:     #aaaaaa;
    --gray-100:     #cccccc;

    --accent:       #ffffff;
    --accent-dim:   rgba(255,255,255,0.55);
    --accent-glow:  rgba(255,255,255,0.12);

    --border:       2px solid #ffffff;
    --border-dim:   1px solid rgba(255,255,255,0.18);
    --border-faint: 1px solid rgba(255,255,255,0.07);

    --font-pixel:   'Press Start 2P', monospace;
    --font-mono:    'Share Tech Mono', monospace;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }

body {
    background-color: var(--black);
    background-image:
        linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
    background-size: 32px 32px;
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.7;
    min-height: 100vh;
    padding-bottom: 80px;
    overflow-x: hidden;
}

/* ─── SPLASH ─── */
#splash-screen {
    position: fixed;
    inset: 0;
    background: var(--black);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.6s ease;
}

.splash-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    animation: splashIn 0.5s ease forwards;
}

@keyframes splashIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

#splash-logo {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    border: var(--border);
    outline: 4px solid rgba(255,255,255,0.25);
    outline-offset: 4px;
    animation: splashPulse 1.8s ease-in-out infinite;
}

@keyframes splashPulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50%       { box-shadow: 0 0 32px 10px var(--accent-glow); }
}

.splash-title {
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--white);
    text-shadow: 0 0 20px rgba(255,255,255,0.4);
    max-width: 360px;
    line-height: 2.2;
}

.splash-bar {
    width: 260px;
    height: 3px;
    background: var(--gray-700);
    border: 1px solid rgba(255,255,255,0.2);
    position: relative;
    overflow: hidden;
}

.splash-bar::after {
    content: '';
    position: absolute;
    left: -100%; top: 0;
    height: 100%; width: 100%;
    background: var(--white);
    animation: loadBar 2.6s linear forwards;
}

@keyframes loadBar {
    0%   { left: -100%; }
    100% { left: 0%; }
}

/* ─── CONTAINER ─── */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 20px;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}
.container.visible { opacity: 1; transform: translateY(0); }

/* ─── MAIN HEADER ─── */
.main-header { margin-bottom: 52px; }

h1.main-title {
    font-family: var(--font-pixel);
    font-size: clamp(0.6rem, 1.8vw, 0.85rem);
    color: var(--white);
    text-align: center;
    line-height: 2.2;
    padding: 32px 20px;
    border: var(--border);
    background: var(--gray-950);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.04em;
}

/* Corner tick marks */
h1.main-title::before,
h1.main-title::after {
    content: '';
    position: absolute;
    width: 12px; height: 12px;
}
h1.main-title::before {
    top: -2px; left: -2px;
    border-top: 3px solid var(--gray-400);
    border-left: 3px solid var(--gray-400);
}
h1.main-title::after {
    bottom: -2px; right: -2px;
    border-bottom: 3px solid var(--gray-400);
    border-right: 3px solid var(--gray-400);
}

h1.main-title .scan-line {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--white), transparent);
    animation: scanLine 3.5s ease-in-out infinite;
}

h1.main-title span {
    color: var(--gray-300);
    font-size: 0.85em;
}

@keyframes scanLine {
    0%, 100% { transform: translateX(-100%); opacity: 0.4; }
    50%       { transform: translateX(100%);  opacity: 0.9; }
}

.main-header-sub {
    text-align: center;
    font-size: 0.72rem;
    color: var(--gray-400);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-top: none;
    background: var(--gray-900);
}

/* ─── HEADINGS ─── */
h2 {
    font-family: var(--font-pixel);
    font-size: 0.72rem;
    color: var(--white);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    line-height: 2;
    display: flex;
    align-items: center;
    gap: 10px;
}
h2::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    background: var(--white);
    flex-shrink: 0;
}

h3 {
    font-family: var(--font-pixel);
    font-size: 0.58rem;
    color: var(--gray-200);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    line-height: 2;
}

h4 {
    font-family: var(--font-pixel);
    font-size: 0.52rem;
    color: var(--gray-300);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    line-height: 2;
}

/* ─── SECTION CARDS ─── */
.item-creator, .manifest-editor, .items-list {
    background: var(--gray-950);
    border: var(--border);
    padding: 32px;
    margin-bottom: 40px;
    position: relative;
    transition: box-shadow 0.3s ease;
}

/* Offset shadow layer */
.item-creator::after,
.manifest-editor::after,
.items-list::after {
    content: '';
    position: absolute;
    bottom: -6px; right: -6px;
    width: 100%; height: 100%;
    border: 1px solid rgba(255,255,255,0.1);
    z-index: -1;
    pointer-events: none;
}

.item-creator:hover,
.manifest-editor:hover {
    box-shadow: 0 0 50px rgba(255,255,255,0.04);
}

/* ─── FORM ─── */
.form-group { margin-bottom: 24px; }

label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--gray-300);
    margin-bottom: 8px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 11px 14px;
    background: var(--gray-900);
    border: 1px solid rgba(255,255,255,0.12);
    border-left: 3px solid var(--white);
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: rgba(255,255,255,0.45);
    border-left-color: var(--white);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.15), inset 0 0 14px rgba(255,255,255,0.02);
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M0 0l5 7 5-7z' fill='%23ffffff'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}
select option { background: var(--gray-900); color: var(--white); }

input[type="file"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--gray-900);
    border: 1px dashed rgba(255,255,255,0.25);
    color: var(--gray-300);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s;
    margin-bottom: 0;
}
input[type="file"]:hover { border-color: var(--white); }

/* ─── IDENTIFIER ROW ─── */
.identifier-input {
    display: flex;
    align-items: center;
    gap: 8px;
}
.identifier-input span {
    color: var(--gray-300);
    font-family: var(--font-pixel);
    font-size: 0.9rem;
    flex-shrink: 0;
}
.namespace { flex: 0 0 42%; }
#itemIdentifier {
    flex: 1;
    background: var(--gray-800);
    color: var(--gray-500);
    border-left-color: var(--gray-600);
    cursor: not-allowed;
}

/* ─── IMAGE PREVIEW ─── */
.image-preview {
    width: 128px;
    height: 128px;
    border: 1px solid rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    background:
        repeating-conic-gradient(var(--gray-900) 0% 25%, var(--gray-800) 0% 50%)
        0 0 / 10px 10px;
    position: relative;
    overflow: hidden;
}
.image-preview p {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--gray-600);
    letter-spacing: 0.1em;
}
.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

/* ─── COMPONENTS ─── */
.components-editor {
    background: var(--gray-900);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 24px;
    margin-bottom: 24px;
}

.component {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0;
    border-bottom: var(--border-faint);
    gap: 12px;
}
.component:last-child { border-bottom: none; }

.component label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 0;
    font-size: 0.72rem;
    color: var(--gray-200);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-grow: 1;
}

/* Custom checkbox */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.35);
    background: var(--black);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
}
input[type="checkbox"]:checked {
    background: var(--white);
    border-color: var(--white);
}
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px; left: 4px;
    width: 4px; height: 8px;
    border-right: 2px solid var(--black);
    border-bottom: 2px solid var(--black);
    transform: rotate(45deg);
}

.component input[type="number"],
.component select {
    width: auto;
    min-width: 90px;
    max-width: 160px;
    flex-shrink: 0;
}

/* ─── BUTTONS ─── */
button {
    display: block;
    width: 100%;
    padding: 13px 20px;
    background: var(--black);
    color: var(--white);
    border: var(--border);
    font-family: var(--font-pixel);
    font-size: 0.52rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-align: center;
    transition: color 0.22s ease;
}
button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--white);
    transform: translateX(-101%);
    transition: transform 0.25s ease;
    z-index: 0;
}
button:hover::before { transform: translateX(0); }
button:hover { color: var(--black); }
button:active { transform: scale(0.97); }
button::after { display: none; }

/* Add item */
#addItem {
    border-color: var(--white);
    color: var(--white);
    margin-top: 4px;
}
#addItem::before { background: var(--white); }
#addItem:hover { color: var(--black); }

/* Download */
#downloadAll {
    max-width: 400px;
    margin: 0 auto;
    padding: 18px 28px;
    font-size: 0.6rem;
    border-color: var(--white);
    color: var(--white);
    background: var(--black);
}
#downloadAll::before { background: var(--white); }
#downloadAll:hover {
    color: var(--black);
    box-shadow: 0 0 40px rgba(255,255,255,0.12);
}

/* Delete */
.delete-btn {
    border-color: rgba(255,255,255,0.5) !important;
    color: var(--gray-300) !important;
    background: var(--black) !important;
}
.delete-btn::before { background: var(--gray-700) !important; }
.delete-btn:hover { color: var(--white) !important; }

/* Edit */
.edit-btn {
    border-color: var(--white) !important;
    color: var(--white) !important;
    background: var(--black) !important;
}
.edit-btn::before { background: var(--white) !important; }
.edit-btn:hover { color: var(--black) !important; }

/* ─── LORE ─── */
.lore-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.lore-item input[type="text"] { flex: 1; }

.lore-item button,
#addLore {
    display: inline-block !important;
    width: auto !important;
    padding: 10px 14px !important;
    font-size: 0.8rem !important;
    flex-shrink: 0;
}

.remove-lore {
    border-color: rgba(255,255,255,0.3) !important;
    color: var(--gray-400) !important;
}
.remove-lore::before { background: var(--gray-700) !important; }
.remove-lore:hover { color: var(--white) !important; }

#addLore {
    margin-top: 8px !important;
    border-color: rgba(255,255,255,0.4) !important;
    color: var(--gray-200) !important;
}
#addLore::before { background: var(--gray-700) !important; }
#addLore:hover { color: var(--white) !important; }

/* ─── MANIFEST SECTIONS ─── */
.manifest-section {
    background: var(--gray-900);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
    position: relative;
}
.manifest-section:hover { border-color: rgba(255,255,255,0.35); }
.manifest-section:last-child { margin-bottom: 0; }

/* Left accent line on manifest sections */
.manifest-section::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--white), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}
.manifest-section:hover::before { opacity: 0.4; }

/* ─── ITEM CARDS ─── */
.item-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 10px;
    background: var(--gray-900);
    position: relative;
    transition: border-color 0.2s, background 0.2s;
    overflow: hidden;
}
.item-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--white);
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform 0.25s ease;
}
.item-card:hover {
    border-color: rgba(255,255,255,0.4);
    background: var(--gray-800);
}
.item-card:hover::before { transform: scaleY(1); }
.item-card:last-child { margin-bottom: 0; }

.item-card .item-preview {
    width: 64px; height: 64px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.2);
    background:
        repeating-conic-gradient(var(--gray-900) 0% 25%, var(--gray-800) 0% 50%)
        0 0 / 8px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.item-card .item-preview img {
    width: 100%; height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}
.item-card .item-info { flex-grow: 1; min-width: 0; }
.item-card .item-info h4 {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--white);
    border: none; padding: 0;
    margin-bottom: 6px;
    line-height: 1.9;
}
.item-card .item-info p {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-card .item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.item-card button {
    padding: 8px 14px;
    width: auto;
    font-size: 0.42rem;
    display: inline-block;
}

/* ─── DOWNLOAD SECTION ─── */
.download-section {
    text-align: center;
    margin-top: 40px;
    padding: 44px 24px;
    border: var(--border);
    background: var(--gray-950);
    position: relative;
    overflow: hidden;
}
.download-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg, transparent, transparent 48px,
        rgba(255,255,255,0.012) 48px, rgba(255,255,255,0.012) 50px
    );
    pointer-events: none;
}

.download-label {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--gray-500);
    letter-spacing: 0.18em;
    margin-bottom: 20px;
    display: block;
}

/* ─── NOTIFICATION ─── */
.notification {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 9000;
    transform: translateX(calc(100% + 40px));
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16,1,0.3,1), opacity 0.35s ease;
}
.notification.show { transform: translateX(0); opacity: 1; }
.notification.hidden { display: none; }

.notification-content {
    background: var(--gray-950);
    border: var(--border);
    border-left: 4px solid var(--white);
    color: var(--white);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 290px;
    max-width: 420px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}
.notification.error .notification-content   { border-left-color: var(--gray-400); }
.notification.warning .notification-content { border-left-color: var(--gray-300); }

#close-notification {
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: 18px;
    padding: 0;
    cursor: pointer;
    width: auto;
    display: block;
    line-height: 1;
    transition: color 0.15s;
}
#close-notification::before { display: none; }
#close-notification:hover { color: var(--white); background: none; }
#close-notification:hover::before { display: none; }
#close-notification:active { transform: none; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--gray-700); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
    .container { padding: 20px 14px; }
    h1.main-title { font-size: 0.52rem; padding: 24px 14px; }
    .item-creator, .manifest-editor, .items-list { padding: 20px; }
    .item-card { flex-wrap: wrap; }
    .item-card .item-actions { width: 100%; }
    .item-card button { flex: 1; text-align: center; }
    .component { flex-direction: column; align-items: flex-start; }
    .component input[type="number"],
    .component select { width: 100%; max-width: 100%; }
    .notification { bottom: 12px; right: 12px; }
    .notification-content { min-width: auto; max-width: calc(100vw - 24px); }
}
