/* ============================================================
   BIRDSWEEPER — field console
   ============================================================ */

:root{
  /* palette */
  --void:      #0A0E12;
  --void-2:    #0E141B;
  --steel:     #18202A;
  --steel-hi:  #222C38;
  --cap:       #33404F;
  --cap-hi:    #435364;
  --cap-lo:    #232E3A;
  --stem:      #10161D;
  --hazard:    #FFB020;
  --hazard-dim:#8A5F14;
  --live:      #E23A3A;
  --live-deep: #6E1414;
  --readout:   #5FD3C8;
  --ink:       #DCE6F0;
  --ink-dim:   #7C8B9C;
  --ink-faint: #4A5765;

  /* counts 1..6 — a key can never touch more than six neighbours */
  --n1: #58C7F3;
  --n2: #63D471;
  --n3: #FFB020;
  --n4: #FF7A45;
  --n5: #FF5252;
  --n6: #5FD3C8;

  /* keyboard lattice: --u is one column pitch (key + gap) */
  --u:   clamp(31px, 8.7vw, 66px);
  --gap: clamp(4px, 0.85vw, 8px);
  --kw:  calc(var(--u) - var(--gap));
  --kh:  calc(var(--u) * 1.1 - var(--gap));
  --row: calc(var(--u) * 10 - var(--gap));

  --r-cap: 9px;

  --display: 'Oxanium', 'Eurostile', 'Bahnschrift', 'Arial Narrow', sans-serif;
  --mono: 'Chivo Mono', ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

*, *::before, *::after{ box-sizing: border-box; }

html, body{ height: 100%; }

body{
  margin: 0;
  font-family: var(--mono);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #16202B 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 110%, #131C25 0%, transparent 55%),
    var(--void);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* A drag down from a key sits at the top of the page, which is exactly where
     pull-to-refresh lives. A refresh would throw away the run. */
  overscroll-behavior-y: contain;
}

/* faint machine-shop texture over everything */
.scanlines{
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.018) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
}

/* full-bleed wash when a bird breaks cover */
.startle{
  position: fixed; inset: 0; z-index: 55; pointer-events: none; opacity: 0;
  background: radial-gradient(60% 45% at 50% 55%, rgba(226,58,58,.34), rgba(226,58,58,0) 70%);
}
.startle.go{ animation: startleFlash .5s ease-out; }
@keyframes startleFlash{ 0%{opacity:0} 12%{opacity:1} 100%{opacity:0} }

.shell{
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(10px, 2.4vw, 22px) clamp(10px, 3vw, 20px) 30px;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vw, 18px);

  /* Holding a key means "call it", so the OS must not read that hold as a
     text gesture. iOS needs the -webkit- forms: unprefixed user-select only
     landed in Safari 17, and the Copy / Look Up callout ignores it entirely.
     `manipulation` drops the double-tap-zoom delay without losing pinch. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
/* display:flex would otherwise win over the hidden attribute */
.shell[hidden]{ display: none; }
.shell.shake{ animation: shake .42s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake{
  10%,90%{ transform: translate3d(-2px,0,0) }
  20%,80%{ transform: translate3d(4px,1px,0) }
  30%,50%,70%{ transform: translate3d(-7px,-1px,0) }
  40%,60%{ transform: translate3d(7px,1px,0) }
}

/* ============================================================
   Main menu — the title screen. Mode buttons are dressed as
   oversized keycaps so the menu reads as part of the same machine.
   ============================================================ */

.menu{
  min-height: 100%;
  display: grid; place-items: center;
  padding: clamp(14px, 4vw, 32px);
}
.menu[hidden]{ display: none; }

.menu__card{
  width: min(100%, 460px);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--steel-hi), #141C25);
  border: 1px solid #35434F;
  box-shadow: 0 28px 64px rgba(0,0,0,.7);
  animation: sheetIn .4s cubic-bezier(.2,.9,.3,1.15);
}
.menu__stripe{
  height: 5px;
  background: repeating-linear-gradient(115deg, var(--hazard) 0 12px, #0F1319 12px 24px);
}
.menu__body{ padding: clamp(24px, 5vw, 34px) clamp(20px, 4vw, 30px) clamp(20px, 4vw, 26px); text-align: center; }

.menu__mark{ width: 54px; height: 54px; filter: drop-shadow(0 3px 8px rgba(0,0,0,.6)); }
.menu__title{
  margin: 8px 0 0;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(34px, 9vw, 50px);
  letter-spacing: .1em; text-transform: uppercase; line-height: 1;
  color: #F2F6FA;
  text-shadow: 0 0 30px rgba(255,176,32,.2);
}
.menu__tag{
  margin: 9px 0 clamp(22px, 4vw, 30px);
  font-size: 9.5px; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-faint);
}

.modes{ display: flex; flex-direction: column; gap: 11px; }

