/* Look B, in the rift: the bench's wood, tags and glaze, from design/mockup.html (approved 2026-10-12). */
@font-face { font-family: Fraunces; src: url(../fonts/fraunces-latin.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url(../fonts/instrument-sans-latin.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }

:root { --ink: #2b1d12; --tag: #fbf4e4; --gold: #f2be3a; --teal: #1f9a96; --dear: #a5321f; --cream: #fbf4e4; }
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: #94643a; color: var(--ink); font: 15px/1.4 'Instrument Sans', system-ui, sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #fff3c4; outline-offset: 2px; }
a { color: inherit; text-decoration: none; }

/* the bench */
.frame { position: relative; height: 100dvh; overflow: hidden; color: var(--ink);
  background-color: #9b6a40; background-image: repeating-linear-gradient(0deg, rgba(60,30,10,.22) 0 2px, transparent 2px 58px), linear-gradient(90deg, #a2703f, #94643a 40%, #a06c3e);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  grid-template-areas: "tags" "stage" "hero" "tray" "panel" "go";
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left)); max-width: 560px; margin: 0 auto; }
.frame::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 7px, rgba(255,230,190,.035) 7px 8px), radial-gradient(ellipse at 20% 0%, rgba(255,214,150,.22), transparent 60%); }
.frame > * { position: relative; }
.title { display: none; grid-area: title; }

/* top tags */
.tags { grid-area: tags; display: flex; align-items: center; gap: 6px; height: 62px; }
.back { width: 16px; color: var(--cream); font: 800 28px Fraunces, serif; text-align: center; flex: none; }
.tag { height: 38px; display: inline-flex; align-items: center; gap: 5px; padding: 0 17px 0 10px; background: var(--tag); flex: none;
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%); box-shadow: inset 0 -3px 0 rgba(120,80,30,.18);
  font: 900 20px/1 Fraunces, serif; font-variant-numeric: lining-nums tabular-nums; }
