/* Full-screen menus: the home screen (living sumi-e plates that burn into one another and into the live vale), the pause kakejiku, options, the confirmation slip,
   the ledger of ema plaques (saves), and the verdict. Screens fade; scrolls unroll; menu items get a vermilion brush stroke on hover / focus. */
.screen { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; opacity: 0; transition: opacity .32s ease; }
.screen.shown { opacity: 1; }
.screen.leaving { opacity: 0; pointer-events: none; }
.screen.pause, .screen.options, .screen.saves, .screen.confirm { background: radial-gradient(ellipse at 50% 45%, rgba(14, 10, 8, .38), rgba(14, 10, 8, .86)); }
.screen.confirm { z-index: 35; background: rgba(14, 10, 8, .45); }
body[data-state="paused"] > canvas { filter: blur(2.5px) saturate(.7) brightness(.82); }
body[data-state="over"] > canvas { filter: saturate(.55); transition: filter 2s; }

/* ---------------------------------------------------------------------------------------------- ink menus */
.inkmenu { display: flex; flex-direction: column; }
.inkmenu button { position: relative; z-index: 0; display: block; padding: 8px 30px; font-size: 21px; font-weight: 600; letter-spacing: .03em; color: var(--washi-ink); text-align: center; transition: color .2s, transform .25s var(--ease-ink); }
.inkmenu button small { display: block; font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--washi-faint); margin-top: 1px; }
.inkmenu button::after { content: ""; position: absolute; z-index: -1; left: 50%; bottom: 3px; width: max(100%, 180px); height: 22px; transform: translateX(-50%); background: var(--shu); opacity: .9;
  -webkit-mask: url("img/stroke.svg") 0 0 / 100% 100%; mask: url("img/stroke.svg") 0 0 / 100% 100%; clip-path: inset(0 100% 0 0); transition: clip-path .42s var(--ease-ink); }
.inkmenu button:not(:disabled):hover::after, .inkmenu button:focus-visible::after { clip-path: inset(0 0 0 0); }
.inkmenu button:focus-visible { outline: none; }
.inkmenu button:disabled { opacity: .32; cursor: default; }
.inkmenu.row { flex-direction: row; gap: 26px; }

