/* ================= MÀN HÌNH TẠO NHÂN VẬT & THẺ HỌC SINH ================= */
#ui-layer {
    position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; height: 100dvh;
    background:
        radial-gradient(ellipse at 50% 115%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 55%),
        linear-gradient(160deg, #0d1442 0%, #1a237e 38%, #3d63b5 72%, #cfe1f6 100%);
    display: flex; justify-content: center; align-items: center;
    z-index: 10; overflow: hidden;
}

.ui-pattern {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image:
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
        repeating-linear-gradient(45deg, rgba(255,255,255,0.04) 0, rgba(255,255,255,0.04) 14px, transparent 14px, transparent 28px);
    background-size: 48px 48px, 48px 48px, auto;
    z-index: -1;
}

.sparkle {
    position: absolute; background: white; border-radius: 50%;
    box-shadow: 0 0 12px 3px rgba(255, 255, 255, 0.7);
    animation: twinkle infinite ease-in-out;
}
@keyframes twinkle {
    0%, 100% { opacity: 0.25; transform: scale(0.6); }
    50% { opacity: 0.9; transform: scale(1.3); }
}

.retro-window {
    background-color: var(--paper);
    box-shadow: inset 1px 1px var(--hl), inset -1px -1px var(--edge), inset 2px 2px var(--lt), inset -2px -2px var(--sh), 0 18px 40px rgba(5,10,50,0.45);
    padding: 4px; display: flex; flex-direction: column; z-index: 2;
}
#window-customize { width: 800px; max-width: 96vw; max-height: 95vh; max-height: 95dvh; }
#window-id-card { width: 400px; max-width: 96vw; display: none; }
#window-id-card .window-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

.title-bar {
    background: var(--navy); padding: 4px 8px;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: bold; font-size: 14px; color: #fff; margin-bottom: 10px;
}
.btn-close {
    background: var(--paper); border: none; font-weight: bold; font-size: 14px; color: var(--navy);
    width: 22px; height: 22px; cursor: pointer;
    box-shadow: inset 1px 1px var(--hl), inset -1px -1px var(--edge), inset 2px 2px var(--lt), inset -2px -2px var(--sh);
}
.btn-close:active { box-shadow: inset 1px 1px var(--edge), inset -1px -1px var(--hl), inset 2px 2px var(--sh), inset -2px -2px var(--lt); }

.window-body { display: flex; gap: 15px; padding: 10px; flex-grow: 1; overflow: hidden; min-height: 0; }
.left-col { width: 250px; flex-shrink: 0; }
.avatar-preview-box {
    background: linear-gradient(180deg, #fffdf5 0%, #eaf2fc 100%);
    height: 320px; position: relative;
    box-shadow: inset 2px 2px var(--edge), inset -2px -2px var(--hl), inset 3px 3px var(--sh), inset -3px -3px var(--lt);
    display: flex; justify-content: center; align-items: center; overflow: hidden;
}

.right-col {
    flex-grow: 1; overflow-y: auto; padding-right: 10px;
    display: flex; flex-direction: column; gap: 12px; max-height: 62vh;
}
.right-col::-webkit-scrollbar { width: 16px; }
.right-col::-webkit-scrollbar-track { background: var(--lt); box-shadow: inset 1px 1px var(--sh); }
.right-col::-webkit-scrollbar-thumb { background: var(--paper); box-shadow: inset 1px 1px var(--hl), inset -1px -1px var(--edge); }

.form-label { font-weight: bold; font-size: 13px; color: var(--navy); margin-bottom: 2px; margin-top: 5px; display: block; }
.retro-input {
    width: 100%; padding: 8px; font-size: 14px; background: #fff; color: #1b1f3b;
    box-shadow: inset 1px 1px var(--edge), inset -1px -1px var(--hl), inset 2px 2px var(--sh), inset -2px -2px var(--lt);
    border: none; outline: none; margin-bottom: 5px; font-family: 'Tahoma', sans-serif;
}
select.retro-input { cursor: pointer; }

.btn-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.grid-btn {
    background: #e3eaf7; padding: 8px 12px; font-size: 12px; font-weight: bold;
    color: #1b1f3b; border: none; cursor: pointer; text-align: center;
    box-shadow: inset 1px 1px var(--hl), inset -1px -1px var(--edge), inset 2px 2px var(--lt), inset -2px -2px var(--sh);
    transition: background 0.1s;
}
.grid-btn.active {
    background: #c2d0f2; color: var(--navy);
    box-shadow: inset 1px 1px var(--edge), inset -1px -1px var(--hl), inset 2px 2px var(--sh), inset -2px -2px var(--lt);
}

.color-box {
    width: 35px; height: 35px; cursor: pointer; border: none;
    box-shadow: inset 1px 1px var(--hl), inset -1px -1px var(--edge), inset 2px 2px var(--lt), inset -2px -2px var(--sh);
}
.color-box.active { box-shadow: inset 2px 2px var(--navy), inset -2px -2px var(--hl), inset 4px 4px var(--sh), inset -4px -4px var(--lt); }

.window-footer { padding: 10px; margin-top: 10px; border-top: 2px solid #a9b8de; }
.btn-save {
    width: 100%; padding: 12px; background: var(--navy); color: #fff; font-size: 16px; font-weight: bold;
    border: none; cursor: pointer;
    box-shadow: inset 1px 1px var(--navy-light), inset -1px -1px #000, inset 2px 2px #5c6bc0, inset -2px -2px var(--navy-dark);
}
.btn-save:active { box-shadow: inset 2px 2px #000, inset -2px -2px var(--navy-light), inset 4px 4px var(--navy-dark), inset -4px -4px #5c6bc0; }

.id-card-info { text-align: center; margin: 15px 0; }
.id-card-info h3 { font-size: 24px; color: var(--navy); margin-bottom: 5px; }
.id-card-info p { font-size: 16px; font-weight: bold; color: #1b1f3b; }

@media (max-width: 700px) {
    .window-body { flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px; }
    .left-col { width: 100%; }
    .avatar-preview-box { height: 240px; }
    #previewCanvas { height: 100%; width: auto; }
    .right-col { max-height: none; overflow: visible; padding-right: 0; }
    .retro-input { font-size: 16px; padding: 10px; }
    .grid-btn { padding: 10px 13px; font-size: 13px; }
    .color-box { width: 40px; height: 40px; }
    .title-bar { margin-bottom: 4px; }
}
@media (max-height: 520px) and (min-width: 701px) {
    .left-col { width: 170px; }
    .avatar-preview-box { height: 210px; }
    #previewCanvas { height: 100%; width: auto; }
    .right-col { max-height: calc(100dvh - 140px); }
    .retro-input { font-size: 16px; }
    .window-footer { padding: 6px 10px; margin-top: 4px; }
}
