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

:root { --ink: #e9eefb; --accent: #64d2ff; --accent2: #a78bfa; --gold: #ffd166; --muted: #8494b8; }

html, body {
    height: 100%; overflow: hidden; background: #0e1424; 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);
    background: radial-gradient(900px 500px at 50% -10%, rgba(100,130,255,0.16), transparent 65%), #0e1424;
}

.hud { display: flex; align-items: flex-start; gap: 7px; padding: 8px 10px 4px; 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(100,210,255,0.24); border-radius: 10px;
    background: rgba(0,0,0,0.26); color: var(--ink);
    font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer; flex: 0 0 auto;
}
.icon-btn-text { font-size: 13px; }
.hud-mid { flex: 1; text-align: center; }
.score {
    font-size: 26px; font-weight: 800; color: var(--accent); line-height: 1.05;
    font-variant-numeric: tabular-nums; text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.sub { font-size: 11px; color: var(--muted); }
.sub b { color: var(--ink); }

.strip { display: flex; align-items: center; gap: 10px; padding: 2px 12px 6px; flex: 0 0 auto; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.slot-label { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.slot canvas { display: block; border-radius: 8px; background: rgba(255,255,255,0.04); }
.counters { flex: 1; display: flex; justify-content: center; gap: 18px; }
.counter { text-align: center; font-size: 10px; color: var(--muted); white-space: nowrap; }
.counter b { display: block; font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }

.board-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board { display: block; touch-action: none; border-radius: 10px; }

.banner {
    position: absolute; top: 26%; left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    font-size: 23px; font-weight: 900; color: var(--gold);
    text-shadow: 0 3px 12px rgba(0,0,0,0.8); letter-spacing: 2px;
    opacity: 0; pointer-events: none; white-space: nowrap;
}
.banner.show { animation: pop 0.9s ease forwards; }
@keyframes pop {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(0.6); }
    22% { opacity: 1; transform: translate(-50%,-50%) scale(1.16); }
    70% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%,-85%) scale(1); }
}

.pad { display: flex; align-items: center; gap: 10px; padding: 8px 12px 12px; flex: 0 0 auto; }
.pad-btn {
    min-width: 62px; height: 44px; padding: 0 12px;
    border: 1px solid rgba(167,139,250,0.32); border-radius: 12px;
    background: rgba(167,139,250,0.12); color: var(--ink);
    font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; flex: 0 0 auto;
}
.pad-btn:active { background: rgba(167,139,250,0.3); }
.pad-hint { flex: 1; text-align: center; font-size: 11px; color: var(--muted); line-height: 1.4; }

.overlay {
    position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
    padding: 20px; background: rgba(6,10,20,0.9); z-index: 20;
}
.overlay.is-open { display: flex; }
.overlay-card {
    width: 100%; max-width: 330px; padding: 24px 20px; border-radius: 20px;
    background: linear-gradient(180deg, #1e2a45, #141b2e);
    border: 1px solid rgba(100,210,255,0.22); text-align: center;
}
.title {
    font-size: 27px; letter-spacing: 4px;
    background: linear-gradient(120deg, var(--accent), var(--accent2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { margin: 8px 0 18px; font-size: 13px; color: var(--muted); }
.over-title { font-size: 25px; color: var(--accent); letter-spacing: 3px; }
.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(100,210,255,0.26); 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, #7ee0ff, #7c6bff);
    border-color: #a5ecff; color: #06162a;
}
.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);
}