.tag b { font-weight: 900; }
.tag small { font: italic 700 17px Fraunces, serif; color: #9a8466; }
.tag .lbl { font: 700 13px 'Instrument Sans'; margin-right: 1px; }
.tag i { display: inline-grid; width: 22px; height: 22px; }
.tag.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.08); } }
.round { width: 44px; height: 44px; border-radius: 50%; background: var(--teal); display: grid; place-items: center; flex: none; color: #fff;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.28), inset 0 -4px 0 rgba(0,0,0,.25), 0 3px 0 #146663; font: 800 17px Fraunces, serif; }
.round svg { width: 16px; height: 16px; }
.round:active { transform: translateY(2px); box-shadow: inset 0 3px 0 rgba(255,255,255,.28), inset 0 -4px 0 rgba(0,0,0,.25), 0 1px 0 #146663; }
.tags .pause { margin-left: auto; }

/* the board */
.stage { grid-area: stage; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
/* the next wave, named: shown when the bench has the room */
.coming { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 10px; border-radius: 10px; background: rgba(43,29,18,.35); color: var(--cream); max-width: 100%; overflow: hidden; }
.c-lbl { font: 800 14px Fraunces, serif; white-space: nowrap; }
.c-list { display: flex; gap: 10px; align-items: center; font: 700 13px 'Instrument Sans'; white-space: nowrap; }
.c-list span { display: inline-flex; align-items: center; gap: 1px; }
.c-list canvas { width: 30px; height: 30px; }
.board { position: relative; background: #6e4426; border-radius: 16px; padding: 7px; line-height: 0;
  box-shadow: inset 0 2px 0 rgba(255,220,170,.35), inset 0 -3px 0 rgba(0,0,0,.3), 0 4px 0 #4b2e18, 0 8px 18px rgba(30,12,0,.35); }
.board canvas { border-radius: 10px; touch-action: none; display: block; }
#ground { position: absolute; left: 7px; top: 7px; pointer-events: none; }
#cv { position: relative; } /* positioned, so it paints over #ground */
.overlay { position: absolute; inset: 7px; border-radius: 10px; background: rgba(43,29,18,.62); display: grid; place-content: center; text-align: center; gap: 10px; color: var(--cream); line-height: 1.3; padding: 16px; }
.overlay h2 { font: 900 30px Fraunces, serif; }
.overlay p { font: 600 15px 'Instrument Sans'; max-width: 28ch; margin: 0 auto; }
.ov-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
.btn { height: 46px; padding: 0 20px; border-radius: 12px; background: rgba(251,244,228,.92); color: var(--ink); font: 800 16px Fraunces, serif;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -4px 0 rgba(0,0,0,.14), 0 3px 0 rgba(30,12,0,.35); }
.btn.gold { background: var(--gold); color: #3a2405; box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -4px 0 rgba(0,0,0,.16), 0 3px 0 #b88a1a; }
.btn:disabled { opacity: .55; cursor: default; }

/* the hero */
.hero { grid-area: hero; display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 2px; color: var(--cream); position: relative; }
.lvb, .hint { display: none; }
.portrait { width: 46px; height: 46px; border-radius: 50%; background: #2f6f6c; box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 0 0 3px var(--gold); overflow: hidden; flex: none; padding: 0; line-height: 0; }
.portrait.moving { box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 0 0 3px #fff3c4, 0 0 14px rgba(242,190,58,.8); }
.h-text { min-width: 0; }
.hname { font: 800 16px/1.1 Fraunces, serif; white-space: nowrap; }
.hname small { display: block; font: 600 12px 'Instrument Sans'; opacity: .85; margin-top: 2px; }
.xp { width: 74px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.3); margin-top: 4px; overflow: hidden; }
.xp i { display: block; width: 0; height: 100%; background: var(--gold); transition: width .3s; }
.ability { height: 44px; min-width: 44px; padding: 0 12px; border-radius: 12px; display: grid; place-items: center; font: 800 14px/1.05 Fraunces, serif; text-align: center; flex: none;
  background: rgba(0,0,0,.22); color: rgba(251,244,228,.7); }
#ability { margin-left: auto; }
#ability.ready { background: var(--gold); color: #3a2405; box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -4px 0 rgba(0,0,0,.18), 0 0 14px rgba(242,190,58,.55); }
#ability:disabled:not(.ready) { font: 600 12px 'Instrument Sans'; }
.ability.locked { font: 600 12px 'Instrument Sans'; }

/* the tray: dark cards with price tags. The icon takes the height left after the name and the price, so a short
   card shrinks the icon and never pushes the price out (tests/rift-capture.cjs checks every tag). */
.tray { grid-area: tray; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
/* more than eight towers: two rows that scroll sideways, the fifth column peeking in */
.tray.many { grid-template-columns: repeat(var(--cols, 5), calc((100% - 18px) / 4.4)); grid-template-rows: repeat(2, auto); grid-auto-flow: row;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 3px 3px 6px; margin: -3px -3px 0; } /* room for the selection ring */
.tray.many::-webkit-scrollbar { display: none; }
.card { position: relative; height: 78px; border-radius: 10px; background: #5e3b20 linear-gradient(180deg, rgba(255,220,170,.12), rgba(0,0,0,.08)); padding: 3px 0 5px; color: var(--cream);
  box-shadow: inset 0 1px 0 rgba(255,220,170,.25), 0 3px 0 rgba(30,12,0,.35); display: grid; grid-template-rows: minmax(0, 1fr) auto auto; justify-items: center; align-items: end; }
.card .ic { height: 100%; max-height: 38px; width: auto; aspect-ratio: 1; min-height: 0; }
.card .tx { display: block; line-height: 0; }
.card .nm { display: block; font: 700 11.5px/13px 'Instrument Sans'; text-align: center; height: 13px; white-space: nowrap; }
.card .ds, .card .n { display: none; }
.pr { margin-top: 3px; height: 19px; padding: 0 11px 0 6px; background: var(--tag); color: var(--ink); font: 900 13px/19px Fraunces, serif; display: inline-flex; gap: 3px; align-items: center;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 0 100%); }
.pr i { display: inline-grid; width: 12px; height: 12px; }
.pr i canvas, .tag i canvas { width: 100%; height: 100%; }
.card.sel { box-shadow: 0 0 0 3px var(--gold), inset 0 1px 0 rgba(255,220,170,.25), 0 3px 0 rgba(30,12,0,.35); background-color: #7a4d29; }
.card.dear .pr { color: var(--dear); }
/* a tower new on this map, on the first visit */
.card .new { position: absolute; top: 3px; left: 4px; z-index: 2; padding: 1px 5px; border-radius: 5px; background: var(--gold); color: #3a2405; font: 800 10px/1.3 'Instrument Sans'; pointer-events: none; }
.card.fresh { box-shadow: inset 0 0 0 2px rgba(242,190,58,.7), inset 0 1px 0 rgba(255,220,170,.25), 0 3px 0 rgba(30,12,0,.35); }

/* ?perf: the frame meter */
.meter { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 56px); transform: translateX(-50%); z-index: 50; pointer-events: none; white-space: pre; text-align: center;
  padding: 3px 8px; border-radius: 6px; background: rgba(20,12,6,.78); color: #fff; font: 600 10.5px/1.35 ui-monospace, Consolas, monospace; }

/* the map list */
body.on-maps { overflow: auto; }
.maps { min-height: 100dvh; max-width: 1100px; margin: 0 auto; color: var(--cream);
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); }
body.on-maps { background-color: #9b6a40; background-image: repeating-linear-gradient(0deg, rgba(60,30,10,.22) 0 2px, transparent 2px 58px), linear-gradient(90deg, #a2703f, #94643a 40%, #a06c3e); }
.m-head { display: flex; align-items: baseline; gap: 14px; padding: 14px 0 12px; }
.m-head .bk { font: 700 16px 'Instrument Sans'; opacity: .9; }
.m-head h1 { font: 900 30px Fraunces, serif; margin: 0; }
.m-line { margin: 0; font: 500 16px/1.4 'Instrument Sans'; opacity: .85; }
.m-line + .m-sub { margin-top: 18px; }
.m-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.map { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; align-items: start; padding: 10px; border-radius: 14px; background: #5e3b20 linear-gradient(180deg, rgba(255,220,170,.12), rgba(0,0,0,.08));
  box-shadow: inset 0 1px 0 rgba(255,220,170,.25), 0 4px 0 rgba(30,12,0,.35); color: var(--cream); }
a.map:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,220,170,.25), 0 2px 0 rgba(30,12,0,.35); }
.map .th { display: block; padding: 4px; border-radius: 10px; background: #6e4426; line-height: 0; box-shadow: inset 0 2px 0 rgba(255,220,170,.3), 0 3px 0 #4b2e18; }
.map .th canvas { width: 100%; height: auto; border-radius: 7px; }
.map.locked .th canvas { filter: saturate(.45) brightness(.82); }
.mt { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-top: 2px; }
.mn { font: 800 21px/1.1 Fraunces, serif; }
.md { font: 600 13px 'Instrument Sans'; opacity: .85; }
.mnew { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px 0 4px; border-radius: 8px; background: var(--tag); color: var(--ink); font: 800 14px Fraunces, serif; }
.chip canvas { width: 26px; height: 26px; }
.foes { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.foes canvas { width: 30px; height: 30px; }
.seal, .lock { align-self: flex-start; margin-top: 4px; font: 700 13px 'Instrument Sans'; }
.seal { padding: 3px 10px; border-radius: 8px; background: var(--gold); color: #3a2405; }
.lock { opacity: .9; }
.m-sub { font: 800 20px Fraunces, serif; margin: 26px 0 10px; }
.m-towers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.tw { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; align-items: center; min-height: 54px; padding: 6px 12px 6px 8px; border-radius: 10px; background: var(--tag); color: var(--ink);
  box-shadow: inset 0 -3px 0 rgba(120,80,30,.16); }
.tw canvas { width: 40px; height: 40px; }
.twt b { display: block; font: 800 16px/1.1 Fraunces, serif; }
.twt small { display: block; font: 500 12px/1.25 'Instrument Sans'; color: #6b5640; }
.tw.locked { background: #e9dcc0; }
.tw.locked canvas { filter: saturate(.35); opacity: .8; }
.tw.locked small { font-weight: 700; color: #7a5a30; }
@media (min-width: 700px) {
  .m-list { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); }
  .map { grid-template-columns: 180px minmax(0, 1fr); padding: 12px; }
  .foes canvas { width: 38px; height: 38px; }
}

/* a placed tower's panel replaces the tray */
.panel { grid-area: panel; display: flex; align-items: center; gap: 10px; min-height: 78px; padding: 8px 10px; border-radius: 10px; background: #5e3b20; color: var(--cream);
  box-shadow: inset 0 1px 0 rgba(255,220,170,.25), 0 3px 0 rgba(30,12,0,.35); }
.p-head { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.p-head i { width: 44px; height: 44px; flex: none; }
.p-head b { font: 800 17px/1.1 Fraunces, serif; display: block; white-space: nowrap; }
.p-head small { font: 600 12px 'Instrument Sans'; opacity: .85; }
.p-buttons { display: flex; gap: 6px; }
.p-buttons .btn { height: 44px; padding: 0 12px; font-size: 14px; }
.x { width: 44px; height: 44px; font: 400 26px/1 'Instrument Sans'; color: var(--cream); opacity: .8; order: 3; }

/* next wave, speed */
.go { grid-area: go; display: flex; gap: 8px; height: 64px; align-items: center; }
.next { flex: 1; height: 52px; border-radius: 14px; background: var(--gold); display: grid; place-items: center; font: 900 22px Fraunces, serif; color: #3a2405;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -5px 0 rgba(0,0,0,.16), 0 4px 0 #b88a1a; }
.next:active { transform: translateY(2px); box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -5px 0 rgba(0,0,0,.16), 0 2px 0 #b88a1a; }
.next.pulse { animation: pulse 1.6s ease-in-out infinite; }
.next:disabled { opacity: .6; cursor: default; animation: none; }
@keyframes pulse { 50% { box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -5px 0 rgba(0,0,0,.16), 0 4px 0 #b88a1a, 0 0 18px rgba(255,214,107,.75); } }
.go .round { width: 60px; height: 52px; border-radius: 14px; font-size: 20px; }
.speed[aria-pressed="true"] { background: #146663; box-shadow: inset 0 3px 0 rgba(0,0,0,.25), 0 1px 0 #0d4644; }
.pause2 { display: none !important; }

/* short phones: compact the chrome so the board keeps its room */
@media (max-height: 700px) and (max-aspect-ratio: 1/1) {
  .tags { height: 50px; } .tag { height: 32px; font-size: 17px; } .tag small { font-size: 14px; } .round { width: 40px; height: 40px; }
  .go { height: 56px; } .next { height: 46px; font-size: 18px; } .go .round { height: 46px; width: 46px; }
  /* the map gets the height: the hero folds into the Next wave row, the cards keep icon and price (CPO 2026-10-12:
     tile >= 26 px at 320x568, >= 30 px at 360x640; tests/rift-capture.cjs holds it) */
  .frame { grid-template-columns: auto minmax(0, 1fr); column-gap: 6px; grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "tags tags" "stage stage" "tray tray" "panel panel" "hero go"; }
  .hero { height: 56px; gap: 6px; padding: 0; }
  .h-text, .hero .ability.locked { display: none; }
  .portrait { width: 42px; height: 42px; }
  .lvb { display: grid; place-items: center; position: absolute; left: 28px; bottom: 4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
    background: var(--gold); color: #3a2405; font: 900 11px/1 Fraunces, serif; box-shadow: 0 0 0 2px #5e3b20; pointer-events: none; }
  #ability { width: 78px; min-width: 0; height: 46px; padding: 0 4px; margin-left: 0; font-size: 13px; }
  #ability:disabled:not(.ready) { font-size: 11px; }
  .card { height: 58px; padding-top: 2px; grid-template-rows: minmax(0, 1fr) auto; }
  .card .tx { display: none; }
  .card .ic { max-height: 32px; }
  .card.sel .tx { display: block; position: absolute; left: 0; right: 0; top: -9px; z-index: 1; text-align: center; line-height: normal; pointer-events: none; }
  .card.sel .nm { display: inline-block; height: auto; padding: 1px 6px; border-radius: 6px; background: var(--gold); color: #3a2405; font: 800 10.5px/1.2 'Instrument Sans'; }
  .tray.many .card.sel .tx { top: 0; }
  .card.sel.fresh .tx { display: none; } /* a new tower keeps its New tag; its name shows from the next visit */
  .hint { display: block; position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 6px 14px; border-radius: 16px; background: rgba(43,29,18,.78);
    color: var(--cream); font: 700 13px 'Instrument Sans'; white-space: nowrap; pointer-events: none; }
  .hint[hidden] { display: none; }
}
@media (max-width: 380px) and (max-aspect-ratio: 1/1) { .card .nm { font-size: 10px; letter-spacing: -.2px; } }
/* four-digit gold still leaves the pause on screen (tests/rift-capture.cjs stages 9999) */
@media (max-width: 430px) and (max-aspect-ratio: 1/1) { .tags { gap: 4px; } .tag { padding: 0 14px 0 8px; gap: 4px; } }
@media (max-width: 340px) and (max-aspect-ratio: 1/1) {
  .tags { gap: 4px; } .tag { padding: 0 13px 0 7px; font-size: 15px; gap: 3px; } .tag .lbl { font-size: 11px; } .tag small { font-size: 12px; }
  .tag i { width: 18px; height: 18px; } .tray { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) { .next.pulse, .tag.bump { animation: none; } }

/* computers and landscape: the map wide, the bench column beside it */
@media (min-aspect-ratio: 1/1) and (min-width: 700px) {
  .frame { max-width: none; grid-template-columns: minmax(0, 1fr) 346px; column-gap: 34px;
    grid-template-rows: 56px auto auto auto auto minmax(0, 1fr);
    grid-template-areas: "title ." "stage tags" "stage tray" "stage panel" "stage hero" "stage go";
    padding: 0 max(40px, env(safe-area-inset-right)) 28px max(40px, env(safe-area-inset-left)); align-content: start; height: 100dvh; }
  .title { display: flex; align-items: baseline; gap: 14px; height: 56px; padding-top: 14px; color: var(--cream); }
  .title .bk { font: 700 16px 'Instrument Sans'; opacity: .9; }
  .title b { font: 900 30px Fraunces, serif; }
  .title span { font: 600 15px 'Instrument Sans'; opacity: .85; }
  .stage { grid-row: 2 / 7; align-self: stretch; }
  .coming { display: none !important; }
  .tags { height: auto; padding-top: 0; } .tags .back, .tags .pause { display: none; }
  .tag { height: 38px; font-size: 20px; padding-right: 22px; } .tag .lbl { font-size: 13px; } .tag small { font-size: 17px; }
  .tray, .tray.many { grid-template-columns: none; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
  .tray.many { max-height: calc(100dvh - 340px); overflow: hidden auto; padding: 0 0 0 8px; margin-left: -8px; }
  .card { height: 50px; display: grid; grid-template-columns: 16px 40px 1fr auto; grid-template-rows: none; justify-items: normal; align-items: center; gap: 8px; padding: 0 20px 0 10px; background: var(--tag); color: var(--ink);
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%); box-shadow: inset 0 -3px 0 rgba(120,80,30,.16); border-radius: 0; text-align: left; }
  .card .n { display: block; font: 700 12px 'Instrument Sans'; color: #8a7458; }
  .card .ic { width: 40px; height: 40px; max-height: none; }
  .card .nm { font: 800 16px/1.05 Fraunces, serif; height: auto; text-align: left; }
  .card .ds { display: block; font: 500 12px/1.2 'Instrument Sans'; color: #6b5640; }
  .card .tx { min-width: 0; line-height: normal; }
  .card .pr { margin: 0; background: none; padding: 0; height: auto; clip-path: none; font: 900 16px Fraunces, serif; gap: 4px; }
  .card .pr i { width: 14px; height: 14px; }
  .card.sel { background: #f9df94; margin-left: -8px; box-shadow: inset 0 -3px 0 rgba(120,80,30,.16); }
  .panel { margin-top: 10px; }
  .hero { height: auto; padding: 14px 0 4px; }
  .go { margin-top: 4px; }
  .go .round { width: 60px; } .pause2 { display: grid !important; width: 52px !important; }
}
@media (min-aspect-ratio: 1/1) and (min-width: 700px) and (max-height: 620px) {
  .frame { grid-template-rows: 40px auto auto auto auto minmax(0, 1fr); padding-bottom: 10px; }
  .title { height: 40px; padding-top: 6px; } .title b { font-size: 22px; }
  .card { height: 38px; } .card .ic { width: 30px; height: 30px; } .card .ds { display: none; } .tray { gap: 4px; margin-top: 6px; }
  .hero { padding: 6px 0 0; } .go { height: 56px; }
}
