:root {
  color-scheme: dark;
  --ink: #151411;
  --panel: #211d17;
  --paper: #ebd3a2;
  --gold: #cba564;
  --text: #e3d9c7;
  --muted: #b1a594;
  --line: rgba(203, 165, 100, .24);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--ink); }
body { color: var(--text); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:disabled { cursor: wait; }
button:focus-visible, a:focus-visible, #player-host:focus-visible { outline: 2px solid var(--paper); outline-offset: 4px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.app-shell { display: grid; grid-template-rows: 68px minmax(0, 1fr) 40px; width: 100%; height: 100%; height: 100dvh; }
.topbar, .helpbar { position: relative; z-index: 4; display: flex; align-items: center; background: #171510; }
.topbar { justify-content: space-between; gap: 20px; padding: 0 32px; border-bottom: 1px solid rgba(203, 165, 100, .5); }
.brand { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; color: var(--paper); white-space: nowrap; }
.brand-muy { font: italic 700 29px/1 Georgia, serif; letter-spacing: -.04em; }
.brand h1 { margin: 0; font: 700 23px/1.2 "STKaiti", "KaiTi", "Noto Serif CJK SC", serif; letter-spacing: .08em; }
.brand-edition { margin-left: 8px; padding-left: 16px; border-left: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.topbar-actions { display: flex; align-items: center; gap: 22px; min-width: 0; }
.download-link { font-size: 13px; color: #d2c0a1; }
.atmosphere-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0; border: 0; color: #baa783; background: none; font-size: 12px; }
.atmosphere-toggle svg { width: 19px; height: 19px; }
.atmosphere-toggle[aria-pressed="false"] { color: #8b8174; }
.atmosphere-toggle[aria-pressed="false"] svg { opacity: .6; }
.icon-button, .secondary-button { min-height: 36px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 3px; color: var(--paper); background: rgba(235, 211, 162, .035); transition: background-color 150ms ease, border-color 150ms ease; }
.stage-shell { position: relative; min-height: 0; overflow: hidden; }
.login-view, .player-view { position: absolute; inset: 0; }
.login-view { display: grid; grid-template-columns: minmax(0, 1fr) clamp(398px, 34%, 520px); }
.login-art { position: relative; overflow: hidden; background: #242725; isolation: isolate; }
.scene-picture, .scene-image, .scene-shade, .scene-atmosphere { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-image { object-fit: cover; object-position: 70% center; }
.scene-shade { z-index: 1; background: linear-gradient(180deg, rgba(12, 14, 13, .03) 38%, rgba(10, 13, 12, .24) 64%, rgba(7, 11, 10, .68)), linear-gradient(90deg, transparent 75%, rgba(14, 15, 13, .18)); }
.scene-atmosphere { z-index: 2; pointer-events: none; }
.scene-title { position: absolute; z-index: 3; left: 6.5%; bottom: 12%; width: min(76%, 640px); }
.scene-title img { display: block; width: 100%; height: auto; filter: drop-shadow(0 3px 12px rgba(0, 0, 0, .6)); }
.scene-title p { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 0 0; white-space: nowrap; color: #f1e1be; font: 400 clamp(15px, 1.5vw, 22px)/1.6 "STKaiti", "KaiTi", "Noto Serif CJK SC", serif; letter-spacing: .17em; text-shadow: 0 2px 7px #000; }
.scene-title p span { flex: 1; height: 1px; max-width: 72px; background: rgba(218, 187, 128, .6); }
.scene-caption { position: absolute; z-index: 3; bottom: 5%; left: 6.5%; display: flex; align-items: center; gap: 12px; color: #c8c0ac; font-size: 12px; letter-spacing: .15em; }
.caption-rule { width: 32px; height: 1px; background: #b39961; }
.login-panel { display: flex; align-items: center; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #61513a #161511; padding: 0 clamp(30px, 3.8vw, 60px); border-left: 1px solid rgba(203, 165, 100, .42); background: linear-gradient(rgba(13, 13, 11, .1), rgba(13, 13, 11, .1)), url("./assets/panel-leaf.webp") center/cover, var(--ink); }
.login-card { width: 100%; max-width: 392px; margin: auto; padding: 38px 0 28px; }
.login-heading { margin-bottom: 30px; padding-bottom: 21px; border-bottom: 1px solid rgba(203, 165, 100, .5); }
.eyebrow { margin: 0 0 10px; color: #b49a6e; font-size: 10px; letter-spacing: .23em; }
.login-heading h2 { margin: 0; color: #f1e2c4; font: 600 clamp(31px, 2.8vw, 42px)/1.35 "STKaiti", "KaiTi", "Noto Serif CJK SC", serif; letter-spacing: .055em; white-space: nowrap; }
.intro { margin: 12px 0 0; color: #cbbca3; font: 16px/1.5 "STKaiti", "KaiTi", "Noto Serif CJK SC", serif; letter-spacing: .08em; }
.field-group + .field-group { margin-top: 22px; }
.field-group label { display: block; margin-bottom: 9px; color: #d8cdb7; font-size: 13px; letter-spacing: .13em; }
.input-wrap { position: relative; }
.input-wrap input { display: block; width: 100%; height: 50px; padding: 0 16px 0 46px; border: 1px solid #5a564e; border-radius: 4px; outline: none; color: #f0e5d1; background: rgba(28, 28, 25, .85); font-size: 14px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.input-wrap input::placeholder { color: #9c9487; font-size: 13px; }
.input-wrap input:focus { border-color: #ceb178; box-shadow: 0 0 0 2px rgba(203, 165, 100, .11); }
.input-wrap input:disabled { opacity: .66; }
.input-wrap input:-webkit-autofill { -webkit-text-fill-color: #f0e5d1; box-shadow: 0 0 0 1000px #23211b inset; caret-color: #f0e5d1; }
.field-icon { position: absolute; z-index: 1; top: 14px; left: 15px; width: 22px; height: 22px; color: #a09a8d; pointer-events: none; }
.password-wrap input { padding-right: 54px; }
.password-toggle { position: absolute; top: 3px; right: 3px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 2px; color: #a59d8e; background: transparent; }
.password-toggle svg { width: 22px; height: 22px; }
.password-toggle[aria-pressed="true"] .eye-slash { display: none; }
.account-note { margin: 14px 0 20px; color: #a99b84; font-size: 11px; line-height: 1.5; }
.primary-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 18px; width: 100%; height: 62px; padding: 0 22px; border: 1px solid #f2d6a0; border-radius: 5px; overflow: hidden; color: #23190b; background: url("./assets/button-gold.webp") center/100% 100%, linear-gradient(180deg, #eed29a, #c49a54); box-shadow: 0 1px 0 rgba(255, 240, 194, .2), 0 7px 20px rgba(0, 0, 0, .24); font: 700 25px/1.2 "STKaiti", "KaiTi", "Noto Serif CJK SC", serif; letter-spacing: .19em; transition: filter 160ms ease, box-shadow 160ms ease; }
.primary-button svg { width: 16px; height: 21px; stroke-width: 2.5; }
.primary-button:active { filter: brightness(.91); box-shadow: inset 0 2px 6px rgba(49, 30, 4, .15); }
.primary-button:disabled { filter: saturate(.5); color: #403420; opacity: .75; }
.local-test-button { width: 100%; margin-top: 10px; padding: 8px; border: 1px dashed var(--line); border-radius: 3px; color: #b8a17b; background: transparent; font-size: 11px; }
.form-feedback { height: 90px; padding-top: 14px; overflow-y: auto; scrollbar-width: thin; }
.form-message { margin: 0; color: #f0ab89; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.form-message.success { color: #bfd0a6; }
.text-button { margin-top: 4px; padding: 3px 0; border: 0; color: #e7c998; background: none; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.security-note { margin: 0 0 16px; color: #e5ae7b; font-size: 12px; line-height: 1.65; }
.login-help { padding-top: 17px; border-top: 1px solid rgba(203, 165, 100, .35); }
.login-help p { margin: 0; color: #aca18e; font-size: 11px; line-height: 1.9; }
.mobile-notice { display: none; }

.player-view { display: grid; place-items: center; background: #080908; }
#player-host { width: min(100%, calc((100dvh - 108px) * 12 / 7)); max-height: 100%; aspect-ratio: 12 / 7; background: #000; outline: none; }
#player-host ruffle-player { display: block; width: 100%; height: 100%; }
.player-view:fullscreen #player-host { width: min(100vw, calc(100dvh * 12 / 7)); }
.loading-curtain { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; overflow-y: auto; background: linear-gradient(rgba(11, 12, 10, .96), rgba(11, 12, 10, .96)), url("./assets/konoha-scene-small.webp") center/cover; transition: opacity 200ms var(--ease-out), visibility 200ms; }
.loading-curtain.ready { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-content { width: min(490px, calc(100% - 40px)); margin: auto; padding: 34px 0; text-align: center; }
.loading-kicker { margin: 0 0 26px; color: #a68b59; font: 18px/1.5 "STKaiti", "KaiTi", serif; letter-spacing: .2em; }
.spinner { width: 27px; height: 27px; margin: 0 auto 20px; border: 1px solid rgba(203, 165, 100, .2); border-top-color: var(--paper); border-radius: 50%; animation: spin 850ms linear infinite; }
.loading-status { min-height: 82px; }
#loading-title { display: block; color: var(--paper); font: 600 25px/1.4 "STKaiti", "KaiTi", serif; letter-spacing: .07em; }
#loading-detail { margin: 10px 0 0; color: #b9ac96; font-size: 12px; line-height: 1.7; }
.loading-steps { display: flex; justify-content: center; gap: 0; margin: 20px 0 28px; padding: 0; list-style: none; }
.loading-steps li { position: relative; display: flex; flex: 1; flex-direction: column; align-items: center; gap: 12px; min-width: 0; color: #8e887c; font-size: 10px; white-space: nowrap; }
.loading-steps li:not(:last-child)::after { position: absolute; top: 6px; left: calc(50% + 9px); width: calc(100% - 18px); height: 1px; content: ""; background: #37352e; }
.step-mark { width: 13px; height: 13px; border: 1px solid #585143; border-radius: 50%; background: #151611; }
.loading-steps li.is-active, .loading-steps li[aria-current="step"] { color: var(--paper); }
.loading-steps li.is-active .step-mark, .loading-steps li[aria-current="step"] .step-mark { border-color: #dbbc7e; background: #a58145; box-shadow: 0 0 0 3px rgba(203, 165, 100, .1); }
.loading-steps li.is-complete { color: #b9b895; }
.loading-steps li.is-complete .step-mark { border-color: #c8b480; background: #c8b480; }
.loading-steps li.is-complete:not(:last-child)::after { background: #86734d; }
#cancel-launch-button { min-width: 134px; font-size: 12px; }
.loading-tip { margin: 18px 0 0; color: #978c78; font-size: 11px; line-height: 1.7; }
.helpbar { justify-content: space-between; gap: 16px; padding: 0 24px; border-top: 1px solid rgba(203, 165, 100, .18); color: #9b907e; font-size: 10px; }
.control-hints { display: flex; align-items: center; gap: 22px; }
kbd { font: inherit; color: #c3b59a; }
#diagnostics-button { flex-shrink: 0; height: 28px; max-width: 190px; padding: 2px 0 2px 10px; overflow: hidden; border: 0; color: #b4a78e; background: none; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
dialog { width: min(760px, calc(100% - 32px)); max-height: calc(100% - 40px); padding: 0; border: 1px solid #665239; border-radius: 5px; color: var(--text); background: #1c1913; box-shadow: 0 20px 90px #000; }
dialog::backdrop { background: rgba(0, 0, 0, .75); }
dialog form { margin: 0; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dialog-title h2 { margin: 0; color: var(--paper); font-size: 15px; }
.runtime-badges { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; }
.badge { padding: 5px 9px; border: 1px solid #544935; border-radius: 3px; color: #b2a88f; font-size: 11px; overflow-wrap: anywhere; }
.badge.pass { color: #bdcf9e; border-color: #4d5940; }
.badge.fail { color: #f0ab89; border-color: #78513b; }
#diagnostics-output { max-height: min(65vh, 580px); margin: 0; padding: 16px 20px; overflow: auto; color: #c5c6b4; background: #11120e; font: 12px/1.7 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.noscript-note { position: fixed; z-index: 10; right: 20px; bottom: 48px; left: 20px; padding: 15px; border: 1px solid var(--gold); color: var(--paper); background: #211d17; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (hover: hover) and (pointer: fine) {
  .primary-button:not(:disabled):hover { filter: brightness(1.08); }
  .icon-button:hover, .secondary-button:hover { border-color: #b59a67; background: rgba(235, 211, 162, .08); }
  .download-link:hover, .atmosphere-toggle:hover, #diagnostics-button:hover, .password-toggle:hover { color: #f1dba9; }
}
@media (min-width: 761px) and (max-height: 740px) {
  .login-card { padding-top: 22px; padding-bottom: 20px; }
  .login-heading { margin-bottom: 22px; padding-bottom: 15px; }
  .field-group + .field-group { margin-top: 16px; }
  .form-feedback { height: 72px; }
  .scene-title { bottom: 14%; }
}
@media (max-width: 1080px) and (min-width: 761px) {
  .login-view { grid-template-columns: minmax(0, 1fr) 390px; }
  .login-panel { padding-right: 30px; padding-left: 30px; }
  .scene-image { object-position: 74% center; }
  .scene-title { width: 89%; left: 5.5%; }
  .scene-title p { gap: 8px; font-size: 14px; letter-spacing: .06em; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-rows: 58px minmax(0, 1fr) 36px; }
  .topbar { gap: 10px; padding: 0 16px; }
  .brand { gap: 7px; }
  .brand-muy { font-size: 23px; }
  .brand h1 { font-size: 19px; }
  .brand-edition { margin-left: 3px; padding-left: 10px; font-size: 10px; }
  .topbar-actions { gap: 14px; }
  .download-link { display: none; }
  .atmosphere-toggle { font-size: 10px; }
  .atmosphere-toggle svg { width: 16px; height: 16px; }
  .login-view { grid-template-columns: 1fr; grid-template-rows: minmax(205px, 30svh) auto; overflow-y: auto; overscroll-behavior-y: contain; }
  .login-art { min-height: 205px; }
  .scene-image { object-position: 65% 43%; }
  .scene-shade { background: linear-gradient(180deg, transparent 20%, rgba(12, 15, 12, .58)); }
  .scene-title { bottom: 26px; left: 6%; width: min(54%, 300px); }
  .scene-title p { gap: 6px; margin-top: 4px; font-size: 11px; letter-spacing: .07em; }
  .scene-title p span { display: none; }
  .scene-caption { display: none; }
  .login-panel { overflow: visible; padding: 0 28px; border-top: 1px solid rgba(203, 165, 100, .35); border-left: 0; }
  .login-card { max-width: 430px; padding: 30px 0 25px; }
  .login-heading { margin-bottom: 22px; padding-bottom: 16px; }
  .login-heading h2 { font-size: 32px; }
  .eyebrow { display: none; }
  .intro { margin-top: 8px; font-size: 15px; }
  .field-group + .field-group { margin-top: 20px; }
  .input-wrap input { height: 50px; font-size: 16px; }
  .primary-button { height: 58px; font-size: 24px; }
  .form-feedback { height: 70px; }
  .mobile-notice { display: block; margin: 13px 0 0; color: #bbad95; font-size: 11px; line-height: 1.7; }
  .helpbar { padding: 0 14px; }
  .control-hints { gap: 13px; }
  #player-host { width: 100%; }
  .loading-steps li { font-size: 9px; }
}
@media (max-width: 370px) {
  .brand-muy, .atmosphere-toggle span { display: none; }
  .brand h1 { font-size: 18px; }
  .login-panel { padding: 0 20px; }
  .login-heading h2 { font-size: 29px; }
  .control-hints span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .spinner { animation: none; }
  .loading-curtain, button, input { transition: none !important; }
}