/* ---------------------------------------------------------------------------------------------- home screen */
.screen.title { display: block; z-index: 25; overflow: hidden; background: transparent; }
.title .paper { position: absolute; inset: 0; background: url("img/washi.svg") 0 0 / 320px, radial-gradient(130% 100% at 70% 40%, #efe4cb, #e1cfab 70%, #cbb487); transition: opacity .3s ease .5s; }   /* leaves only once the canvas (which paints the same sheet) is fully up */
.title.gl-live .paper { opacity: 0; }
.title .painting { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 95% 50%; opacity: 0; transition: opacity 1.6s ease .35s; }   /* crops toward the subject, like the renderer */
.title.no-gl .painting { opacity: 1; }
/* the backdrop renderer's canvas fades in over the identical static poster on its first frame (src/view/ui/backdrop) */
.title .backdrop-gl { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .4s ease; }
.title.gl-live .backdrop-gl { opacity: 1; }
.title:not(.no-gl) .petals { display: none; }
/* the plate's name, hung like a painting's label */
.plate-caption { position: absolute; right: 30px; bottom: 58px; display: flex; align-items: flex-end; gap: 12px; color: var(--paper-text); text-shadow: 0 2px 12px rgba(0, 0, 0, .75);
  opacity: 0; transform: translateY(8px); transition: opacity 1.1s ease, transform 1.1s var(--ease-ink); pointer-events: none; }
.plate-caption.on { opacity: .92; transform: none; }
.plate-caption .kanji { writing-mode: vertical-rl; font-size: 30px; letter-spacing: .08em; }
.plate-caption .name { font-size: 12px; letter-spacing: .3em; text-transform: uppercase; padding-bottom: 4px; }
/* departing into battle: the painting burns away into the battlefield while the menu and the ink veil withdraw */
.title.departing .titlecol, .title.departing .veil, .title.departing .veil2, .title.departing .titlefoot, .title.departing .plate-caption { opacity: 0; transition: opacity .9s ease; pointer-events: none; }
.title .veil { position: absolute; top: 0; bottom: 0; left: 0; width: min(760px, 62vw); background: var(--sumi); opacity: .9;
  -webkit-mask: url("img/veil.svg") 0 0 / 100% 100%; mask: url("img/veil.svg") 0 0 / 100% 100%; }
.title .veil2 { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(14, 10, 8, .75), rgba(14, 10, 8, .25) 30%, transparent 46%), radial-gradient(ellipse at 70% 50%, transparent 55%, rgba(14, 10, 8, .5)); }
.titlecol { position: absolute; left: clamp(28px, 7vw, 128px); top: 50%; transform: translateY(-52%); width: 460px; max-width: calc(100vw - 56px); }
.brand { display: flex; align-items: flex-start; gap: 26px; margin-bottom: 34px; }
.brand .vert { writing-mode: vertical-rl; font-size: clamp(53px, 8.6vh, 86px); color: var(--paper-text); letter-spacing: .04em; text-shadow: 0 4px 22px rgba(0, 0, 0, .6); }   /* five glyphs (two of them small) stand 4.4 em tall: the size follows the window's height, so the title column still fits a low window */
.brand .vert .no { font-size: .6em; color: var(--kin-hi); }
.brand h1 { margin: 6px 0 0; font-size: 62px; line-height: .98; font-weight: 800; letter-spacing: .06em; color: var(--paper-text); text-shadow: 0 3px 18px rgba(0, 0, 0, .55); }
.brand h1 em { display: block; font-style: normal; font-weight: 400; color: var(--kin-hi); letter-spacing: .14em; }
.brand .tag { margin: 16px 0 0; font-size: 15px; color: var(--paper-dim); max-width: 260px; }
.brand .seal { margin-top: 18px; }
.title .inkmenu { align-items: flex-start; }
.title .inkmenu button { color: var(--paper-text); font-size: 25px; padding: 8px 0 8px 38px; text-align: left; text-shadow: 0 2px 10px rgba(0, 0, 0, .55); }
.title .inkmenu button small { color: var(--paper-dim); font-size: 13px; text-shadow: none; }
.title .inkmenu button::before { content: ""; position: absolute; left: 10px; top: 21px; width: 13px; height: 13px; border-radius: 50%; background: var(--shu); box-shadow: 0 0 10px rgba(193, 57, 43, .7); transform: scale(0); transition: transform .25s var(--ease-ink); }
.title .inkmenu button::after { left: 30px; transform: none; width: 280px; bottom: 6px; opacity: .85; }
.title .inkmenu button:not(:disabled):hover, .title .inkmenu button:focus-visible { transform: translateX(6px); }
.title .inkmenu button:not(:disabled):hover::before, .title .inkmenu button:focus-visible::before { transform: scale(1); }
.loader { margin: 26px 0 0 38px; transition: opacity .8s; }
.loader .track { width: 300px; height: 15px; background: rgba(243, 232, 210, .14); -webkit-mask: url("img/stroke.svg") 0 0 / 100% 100%; mask: url("img/stroke.svg") 0 0 / 100% 100%; }
.loader .track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--kin-lo), var(--kin-hi)); transition: width .35s ease; }
.loader #loadmsg { display: block; margin-top: 8px; font-size: 13px; color: var(--paper-dim); }
.title.ready .loader { opacity: 0; pointer-events: none; }
.title.failed #loadmsg { color: #ff9a84; }
.titlefoot { position: absolute; right: 26px; bottom: 20px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--paper-dim); text-shadow: 0 1px 4px #000; }
/* starts readable: a page that has not painted its second frame yet (a background tab) still shows the title */
@keyframes rise { from { opacity: .3; transform: translateY(12px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }

/* the opening (html.intro, set before first paint for a visible page that welcomes motion): the ink veil sweeps in from the left, the title is
   written top to bottom with the brush, then the name, the line and the menu settle in; the renderer meanwhile inks the first painting onto the paper */
html.intro .title .veil { animation: veil-in 1.5s cubic-bezier(.6, 0, .25, 1) .15s both; }
html.intro .title .veil2 { animation: fade-in 1.8s ease .2s both; }
html.intro .brand .vert { -webkit-mask: linear-gradient(#000 44%, transparent 56%) 0 100% / 100% 240% no-repeat; mask: linear-gradient(#000 44%, transparent 56%) 0 100% / 100% 240% no-repeat;
  animation: write 1.9s cubic-bezier(.55, 0, .3, 1) .9s both; }
html.intro .brand h1 { animation: rise 1.3s var(--ease-ink) 1.9s both; }
html.intro .brand .tag { animation: rise 1.3s var(--ease-ink) 2.3s both; }
html.intro .title .inkmenu button { animation: rise .9s var(--ease-ink) both; }
html.intro .title .inkmenu button:nth-child(1) { animation-delay: 2.6s; } html.intro .title .inkmenu button:nth-child(2) { animation-delay: 2.72s; }
html.intro .title .inkmenu button:nth-child(3) { animation-delay: 2.84s; } html.intro .title .inkmenu button:nth-child(4) { animation-delay: 2.96s; }
html.intro .title .loader, html.intro .titlefoot { animation: fade-in 1.2s ease 2.4s both; }
@keyframes veil-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes write { from { -webkit-mask-position: 0 100%; mask-position: 0 100%; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* falling petals over the painting */
.petals { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.petals i { position: absolute; top: -4%; width: 13px; height: 9px; border-radius: 70% 0 70% 0; background: radial-gradient(circle at 30% 30%, #fde3ea, #f2a9bd 60%, #d9819b); opacity: .85; animation: fall linear infinite; }
.petals i:nth-child(1) { left: 52%; animation-duration: 15s; animation-delay: -2s; } .petals i:nth-child(2) { left: 61%; animation-duration: 19s; animation-delay: -8s; transform: scale(.7); }
.petals i:nth-child(3) { left: 70%; animation-duration: 13s; animation-delay: -5s; } .petals i:nth-child(4) { left: 78%; animation-duration: 21s; animation-delay: -12s; }
.petals i:nth-child(5) { left: 86%; animation-duration: 16s; animation-delay: -1s; } .petals i:nth-child(6) { left: 93%; animation-duration: 18s; animation-delay: -9s; }
.petals i:nth-child(7) { left: 44%; animation-duration: 22s; animation-delay: -15s; } .petals i:nth-child(8) { left: 66%; animation-duration: 14s; animation-delay: -10s; }
.petals i:nth-child(9) { left: 74%; animation-duration: 24s; animation-delay: -4s; } .petals i:nth-child(10) { left: 97%; animation-duration: 17s; animation-delay: -13s; }
.petals i:nth-child(11) { left: 57%; animation-duration: 20s; animation-delay: -17s; } .petals i:nth-child(12) { left: 82%; animation-duration: 12s; animation-delay: -6s; }
@keyframes fall {
  0% { transform: translate3d(0, 0, 0) rotate(0); }
  25% { transform: translate3d(-40px, 26vh, 0) rotate(110deg); }
  50% { transform: translate3d(-10px, 52vh, 0) rotate(220deg) rotateY(160deg); }
  75% { transform: translate3d(-70px, 78vh, 0) rotate(300deg); }
  100% { transform: translate3d(-50px, 108vh, 0) rotate(400deg) rotateY(360deg); }
}

/* ---------------------------------------------------------------------------------------------- kakejiku (pause, options) */
.kakejiku { width: 380px; }
.kakejiku.wide { width: 560px; }
.kakejiku .rod { position: relative; height: 18px; margin: 0 -18px; border-radius: 9px; background: linear-gradient(180deg, #6a432b, #2a170e 55%, #110905); box-shadow: inset 0 1px 0 rgba(255, 220, 170, .25), 0 4px 8px rgba(0, 0, 0, .5); z-index: 1; }
.kakejiku .rod::before, .kakejiku .rod::after { content: ""; position: absolute; top: -3px; width: 14px; height: 24px; border-radius: 7px; background: linear-gradient(180deg, var(--kin-hi), var(--kin-lo)); }
.kakejiku .rod::before { left: -10px; } .kakejiku .rod::after { right: -10px; }
.kakejiku .rod.low i { position: absolute; top: 14px; width: 2px; height: 46px; background: var(--shu-deep); }
.kakejiku .rod.low i::after { content: ""; position: absolute; bottom: -18px; left: -5px; width: 12px; height: 22px; border-radius: 40% 40% 50% 50%; background: linear-gradient(180deg, var(--shu), var(--shu-deep)); }
.kakejiku .rod.low i:first-child { left: 24px; } .kakejiku .rod.low i:last-child { right: 24px; }
.kakejiku .sheet { margin: -4px 0; padding: 34px 44px 30px; text-align: center; }
.screen.shown .kakejiku .sheet { animation: unrolldown .55s var(--ease-ink) both; }
@keyframes unrolldown { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
.kakejiku h2, .ledger h2 { margin: 12px 0 2px; font-size: 26px; font-weight: 800; color: var(--washi-ink); letter-spacing: .03em; }
.kakejiku .meta { margin: 0 0 16px; font-size: 13px; color: var(--washi-faint); }
.kakejiku .inkmenu { align-items: center; margin-top: 6px; }
.hint { margin: 14px 0 4px; font-size: 12.5px; color: var(--washi-faint); }

/* options */
.opts { margin: 16px 0 4px; text-align: left; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 5px 0; }
.options .opts { max-height: calc(100vh - 300px); overflow-y: auto; scrollbar-width: thin; padding-right: 2px; }        /* ten options and more: the list scrolls inside the scroll on a low window */
.options .opt { padding: 2px 0; }
.opt .lbl { font-size: 15.5px; font-weight: 600; color: var(--washi-ink); }
.optnote { margin: 0 0 6px; font-size: 13px; line-height: 1.35; font-style: italic; color: var(--washi-ink); opacity: 0.72; text-align: right; }        /* what an option says about the choice made (the enemy lord's line) */
.chooser { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 210px; padding: 5px 6px; border-radius: 999px; color: var(--washi-ink); transition: background .2s; }
.chooser b { font-weight: 700; font-size: 15px; }
.chooser .arr { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--shu-deep); transition: background .2s; }
.chooser:hover, .chooser:focus-visible { background: rgba(42, 31, 24, .08); outline: none; }
.chooser:hover .arr:hover { background: rgba(193, 57, 43, .14); }
.chooser:focus-visible { box-shadow: inset 0 0 0 1.5px rgba(193, 57, 43, .55); }

/* ---------------------------------------------------------------------------------------------- brush buttons */
/* the brush stroke is a masked layer BEHIND the label (masking the button itself would cut the letters where the brush runs dry) */
.inkbtn { --bg: var(--sumi-2); position: relative; z-index: 0; padding: 12px 32px 13px; font-size: 15px; font-weight: 700; letter-spacing: .04em; color: var(--paper-text); white-space: nowrap; transition: transform .2s var(--ease-ink); }
.inkbtn::before { content: ""; position: absolute; z-index: -1; inset: -2px -6px; background: var(--bg); transition: background .2s;
  -webkit-mask: url("img/stroke.svg") 0 0 / 100% 100%; mask: url("img/stroke.svg") 0 0 / 100% 100%; }
.inkbtn:hover, .inkbtn:focus-visible { --bg: var(--shu-deep); outline: none; transform: scale(1.04); }
.inkbtn.danger { --bg: var(--shu-deep); } .inkbtn.danger:hover, .inkbtn.danger:focus-visible { --bg: var(--shu); }

/* ---------------------------------------------------------------------------------------------- confirmation slip */
.slip { width: 420px; max-width: 86vw; padding: 30px 36px 26px; text-align: center; }
.screen.shown .slip { animation: rise .4s var(--ease-ink) both; }
.slip p { margin: 12px 0 22px; font-size: 17px; color: var(--washi-ink); line-height: 1.45; }
.slip .acts { display: flex; justify-content: center; gap: 12px; }

/* ---------------------------------------------------------------------------------------------- the ledger of ema (saves) */
.ledger { width: min(1140px, 94vw); }
.ledger .sheet { height: min(740px, 88vh); box-sizing: border-box; padding: 30px 44px 22px; display: flex; flex-direction: column; }
.screen.shown .ledger .sheet { animation: rise .45s var(--ease-ink) both; }
.ledger header { display: flex; align-items: center; gap: 16px; }
.ledger h2 { flex: 1; margin: 0; text-align: left; }
.ledger .close .icon { width: 22px; height: 22px; }
.newsave { display: flex; gap: 16px; align-items: center; margin: 16px 0 2px; }
.newsave input { flex: 1; min-width: 0; font: 600 19px var(--font); color: var(--washi-ink); background: url("img/stroke.svg") 0 100% / 100% 9px no-repeat; border: 0; padding: 10px 4px 14px; outline: none; }
.newsave input::placeholder { color: rgba(109, 90, 73, .7); }
.emas { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 24px 18px; padding: 20px 6px 12px; align-content: start; scrollbar-width: thin; scrollbar-color: rgba(42, 31, 24, .4) transparent; }
.ema { position: relative; justify-self: center; width: 214px; padding-top: 16px; }
.ema .cord { position: absolute; top: 0; left: 50%; width: 32px; height: 26px; transform: translateX(-50%); border: 3px solid var(--shu); border-bottom: 0; border-radius: 50% 50% 0 0; z-index: 1; }
.ema .board { position: relative; width: 214px; height: 292px; box-sizing: border-box; padding: 64px 14px 14px; display: flex; flex-direction: column; align-items: center; text-align: center; color: #2b1a0d;
  clip-path: path("M0 74 Q0 64 9 59 L98 6 Q107 0 116 6 L205 59 Q214 64 214 74 L214 281 Q214 292 203 292 L11 292 Q0 292 0 281 Z");
  background: repeating-linear-gradient(91deg, rgba(60, 30, 10, .07) 0 2px, transparent 2px 9px), repeating-linear-gradient(89deg, rgba(255, 230, 190, .08) 0 1px, transparent 1px 13px), linear-gradient(180deg, #d1a46b, #b8874d 60%, #a5763f);
  transition: transform .3s var(--ease-ink), filter .3s; transform-origin: 50% 0; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .3)); }
.ema .board > * { flex-shrink: 0; }
.ema .board::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 62px; background: linear-gradient(180deg, #4a2a12, #6e4220); }
.ema:hover .board, .ema:focus-within .board { transform: rotate(-1.4deg) translateY(-2px); }
.ema .pic { position: relative; width: 96px; height: 96px; margin-top: -24px; border-radius: 50%; overflow: hidden; flex: none; background: var(--sumi); display: grid; place-items: center; box-shadow: 0 0 0 3px #2b1a0d, 0 0 0 5.5px var(--kin), 0 4px 10px rgba(0, 0, 0, .4); }
.ema .pic img { width: 100%; height: 100%; object-fit: cover; }
.ema .pic .kanji { font-size: 46px; color: var(--paper-dim); }
.ema .kind { position: absolute; top: 62px; right: 22px; }
.ema h3 { margin: 8px 0 1px; font-size: 16px; font-weight: 800; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ema p { margin: 0; font-size: 12px; line-height: 1.45; }
.ema .when { font-weight: 600; }
.ema .meta, .ema .ago { color: rgba(43, 26, 13, .72); }
.ema .acts { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.ema .acts .inkbtn { padding: 9px 22px 10px; font-size: 14px; }
.ema .del { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--shu-deep); transition: background .2s, color .2s; }
.ema .del:hover { background: var(--shu-deep); color: var(--paper-text); }
.ema.kind-auto .board::before { background: linear-gradient(180deg, #2f2a3a, #4a4058); }
.ema.kind-quick .board::before { background: linear-gradient(180deg, #23352a, #3b5244); }
.empty { text-align: center; color: var(--washi-faint); margin: 60px 0; font-size: 16px; }

/* ---------------------------------------------------------------------------------------------- the verdict */
.screen.end { z-index: 28; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: radial-gradient(ellipse at 50% 42%, rgba(14, 10, 8, .25), rgba(14, 10, 8, .9)); }
.endmark { position: relative; width: 300px; height: 300px; }
.endenso { position: absolute; inset: 0; }
.screen.shown .endenso { animation: enso-in 1.4s var(--ease-ink) both; }
@keyframes enso-in { from { clip-path: circle(0 at 50% 50%); transform: rotate(-40deg); } to { clip-path: circle(75% at 50% 50%); transform: none; } }
.endmark .kanji { position: absolute; inset: 0; display: grid; place-items: center; font-size: 168px; text-shadow: 0 6px 30px rgba(0, 0, 0, .6); }
.end.win .endmark .kanji { color: var(--kin-hi); } .end.loss .endmark .kanji { color: #e04a37; }
.screen.shown .endmark .kanji { animation: rise 1s var(--ease-ink) .45s both; }
.end h1 { margin: 6px 0 0; font-size: 50px; font-weight: 800; letter-spacing: .42em; padding-left: .42em; text-transform: uppercase; color: var(--paper-text); }
.end .sub { margin: 6px 0 0; font-size: 16px; color: var(--paper-dim); }
.endstats { display: flex; gap: 52px; margin: 26px 0 30px; }
.endstats b { display: block; font-size: 30px; font-weight: 800; color: var(--paper-text); font-variant-numeric: tabular-nums; }
.endstats span { font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--paper-dim); }
.end .inkmenu button { color: var(--paper-text); }
.end .inkmenu button small { color: var(--paper-dim); }

.crest.close { width: 42px; height: 42px; }
