/* Layout: one full-screen engraved scene drawn by a fragment shader; HTML cartouches float over it. Single deliberate look: paper and ink, colors driven per mode from JS. */
:root {
  --paper: #EFE8DA;
  --ink: #15110E;
  --spot: #5C6270;
  --f-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --f-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
html, body { height: 100%; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--f-body);
  overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none; cursor: none;
}
#stage { position: fixed; inset: 0; }
#gl { width: 100%; height: 100%; display: block; }
.crack { position: fixed; inset: 0; pointer-events: none; }
.crack path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linejoin: bevel; }
.crack path.hl { stroke: var(--paper); stroke-width: 1.5; transform: translate(2px, 2px); }

.hud {
  position: fixed; inset: 0; pointer-events: none;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; grid-template-rows: auto 1fr auto; gap: 12px;
}
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.plate {
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink); padding: 8px 14px 10px;
}
.daycard { display: flex; flex-direction: column; min-width: 0; }
.daycard small { font-family: var(--f-display); font-weight: 800; font-size: 14px; letter-spacing: .14em; }
.daycard b { font-family: var(--f-display); font-weight: 900; font-size: clamp(64px, 12vw, 128px); line-height: .82; font-variant-numeric: tabular-nums; }
.daycard span { font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; margin-top: 4px; }
.right { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.squares { display: grid; grid-template-columns: repeat(7, 12px); gap: 4px; padding: 10px; }
.sq { width: 12px; height: 12px; border: 1.5px solid var(--ink); background: transparent; }
.sq.done { background: var(--ink); }
.sq.late { background: repeating-linear-gradient(135deg, var(--ink) 0 2px, transparent 2px 4.5px); }
.sq.pending { background: #F2A93B; }
.sq.missed { background: #D12C3A; }
.sq.today { border-color: var(--spot); border-width: 2.5px; }
.sq.future { border-style: dashed; opacity: .55; }
.mute {
  pointer-events: auto; cursor: pointer; font-family: var(--f-display); font-weight: 800; font-size: 13px;
  letter-spacing: .12em; padding: 6px 10px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
}
.mute:focus-visible { outline: 3px solid var(--spot); outline-offset: 2px; }
.center {
  position: fixed; inset: 0; display: grid; place-items: start center; padding-top: max(16px, env(safe-area-inset-top)); pointer-events: none; text-align: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.card { max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 24px 24px; }
.card h2 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; margin: 0; line-height: .86; }
.card h2 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; margin: 0; line-height: .86; }
.card h1 { font-size: clamp(64px, 14vw, 150px); letter-spacing: -.01em; }
.card h2 { font-size: clamp(40px, 8vw, 84px); }
.card p { margin: 0; font-size: 16px; line-height: 1.45; max-width: 40ch; }
.card .kicker { font-family: var(--f-display); font-weight: 800; font-size: 15px; letter-spacing: .16em; text-transform: uppercase; }
.card .hint { font-size: 13px; opacity: .75; }
.card button {
  pointer-events: auto; cursor: pointer; margin-top: 8px; font-family: var(--f-display); font-weight: 800; font-size: 20px;
  letter-spacing: .08em; text-transform: uppercase; padding: 10px 22px; background: var(--ink); color: var(--paper); border: 0;
}
.card button:focus-visible { outline: 3px solid var(--spot); outline-offset: 3px; }
.ring { position: fixed; left: 0; top: 0; width: 92px; height: 92px; margin: -46px 0 0 -46px; pointer-events: none; will-change: transform; }
.ring svg { width: 100%; height: 100%; overflow: visible; }
.ring .track { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.ring .prog { fill: none; stroke: var(--spot); stroke-width: 6; stroke-linecap: butt; transform: rotate(-90deg); transform-origin: 46px 46px; }
.ring text { font-family: var(--f-display); font-weight: 900; font-size: 19px; letter-spacing: .08em; fill: var(--ink); }
.ring.idle { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: var(--pos) scale(1.08); } }
@media (max-width: 560px) {
  .squares { grid-template-columns: repeat(7, 10px); gap: 3px; padding: 8px; }
  .sq { width: 10px; height: 10px; }
  #progress { padding: 6px 8px 8px; }
}

* { box-sizing: border-box; }
#holdfast { font: 900 24px var(--f-display); letter-spacing: .10em; }
#dayNum { font-size: clamp(45px, 8vw, 92px); white-space: nowrap; }
.right { display: grid; justify-items: end; gap: 8px; }
.pips { display: flex; gap: 6px; padding-top: 6px; justify-content: center; }
.pip { width: 13px; height: 5px; border: 1px solid var(--ink); }
.pip.full { background: var(--spot); }
#tap { font: 600 16px var(--f-display); text-decoration: underline; letter-spacing: .025em; }
#holdDetails {
  position: fixed; left: 50%; bottom: calc(14.5% + 46px); transform: translateX(-50%);
  width: min(calc(100% - 32px), 480px); display: grid; justify-items: center; gap: 6px;
  pointer-events: none; text-align: center; color: #15110e;
  text-shadow: 0 0 5px #efe8da, 0 0 5px #efe8da, 0 0 8px #efe8da;
}
#holdActions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; }
#ringTag { font: 900 18px/1 var(--f-display); white-space: nowrap; }
#ringTag:empty { display: none; }
#soundHint { display: flex; align-items: center; gap: 5px; font: 900 16px/1 var(--f-display); white-space: nowrap; }
#soundHint svg { width: 16px; height: 16px; filter: drop-shadow(0 0 2px #efe8da); }
#footnote span { display: block; }
#footnote span:empty { display: none; }
#about {
  pointer-events: auto; cursor: pointer; padding: 3px 6px; border: 1px solid #15110e;
  background: #efe8da; color: #15110e; font: 600 14px/1.2 var(--f-body); text-decoration: underline;
}
#about:focus-visible, #finish a:focus-visible { outline: 3px solid var(--spot); outline-offset: 3px; }
/* Paper plates keep small text readable over the engraving. */
#footnote, #appNote, #introCopy, #tasks {
  margin: 0; max-width: 100%; padding: 7px 11px 8px;
  font: 600 14px/1.25 var(--f-body); background: #efe8da; color: #15110e;
  border: 2px solid #15110e; box-shadow: 3px 3px 0 #15110e; text-shadow: none;
}
#appNote { max-width: min(100%, 390px); font-size: 13px; }
#introCopy { font-size: 16px; text-wrap: pretty; }
#introCopy p { margin: 0; }
#introCopy p + p { margin-top: 4px; }
#tasks {
  position: absolute; top: 60%; left: max(16px, env(safe-area-inset-left)); display: grid; gap: 3px;
  list-style: none; font: 800 16px/1.1 var(--f-display);
}
#tasks li { display: flex; align-items: center; gap: 6px; }
#tasks li::before { content: ""; width: 9px; height: 9px; border: 1px solid; }
body[data-mode="restart"] #footnote, body[data-mode="restart"] #ringTag { color: #efe8da; text-shadow: 0 0 5px #15110e, 0 0 5px #15110e, 0 0 8px #15110e; }
body[data-mode="restart"] #footnote { background: #15110e; border-color: #efe8da; box-shadow: 3px 3px 0 #efe8da; text-shadow: none; }
.hud { display: block; }
.hud.out { opacity: 0; transition: opacity .3s; }
.sq.flash { animation: flash .45s ease-out; }
@keyframes flash { 30% { background: var(--spot); box-shadow: 0 0 0 2px var(--spot); } }
#ring.remind .track { animation: remind .32s ease-out; }
@keyframes remind { 30% { stroke: #efe8da; stroke-width: 8; } }
#props, #fallbackSky { position: absolute; inset: 0; pointer-events: none; }
#fallbackSky { overflow: hidden; }
.fallbackPhrase, .fallbackClearing, .fallbackLine { position: absolute; }
.fallbackLine { white-space: nowrap; color: var(--sky-type); }
.fallbackLine .impression {
  letter-spacing: 5px; -webkit-text-stroke: 2px var(--sky-type); paint-order: stroke fill;
  filter: drop-shadow(3px 3px 0 var(--sky-type));
}
.fallbackLine .ember { color: var(--sky-ember); }
.crew { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 4px; white-space: nowrap; color: #15110e; }
.avatar { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 1.5px solid #15110e; border-radius: 50%; background: conic-gradient(var(--crew-color, #5c6270) var(--progress, 0deg), #15110e 0); box-shadow: 1px 2px #15110e; }
.avatar b { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #efe8da; font: 900 17px var(--f-display); }
.crewDay { font: 900 13px var(--f-display); letter-spacing: .04em; color: #15110e; text-shadow: 0 0 4px #efe8da, 0 0 4px #efe8da, 0 0 6px #efe8da; }
#clockLabel, #ticket { position: absolute; left: 0; top: 0; }
#clockLabel { color: #15110e; text-shadow: 0 0 5px #efe8da, 0 0 5px #efe8da; font: 900 clamp(24px, 5vh, 46px)/1 var(--f-display); }
#ticket { color: #15110e; background: #c9ccd2; border: 1.5px solid #15110e; box-shadow: 2px 2px #15110e; padding: 3px 8px 3px 4px; font: bold 10px/1.2 ui-monospace, monospace; }
#ticket::after { content: ""; position: absolute; right: 4px; top: 0; bottom: 0; border-right: 1px dotted #15110e; }
#finish { z-index: 1; overflow-y: auto; padding-bottom: 10px; touch-action: pan-y; pointer-events: auto; inset: 0 0 auto; max-height: 100%; animation: rise .36s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
#finish .card { width: min(100%, 540px); gap: 8px; padding: 12px 18px 14px; }
#finish h2 { font-size: clamp(33px, 6.6vw, 63px); }
#finish p { font-size: 14px; line-height: 1.3; }
#finish .hint { font-size: 13px; }
#finish button { margin: 2px 0; padding: 8px 12px; font-size: 17px; letter-spacing: .035em; }
#finish #again { background: transparent; color: var(--ink); border: 1px solid; }
#finish footer { font-size: 12px; }
#finish a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
body:is([data-mode="pitch"], [data-mode="skipped"]) { touch-action: auto; cursor: auto; }
body[data-mode="skipped"] #fallbackSky { visibility: hidden; }
@media (max-width: 560px) {
  .top { gap: 4px; }
  .daycard { padding: 7px 9px; }
  .daycard span { font-size: 13px; }
  .hud { padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); }
  .crewDay { font-size: 12px; }
  #tasks { left: auto; right: max(12px, env(safe-area-inset-right)); }
  #finish .card { padding: 10px 12px; gap: 6px; }
}
@media (max-width: 560px) and (min-height: 740px) {
  #introCopy { position: absolute; bottom: calc(100% + 19.5vh); }
  #holdDetails:has(#footnote:not([hidden])) #introCopy { bottom: calc(100% + 15vh); }
}
@media (prefers-reduced-motion: reduce) { #finish, .sq.flash, #ring.remind .track { animation: none; } }
@media (prefers-reduced-motion: reduce) { .ring.idle { animation: none; } }
[hidden] { display: none !important; }
