/* ==========================================================================
   KPAH – Trang đăng ký tài khoản
   Màu: Void #0b0a16 · Night #14112b · Arcane #7f8cff · Gold #e2b45a · Moon #cfd6ff
   Chữ: Baloo 2 (tiêu đề/nhận diện), Be Vietnam Pro (nội dung)
   ========================================================================== */

:root {
    --void: #0b0a16;
    --night: #14112b;
    --arcane: #7f8cff;
    --moon: #cfd6ff;
    --gold: #e2b45a;
    --gold-hi: #f6dc9b;
    --gold-lo: #b8801f;
    --ember: #ff8a7a;
    --jade: #4fd6a0;
    --text: #ece8fb;
    --muted: #aaa6cd;
    --line: rgba(207, 214, 255, .16);
    --field: rgba(7, 6, 18, .6);

    --font-logo: "Baloo 2", "Be Vietnam Pro", sans-serif;
    --font-head: "Baloo 2", "Be Vietnam Pro", sans-serif;
    --font-body: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background: var(--void);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }

:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 50;
    background: var(--gold); color: #1a1204; padding: 10px 16px; border-radius: 8px;
    font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.icon {
    width: 20px; height: 20px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Cảnh nền ---------- */
.scene {
    position: fixed; inset: 0; z-index: -1;
    background:
        linear-gradient(90deg, rgba(11, 10, 22, .78) 0%, rgba(11, 10, 22, .35) 55%, rgba(11, 10, 22, .15) 100%),
        url("../img/scene.webp") center bottom / cover no-repeat,
        var(--void);
}
.scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- Bố cục ---------- */
.stage {
    flex: 1;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 40px);
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(340px, 480px);
    gap: clamp(28px, 6vw, 80px);
    align-items: center;
}

/* ---------- Khu thương hiệu ---------- */
.brand { position: relative; padding: 8px 0; animation: rise .8s cubic-bezier(.2, .7, .2, 1) both; }

.emblem {
    position: absolute; z-index: -1;
    left: clamp(-120px, -8vw, -40px); top: clamp(-90px, -6vw, -30px);
    width: clamp(280px, 36vw, 460px); aspect-ratio: 1;
    opacity: .3; pointer-events: none;
    animation: spin 160s linear infinite;
}
.emblem img { width: 100%; height: 100%; display: block; }

.wordmark {
    font-family: var(--font-logo);
    font-weight: 900;
    font-size: clamp(4.2rem, 12vw, 8.4rem);
    line-height: 1;
    letter-spacing: .09em;
    margin-left: .04em;
    background: linear-gradient(180deg, #fff3c9 0%, var(--gold-hi) 24%, var(--gold) 58%, var(--gold-lo) 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    filter: drop-shadow(0 8px 28px rgba(226, 180, 90, .28));
}

.brand h1 {
    margin-top: 14px;
    font-family: var(--font-head);
    font-size: clamp(1.7rem, 3.4vw, 2.4rem);
    line-height: 1.2;
    color: var(--moon);
}
.brand .lead { margin-top: 8px; max-width: 34ch; color: var(--muted); font-size: 1.05rem; }

.rules { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 12px; max-width: 46ch; }
.rules li {
    display: flex; gap: 12px; align-items: flex-start;
    color: var(--muted); font-size: .94rem;
    padding-left: 14px; border-left: 2px solid rgba(226, 180, 90, .45);
}
.rules .icon { color: var(--gold); margin-top: 2px; width: 18px; height: 18px; }
.rules strong { color: var(--text); font-weight: 600; }

/* ---------- Khung form (glass) ---------- */
.panel { position: relative; animation: rise .8s .14s cubic-bezier(.2, .7, .2, 1) both; }

.panel-inner {
    position: relative;
    padding: clamp(22px, 4vw, 34px);
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(28, 24, 62, .72), rgba(14, 12, 34, .72));
    border: 1px solid var(--line);
    -webkit-backdrop-filter: blur(18px) saturate(1.25);
    backdrop-filter: blur(18px) saturate(1.25);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7), 0 0 0 1px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .08);
}
/* góc trang trí kiểu khung game */
.panel-inner::before, .panel-inner::after {
    content: ""; position: absolute; width: 26px; height: 26px; pointer-events: none;
    border: 2px solid var(--gold);
}
.panel-inner::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 20px; }
.panel-inner::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 20px; }

.panel h2 {
    font-family: var(--font-head);
    font-size: 1.55rem; line-height: 1.2; margin-bottom: 18px; color: var(--text);
}

/* ---------- Trường nhập ---------- */
.fields { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 16px; }
.fields[disabled] { opacity: .55; }

.field label:not(.check-label) { display: block; margin-bottom: 6px; font-weight: 500; font-size: .93rem; }
.field .opt { color: var(--muted); font-weight: 400; }