.mode-card{
  display: block; width: 100%; text-align: left;
  padding: 15px 18px;
  border: none; border-radius: 11px; cursor: pointer;
  background: linear-gradient(180deg, var(--cap-hi) 0%, var(--cap) 52%, var(--cap-lo) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.20),
    inset 0 -3px 0 rgba(0,0,0,.38),
    0 4px 0 var(--stem),
    0 6px 12px rgba(0,0,0,.5);
  transition: transform .08s ease, box-shadow .08s ease, background .18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mode-card:hover{ background: linear-gradient(180deg, #4C5D70 0%, #3A4757 52%, var(--cap-lo) 100%); }
.mode-card:active{
  transform: translateY(4px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 0 0 var(--stem), 0 2px 4px rgba(0,0,0,.5);
}
.mode-card:focus-visible{ outline: 2px solid var(--hazard); outline-offset: 3px; }

.mode-card__name{
  display: block;
  font-family: var(--display); font-weight: 800; font-size: 19px;
  letter-spacing: .1em; text-transform: uppercase; color: #EEF4FA;
}
.mode-card__meta{
  display: block; margin-top: 3px;
  font-size: 11px; letter-spacing: .04em; color: var(--ink-dim);
}
.mode-card__note{
  display: block; margin-top: 6px;
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--hazard);
}
.mode-card__note:empty{ display: none; }
/* today's puzzle already played out */
.mode-card.is-done .mode-card__note{ color: var(--readout); }

.menu__links{ display: flex; justify-content: center; gap: 22px; }
.menu__link{
  margin-top: 20px; padding: 6px 4px;
  background: none; border: none; cursor: pointer;
  border-bottom: 1px dashed #2E3A48;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
  -webkit-tap-highlight-color: transparent;
}
.menu__link:hover{ color: var(--hazard); border-color: var(--hazard-dim); }

/* ============================================================
   Topbar
   ============================================================ */

.topbar{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(10px, 2vw, 20px);
  padding: 12px clamp(12px, 2vw, 18px);
  background: linear-gradient(180deg, var(--steel-hi), var(--steel));
  border: 1px solid #2A3644;
  border-top: none;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 10px 26px rgba(0,0,0,.5), inset 0 -1px 0 rgba(0,0,0,.5);
  position: relative;
}
/* hazard tape pinned to the top edge of the console */
.topbar::before{
  content:''; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  border-radius: 0 0 2px 2px;
  background: repeating-linear-gradient(115deg, var(--hazard) 0 12px, #0F1319 12px 24px);
  opacity: .9;
}

.brand{ display: flex; align-items: center; gap: 11px; }
.brand__mark{ width: 40px; height: 40px; flex: none; filter: drop-shadow(0 2px 5px rgba(0,0,0,.6)); }
.bird-body{ fill: #7A8DA0; }
.bird-tail{ fill: #5D6E80; }
.bird-bill{ fill: #93A6B8; }
.bird-pupil{ fill: #0A0E12; }
.bird-eye{ fill: var(--hazard); animation: spark 2.6s ease-in-out infinite; transform-origin: 29.3px 10.3px; }
@keyframes spark{ 0%,100%{ transform: scale(.75); opacity: .75 } 50%{ transform: scale(1.15); opacity: 1 } }

.brand__text h1{
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(20px, 4.4vw, 29px);
  letter-spacing: .10em;
  text-transform: uppercase;
  line-height: 1;
  color: #F2F6FA;
  text-shadow: 0 0 22px rgba(255,176,32,.16);
}
.brand__text p{
  margin: 4px 0 0;
  font-size: 9.5px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.hud{ display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.chip{
  min-width: 62px;
  padding: 5px 10px 6px;
  border-radius: 7px;
  background: #0D131A;
  border: 1px solid #263140;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.7);
  text-align: center;
}
.chip__label{
  display: block; font-size: 8px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 2px;
}
.chip__value{
  display: block; font-family: var(--display); font-weight: 700; font-size: 17px;
  color: var(--readout); line-height: 1.05; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(95,211,200,.35);
}
.chip__value.bump{ animation: bump .34s ease-out; }
@keyframes bump{ 0%{ transform: scale(1) } 35%{ transform: scale(1.28); color: var(--hazard) } 100%{ transform: scale(1) } }

.lives{ letter-spacing: 1px; color: var(--live); text-shadow: 0 0 12px rgba(226,58,58,.45); }
.lives .spent{ color: #2B3541; text-shadow: none; }

.tools{ display: flex; gap: 6px; }
.tool{
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px;
  font-family: var(--display); font-weight: 700; font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-dim);
  background: linear-gradient(180deg, #2B3744, #1C242E);
  border: 1px solid #33414F;
  border-radius: 8px;
  box-shadow: 0 2px 0 #10161D;
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .08s, box-shadow .08s;
}
.tool:hover{ color: var(--hazard); border-color: var(--hazard-dim); }
.tool:active{ transform: translateY(2px); box-shadow: 0 0 0 #10161D; }
.tool__glyph{ font-size: 13px; line-height: 1; }
.tool[aria-pressed="false"] .tool__glyph{ color: var(--ink-faint); }
.tool[aria-pressed="true"] .tool__glyph{ color: var(--readout); }

/* ============================================================
   Brief — theme + phrase
   ============================================================ */

.board{ display: flex; flex-direction: column; gap: clamp(12px, 2.2vw, 20px); }

.brief{ text-align: center; padding: 4px 0 0; }
.brief__eyebrow{
  margin: 0; display: inline-flex; align-items: center; gap: 7px;
  font-size: 9px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-faint);
}
.brief__dot{
  width: 6px; height: 6px; border-radius: 50%; background: var(--readout);
  box-shadow: 0 0 9px var(--readout); animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink{ 0%,100%{ opacity: 1 } 50%{ opacity: .28 } }

.brief__theme{
  margin: 5px 0 clamp(12px, 2vw, 18px);
  font-family: var(--display); font-weight: 800;
  font-size: clamp(23px, 5.6vw, 38px);
  letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  color: var(--hazard);
  text-shadow: 0 0 26px rgba(255,176,32,.3);
}

.phrase{
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 5px clamp(11px, 2.4vw, 20px);
  min-height: 44px;
}
.word{ display: flex; gap: 4px; }
.slot{
  --sw: clamp(21px, 5.2vw, 34px);
  width: var(--sw); height: calc(var(--sw) * 1.28);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800;
  font-size: calc(var(--sw) * .68);
  border-radius: 5px;
  background: #0C1218;
  border: 1px solid #222C38;
  border-bottom: 2px solid #2E3A48;
  box-shadow: inset 0 2px 7px rgba(0,0,0,.75);
  color: transparent;
  transition: color .2s;
}
.slot.punct{
  background: none; border: none; box-shadow: none;
  color: var(--ink-faint); width: auto; min-width: 10px;
}
.slot.filled{
  color: var(--hazard);
  background: linear-gradient(180deg, #212C38, #161E27);
  border-color: #3B4A5A;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 0 18px rgba(255,176,32,.14);
  text-shadow: 0 0 14px rgba(255,176,32,.5);
}
.slot.reveal{ animation: flipIn .45s cubic-bezier(.2,.9,.3,1.2) backwards; animation-delay: var(--d, 0ms); }
/* filled, but the bird carrying it has not landed yet */
.slot.awaiting{ color: transparent; }

/* the bird in transit between a key and the slots its letter fills */
.flyer{
  position: fixed; left: 0; top: 0; z-index: 58;
  width: 34px; height: 34px;
  pointer-events: none;
  color: var(--hazard);
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.65));
}
.flyer svg{ width: 100%; height: 100%; fill: currentColor; }
.flyer--gone{ color: var(--live); }
@keyframes flipIn{
  0%{ transform: rotateX(-92deg) translateY(-4px); opacity: 0 }
  60%{ transform: rotateX(12deg); opacity: 1 }
  100%{ transform: rotateX(0); opacity: 1 }
}

/* ============================================================
   Readout strip
   ============================================================ */

.deck-wrap{ display: flex; flex-direction: column; align-items: center; gap: 10px; }

.readouts{
  display: flex; gap: 7px; flex-wrap: wrap; justify-content: center;
  width: min(100%, var(--row));
}
.readout{
  flex: 1 1 0; min-width: 96px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 9px;
  padding: 6px 11px;
  border-radius: 7px;
  background: #0C1219;
  border: 1px solid #202A36;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
}
.readout__label{
  font-size: 8.5px; letter-spacing: .17em; text-transform: uppercase;
  color: var(--ink-faint); white-space: nowrap;
}
.readout__value{
  font-family: var(--display); font-weight: 700; font-size: 16px;
  color: var(--readout); font-variant-numeric: tabular-nums;
}
.readout--live .readout__value{ color: var(--live); text-shadow: 0 0 12px rgba(226,58,58,.4); }
.readout--live{ border-color: #3A2027; }

/* ============================================================
   The deck — machined chassis holding the keycaps
   ============================================================ */

.deck{
  position: relative;
  width: min(100%, calc(var(--row) + 2 * clamp(9px, 1.6vw, 16px)));
  padding: clamp(13px, 2vw, 18px) clamp(9px, 1.6vw, 16px) clamp(11px, 1.6vw, 15px);
  border-radius: 16px;
  background:
    linear-gradient(180deg, #212B36 0%, #19222C 42%, #131B23 100%);
  border: 1px solid #35434F;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -2px 0 rgba(0,0,0,.6),
    0 22px 44px rgba(0,0,0,.62),
    0 2px 0 #0B1015;
}
/* thin amber service rail across the top of the chassis */
.deck__rail{
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 62px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--hazard-dim), transparent);
}

.keyboard{ display: flex; flex-direction: column; gap: var(--gap); }
.krow{ display: flex; gap: var(--gap); justify-content: center; }
.krow--r3{ justify-content: flex-start; }
.krow--mods{ margin-top: var(--gap); justify-content: center; }

/* ---- keycap ---- */
.key{
  position: relative;
  width: var(--kw); height: var(--kh);
  flex: none;
  padding: 0; margin: 0;
  border: none;
  border-radius: var(--r-cap);
  cursor: pointer;
  font-family: var(--mono);
  background: linear-gradient(180deg, var(--cap-hi) 0%, var(--cap) 52%, var(--cap-lo) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.20),
    inset 0 -3px 0 rgba(0,0,0,.38),
    0 3px 0 var(--stem),
    0 5px 9px rgba(0,0,0,.5);
  transition: transform .07s ease, box-shadow .07s ease, background .18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.key__glyph{
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800;
  font-size: calc(var(--u) * .40);
  color: #E7EEF6;
  letter-spacing: .02em;
  text-shadow: 0 1px 0 rgba(0,0,0,.45);
}
.key__glyph svg{ width: calc(var(--u) * .46); height: calc(var(--u) * .46); }
/* tiny letter stencilled in the corner once the cap is resolved */
.key__tag{
  position: absolute; top: 3px; left: 5px;
  font-size: calc(var(--u) * .21);
  font-weight: 700;
  color: rgba(220,230,240,.34);
  letter-spacing: .04em;
  pointer-events: none;
}
/* neighbour trace ring */
.key::after{
  content: ''; position: absolute; inset: -2px;
  border-radius: calc(var(--r-cap) + 2px);
  border: 1.5px solid transparent;
  pointer-events: none;
  transition: border-color .13s ease, box-shadow .13s ease;
}
.key.nbr::after{ border-color: rgba(255,176,32,.62); box-shadow: 0 0 11px rgba(255,176,32,.2); }
.key.hot::after{ border-color: var(--readout); box-shadow: 0 0 13px rgba(95,211,200,.35); }

.key:focus-visible{ outline: none; }
.key:focus-visible::after{ border-color: #FFF; box-shadow: 0 0 0 2px rgba(0,0,0,.7); }

.key.s-hidden:hover{ background: linear-gradient(180deg, #4C5D70 0%, #3A4757 52%, var(--cap-lo) 100%); }
.key.s-hidden:active,
.key.press{
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.14),
    inset 0 -1px 0 rgba(0,0,0,.3),
    0 0 0 var(--stem),
    0 1px 3px rgba(0,0,0,.5);
}

/* ---- swept: a hole punched clean through the deck ---- */
.key.s-safe{
  cursor: default;
  transform: translateY(3px);
  background: radial-gradient(120% 130% at 50% 0%, #0B1117 0%, #05080B 100%);
  box-shadow:
    inset 0 4px 10px rgba(0,0,0,.95),
    inset 0 -1px 0 rgba(255,255,255,.05),
    0 0 0 1px rgba(255,255,255,.04);
}
.key.s-safe .key__glyph{
  font-size: calc(var(--u) * .46);
  text-shadow: 0 0 13px currentColor;
}
.key.s-safe .key__tag{ color: rgba(140,158,178,.58); }
.key.n1 .key__glyph{ color: var(--n1); }
.key.n2 .key__glyph{ color: var(--n2); }
.key.n3 .key__glyph{ color: var(--n3); }
.key.n4 .key__glyph{ color: var(--n4); }
.key.n5 .key__glyph{ color: var(--n5); }
.key.n6 .key__glyph{ color: var(--n6); }

/* ---- logged: called right, bird recorded ---- */
.key.s-locked{
  background: linear-gradient(180deg, #7A1D1D 0%, #571414 55%, #3C0D0D 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,160,160,.22),
    inset 0 -3px 0 rgba(0,0,0,.45),
    0 0 0 2px var(--readout),
    0 3px 0 #180708,
    0 0 22px rgba(95,211,200,.28);
  cursor: default;
}
.key.s-locked .key__glyph{ color: #FFF1EC; }
.key.s-locked .key__tag{ color: rgba(255,220,220,.55); }
/* small confirmation tick */
.key.s-locked::before{
  content: '✓'; position: absolute; top: 2px; right: 5px;
  font-size: calc(var(--u) * .22); font-weight: 700; color: var(--readout);
  text-shadow: 0 0 8px rgba(95,211,200,.7);
}

/* ---- flushed: broke cover and gone ---- */
.key.s-flush{
  /* it was here and it is gone: a spent cap, clearly marked as a loss */
  background: linear-gradient(180deg, #4A2226 0%, #331519 55%, #230E11 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,160,160,.14),
    inset 0 -3px 0 rgba(0,0,0,.45),
    0 0 0 1px rgba(226,58,58,.55),
    0 3px 0 #170809;
  cursor: default;
}
.key.s-flush .key__glyph{ color: rgba(255,150,150,.42); }
.key.s-flush .key__tag{ color: rgba(255,150,150,.5); }

/* ---- a flag that turned out to be nothing ---- */
.key.misflag{
  background: radial-gradient(120% 130% at 50% 0%, #12100C 0%, #080705 100%);
  box-shadow: inset 0 4px 10px rgba(0,0,0,.95), 0 0 0 1px rgba(255,176,32,.18);
}
.key.misflag::before{
  content: '✕'; position: absolute; top: 2px; right: 5px;
  font-size: calc(var(--u) * .22); font-weight: 700; color: rgba(226,58,58,.85);
}

/* ---- animations on state change ---- */
.key.anim-pop{ animation: popIn .3s cubic-bezier(.2,.9,.3,1.3) backwards; animation-delay: var(--d, 0ms); }
@keyframes popIn{ 0%{ transform: translateY(0) scale(1) } 45%{ transform: translateY(3px) scale(.9) } 100%{ transform: translateY(3px) scale(1) } }

.key.anim-lock{ animation: lockIn .55s ease-out; }
@keyframes lockIn{
  0%{ transform: scale(1) }
  30%{ transform: scale(1.16); filter: brightness(1.7) }
  100%{ transform: scale(1); filter: brightness(1) }
}

.key.anim-flush{ animation: flushout .5s ease-out; z-index: 3; }
/* up and away rather than outward — a bird leaving, not an explosion */
@keyframes flushout{
  0%{ transform: translateY(0) scale(1); filter: brightness(1) }
  22%{ transform: translateY(-9px) scale(1.1); filter: brightness(1.7) }
  55%{ transform: translateY(-3px) scale(1.02) }
  100%{ transform: translateY(3px) scale(1); filter: brightness(1) }
}

.key.anim-deny{ animation: deny .3s ease-in-out; }
@keyframes deny{ 0%,100%{ transform: translateX(0) } 25%{ transform: translateX(-4px) } 75%{ transform: translateX(4px) } }

/* ---- decorative caps: shift / backspace ---- */
.cap-blank{
  flex: none; height: var(--kh);
  border-radius: var(--r-cap);
  background: linear-gradient(180deg, #2C3644 0%, #212A35 55%, #1A222B 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -3px 0 rgba(0,0,0,.35),
    0 3px 0 #0E1319,
    0 5px 8px rgba(0,0,0,.42);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700;
  font-size: calc(var(--u) * .26);
  color: #4B5A6B;
  letter-spacing: .1em;
}
.cap-blank.w1{ width: var(--kw); }
.cap-blank.w2{ width: calc(var(--u) * 2 - var(--gap)); }

/* ---- modifier row: real controls, keycap dress ---- */
.mod{
  height: calc(var(--kh) * .92);
  border: none; padding: 0 8px; cursor: pointer;
  border-radius: var(--r-cap);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--display); font-weight: 700;
  font-size: clamp(9.5px, 1.5vw, 12.5px);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-dim);
  background: linear-gradient(180deg, #2C3644 0%, #212A35 55%, #1A222B 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -3px 0 rgba(0,0,0,.35),
    0 3px 0 #0E1319,
    0 5px 8px rgba(0,0,0,.42);
  transition: transform .07s, box-shadow .07s, color .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* two caps spanning the deck: 6u + 4u + the gap between them = one full row */
.mod--mode{ width: calc(var(--u) * 6 - var(--gap)); }
.mod--guess{ width: calc(var(--u) * 4 - var(--gap)); }
.mod:hover{ color: var(--ink); }
.mod:active{ transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 #0E1319, 0 1px 3px rgba(0,0,0,.5); }
.mod__glyph{ font-size: 1.25em; line-height: 1; }
.mod__text{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod__text b{ color: var(--ink); font-weight: 700; }

/* flag mode: the whole deck goes on alert */
.mod--mode[aria-pressed="true"]{
  background: linear-gradient(180deg, #564318 0%, #3E3011 55%, #2C2109 100%);
  color: var(--hazard);
  box-shadow:
    inset 0 1px 0 rgba(255,214,140,.25),
    inset 0 -3px 0 rgba(0,0,0,.4),
    0 3px 0 #14100A,
    0 0 20px rgba(255,176,32,.2);
}
.mod--mode[aria-pressed="true"] .mod__text b{ color: var(--hazard); }
.deck.flagmode{ border-color: var(--hazard-dim); box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -2px 0 rgba(0,0,0,.6),
    0 22px 44px rgba(0,0,0,.62),
    0 0 0 1px rgba(255,176,32,.18); }
.deck.flagmode .key.s-hidden:hover{ background: linear-gradient(180deg, #5B4A22 0%, #42341A 52%, #2C2109 100%); }

/* ============================================================
   Call-it prompt
   ============================================================ */

.callout{ display: flex; flex-direction: column; align-items: center; gap: 8px; }

.prompt{
  display: flex; align-items: center; gap: 9px;
  width: min(100%, var(--row));
  padding: 4px 4px 4px 13px;
  background: #0A0F14;
  border: 1px solid #232E3A;
  border-radius: 10px;
  box-shadow: inset 0 2px 9px rgba(0,0,0,.75);
}
.prompt:focus-within{ border-color: var(--hazard-dim); box-shadow: inset 0 2px 9px rgba(0,0,0,.75), 0 0 0 1px rgba(255,176,32,.2); }
.prompt__caret{ color: var(--hazard); font-weight: 700; font-size: 15px; line-height: 1; }
.prompt__input{
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--ink);
  font-family: var(--mono);
  /* Must stay at 16px or above. iOS auto-zooms the page on focus for anything
     smaller, and it does not zoom back out when the field is blurred. */
  font-size: 16px;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 10px 0;
  caret-color: var(--hazard);
  /* the board opts out of selection wholesale — this field needs it back */
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.prompt__input::placeholder{ color: #3B4654; text-transform: none; letter-spacing: .04em; }
.prompt__go{
  flex: none;
  padding: 9px 17px;
  border: none; border-radius: 7px; cursor: pointer;
  font-family: var(--display); font-weight: 800; font-size: 12px;
  letter-spacing: .16em; text-transform: uppercase;
  color: #241700;
  background: linear-gradient(180deg, #FFC64D, var(--hazard));
  box-shadow: 0 3px 0 #8A5F14;
  transition: transform .07s, box-shadow .07s;
}
.prompt__go:active{ transform: translateY(3px); box-shadow: 0 0 0 #8A5F14; }
.prompt__hint{
  margin: 0; text-align: center;
  font-size: 10px; letter-spacing: .07em; color: var(--ink-faint);
}


/* ============================================================
   Toasts
   ============================================================ */

.toasts{
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 50; display: flex; flex-direction: column-reverse; gap: 7px;
  align-items: center; pointer-events: none; width: min(92vw, 460px);
}
.toast{
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px;
  border-radius: 9px;
  background: rgba(14,20,27,.96);
  border: 1px solid #2A3644;
  border-left: 3px solid var(--readout);
  box-shadow: 0 10px 26px rgba(0,0,0,.6);
  font-size: 12px; letter-spacing: .03em; color: var(--ink);
  animation: toastIn .28s cubic-bezier(.2,.9,.3,1.2);
}
.toast.out{ animation: toastOut .3s ease-in forwards; }
.toast--bad{ border-left-color: var(--live); }
.toast--good{ border-left-color: var(--n2); }
.toast--warn{ border-left-color: var(--hazard); }
.toast__glyph{ font-size: 15px; line-height: 1; }
@keyframes toastIn{ from{ opacity: 0; transform: translateY(14px) } to{ opacity: 1; transform: none } }
@keyframes toastOut{ to{ opacity: 0; transform: translateY(-8px) } }

/* ============================================================
   Overlay sheets
   ============================================================ */

.overlay{
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  padding: 18px;
  background: rgba(5,8,11,.82);
  backdrop-filter: blur(4px);
  animation: fade .2s ease-out;
}
.overlay[hidden]{ display: none; }
@keyframes fade{ from{ opacity: 0 } to{ opacity: 1 } }

.sheet{
  position: relative;
  width: min(100%, 520px);
  max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, var(--steel-hi), #141C25);
  border: 1px solid #35434F;
  border-radius: 15px;
  box-shadow: 0 30px 70px rgba(0,0,0,.75);
  animation: sheetIn .32s cubic-bezier(.2,.9,.3,1.15);
}
@keyframes sheetIn{ from{ opacity: 0; transform: translateY(18px) scale(.97) } to{ opacity: 1; transform: none } }
.sheet__stripe{
  flex: none;
  height: 5px; border-radius: 14px 14px 0 0;
  background: repeating-linear-gradient(115deg, var(--hazard) 0 12px, #0F1319 12px 24px);
}
.sheet__body{
  --pad: clamp(20px, 4vw, 30px);
  padding: var(--pad);
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #3B4A5A transparent;
}
.sheet__body::-webkit-scrollbar{ width: 9px; height: 9px; }
.sheet__body::-webkit-scrollbar-track{ background: transparent; }
.sheet__body::-webkit-scrollbar-thumb{ background: #33414F; border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
.sheet__body::-webkit-scrollbar-corner{ background: transparent; }

.sheet h2{
  margin: 0 0 5px;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(21px, 5vw, 30px);
  letter-spacing: .07em; text-transform: uppercase; line-height: 1.08;
}
.sheet h2.win{ color: var(--n2); text-shadow: 0 0 24px rgba(99,212,113,.3); }
.sheet h2.lose{ color: var(--live); text-shadow: 0 0 24px rgba(226,58,58,.3); }
.sheet h2.info{ color: var(--hazard); }
.sheet .sub{
  margin: 0 0 18px; font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-faint);
}

.answer{
  margin: 0 0 18px; padding: 13px 16px;
  background: #0A0F14; border: 1px solid #263140; border-radius: 9px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.7);
}
.answer__label{ display: block; font-size: 9px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 5px; }
.answer__value{
  font-family: var(--display); font-weight: 800; font-size: clamp(18px, 4.2vw, 25px);
  letter-spacing: .09em; color: var(--hazard); word-break: break-word;
}

.tally{ list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.tally li{
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 8px 2px; border-bottom: 1px dashed #232E3A;
  font-size: 12px; color: var(--ink-dim);
}
.tally li:last-child{ border-bottom: none; }
.tally b{ font-family: var(--display); font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.tally li.total b{ color: var(--readout); font-size: 19px; }

/* ---- the goal, stated before any mechanics ---- */
.goal{
  margin: 0 0 13px;
  font-size: 13px; line-height: 1.68; color: var(--ink-dim);
}
.goal b{ color: var(--ink); font-weight: 700; }
.goal--lead{ margin: 18px 0 12px; font-size: 12px; color: var(--ink-faint); }

/* an aside for people who already know the mechanic — set apart from the
   rules so it reads as a shortcut, not as another thing to learn */
.knowit{
  margin: 18px 0 0;
  padding: 11px 14px;
  border-radius: 9px;
  border-left: 3px solid var(--hazard);
  background: rgba(255,176,32,.07);
  font-size: 11.5px; line-height: 1.6; color: var(--ink-dim);
}
.knowit b{ color: var(--hazard); font-weight: 700; }

.goal-demo{
  padding: 13px 15px 14px;
  border-radius: 10px;
  background: #0A0F14;
  border: 1px solid #232E3A;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.65);
}
.goal-demo__head{ margin: 0; display: flex; align-items: baseline; gap: 9px; }
.goal-demo__eyebrow{
  font-size: 8.5px; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-faint);
}
.goal-demo__theme{
  font-family: var(--display); font-weight: 800; font-size: 15px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--hazard);
}
/* .slot sets --sw on itself, so this needs the extra specificity to shrink it */
.goal-demo .slot{ --sw: 25px; }
.goal-demo .phrase{ min-height: 0; margin-top: 10px; justify-content: flex-start; gap: 4px 13px; }
.goal-demo .demo__cap{ max-width: none; margin-top: 11px; }

/* ---- the daily collectible ---- */
.collect{ margin: 0 0 18px; }
.collect__frame{
  /* The card is 4:5 at 1080x1350; full sheet width would push the tally and
     the buttons clean off the screen. */
  width: min(100%, 264px);
  margin: 0 auto;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid #2E3B47;
  background: #0A0F14;
  box-shadow: inset 0 2px 10px rgba(0,0,0,.7), 0 8px 22px rgba(0,0,0,.45);
  min-height: 150px;
  display: grid; place-items: center;
}
.collect__card{ display: block; width: 100%; height: auto; }
.collect__wait{
  font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-faint);
  padding: 40px 0;
}
.collect__cap{
  margin: 10px 0 0;
  font-size: 11.5px; color: var(--ink-dim);
}
.collect__cap b{ color: var(--ink); font-weight: 700; }
.collect__full{ color: var(--n2); font-weight: 700; }
.collect__hint{
  display: block; margin: 6px 0 0;
  font-size: 10.5px; line-height: 1.55; color: var(--ink-faint);
}

/* pick which version goes out — the preview follows it, so Share is
   always exactly what is on screen */
.switch{
  display: flex; gap: 3px;
  width: min(100%, 264px);
  margin: 11px auto 0;
  padding: 3px;
  border-radius: 9px;
  background: #0A0F14;
  border: 1px solid #232E3A;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
}
.switch__opt{
  flex: 1;
  padding: 8px 6px;
  border: none; border-radius: 7px; cursor: pointer;
  background: none;
  font-family: var(--display); font-weight: 700; font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint);
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.switch__opt:hover{ color: var(--ink-dim); }
.switch__opt.is-on{
  background: linear-gradient(180deg, #2C3644, #212A35);
  color: var(--hazard);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 1px 3px rgba(0,0,0,.5);
}

/* ---- the shelf ---- */
.shelf{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  margin: 4px 0 6px;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
  scrollbar-color: #3B4A5A transparent;
}
/* What you own sizes to content — it is the part worth looking at. The rest
   is capped and scrolls, or ninety unearned plates bury the sheet. */
.shelf--rest{ max-height: 34vh; overflow-y: auto; }

.shelf__head{
  margin: 14px 0 2px;
  font-size: 9.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--hazard);
}
.shelf__head--rest{ color: var(--ink-faint); }
.shelf::-webkit-scrollbar{ width: 9px; }
.shelf::-webkit-scrollbar-track{ background: transparent; }
.shelf::-webkit-scrollbar-thumb{ background: #33414F; border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }

.plate{ display: flex; flex-direction: column; gap: 3px; }
.plate canvas{
  display: block; width: 100%; height: auto;
  border-radius: 7px;
  border: 1px solid #2A3644;
  background: #0A0F14;
}
.plate--locked canvas{ opacity: .55; filter: grayscale(.5); }
.plate__name{
  font-size: 9px; letter-spacing: .06em; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plate__tiles{
  font-size: 8.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--hazard);
}
.plate--locked .plate__tiles{ color: var(--ink-faint); }
.plate__bird{
  font-size: 8.5px; line-height: 1.3; color: var(--ink-faint);
  font-style: italic;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* the bird's one line, set above the plate caption */
.collect__lore{
  display: block; margin-bottom: 5px;
  font-size: 11.5px; font-style: italic; line-height: 1.5;
  color: var(--hazard);
}

.rules{ margin: 0 0 20px; padding: 0; list-style: none; counter-reset: r; }
.rules li{
  position: relative;
  padding: 0 0 11px 34px;
  font-size: 12.5px; line-height: 1.6; color: var(--ink-dim);
  counter-increment: r;
}
.rules li::before{
  content: counter(r);
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px; border-radius: 5px;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 11px;
  color: var(--hazard); background: #0C1219; border: 1px solid #2E3A48;
}
.rules b{ color: var(--ink); font-weight: 700; }
.rules em{ color: var(--readout); font-style: normal; }

/* worked example hanging off a rule */
.rules .eg{
  display: block; margin: 7px 0 0; padding-left: 11px;
  border-left: 2px solid #2E3A48;
  font-size: 11.5px; line-height: 1.6; color: var(--ink-faint);
}
.rules .eg b{ color: var(--hazard); font-weight: 700; }

/* ---- rule diagrams: real keycaps, shrunk ----
   --kw and --kh are computed on :root, so a new --u alone would not reach
   them. Redeclare all three here or the caps keep their full-size width. */
.mini{
  --u: 38px;
  --gap: 4px;
  --r-cap: 7px;
  --kw: calc(var(--u) - var(--gap));
  --kh: calc(var(--u) * 1.08 - var(--gap));
  display: flex; flex-direction: column; gap: var(--gap);
  width: max-content;
  padding: 11px 13px;
  border-radius: 10px;
  background: linear-gradient(180deg, #212B36, #151D25);
  border: 1px solid #2E3B47;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.mini-row{ display: flex; gap: var(--gap); margin-left: calc(var(--off, 0) * var(--u)); }
.mini .key{ pointer-events: none; }
.mini .key__tag{ top: 2px; left: 4px; }

.demo{ display: flex; flex-wrap: wrap; gap: 11px; margin: 12px 0 2px; }
.demo__step{ display: flex; flex-direction: column; gap: 7px; }
.demo__cap{
  margin: 0; max-width: 132px;
  font-size: 10.5px; line-height: 1.55; color: var(--ink-faint);
}
.demo__cap b{ color: var(--ink-dim); font-weight: 700; }

/* a lone diagram reads better with its caption alongside than stacked under */
.demo--side .demo__step{ flex-direction: row; align-items: center; gap: 14px; flex-wrap: wrap; }
.demo--side .demo__cap{ max-width: none; flex: 1 1 150px; font-size: 11.5px; }

/* one-cap outcomes compared line by line, so the two results sit under
   each other rather than floating side by side over empty space */
.demo--rows{ flex-direction: column; gap: 9px; }
.demo--rows .demo__step{ flex-direction: row; align-items: center; gap: 13px; width: 100%; }
.demo--rows .demo__cap{ max-width: none; flex: 1; font-size: 11.5px; }

/* too narrow for steps side by side — turn each one into its own row instead,
   which stays a readable sequence without three stacked columns of height */
@media (max-width: 560px){
  .demo{ gap: 9px; }
  .demo__step{ flex-direction: row; align-items: center; gap: 13px; width: 100%; }
  .demo__cap{ max-width: none; flex: 1; font-size: 11.5px; }
}

.ctrls{
  margin: 0 0 4px; padding: 13px 15px;
  background: #0A0F14; border: 1px solid #232E3A; border-radius: 9px;
  font-size: 11.5px; line-height: 1.85; color: var(--ink-dim);
}
.ctrls kbd{
  font-family: var(--mono); font-size: 10.5px;
  padding: 2px 6px; border-radius: 4px;
  background: #1D2733; border: 1px solid #33414F; border-bottom-width: 2px;
  color: var(--ink);
}

/* the primary action stays reachable however tall the sheet gets */
.sheet__actions{
  display: flex; gap: 9px; flex-wrap: wrap;
  position: sticky; bottom: 0;
  margin: 14px calc(-1 * var(--pad)) calc(-1 * var(--pad));
  padding: 26px var(--pad) var(--pad);
  background: linear-gradient(180deg, rgba(20,28,37,0), rgba(20,28,37,.86) 45%, #151D26 72%);
}
.btn{
  flex: 1 1 140px;
  padding: 13px 18px;
  border: none; border-radius: 9px; cursor: pointer;
  font-family: var(--display); font-weight: 800; font-size: 13px;
  letter-spacing: .15em; text-transform: uppercase;
  transition: transform .07s, box-shadow .07s;
}
.btn--go{ color: #241700; background: linear-gradient(180deg, #FFC64D, var(--hazard)); box-shadow: 0 3px 0 #8A5F14; }
.btn--ghost{ color: var(--ink-dim); background: linear-gradient(180deg, #2B3744, #1C242E); box-shadow: 0 3px 0 #10161D; }
.btn:active{ transform: translateY(3px); box-shadow: none; }

/* every remaining tappable control: no grey flash box on touch */
.tool, .btn, .prompt__go, .slot{
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ============================================================
   Responsive + motion
   ============================================================ */

/* enough room to read the deck as a physical object on a bench */
@media (min-width: 760px){
  .deck{ transform: perspective(1500px) rotateX(5deg); transform-origin: 50% 100%; }
}

/* Below this the four readouts no longer fit beside the brand without wrapping
   into an uneven 2x2, so give them their own full-width row instead. */
@media (max-width: 880px){
  .topbar{ grid-template-columns: 1fr auto; row-gap: 10px; }
  .hud{ order: 3; grid-column: 1 / -1; justify-content: space-between; }
  .chip{ flex: 1 1 0; min-width: 0; }
}

@media (max-width: 620px){
  .tool__text{ display: none; }
  .tool{ padding: 8px 11px; }
  .brand__text p{ display: none; }
}

@media (max-width: 400px){
  .mod__text{ font-size: 9px; letter-spacing: .04em; }
  .readout{ min-width: 84px; padding: 5px 8px; }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .deck{ transform: none !important; }
}
