* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root { --ink: #e8f1f7; --gold: #ffcf5c; --accent: #5ad6a8; --danger: #ff7a6b; --muted: #86a0b3; }

html, body {
    height: 100%; overflow: hidden; background: #14202a; color: var(--ink);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    user-select: none; -webkit-user-select: none; overscroll-behavior: none;
}
.wrap {
    position: relative; display: flex; flex-direction: column; height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hud { display: flex; align-items: center; gap: 6px; padding: 8px 10px; flex: 0 0 auto; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 34px; padding: 0 8px;
    border: 1px solid rgba(90, 214, 168, 0.26); border-radius: 10px;
    background: rgba(0, 0, 0, 0.28); color: var(--ink);
    font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer; flex: 0 0 auto;
}
.icon-btn-text { font-size: 13px; }
.stat {
    display: inline-flex; align-items: center; gap: 4px;
    height: 34px; padding: 0 10px; border-radius: 10px;
    background: rgba(0, 0, 0, 0.28); font-size: 14px; font-weight: 800;
    font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
.stat .ic { font-size: 13px; }
.stat-life { color: var(--danger); }
.stat-gold { color: var(--gold); }
.stat-wave { color: var(--accent); font-size: 12px; }
.stat-wave b { font-size: 14px; }
.hud .stat:first-of-type { margin-left: 2px; }
.stat-wave { margin-right: auto; }

.board-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
#stage { display: block; touch-action: manipulation; border-radius: 12px; }

.dock { flex: 0 0 auto; padding: 8px 12px 12px; text-align: center; }
.call-btn {
    width: 100%; max-width: 420px; min-height: 46px;
    border: 1px solid rgba(90, 214, 168, 0.35); border-radius: 13px;
    background: rgba(90, 214, 168, 0.14); color: var(--accent);
    font: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
}
.call-btn b { margin-left: 8px; color: var(--gold); font-variant-numeric: tabular-nums; }
.call-btn:disabled { opacity: 0.45; }
.dock-note { margin-top: 5px; font-size: 11px; color: var(--muted); min-height: 15px; }

/* ---------- the build sheet ---------- */
.sheet {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 15;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    background: linear-gradient(180deg, #22313f, #17222c);
    border-top: 1px solid rgba(90, 214, 168, 0.3);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
}
.sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 14px; font-weight: 800; margin-bottom: 10px;
}
.sheet-x {
    width: 30px; height: 30px; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, 0.08); color: var(--ink);
    font-size: 19px; line-height: 1; cursor: pointer;
}
.sheet-body { display: flex; gap: 8px; }
.pick {
    flex: 1 1 0; min-width: 0; padding: 10px 6px;
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 13px;
    background: rgba(0, 0, 0, 0.28); color: var(--ink); font: inherit; cursor: pointer;
    min-height: 78px;
}
.pick:disabled { opacity: 0.4; }
.pick .glyph { display: block; font-size: 19px; }
.pick .nm { display: block; margin-top: 2px; font-size: 13px; font-weight: 800; }
.pick .price { display: block; margin-top: 2px; font-size: 12px; color: var(--gold); font-weight: 700; }
.pick .note { display: block; margin-top: 1px; font-size: 10px; color: var(--muted); }
.pick.sell { border-color: rgba(255, 122, 107, 0.35); }
.pick.sell .price { color: var(--danger); }

/* ---------- overlays ---------- */
.overlay {
    position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
    padding: 20px; background: rgba(8, 14, 19, 0.9); z-index: 30;
}
.overlay.is-open { display: flex; }
.overlay-card {
    width: 100%; max-width: 330px; padding: 24px 20px; border-radius: 20px;
    background: linear-gradient(180deg, #21323f, #16222c);
    border: 1px solid rgba(90, 214, 168, 0.22); text-align: center;
}
.title { font-size: 30px; letter-spacing: 6px; color: var(--accent); }
.subtitle { margin: 8px 0 18px; font-size: 13px; color: var(--muted); }
.over-title { font-size: 25px; color: var(--accent); letter-spacing: 3px; }
.over-title.lose { color: var(--danger); }
.over-sub { margin: 5px 0 12px; font-size: 13px; color: var(--muted); min-height: 18px; }
.btn {
    min-height: 46px; padding: 0 18px;
    border: 1px solid rgba(90, 214, 168, 0.28); border-radius: 13px;
    background: rgba(0, 0, 0, 0.24); color: var(--ink);
    font-size: 16px; font-weight: 700; font-family: inherit; cursor: pointer;
}
.btn-primary {
    background: linear-gradient(140deg, #7ff0c4, #2fae86);
    border-color: #a5f7dc; color: #05231a;
}
.btn-wide { width: 100%; margin-top: 8px; }
.how { margin-top: 18px; text-align: left; }
.how-row {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 5px 0; font-size: 12px; color: var(--muted);
}
.how-key { color: var(--ink); font-weight: 600; flex: 0 0 auto; }
.result-row {
    display: flex; justify-content: space-between;
    padding: 7px 4px; font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
