:root { color-scheme: dark; }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    background: radial-gradient(circle at 50% 0%, #4a1d6e, #1a0b2e 70%);
    color: #fff; min-height: 100vh; display: flex; justify-content: center; user-select: none;
  }
  #app { width: 100%; max-width: 900px; padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .screen { display: none; }
  .screen.active { display: block; }
  h1 { text-align: center; font-size: 52px; margin: 20px 0 6px; color: #ffd54a;
       text-shadow: 0 4px 0 #b3541e, 0 0 30px rgba(255,200,60,.5); letter-spacing: 6px; }
  .sub { text-align: center; color: #e8c9ff; margin-bottom: 24px; }
  .panel { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
           border-radius: 16px; padding: 18px; margin: 12px auto; max-width: 560px; }
  .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
  .row label { min-width: 70px; color: #e8c9ff; }
  .seg button { flex: 1; }
  button {
    font-family: inherit; font-size: 16px; color: #fff; cursor: pointer;
    background: #6b35a0; border: 2px solid #9b6bd0; border-radius: 10px; padding: 9px 16px;
    transition: transform .08s, background .15s;
  }
  button:hover:not(:disabled) { background: #8448c2; }
  button:active:not(:disabled) { transform: scale(.96); }
  button:disabled { opacity: .4; cursor: not-allowed; }
  button.on { background: #ffb300; border-color: #ffe08a; color: #3a1a00; font-weight: bold; }
  .big { font-size: 24px; padding: 14px 40px; background: #e2442f; border-color: #ff8a70;
         display: block; margin: 18px auto 0; font-weight: bold; }
  .big:hover:not(:disabled) { background: #f05a44; }
  .big.alt { background: #6b35a0; border-color: #9b6bd0; margin-top: 10px; }
  .big.alt:hover:not(:disabled) { background: #7d44b5; }
  .note { font-size: 13px; color: #c9b0e0; margin-top: 6px; line-height: 1.6; }
  .best { text-align: center; color: #ffd54a; margin-top: 10px; }

  /* HUD */
  .hud { display: flex; justify-content: space-between; align-items: center; font-size: 20px;
         background: rgba(0,0,0,.3); border-radius: 12px; padding: 10px 16px; }
  .hud .floor { font-size: 24px; color: #ffd54a; font-weight: bold; }
  .lives span { margin-left: 2px; }
  /* 楼层与门 */
  .building { margin: 16px 0; background: linear-gradient(#5c2e1a, #3b1c10); border-radius: 14px;
              padding: 22px 16px 0; border-bottom: 10px solid #2a120a; position: relative; }
  .floor-sign { position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
                font-size: 14px; color: #f5c27a; letter-spacing: 3px; }
  .doors { display: flex; justify-content: center; gap: 22px; }
  .door-wrap { width: 160px; text-align: center; }
  .frame { width: 130px; height: 175px; margin: 0 auto; background: #120806; border: 8px solid #b8862e;
           border-bottom: none; border-radius: 70px 70px 0 0; position: relative; overflow: hidden;
           perspective: 600px; }
  .behind { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
            font-size: 54px; background: radial-gradient(circle, #fff3b0, #ffb300 70%); }
  .door { position: absolute; inset: 0; background: linear-gradient(90deg, #c0392b, #e74c3c 50%, #c0392b);
          transform-origin: left center; transition: transform .9s cubic-bezier(.3,.1,.3,1);
          display: flex; align-items: center; justify-content: center; font-size: 46px; font-weight: bold;
          color: #ffd54a; text-shadow: 0 2px 0 #7a1a10; border-radius: 62px 62px 0 0; }
  .door::after { content: ""; position: absolute; right: 14px; top: 55%; width: 12px; height: 12px;
                 border-radius: 50%; background: #ffd54a; box-shadow: 0 0 6px #ffd54a; }
  .door-wrap.open .door { transform: rotateY(-100deg); }
  .door-wrap.fail .door { background: linear-gradient(90deg, #444, #666 50%, #444); color: #ccc; }
  .door-wrap.done-skip .door { background: linear-gradient(90deg, #556, #778 50%, #556); }
  .door-wrap.current .frame { box-shadow: 0 0 24px #ffd54a; }
  .door-wrap.current .door { animation: glow 1.4s infinite; }
  @keyframes glow { 50% { filter: brightness(1.25); } }
  .door-label { margin: 6px 0 10px; font-size: 13px; color: #f5c27a; min-height: 18px; }
  /* 门铃 */
  .bell-area { text-align: center; margin: 6px 0; }
  .bell { width: 96px; height: 96px; border-radius: 50%; font-size: 44px; padding: 0;
          background: radial-gradient(circle at 35% 30%, #ffe680, #f0a400); border: 4px solid #fff3c0;
          box-shadow: 0 6px 0 #a06a00; }
  .bell:hover:not(:disabled) { background: radial-gradient(circle at 35% 30%, #fff0a0, #ffb820); }
  .bell.ringing { animation: ring .25s infinite; }
  @keyframes ring { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
  .timer { height: 10px; background: rgba(255,255,255,.15); border-radius: 5px; margin: 12px auto; max-width: 560px; overflow: hidden; }
  .timer div { height: 100%; width: 100%; background: linear-gradient(90deg, #4caf50, #ffeb3b); transition: width .1s linear; }
  .timer.warn div { background: #f44336; }
  .msg { text-align: center; font-size: 20px; min-height: 30px; margin: 6px 0; }
  .msg.good { color: #7dff9a; } .msg.bad { color: #ff8a80; }
  /* 答题 */
  .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 560px; margin: 8px auto; }
  .choices button { font-size: 19px; padding: 14px 8px; background: #2d5ea8; border-color: #6a9be0; }
  .choices button:hover:not(:disabled) { background: #3a72c4; }
  .choices button.gone { visibility: hidden; }
  .choices button.right { background: #2e9e4f; border-color: #8ef0a8; }
  .choices button.wrong { background: #b3261e; border-color: #ff8a80; }
  .typebox { display: flex; gap: 10px; max-width: 560px; margin: 8px auto; }
  .typebox button { white-space: nowrap; }
  .typebox input { flex: 1; font-size: 20px; padding: 10px 14px; border-radius: 10px; border: 2px solid #9b6bd0;
                   background: rgba(0,0,0,.35); color: #fff; font-family: inherit; }
  .hint-line { text-align: center; color: #ffd54a; min-height: 24px; font-size: 18px; }
  .hints { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
  .hints button { font-size: 14px; background: #3d2a55; border-color: #7a5aa0; }
  .next-btn { display: none; }
  /* 掉落弹窗 */
  .drop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 10; }
  .drop.show { display: flex; }
  .drop-card { background: linear-gradient(#fff6d8, #ffd66b); color: #4a2400; border-radius: 18px; padding: 26px 36px;
               text-align: center; animation: pop .35s cubic-bezier(.2,1.6,.4,1); min-width: 280px; }
  @keyframes pop { from { transform: scale(.3); opacity: 0; } }
  .drop-card .icon { font-size: 70px; }
  .drop-card .t { font-size: 24px; font-weight: bold; margin: 6px 0; }
  .drop-card button { margin-top: 14px; }
  /* 图鉴 */
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
  .disc { background: rgba(255,255,255,.08); border-radius: 12px; padding: 12px; text-align: center; border: 1px solid rgba(255,255,255,.12); }
  .disc .cd { width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 8px;
              background: radial-gradient(circle, #222 12%, #eee 13%, #eee 16%, var(--c) 17%, #111 70%); }
  .disc.locked { opacity: .35; }
  .disc.locked .cd { background: radial-gradient(circle, #222 12%, #555 13%, #333 70%); }
  .disc .name { font-size: 15px; min-height: 20px; }
  .disc .tag { font-size: 12px; color: #c9b0e0; }
  .disc button { font-size: 12px; padding: 4px 10px; margin-top: 6px; }
  .over-stats { font-size: 22px; text-align: center; line-height: 2; }
  .over-stats b { color: #ffd54a; font-size: 30px; }
  .center { text-align: center; }
  .songlist { max-height: 260px; overflow: auto; font-size: 13px; color: #e8c9ff; margin-top: 6px; }
  .mrow { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.08); flex-wrap: wrap; }
  .mrow .mname { flex: 1 1 60%; min-width: 0; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mrow input.mname { font-family: inherit; font-size: 15px; padding: 6px 10px; border-radius: 8px; border: 1px solid #9b6bd0; background: rgba(0,0,0,.3); }
  .mrow.gone .mname { text-decoration: line-through; opacity: .5; }
  .subhead { margin: 18px 0 4px; font-size: 16px; color: #ffd54a; }
  button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #ffd54a; outline-offset: 2px; }
  @media (max-width: 600px) {
    h1 { font-size: 38px; letter-spacing: 3px; }
    .doors { gap: 8px; }
    .door-wrap { width: 31%; }
    .frame { width: 92%; height: 130px; border-width: 6px; }
    .door { font-size: 32px; }
    .behind { font-size: 36px; }
    .big { font-size: 20px; padding: 12px 28px; }
    .choices button { font-size: 16px; padding: 12px 6px; }
    .drop-card { min-width: 0; width: calc(100% - 48px); }
    .panel { padding: 14px; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
  .mrow input[type=range] { flex: 1; min-width: 120px; accent-color: #ffb300; }
  .mrow .mtime { min-width: 64px; color: #ffd54a; }
  .mrow button { font-size: 12px; padding: 4px 8px; }
  select { font-family: inherit; font-size: 16px; color: #fff; background: #6b35a0; border: 2px solid #9b6bd0; border-radius: 10px; padding: 8px 12px; flex: 1; }
  select option, select optgroup { background: #2a1440; }
