:root {
  --bg: #16232d;
  --panel: #213441;
  --panel-2: #2a4050;
  --line: rgba(255, 255, 255, .12);
  --text: #f4f1ea;
  --muted: #a9b8c2;
  --pop: #ff5e7a;
  --pop-2: #ffc93c;
  --ok: #3ccf91;
  --hud-h: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.btn {
  border: 0; border-radius: 999px; padding: 10px 22px; font-weight: 700;
  background: linear-gradient(180deg, #ff7690, var(--pop)); color: #fff;
  box-shadow: 0 3px 0 #c63c57, 0 6px 16px rgba(255, 94, 122, .3);
  transition: transform .08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c63c57; }
.btn.big { padding: 14px 34px; font-size: 18px; }
.btn.ghost { background: var(--panel-2); box-shadow: 0 3px 0 #15222b; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px;
}

/* ---------- 菜单 ---------- */
.screen {
  position: fixed; inset: 0; overflow-y: auto; z-index: 20;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 94, 122, .18), transparent 60%),
    radial-gradient(900px 600px at 110% 10%, rgba(255, 201, 60, .14), transparent 60%),
    var(--bg);
}
.menu-inner { max-width: 1040px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
.menu-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: .3px; }
.menu-inner h2 { font-size: 17px; margin: 22px 0 12px; color: var(--muted); font-weight: 600; }

.resume {
  display: flex; align-items: center; gap: 14px; padding: 12px; margin-top: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.resume canvas { width: 96px; height: 72px; border-radius: 10px; flex: none; background: #0003; }
.resume-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.resume-text span { color: var(--muted); font-size: 14px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  position: relative; border: 2px solid transparent; border-radius: 14px; padding: 0; overflow: hidden;
  background: var(--panel); text-align: left; transition: transform .12s, border-color .12s;
}
.tile:hover { transform: translateY(-2px); }
.tile[aria-pressed="true"] { border-color: var(--pop-2); box-shadow: 0 0 0 3px rgba(255, 201, 60, .25); }
.tile .thumb { display: block; width: 100%; aspect-ratio: 4 / 3; background: #0003; object-fit: cover; }
.tile .name { display: block; padding: 7px 10px 9px; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .badge {
  position: absolute; top: 6px; right: 6px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: var(--pop-2);
}
.tile.upload .thumb { display: grid; place-items: center; color: var(--muted); font-size: 40px; border-bottom: 1px dashed var(--line); }
.tile.upload .thumb small { display: block; font-size: 12px; text-align: center; margin-top: -10px; }

.sizes { display: flex; flex-wrap: wrap; gap: 10px; }
.size {
  border: 2px solid var(--line); background: var(--panel); border-radius: 14px; padding: 8px 16px; min-width: 86px; text-align: center;
}
.size b { display: block; font-size: 20px; }
.size span { font-size: 12px; color: var(--muted); }
.size[aria-pressed="true"] { border-color: var(--pop); background: #3a2d3d; }
.modes .size { min-width: 0; flex: 1 1 150px; max-width: 220px; }
.modes .size b { font-size: 16px; padding: 2px 0; }
.start-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 28px; }
.best { color: var(--muted); }

/* ---------- 桌面 ---------- */
#table { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#hud {
  position: fixed; left: 0; right: 0; top: 0; height: calc(var(--hud-h) + env(safe-area-inset-top)); z-index: 10;
  padding: env(safe-area-inset-top) 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: linear-gradient(180deg, rgba(14, 22, 28, .92), rgba(14, 22, 28, .7));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.hud-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hud-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.hud-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-title > span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-tools { display: flex; gap: 2px; flex: none; }
.ico {
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; display: grid; place-items: center; padding: 0;
}
.ico:hover { background: rgba(255, 255, 255, .08); }
.ico[aria-pressed="true"] { background: rgba(255, 201, 60, .2); color: var(--pop-2); }
.ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#sound-btn .off { display: none; }
#sound-btn[data-muted] .on { display: none; }
#sound-btn[data-muted] .off { display: inline; }

#preview {
  position: fixed; right: 10px; top: calc(var(--hud-h) + env(safe-area-inset-top) + 10px); z-index: 9;
  padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45); cursor: pointer;
}
#preview canvas { display: block; width: min(320px, 42vw); height: auto; border-radius: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 30;
  background: rgba(14, 22, 28, .92); border: 1px solid var(--line); padding: 9px 16px; border-radius: 999px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(6, 10, 14, .45); }
.modal .card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 26px 22px 22px;
  text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
.modal h2 { margin: 6px 0 6px; }
.modal p { margin: 4px 0; color: var(--muted); }
.modal .record { color: var(--pop-2); font-weight: 700; }
.modal .row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.done-badge { font-size: 46px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 640px) {
  :root { --hud-h: 52px; }
  .ico { width: 36px; height: 36px; }
  .ico svg { width: 20px; height: 20px; }
  #full-btn { display: none; }
  .hud-title b { font-size: 14px; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .size { min-width: 0; flex: 1 1 28%; padding: 8px 6px; }
}
@media (max-width: 400px) {
  #fit-btn { display: none; }
  .ico { width: 33px; }
}
