/* Right of Way: dusk over the rooftops. A deep evening page, the duel in a lit window, the two fencers' colours. */
@font-face { font-family: "Young Serif"; font-display: swap; src: url(../fonts/young-serif-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-weight: 100 900; font-display: swap; src: url(../fonts/jost-latin-wght-normal.woff2) format("woff2"); }

:root {
  --bg: #D9DEE3; --panel: #F3F5F7; --ink: #1A1620; --muted: #585266; --line: #B9C0C9; --tile: #FFFFFF; --tile-ink: #1A1620;
  --y: #F2C230; --r: #E4473B; --me: var(--y); --go: #1A1620; --go-ink: #F3F5F7;
  --head: "Young Serif", Georgia, serif; --body: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  --lb-panel: #F3F5F7; --lb-panel2: #E6EAEE; --lb-text: #1A1620; --lb-muted: #585266; --lb-line: #C3CAD2; --lb-accent: #1A1620; --lb-ink: #F3F5F7; --lb-font: var(--body); --lb-head: var(--head);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1C1A2B; --panel: #262338; --ink: #F1E7D6; --muted: #A9A0BA; --line: #3B3651; --tile: #2E2A44; --tile-ink: #F1E7D6;
  --go: #F1E7D6; --go-ink: #1C1A2B;
  --lb-panel: #262338; --lb-panel2: #211E31; --lb-text: #F1E7D6; --lb-muted: #A9A0BA; --lb-line: #3B3651; --lb-accent: #F2C230; --lb-ink: #1C1A2B;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 16px/1.45 var(--body); min-height: 100vh; min-height: 100dvh; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
.wrap { max-width: 720px; margin: 0 auto; padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; }
.bar { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.back { color: var(--muted); text-decoration: none; font-weight: 500; }
.bar-r { display: flex; gap: 6px; }
.icon { width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--line); background: transparent; font-weight: 600; cursor: pointer; display: grid; place-items: center; }
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon svg .fill { fill: currentColor; stroke: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }

/* home: the title stands on the piste, a long strip with each fencer's end marked */
.logo { font: 400 clamp(2.6rem, 12vw, 4.4rem)/1 var(--head); margin: 26px 0 0; letter-spacing: -.01em; }
.piste { position: relative; height: 3px; background: var(--ink); margin: 14px 0 0; border-radius: 2px; }
.piste i { position: absolute; top: -5px; width: 4px; height: 13px; border-radius: 2px; }
.piste .m0 { right: 0; background: var(--y); } .piste .m1 { left: 0; background: var(--r); }
.pitch { max-width: 33em; color: var(--muted); font-size: 1.05rem; margin: 18px 0 22px; }
.cpu { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.cpu h2 { font: 400 1.3rem/1.2 var(--head); margin: 0 0 10px; }
.opt { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.opt .fine { width: 5.5em; flex: none; }
.fine { color: var(--muted); font-size: .92rem; margin: 2px 0; }
.chips { display: flex; gap: 8px; flex: 1; }
.chips button { flex: 1; min-height: 50px; border-radius: 10px; border: 1.5px solid var(--line); background: transparent; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.chips button small { font-weight: 400; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips button.on small { color: inherit; opacity: .75; }
.go { display: block; width: 100%; border: 0; border-radius: 12px; background: var(--go); color: var(--go-ink); font: 400 1.2rem/1 var(--head); padding: 15px; cursor: pointer; margin-top: 6px; }
.go:active { transform: translateY(1px); }
.ghost { border: 1.5px solid var(--line); background: transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer; color: var(--muted); font-weight: 500; }
.lb-box { margin-bottom: 14px; }

/* the duel */
#game { --me: var(--y); }
#game.p1 { --me: var(--r); }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 2px; }
.side { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; font-weight: 600; }
.side b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.s1 { justify-content: flex-end; }
.kc { font: 400 1.25rem/1 var(--head); min-width: 1.6em; height: 1.6em; display: grid; place-items: center; border-radius: 8px; color: #1A1620; }
.s0 .kc { background: var(--y); } .s1 .kc { background: var(--r); color: #fff; }
.pips { display: flex; align-items: center; gap: 5px; flex: none; }
.pip { width: 12px; height: 6px; border-radius: 3px; background: var(--line); }
.pip.here { background: var(--ink); width: 18px; }
.end { width: 4px; height: 14px; border-radius: 2px; }
.end.e0 { background: var(--y); } .end.e1 { background: var(--r); }
.rowline { text-align: center; margin: 2px 0 6px; font-size: .9rem; color: var(--muted); min-height: 1.3em; }
.rowline.r0 { color: inherit; } .rowline.r1 { color: inherit; }
.rowline.r0::before, .rowline.r1::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.rowline.r0::before { background: var(--y); } .rowline.r1::before { background: var(--r); }
.stage { position: relative; border-radius: 8px; overflow: hidden; background: #0E0B12; box-shadow: 0 0 0 1px var(--line); }
#cv { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; image-rendering: auto; }
.skip { position: absolute; right: 6px; bottom: 6px; min-height: 44px; border: 1.5px solid rgba(244, 241, 234, .5); border-radius: 10px; background: rgba(14, 11, 18, .85); color: #F4F1EA; padding: 8px 16px; font-size: .95rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
#cv { cursor: pointer; }
.status { text-align: center; min-height: 1.5em; margin: 6px 0 5px; font-weight: 500; font-size: .95rem; }

/* the move pad */
.pad { display: grid; gap: 6px; }
.plab { width: 3.7em; flex: none; font-size: .78rem; color: var(--muted); display: flex; align-items: center; }
/* nine big buttons, three by three: moves, attacks, guards */
.pgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pb { min-width: 0; min-height: 58px; border-radius: 11px; border: 1.5px solid var(--line); background: var(--tile); color: var(--tile-ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5px 4px; line-height: 1.1; text-align: center; }
.pb b { font-size: 1rem; font-weight: 600; }
.pb span { font-size: .74rem; color: var(--muted); margin-top: 3px; line-height: 1.15; }
.pb { position: relative; touch-action: manipulation; }
.pb:active:not(:disabled) { transform: translateY(1px); border-color: var(--me); }
.pb.off { opacity: .32; cursor: default; }
.pb.atk:not(.off) { border-bottom: 3px solid var(--r); }
.pb.grd:not(.off) { border-bottom: 3px solid #4F7CC4; }
.pb.fl:not(.off) { border-color: var(--me); border-bottom: 3px solid var(--me); }
.pb kbd { display: none; position: absolute; top: 2px; right: 4px; font: 500 .62rem/1 var(--body); color: var(--muted); }
@media (hover: hover) and (min-width: 640px) { .pb kbd { display: block; } }
.chain { display: flex; align-items: stretch; gap: 5px; margin-bottom: 2px; }
.slot { flex: 1; min-width: 0; min-height: 38px; border-radius: 9px; border: 1.5px dashed var(--line); background: transparent; color: var(--muted); display: flex; align-items: center; gap: 5px; padding: 2px 6px; font-size: .78rem; cursor: pointer; text-align: left; }
.slot i { font-style: normal; font: 400 .9rem/1 var(--head); opacity: .7; flex: none; }
.slot span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.full { border-style: solid; border-color: var(--me); color: var(--ink); background: var(--tile); font-weight: 500; }
.slot.next { border-color: var(--muted); }
.slot:disabled { cursor: default; }
.undo { flex: none; width: 44px; border-radius: 9px; border: 1.5px solid var(--line); background: transparent; cursor: pointer; font-size: 1rem; }
.undo:disabled { opacity: .35; cursor: default; }
.flp { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; }
.flp.on { border-color: var(--me); background: var(--y); box-shadow: 0 0 6px var(--y); }
.s1 .flp.on { background: var(--r); box-shadow: 0 0 6px var(--r); border-color: var(--r); }
.s0 .flp.on { border-color: var(--y); }
.gorow { margin-top: 7px; }
.gorow .go { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.1rem; padding: 13px; }
.gorow .go { margin: 0; border-left: 6px solid var(--me); }
.leave { display: flex; justify-content: flex-end; margin-top: 10px; }

/* the finish */
.over { position: fixed; inset: 0; z-index: 50; background: rgba(14, 11, 18, .6); display: grid; place-items: center; padding: 20px; }
.obox { background: var(--panel); color: var(--ink); border-radius: 16px; padding: 22px 20px; max-width: 360px; width: 100%; text-align: center; border-top: 6px solid var(--y); }
.obox.w1 { border-top-color: var(--r); }
.obox h2 { font: 400 2rem/1.05 var(--head); margin: 0 0 8px; }
.obox p { color: var(--muted); margin: 0 0 12px; }
.obtns { display: grid; gap: 8px; margin-top: 6px; }
.obtns .ghost { width: 100%; }

/* help */
.dlg { border: 1px solid var(--line); border-radius: 16px; padding: 20px 18px; max-width: 560px; width: calc(100% - 24px); background: var(--panel); color: var(--ink); }
.dlg::backdrop { background: rgba(14, 11, 18, .55); }
.dlg h2 { font: 400 1.6rem var(--head); margin: 0 0 8px; }
.dlg .x { position: absolute; right: 12px; top: 10px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 1.6rem; cursor: pointer; color: var(--ink); }
.dlg form { margin: 0; }
/* the close button is 44px and rides along when a tall help sheet scrolls on a phone (as on the other games) */
.dlg > form:first-child { position: sticky; top: 20px; height: 0; z-index: 3; background: inherit; }
.dlg .x { top: -14px; right: -10px; width: 44px; height: 44px; border-radius: 50%; background: inherit; touch-action: manipulation; }
.lede { font-style: italic; color: var(--muted); line-height: 1.55; }
.htoast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 24px); opacity: 0; background: var(--ink); color: var(--bg);
  padding: 11px 20px; border-radius: 99px; font: 500 15px/1.2 var(--body); transition: all .3s; z-index: 60; pointer-events: none; max-width: calc(100vw - 32px); }
.htoast.show { opacity: 1; transform: translate(-50%, 0); }
.ad-inline { margin: 18px 0 6px; }
.foot { display: flex; gap: 18px; justify-content: center; padding: 14px 0; }
.foot a { color: var(--muted); }
@media (min-width: 640px) { .pb { min-height: 62px; } .pb b { font-size: 1.08rem; } .pb span { font-size: .8rem; } .plab { width: 4.5em; font-size: .85rem; } }
