:root{color-scheme:dark;--ink:#f0f3e9;--muted:#acc2b6;--panel:#172c2a;--line:#38504b;font-family:SimHei,"Heiti SC","PingFang SC",sans-serif}*{box-sizing:border-box}body{margin:0;height:100vh;height:100dvh;background:var(--panel);color:var(--ink);display:flex;flex-direction:column}header{min-height:82px;display:flex;justify-content:space-between;align-items:center;padding:11px clamp(16px,4vw,58px);border-bottom:1px solid var(--line)}.kicker{font-size:12px;color:#bdcfc1;letter-spacing:.12em}.kicker span{color:#85a895;padding:0 3px}h1{font-size:clamp(20px,2vw,30px);font-weight:600;margin:4px 0 0;letter-spacing:.05em}.studio{width:clamp(105px,12vw,155px);height:auto}main{position:relative;flex:1;min-height:0;isolation:isolate;background:#c9d9d3 url(coast.webp) center center/cover no-repeat;overflow:hidden}canvas{display:block;width:100%;height:100%;outline:0;touch-action:none;cursor:grab}canvas:active{cursor:grabbing}button,select{font:inherit;color:var(--ink);cursor:pointer}button{padding:8px 14px;border:1px solid #7c9185;border-radius:4px;background:#19312eea;font-size:13px;min-height:38px}button[aria-pressed=true]{background:#c3dfc9;color:#1b3931}button:focus-visible,select:focus-visible{outline:3px solid #d1bc70;outline-offset:2px}.nav-tools{position:absolute;right:clamp(12px,3vw,42px);bottom:16px;display:flex;gap:6px}#status{z-index:3;position:absolute;top:12px;left:50%;transform:translateX(-50%);background:#162e2ce8;border-radius:3px;padding:8px 14px;font-size:13px;text-align:center;max-width:95%;width:max-content}#split{position:absolute;inset:0;pointer-events:none;z-index:1}#split:after{content:"";position:absolute;left:50%;top:0;bottom:0;width:2px;background:#f0f4e3b0}#split span{position:absolute;top:12px;left:12px;background:#19312eea;padding:5px 11px;font-size:12px;border-radius:3px}#split span+span{left:calc(50% + 12px)}footer{padding:12px clamp(16px,4vw,58px) max(10px,env(safe-area-inset-bottom));border-top:1px solid var(--line)}.options,.field,.notes{display:flex;align-items:center}.options{gap:20px}.field{gap:10px}.field label{font-size:13px;color:#c0d0c6}.field select{padding:8px 28px 8px 10px;background:#243e37;border:1px solid #59766b;border-radius:4px;min-height:38px;font-size:14px}.gesture,.notes{font-size:12px;color:var(--muted)}.gesture{margin:0 0 0 auto}.notes{border-top:1px solid var(--line);margin-top:10px;padding-top:9px;justify-content:space-between;gap:6px 14px;flex-wrap:wrap}.notes span:first-child{color:#cbd8c9}[hidden]{display:none!important}@media(max-width:650px){header{min-height:64px;padding:8px 14px}.kicker{font-size:10px}.studio{width:94px}.options{display:grid;grid-template-columns:1fr 1.16fr;gap:12px}.field{align-items:flex-start;flex-direction:column;gap:3px}.field label{font-size:11px}.field select{min-height:40px;width:100%;padding-right:10px}.gesture{display:none}.notes{font-size:10px;line-height:1.4;margin-top:9px;padding-top:6px}.nav-tools{right:10px;bottom:13px}.nav-tools button{min-height:42px}footer{padding:9px 12px max(8px,env(safe-area-inset-bottom))}}@media(max-height:480px){header{min-height:42px;padding-top:4px;padding-bottom:4px}.heading{display:flex;align-items:center;gap:12px}.notes,.gesture{display:none}h1{font-size:18px;margin:0}footer{padding-top:5px;padding-bottom:5px}.field{flex-direction:row;align-items:center}}

.layer-tools{position:absolute;z-index:2;left:clamp(12px,3vw,42px);bottom:16px;display:flex;gap:6px;align-items:end}
#legend summary{display:block;cursor:pointer;background:#19312ef5;border:1px solid #7c9185;border-radius:4px;padding:9px 14px;font-size:13px;min-height:38px}
#legend summary::-webkit-details-marker{display:none}
#legend[open] summary{background:#c3dfc9;color:#1b3931}
.layer-sheet{position:absolute;left:0;bottom:calc(100% + 6px);width:min(330px,calc(100vw - 32px));max-height:min(58vh,440px);overflow:auto;overscroll-behavior:contain;padding:12px 14px;background:#172e2bf7;border:1px solid #819b90;border-radius:5px;box-shadow:0 5px 20px #0b211f40;font-size:13px}
.layer-sheet fieldset{border:0;padding:0;margin:0 0 10px}.layer-sheet fieldset:last-child{margin:0}
.layer-sheet legend{font-weight:bold;color:#cbe1d3;margin:0 0 4px;padding:0}
.layer-sheet label{display:inline-flex;gap:5px;align-items:center;min-height:34px;margin-right:8px;cursor:pointer}
.layer-sheet input{accent-color:#a9d6b3;width:16px;height:16px}
.surface-row{display:flex!important;margin:0!important}.surface-row i{width:11px;height:11px;border-radius:2px;border:1px solid #ffffff60}
.surface-actions{display:flex;gap:6px}.surface-actions button{min-height:30px;padding:4px 12px;font-size:12px}
main:not(.rendered) canvas,
main:not(.rendered) .nav-tools,
main:not(.rendered) .layer-tools,
main:not(.rendered) .water-tools {visibility: hidden;}

.water-tools {
    position: absolute;
    right: clamp(12px, 3vw, 42px);
    bottom: 64px;
    z-index: 2;
}
#water-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 7px 9px 7px 12px;
    border: 1px solid #95bca7;
    border-radius: 8px;
    background: #16332e;
    color: #f0f3e9;
    font-weight: 700;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .28);
}
#water-toggle::after {
    content: "关";
    content: "关" / "";
    border-radius: 4px;
    padding: 3px 6px;
    background: #35554a;
    color: #e7f2e8;
    font-size: 11px;
}
#water-toggle[aria-pressed="true"] {
    border-color: #c3dfc9;
    background: #c3dfc9;
    color: #142d26;
}
#water-toggle[aria-pressed="true"]::after {
    content: "开";
    content: "开" / "";
    background: #214d3a;
}
@media (max-width: 650px) {
    .water-tools {right: 10px;}
}
@media(max-width:650px){.layer-tools{left:10px;bottom:13px}.layer-tools>button,#legend summary{min-height:42px}.layer-sheet label{min-height:40px}}
/* === GATE_UI_V1 === */
.hdr-right{display:flex;align-items:center;gap:14px;flex-wrap:wrap;justify-content:flex-end}
#gate-timer{display:inline-flex;align-items:center;gap:8px}
#gate-rem{font-size:13px;font-weight:700;color:#ffd6d6;background:rgba(185,28,28,.28);border:1px solid rgba(252,165,165,.55);padding:5px 12px;border-radius:18px;font-variant-numeric:tabular-nums;white-space:nowrap}
#gate-rem.warn{color:#fde68a;background:rgba(180,83,9,.32);border-color:rgba(252,211,77,.6)}
#gate-lock{min-height:30px;padding:4px 10px;font-size:12px;border-radius:14px;background:rgba(255,255,255,.08);border:1px solid #59766b;color:#d6e5dc}
#gate-lock:hover{background:rgba(195,223,201,.2);color:#fff}
#gate-wrap {
    position: fixed;
    inset: var(--gallery-visible-top, 0px) 0 auto;
    z-index: 50;
    height: var(--gallery-visible-height, 100vh);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
             max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: #0e201e;
    scroll-padding-block: 12px;
}
@supports (height: 100dvh) {
    #gate-wrap {height: var(--gallery-visible-height, 100dvh);}
}
#gate-bg,#gate-scrim {
    position: fixed;
    inset: 0;
    pointer-events: none;
}
#gate-bg {
    background: url(coast.webp) center center/cover no-repeat;
    filter: blur(10px) brightness(.44) saturate(1.1);
    transform: scale(1.06);
}
#gate-scrim {
    background: radial-gradient(circle at 30% 20%, rgba(42,107,96,.32), rgba(12,26,24,.88));
}
#gate-card{position:relative;z-index:2;flex:none;width:720px;max-width:100%;margin:auto;background:rgba(23,44,42,.94);backdrop-filter:blur(14px);border:1px solid rgba(169,214,179,.28);border-radius:16px;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.52);color:#f0f3e9}
.g-top{background:linear-gradient(120deg,#122927,#1f4c46);padding:18px 24px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;border-bottom:1px solid #2e4b45}
.g-top h2{margin:0;font-size:19px;letter-spacing:.04em;color:#f4f7ef}
.g-badge{font-size:11px;background:rgba(195,223,201,.16);border:1px solid rgba(195,223,201,.34);color:#d7efe0;padding:3px 10px;border-radius:16px}
.g-body{display:grid;grid-template-columns:1fr 220px;gap:22px;padding:24px}
.g-lead{font-size:13px;color:#c9dbd0;line-height:1.68;margin:0 0 16px}.g-lead b{color:#e6f7eb}
.g-lbl{font-size:12px;font-weight:700;color:#b8d4c3;letter-spacing:.04em}
.g-digs {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: clamp(5px, 2vw, 10px);
    max-width: 338px;
    margin: 12px 0;
}
.g-dig{width:100%;min-width:0;height:56px;border:1.6px solid #59766b;border-radius:10px;text-align:center;font-size:24px;font-weight:700;color:#f4f9f5;background:#102220;outline:none;transition:border-color .15s,box-shadow .15s;font-variant-numeric:tabular-nums}
.g-dig:focus{border-color:#a9d6b3;box-shadow:0 0 0 3px rgba(169,214,179,.22);background:#142b28}
#gate-err{font-size:12px;color:#fecaca;background:rgba(185,28,28,.24);border:1px solid rgba(252,165,165,.45);border-radius:7px;padding:7px 10px;margin:0 0 12px}
.g-acts{display:flex;gap:10px;margin-top:10px}
.g-acts button{flex:1;padding:10px 14px;border-radius:8px;font-size:14px;font-weight:600;min-height:42px}
#gate-ok{background:#c3dfc9;border-color:#c3dfc9;color:#142d26}#gate-ok:hover{background:#d7eedc}
#gate-quit{background:#1b3532;border-color:#59766b;color:#d2e2d8}#gate-quit:hover{background:#23423e}
.g-wx{border-left:1px solid #2e4b45;padding-left:20px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center}
.g-qr-ph{width:148px;height:148px;border:1.5px dashed #6b8e80;border-radius:12px;background:rgba(16,34,32,.65);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;color:#c3dfc9;font-size:13px;font-weight:600}
.g-qr-ph small{font-size:11px;font-weight:400;color:#93b2a3}
.g-wxid{margin:10px 0 8px;font-size:13px;color:#e6f4ea;font-weight:700}
#gate-copy{min-height:32px;font-size:12px;padding:5px 12px;border-radius:16px;background:rgba(195,223,201,.14);border:1px solid rgba(195,223,201,.4);color:#d7efe0}
#gate-copy:hover{background:rgba(195,223,201,.26)}
.g-wxnote{font-size:11px;color:#98b5a7;margin-top:8px;line-height:1.45}
.g-wx img.g-qr{width:148px;height:148px;border-radius:10px;display:block;border:1px solid #59766b}

@media (max-width: 680px) {
    .g-top {padding: 12px 14px; gap: 8px;}
    .g-top h2 {font-size: 18px;}
    .g-body {grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 14px;}
    .g-lead {margin-bottom: 14px;}
    .g-dig {height: 48px; font-size: 21px;}
    .g-acts button {min-height: 44px;}
    .g-wx {
        display: grid;
        grid-template-columns: minmax(0, 104px) minmax(0, 1fr);
        gap: 6px 12px;
        align-items: center;
        justify-content: stretch;
        border-left: 0;
        border-top: 1px solid #2e4b45;
        padding: 14px 0 0;
        text-align: left;
    }
    .g-wx img.g-qr {grid-row: span 3; width: 100%; height: auto;}
    .g-wxid,.g-wxnote {margin: 0; overflow-wrap: anywhere;}
    #gate-copy {min-height: 38px; justify-self: start;}
    #gate-rem {font-size: 11px; padding: 4px 9px;}
}
.back-home{font-size:12px;color:#d9b46a;text-decoration:none;border:1px solid rgba(217,180,106,.45);border-radius:999px;padding:4px 11px;white-space:nowrap;transition:background .15s}
.back-home:hover{background:rgba(217,180,106,.16)}
@media(max-width:520px){.back-home{padding:3px 8px;font-size:11px}}

/* Preserve the 3D stage when the browser chrome or the session controls take space. */
body { height: var(--gallery-body-height, 100dvh); }
header, footer { flex: none; }
.heading { min-width: 0; }
h1, .field label, #gate-lock, .back-home { white-space: nowrap; }
.water-credit { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.water-credit a { color: inherit; }

@media (max-width: 720px) {
    header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "title home" "timer timer";
        gap: 6px 10px;
        min-height: 0;
        padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    }
    .heading { display: block; grid-area: title; }
    .heading h1 { margin-top: 2px; font-size: clamp(17px, 5vw, 23px); }
    .hdr-right { display: contents; }
    .back-home { grid-area: home; }
    .studio { display: none; }
    #gate-timer { grid-area: timer; justify-content: space-between; min-width: 0; }
    #gate-rem { min-width: 0; padding: 3px 9px; font-size: 12px; white-space: normal; }
    footer .options { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.16fr); gap: 8px; }
    footer .field { align-items: stretch; flex-direction: column; min-width: 0; gap: 3px; }
    footer .field select { max-width: 100%; min-width: 0; }
    footer .gesture { display: none; }
}
@media (max-height: 480px) and (orientation: landscape) {
    header .kicker { display: none; }
    footer .field { align-items: center; flex-direction: row; }
    footer .field select { min-height: 34px; padding-block: 4px; }
    .water-tools { bottom: 57px; }
}

#app:not([hidden]){display:contents}#gate-quit{display:inline-flex;align-items:center;justify-content:center;text-decoration:none}#gate-ok{cursor:pointer}#status-msg{min-height:1.4em;color:#eed7ac}#pick{position:absolute;top:11px;right:12px;background:#122923df;color:#fff;padding:4px 8px;pointer-events:none}#pick:empty{display:none}#close-panel{float:right;margin:0 0 7px 10px}#layers label{display:flex}.layer-sheet fieldset{clear:both}#layers i{width:10px;height:10px;border-radius:50%;display:inline-block}.layer-sheet{touch-action:pan-y}.g-dig{min-width:0}#gate-card{max-height:calc(100dvh - 24px);overflow:auto}#stage canvas{position:absolute;inset:0;z-index:-1;touch-action:none}#split[hidden]{display:none}.water-credit a,.g-lead a,.g-wxnote a{color:inherit}

#stage{container-type:size}.layer-sheet{max-height:min(58vh,440px,calc(100cqh - 100px))}#close-panel{position:sticky;top:0;z-index:1}

.layer-sheet .face-alpha {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4.3em;
    align-items: center;
    gap: .6em;
    padding-left: 23px;
    margin-bottom: 3px;
}
.layer-sheet .face-alpha input[type="range"] {
    width: 100%;
    min-width: 0;
    height: 28px;
    margin: 0;
    cursor: pointer;
    touch-action: pan-y;
}
.layer-sheet .face-alpha output {
    text-align: right;
    color: #dcebdd;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.layer-sheet .group-alpha {
    grid-template-columns: auto minmax(0,1fr) 4.3em;
    padding: 5px 0;
    border-bottom: 1px solid #526961;
}
@media (pointer: coarse) {
    .layer-sheet .face-alpha input[type="range"] {height: 44px}
}