.control { position: relative; }
.control input {
    width: 100%; height: 48px;
    padding: 0 14px 0 44px;
    background: var(--field); color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    font: inherit; font-size: 1rem;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.control input::placeholder { color: rgba(170, 166, 205, .55); }
.control input:hover { border-color: rgba(207, 214, 255, .32); }
.control input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226, 180, 90, .24); background: rgba(7, 6, 18, .8); }
.lead-icon { position: absolute; left: 14px; top: 14px; color: var(--muted); pointer-events: none; transition: color .15s; }
.control:focus-within .lead-icon { color: var(--gold); }
.control:has(input[type="password"]) input, .control:has(.eye) input { padding-right: 48px; }

.field.has-error input { border-color: var(--ember); }
.field.has-error input:focus { box-shadow: 0 0 0 3px rgba(255, 138, 122, .25); }

.eye {
    position: absolute; right: 6px; top: 6px; width: 36px; height: 36px;
    display: grid; place-items: center; padding: 0;
    background: transparent; color: var(--muted);
    border: 0; border-radius: 8px; cursor: pointer;
    transition: color .15s, background .15s;
}
.eye:hover { color: var(--text); background: rgba(207, 214, 255, .1); }

.hint { margin-top: 6px; font-size: .82rem; color: var(--muted); }
.field-error { margin-top: 6px; font-size: .85rem; color: var(--ember); font-weight: 500; }
.field-error:empty { display: none; }
.field-ok { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--jade); }
.field-ok .icon { width: 16px; height: 16px; }

/* độ mạnh mật khẩu */
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 9px; }
.meter i { height: 4px; border-radius: 3px; background: rgba(207, 214, 255, .14); transition: background .2s; }
.meter[data-level="1"] { --mc: var(--ember); }
.meter[data-level="2"] { --mc: var(--gold); }
.meter[data-level="3"] { --mc: #8fb4ff; }
.meter[data-level="4"] { --mc: var(--jade); }
.meter[data-level="1"] i:nth-child(-n+1),
.meter[data-level="2"] i:nth-child(-n+2),
.meter[data-level="3"] i:nth-child(-n+3),
.meter[data-level="4"] i:nth-child(-n+4) { background: var(--mc); }

/* CAPTCHA */
.captcha-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.captcha-box { display: flex; align-items: center; gap: 6px; }
.captcha-box img {
    display: block; width: 168px; height: 58px; max-width: 100%;
    border-radius: 10px; border: 1px solid var(--line); background: var(--night);
}
.icon-btn {
    width: 40px; height: 40px; display: grid; place-items: center; padding: 0;
    background: rgba(207, 214, 255, .08); color: var(--moon);
    border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
    transition: background .15s, transform .4s;
}
.icon-btn:hover { background: rgba(207, 214, 255, .16); }
.icon-btn.spin .icon { animation: spin .6s linear; }

#f-captcha { text-transform: uppercase; letter-spacing: .14em; font-weight: 600; }
#f-captcha::placeholder { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* checkbox điều khoản */
.check-label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: .92rem; color: var(--muted); position: relative; }
.check-label input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; cursor: pointer; }
.check-label .box {
    flex: none; width: 22px; height: 22px; border-radius: 6px; margin-top: 1px;
    border: 1.5px solid rgba(207, 214, 255, .4); background: var(--field);
    transition: background .15s, border-color .15s, box-shadow .15s; position: relative;
}
.check-label .box::after {
    content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px;
    border: solid #1a1204; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) scale(0); transition: transform .12s;
}
.check-label input:checked ~ .box { background: var(--gold); border-color: var(--gold); }
.check-label input:checked ~ .box::after { transform: rotate(45deg) scale(1); }
.check-label input:focus-visible ~ .box { box-shadow: 0 0 0 3px rgba(226, 180, 90, .35); }
.field.has-error .box { border-color: var(--ember); }

