@import url("./sky.css");

@font-face {
    font-family:"DM Sans"; src:url("./city/dm-sans.woff2") format("woff2");
    font-weight:100 1000; font-display:swap;
}
:root {
    color-scheme:light; --ink:#284749; --oxide:#a23c2c; --chalk:#f5e8c9; --ochre:#dfa34e;
    --typewriter:"Courier New",Courier,monospace;
    font-family:"DM Sans",system-ui,sans-serif; background:var(--ink); color:var(--ink);
    -webkit-tap-highlight-color:transparent;
}
* { box-sizing:border-box; }
html,body { margin:0; width:100%; height:100%; overflow:hidden; overscroll-behavior:none; }
button { font:inherit; color:inherit; touch-action:manipulation; cursor:pointer; }
button:disabled { cursor:default; }
button:focus-visible { outline:3px solid #ffdc83; outline-offset:3px; }
h1,h2,p,dl,dt,dd { margin:0; }
[hidden],.symbols { display:none!important; }
.sr-only { position:absolute; top:0; left:0; width:1px; height:1px; padding:0; white-space:nowrap; clip-path:inset(50%); overflow:hidden; }
#site {
    position:relative; isolation:isolate; width:100%; height:100%; height:100dvh;
    display:grid; grid-template-rows:auto minmax(0,1fr); overflow:hidden;
    user-select:none; -webkit-user-select:none; touch-action:none;
}
#site > .sky { z-index:-2; }
#site canvas { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; z-index:-1; display:block; }