.link {
    background: none; border: 0; padding: 0; font: inherit; color: var(--gold-hi);
    text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link:hover { color: #fff; }

/* bẫy bot */
.hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Nút ---------- */
.btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 50px; padding: 0 22px; border-radius: 12px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 1rem; text-decoration: none; cursor: pointer;
    transition: transform .12s, filter .15s, box-shadow .2s, background .15s;
}
.btn-primary {
    width: 100%; margin-top: 20px; color: #1a1204;
    background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, #cf9a38);
    box-shadow: 0 10px 24px -8px rgba(226, 180, 90, .55), inset 0 1px 0 rgba(255, 255, 255, .55);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 14px 30px -8px rgba(226, 180, 90, .7), inset 0 1px 0 rgba(255, 255, 255, .55); }
.btn-primary:active { transform: translateY(1px) scale(.995); filter: brightness(.96); }
.btn-ghost { color: var(--moon); background: rgba(207, 214, 255, .07); border-color: var(--line); }
.btn-ghost:hover { background: rgba(207, 214, 255, .14); }
.btn-ghost:active { transform: translateY(1px); }
.btn[disabled] { cursor: not-allowed; filter: grayscale(.5) brightness(.8); box-shadow: none; }
.btn.is-loading { cursor: progress; }

.spinner {
    display: none; width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid rgba(26, 18, 4, .3); border-top-color: #1a1204;
    animation: spin .7s linear infinite;
}
.btn.is-loading .spinner { display: inline-block; }

.alt-link { margin-top: 16px; text-align: center; color: var(--muted); font-size: .92rem; }
.alt-link a { color: var(--gold-hi); text-underline-offset: 3px; }

/* ---------- Thông báo ---------- */
.alert {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 13px 14px; margin-bottom: 18px; border-radius: 12px;
    border: 1px solid var(--ac, var(--line)); background: rgba(255, 255, 255, .04);
    border-left-width: 4px; animation: pop .25s ease-out;
}
.alert .icon { color: var(--ac); margin-top: 1px; }
.alert strong { display: block; font-weight: 600; color: var(--text); }
.alert p { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.alert:focus { outline: none; }
.alert[data-type="error"] { --ac: var(--ember); background: rgba(255, 138, 122, .09); }
.alert[data-type="warn"] { --ac: var(--gold); background: rgba(226, 180, 90, .09); }
.alert[data-type="info"] { --ac: var(--arcane); background: rgba(127, 140, 255, .09); }

/* ---------- Thành công ---------- */
.success { text-align: center; animation: pop .35s ease-out; }
.success-mark {
    width: 72px; height: 72px; margin: 4px auto 14px; display: grid; place-items: center; border-radius: 50%;
    color: var(--jade); background: rgba(79, 214, 160, .12); border: 1px solid rgba(79, 214, 160, .4);
    box-shadow: 0 0 40px rgba(79, 214, 160, .25);
}
.success-mark .icon { width: 36px; height: 36px; stroke-width: 1.6; }
.success h2 { margin-bottom: 8px; }
.success h2:focus { outline: none; }
.acct { color: var(--gold-hi); font-weight: 600; word-break: break-all; }
.steps { text-align: left; margin: 20px auto 0; padding-left: 22px; max-width: 34ch; color: var(--muted); display: grid; gap: 6px; }
.steps li::marker { color: var(--gold); font-weight: 600; }
.note { margin-top: 18px; font-size: .85rem; color: var(--muted); }
.success-actions { margin-top: 22px; display: grid; gap: 10px; }
.success-actions .btn { width: 100%; margin-top: 0; }

/* ---------- Hộp thoại điều khoản ---------- */
dialog {
    width: min(560px, calc(100vw - 32px)); max-height: min(80vh, 640px); padding: 0;
    color: var(--text); background: var(--night);
    border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, .7);
}
dialog[open] { display: flex; flex-direction: column; animation: pop .22s ease-out; }
dialog::backdrop { background: rgba(5, 4, 14, .72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.dlg-head h2 { margin: 0; font-size: 1.35rem; }
.dlg-body { padding: 4px 20px 12px; overflow: auto; color: var(--muted); font-size: .94rem; }
.dlg-body ol { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.dlg-body strong { color: var(--text); font-weight: 600; }
.dlg-foot { padding: 12px 20px 20px; }
.dlg-foot .btn { margin-top: 0; }

/* ---------- Footer ---------- */
.footer {
    display: flex; flex-wrap: wrap; gap: 6px 22px; justify-content: center;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    color: var(--muted); font-size: .82rem;
}
.footer a { color: var(--muted); text-underline-offset: 3px; }
.footer a:hover { color: var(--text); }

/* ---------- Chuyển động ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
    .stage { grid-template-columns: minmax(0, 1fr); gap: 26px; max-width: 560px; }
    .brand { text-align: center; padding-top: 4px; }
    .brand .lead { margin-inline: auto; }
    .emblem { left: 50%; top: -40px; margin-left: -160px; width: 320px; opacity: .3; }
    .wordmark { font-size: clamp(3.6rem, 18vw, 5.6rem); margin-left: 0; }
    .rules { display: none; }
    .scene { background:
        linear-gradient(180deg, rgba(11, 10, 22, .55) 0%, rgba(11, 10, 22, .25) 100%),
        url("../img/scene.webp") 62% bottom / cover no-repeat, var(--void); }
}

@media (max-width: 480px) {
    .captcha-row { grid-template-columns: minmax(0, 1fr); }
    .panel-inner { border-radius: 16px; }
    .panel-inner::before { border-top-left-radius: 16px; }
    .panel-inner::after { border-bottom-right-radius: 16px; }
}

@media (forced-colors: active) {
    .panel-inner, .control input, .btn { border: 1px solid CanvasText; }
    .wordmark { -webkit-text-fill-color: CanvasText; color: CanvasText; background: none; }
}

/* Email verification actions */
.code-action { width:100%; min-height:42px; margin-top:10px; font-size:.92rem; }
.code-action.is-loading { opacity:.7; pointer-events:none; }
.code-action.is-done { border-color:rgba(79,214,160,.5); color:var(--jade); }