/* Keep the printed mark clear of the swing and the bolted counter. */
.hud {
    display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:start;
    gap:clamp(9px,1.8vw,24px); padding:max(18px,env(safe-area-inset-top)) max(22px,env(safe-area-inset-right)) 0 max(20px,env(safe-area-inset-left));
    pointer-events:none;
}
.maker { width:max-content; max-width:100%; padding-top:1px; }
.wordmark { display:block; width:clamp(67px,9vmin,87px); max-width:100%; height:auto; }
.district {
    display:flex; align-items:center; gap:7px; margin:4px 0 0 3px;
    color:#213b3b; font:700 clamp(10px,1.25vmin,13px)/1 var(--typewriter);
    letter-spacing:.075em; text-transform:uppercase; text-shadow:0 1px #f4e8c390;
}
.pennant {
    position:relative; display:block; width:21px; height:9px; flex:none;
    background:linear-gradient(37deg,#efdeb3 0 46%,#ad4830 47% 70%,#e2bd7c 71%);
    border-left:2px solid #25413f; clip-path:polygon(0 0,100% 8%,77% 52%,100% 94%,0 100%);
    transform-origin:left center;
}
#site[data-elevation="1"] .pennant { background:linear-gradient(90deg,#efe2c4 0 34%,#af422e 35% 66%,#efe2c4 67%); }
#site[data-elevation="2"] .pennant { background:linear-gradient(135deg,#ecd997 50%,#a74433 50%); }
#site[data-elevation="3"] .pennant { background:repeating-linear-gradient(0deg,#a74433 0 3px,#f0dcab 3px 6px); }
#site:is([data-elevation="4"],[data-elevation="5"]) .pennant { background:conic-gradient(#e6ca83 25%,#9f4b36 0 50%,#e6ca83 0 75%,#9f4b36 0); }
#site:is([data-elevation="4"],[data-elevation="5"],[data-elevation="6"],[data-elevation="7"],[data-elevation="8"]) .district { color:#f7e9c9; text-shadow:0 1px #2e414c; }
.tally {
    position:relative; align-self:start; min-width:77px; padding:6px 10px 5px;
    color:#f6ead1; background:linear-gradient(160deg,#3f5550,#263f40 50%,#294041);
    border:1px solid #304443; border-radius:4px;
    box-shadow:inset 0 1px #74857a,inset 0 0 0 2px #47605a,0 2px 0 #807f68,0 3px 3px #29434130;
    transform:translateZ(0) rotate(.6deg);
}
.tally::before,.tally::after {
    content:""; position:absolute; top:9px; bottom:9px; width:3px;
    background:radial-gradient(circle at center,#d4bd85 1px,transparent 1.5px) center top/3px 3px no-repeat,
        radial-gradient(circle at center,#aa9871 1px,transparent 1.5px) center bottom/3px 3px no-repeat;
}
.tally::before { left:3px; }.tally::after { right:3px; }
/* Keep changes to the accessible count outside the painted dial. */
#floors { position:fixed; clip:rect(0,0,0,0); clip-path:none; }
#drums { display:flex; align-items:stretch; justify-content:center; gap:2px; }
#drums i {
    position:relative; display:block; overflow:hidden; contain:layout paint; height:calc(1.02em + 5px);
    min-width:.68em; padding:1px .05em 2px; color:#faf0d8;
    font:700 clamp(29px,4.3vmin,42px)/1.02 Menlo,Consolas,var(--typewriter); font-variant-numeric:tabular-nums;
    background:linear-gradient(#314345 0,#293c3c 45%,#172c2e 51%,#22373a 88%,#2c4140);
    border:1px solid #1d3030; border-radius:2px;
}
#drums i::after { content:""; position:absolute; top:51%; left:0; right:0; height:1px; background:#192c2e8c; }
#drums b { display:block; position:relative; white-space:pre; text-align:center; font:inherit; }
#drums .leading { color:#95a49a; }
@media (forced-colors:none) {
    /* A preprinted dial avoids first-use glyph rasterization on slower GPUs. */
    .limited-resolution ~ .hud #drums.printed b {
        color:transparent; background:url("./yard-digits.png") left top / 200% 100% no-repeat;
    }
    .limited-resolution ~ .hud #drums.printed .leading b { background-position:right top; }
}
.tally-caption { display:flex; align-items:center; justify-content:space-between; gap:5px; margin-top:5px; }
.tally-caption span { font:700 9px/1 var(--typewriter); letter-spacing:.04em; text-transform:uppercase; }
#chances { display:flex; align-items:center; gap:3px; will-change:transform; }
#chances i {
    position:relative; width:7px; height:7px; border-radius:50%; border:1px solid #757c69;
    background:#374b47; box-shadow:0 0 0 1px #233437,inset 0 1px #293f3d;
}
#chances i::before {
    content:""; position:absolute; inset:-1px; border-radius:inherit; border:1px solid #b68e56; will-change:opacity;
    box-shadow:inset 0 1px #fff1af;
    background:radial-gradient(circle at 35% 33%,#ffeab7 0 19%,#edb764 40%,#b66c39 90%);
}
#chances i.spent::before { opacity:0; }
.pause-key {
    position:relative; display:grid; place-items:center; pointer-events:auto;
    width:46px; height:46px; margin-top:2px; padding:0; border:1px solid #5b5142; border-radius:5px;
    background:linear-gradient(#f2d99d,#dcc18c);
    color:#344746; box-shadow:inset 0 0 0 2px #f4e1b3,inset 0 0 0 3px #bba67e,0 3px 0 #786f59,0 4px 4px #25433c28;
}
.pause-key svg { width:19px; height:19px; }
.pause-key:active { translate:0 2px; box-shadow:inset 0 0 0 2px #f4e1b3,0 1px 0 #766c56; }
.pause-key:disabled { opacity:.56; }
#play-area {
    appearance:none; -webkit-appearance:none; display:block; width:100%; min-height:0;
    margin:0; padding:0; border:0; background:none; border-radius:0; touch-action:none;
}
#play-area:focus-visible { outline:2px solid #f3e3bb; outline-offset:-6px; }

/* The shift record is a dock-office ticket with a print of the actual tower. */
.ticket {
    isolation:isolate; position:relative; color:var(--ink); background-color:#f2e6c9;
    background-image:repeating-linear-gradient(0deg,#71563703 0 1px,transparent 1px 3px),
        linear-gradient(115deg,#f7ebcd,#ecddba);
    border:0; border-top:6px solid var(--oxide); border-bottom:4px solid #a79672;
    padding:17px 20px 13px; width:min(330px,calc(100% - 32px));
    box-shadow:0 2px 0 #29403cbb,0 10px 24px #253b3755;
}
.ticket::after {
    content:""; position:absolute; inset:3px 5px 4px; z-index:-1; pointer-events:none;
    border:1px solid #9d8d6a86;
}
#scene-message {
    position:absolute; z-index:3; top:50%; left:50%; translate:-50% -50%;
    rotate:-.65deg; max-height:calc(100% - 18px); overflow:auto; overscroll-behavior:contain;
}
#site[data-phase=over] #scene-message { top:auto; bottom:max(17px,env(safe-area-inset-bottom)); translate:-50% 0; rotate:.55deg; }
.ticket-head { display:flex; align-items:center; gap:7px; padding-bottom:8px; border-bottom:2px solid #37504a; }
.ticket-head svg { width:49px; height:auto; flex:none; }
.ticket-head span,.ticket-head b,.ticket-stats dt,.ticket-tools button,.secondary-action,#scene-detail {
    font-family:var(--typewriter); font-weight:700; letter-spacing:.035em;
}
.ticket-head span { font-size:12px; letter-spacing:.11em; text-transform:uppercase; }
.ticket-head b { margin-left:auto; font-size:10px; color:var(--oxide); letter-spacing:.075em; text-transform:uppercase; }
.ticket-body { display:grid; grid-template-columns:minmax(0,1fr) 65px; align-items:center; gap:5px; min-height:91px; }
.ticket h2 { color:#293e3b; font-weight:950; font-size:clamp(25px,4.8vmin,34px); line-height:.96; letter-spacing:-.06em; }
#scene-detail { margin-top:6px; color:#5f6858; font-size:11px; line-height:1.3; }
.tower-print { display:block; width:63px; height:73px; color:var(--oxide); transform:rotate(2deg); }
.register { fill:none; stroke:#a89975; stroke-width:.8; }
.tower-shadow { fill:#d8b186; }
.tower-lines { fill:none; stroke:currentColor; stroke-width:1.15; stroke-linejoin:round; }
.ticket-stats { display:flex; border-block:1px solid #a79979; }
.ticket-stats div { flex:1; display:flex; flex-direction:column; gap:2px; padding:7px 0; }
.ticket-stats div+div { border-left:1px solid #ab9d7e; padding-left:12px; }
.ticket-stats dt { font-size:9px; text-transform:uppercase; color:#586354; }
.ticket-stats dd { font:700 20px/1 var(--typewriter); }
.ticket-actions { margin-top:12px; }
.ticket-action {
    display:flex; align-items:center; justify-content:space-between; width:100%; min-height:44px; gap:8px;
    padding:8px 13px; color:#fbefd4; background:#94402f; border:1px solid #703b2e; border-radius:2px;
    box-shadow:inset 0 1px #cb8064,0 2px 0 #674936; font-size:16px; font-weight:800;
}
.ticket-action svg,.ticket-tools svg { width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.ticket-action:active { translate:0 1px; box-shadow:0 1px 0 #674936; }
.ticket button:focus-visible { outline-color:#8c472e; outline-offset:2px; }
.secondary-action,.ticket-tools button { background:none; border:0; padding:5px; }
.secondary-action { display:block; margin:4px auto 0; min-height:33px; font-size:12px; text-decoration:underline; text-underline-offset:3px; }
.ticket-tools { display:flex; justify-content:space-between; margin-top:8px; border-top:1px dashed #aa9a78; }
.ticket-tools button { display:inline-flex; align-items:center; justify-content:center; min-height:44px; gap:5px; font-size:11px; }
.ticket-tools svg { width:16px; height:16px; }

/* The dock-office sign sits clear of the crane on wide screens. Keep the HUD's
   grid row in place so starting a shift doesn't reframe the 3D yard. */
#site[data-phase=home] { touch-action:pan-y; }
#site[data-phase=home] .hud { visibility:hidden; }
.home-ticket {
    position:absolute; z-index:3; left:max(15px,env(safe-area-inset-left)); right:max(15px,env(safe-area-inset-right));
    bottom:max(15px,env(safe-area-inset-bottom)); margin-inline:auto; width:auto; max-width:352px;
    max-height:calc(100% - 30px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
    overflow:auto; overscroll-behavior:contain; touch-action:pan-y;
    padding:clamp(14px,2.6vmin,24px); border-top:3px solid var(--ink);
}
.home-masthead {
    display:grid; place-items:center; padding:9px 12px;
    background:var(--ink); color:#f5e8cc;
}
.home-masthead .wordmark { width:clamp(88px,13vmin,122px); }
.home-modes { border:0; margin:13px 0 0; padding:0; min-width:0; }
.home-modes legend,.home-record dt {
    padding:0; color:#4d5c50; font:700 11px/1.3 var(--typewriter); letter-spacing:.07em; text-transform:uppercase;
}
.mode-options { display:flex; gap:5px; margin-top:5px; }
.mode-options label {
    display:flex; align-items:center; justify-content:center; gap:7px; flex:1; min-height:44px;
    background:#f8edd2; border:1px solid #aa9b79; border-radius:2px; color:var(--ink);
    font-size:15px; font-weight:750; cursor:pointer; touch-action:manipulation;
}
.mode-options label:has(input:checked) { background:var(--ink); border-color:var(--ink); color:#fff2d5; }
.mode-options input { margin:0; width:15px; height:15px; accent-color:var(--ink); cursor:pointer; }
.mode-options label:has(input:focus-visible) { outline:3px solid #8c472e; outline-offset:2px; }
#home-description { margin-top:7px; color:#435448; font-size:14px; line-height:1.35; }
#mode-info { margin-top:4px; font-size:14px; line-height:1.35; }
#mode-info summary { cursor:pointer; width:fit-content; padding:6px 0; font-weight:650; }
#mode-info p { margin:4px 0 8px; }
#home-help { min-height:40px; }
#practice-strip {
    position:absolute; z-index:2; left:50%; bottom:max(14px,env(safe-area-inset-bottom)); translate:-50% 0;
    width:min(475px,calc(100% - 24px)); display:flex; align-items:center; gap:12px;
    background:#f5e8cc; color:#273f3c; border-left:4px solid var(--ink); padding:6px 12px;
    box-shadow:0 2px 6px #263f3a55; pointer-events:none;
}
#practice-hint { font-size:14px; line-height:1.3; }
#exit-practice { margin-left:auto; padding:6px; min-height:44px; flex:none; background:none; border:0; text-decoration:underline; pointer-events:auto; }
#site[data-practice] #chances { visibility:hidden; }
#guide #close-help.secondary-action svg { display:none; }
.home-record { margin:12px 0 10px; padding-top:9px; border-top:1px dashed #ad9f80; }
.home-record div { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.home-record dd { color:#2c463e; font:700 15px/1.3 var(--typewriter); }
#home-start { padding-inline:15px; font-size:17px; }
#home-continue { min-height:44px; margin:3px auto -4px; }
@media (min-width:760px) {
    .home-ticket {
        left:max(clamp(20px,4vw,80px),env(safe-area-inset-left)); right:auto;
        bottom:max(clamp(20px,6vh,64px),env(safe-area-inset-bottom)); width:min(32vw,352px);
    }
}
@media (orientation:landscape) and (max-height:500px) {
    .home-ticket { left:max(12px,env(safe-area-inset-left)); right:auto; bottom:max(8px,env(safe-area-inset-bottom)); width:min(42vw,310px); padding:10px 15px; }
    .home-masthead { padding:5px; }
    .home-masthead .wordmark { width:65px; }
    .home-modes { margin-top:6px; }
    .home-record { margin:7px 0; padding-top:6px; }
}

.handbook { max-width:none; max-height:calc(100dvh - 20px); padding-bottom:20px; overscroll-behavior:contain; }
.handbook h2 { margin-top:18px; }
.handbook p { font-size:15px; line-height:1.44; margin:12px 0; }
.handbook .ticket-action { margin-top:16px; }
.handbook::backdrop { background:#203735b5; }
/* The setting lives on its own dock ticket so neither the release surface nor
   the tower is obscured during a live swing. */
.settings-sheet { position:fixed; inset:0; width:min(330px,calc(100% - 24px)); height:fit-content; margin:auto; overflow:auto; }
.scaling-head,.scaling-ends { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.scaling-head { margin-top:18px; }
.scaling-head label { font-size:16px; font-weight:800; }
.scaling-head output { color:var(--oxide); font:700 17px/1 var(--typewriter); }
#game-scaling { display:block; width:100%; height:32px; margin:0; padding:0; background:transparent; accent-color:var(--oxide); cursor:pointer; }
#game-scaling:focus-visible { outline:2px solid var(--oxide); outline-offset:-2px; border-radius:3px; }
.scaling-ends { color:#5c614e; font:700 10px/1.25 var(--typewriter); }
.settings-sheet #scaling-cadence { margin:14px 0 0; font-size:14px; line-height:1.35; }
.settings-sheet #scaling-scope { margin:7px 0 0; color:#55604f; font-size:12px; line-height:1.35; }
@media (max-width:360px), (max-height:500px) { .ticket-tools svg { display:none; } }
kbd { padding:1px 4px; font:700 .84em var(--typewriter); border:1px solid #9e977d; border-bottom-width:2px; }
@media (min-width:760px) and (min-height:520px) {
    #site[data-phase=over] #scene-message { right:max(24px,env(safe-area-inset-right)); left:auto; translate:0; }
}
@media (max-width:440px) {
    .hud { gap:9px; padding:max(11px,env(safe-area-inset-top)) max(11px,env(safe-area-inset-right)) 0 max(11px,env(safe-area-inset-left)); }
    .tally { min-width:71px; padding:5px 8px; }.pause-key { width:44px; height:44px; }
    .district { font-size:10px; gap:6px; margin-top:3px; }
}
@media (max-height:500px) {
    .hud { gap:10px; padding:max(6px,env(safe-area-inset-top)) max(11px,env(safe-area-inset-right)) 0 max(11px,env(safe-area-inset-left)); }
    .wordmark { width:55px; }.district { margin-top:1px; font-size:9px; }
    .pause-key { width:44px; height:40px; margin:0; }
    .tally { display:flex; align-items:center; gap:7px; padding-block:4px; }#drums i { font-size:25px; }
    .tally-caption { flex-direction:column; align-items:flex-start; gap:6px; margin:0; }
    .ticket { padding:10px 16px 6px; }.ticket-body { min-height:58px; }.tower-print { height:48px; width:45px; justify-self:end; }
    .ticket-stats div { flex-direction:row; align-items:center; justify-content:flex-start; gap:8px; padding-block:4px; }.ticket-stats dd { font-size:15px; }
    .ticket-head { padding-bottom:4px; }.ticket-actions { margin-top:6px; }.ticket-tools { margin-top:4px; }
    #site[data-phase=over] #scene-message { left:auto; right:max(12px,env(safe-area-inset-right)); bottom:9px; translate:0; width:min(248px,48%); }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { transition:none!important; animation:none!important; } }
