/*
 * 影法師 Kageboushi — shadow-play fighter.
 *
 * The only landscape game on the site, and deliberately: a side-on fighter
 * needs the width, and two people sharing one phone works best with it flat
 * on the table between them. Everything else here is portrait one-thumb.
 */
.kb-stage { position: relative; overflow: hidden; touch-action: none; }
.kb-stage canvas#canvas { display: block; width: 100%; height: 100%; background: #0b0906; }

:root {
  --kb-ink: #14100c;
  --kb-paper: #f3e2ba;
  --kb-gold: #e0a83c;
  --kb-red: #c0392b;
  --kb-serif: "Shippori Mincho B1", "Hiragino Mincho ProN", Georgia, serif;
}
.kb-hud[hidden], .kb-screen[hidden], .kb-banner[hidden] { display: none !important; }

/* ---- HUD ---- */
.kb-hud { position: absolute; inset: 10px 14px auto 14px; display: flex;
  align-items: flex-start; gap: 10px; pointer-events: none; }
.kb-bar { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.kb-hp { display: block; height: 18px; background: rgba(20,14,8,.45);
  border: 2px solid var(--kb-ink); border-radius: 2px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,245,215,.35); }
.kb-hp i { display: block; height: 100%; width: 100%; background: var(--kb-paper);
  transition: width .12s linear; }
.kb-right .kb-hp { transform: scaleX(-1); }
.kb-wins { font-family: var(--kb-serif); font-size: 14px; color: var(--kb-ink);
  letter-spacing: .18em; }
.kb-right .kb-wins { text-align: right; }
.kb-clock { font-family: var(--kb-serif); font-size: 26px; color: var(--kb-ink);
  min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; }

.kb-banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%,-50%);
  font-family: var(--kb-serif); font-size: 40px; letter-spacing: .16em;
  color: var(--kb-ink); pointer-events: none;
  text-shadow: 0 2px 0 rgba(255,245,215,.55); }

/* ---- screens ---- */
.kb-screen { position: absolute; inset: auto; left: 50%; top: 50%;
  transform: translate(-50%,-50%); width: min(94%, 520px); max-height: 94%;
  overflow-y: auto; justify-content: flex-start;
  background: linear-gradient(180deg, rgba(26,19,12,.97), rgba(12,9,6,.98));
  border: 1px solid rgba(224,168,60,.3); border-radius: 16px;
  font-family: var(--kb-serif); color: var(--kb-paper);
  box-shadow: 0 22px 60px rgba(0,0,0,.65); z-index: 5; }
.kb-logo { text-align: center; margin: 0; }
.kb-logo span { display: block; font-size: 44px; letter-spacing: .14em; color: var(--kb-gold); }
.kb-logo em { display: block; font-style: normal; font-family: Inter, system-ui, sans-serif;
  font-size: 9px; letter-spacing: .3em; color: rgba(243,226,186,.5); margin-top: 6px; }
.kb-logo.kb-small span { font-size: 30px; }
.kb-screen p { font-size: 15px; line-height: 1.5; text-align: center;
  color: rgba(243,226,186,.85); }
.kb-fine { font-size: 12px !important; color: rgba(243,226,186,.45) !important; }
.kb-moves { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; width: 100%;
  font-size: 13px; color: rgba(243,226,186,.7); }
.kb-moves b { font-weight: 600; color: var(--kb-paper); }
.kb-moves .kb-wide { grid-column: 1 / -1; color: var(--kb-gold); }
.kb-levels { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.kb-lbl { font-family: Inter, system-ui, sans-serif; font-size: 8px; letter-spacing: .16em;
  color: rgba(243,226,186,.45); }
.kb-seg { font-family: Inter, system-ui, sans-serif; font-size: 10px; letter-spacing: .06em;
  padding: 7px 10px; background: rgba(255,255,255,.05); color: var(--kb-paper);
  border: 1px solid rgba(224,168,60,.28); border-radius: 999px; cursor: pointer; }
.kb-seg.on { background: var(--kb-gold); color: #26190a; border-color: var(--kb-gold); }
.kb-btn-gold { background: var(--kb-gold); color: #26190a; border: 0; border-radius: 999px;
  font-family: Inter, system-ui, sans-serif; font-weight: 700; font-size: 12px;
  letter-spacing: .14em; text-transform: uppercase; padding: 13px 26px; }
.kb-screen .jg-btn { border-radius: 999px; font-family: Inter, system-ui, sans-serif;
  font-size: 12px; letter-spacing: .12em; }
.kb-rotate { display: none; }

/* ---- touch pads: one half of the screen per player ---- */
.kb-pads { position: absolute; inset: 0; pointer-events: none; z-index: 2; display: none; }
body.kb-touch .kb-pads { display: block; }
.kb-pad { position: absolute; bottom: 0; top: 0; width: 50%; }
.kb-pad-l { left: 0; } .kb-pad-r { right: 0; }
.kb-b { position: absolute; pointer-events: auto; border-radius: 50%;
  background: rgba(20,14,8,.30); border: 2px solid rgba(20,14,8,.5);
  color: rgba(243,226,186,.92); font-family: var(--kb-serif); font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; }
.kb-b.on { background: var(--kb-gold); color: #26190a; border-color: #8a6414; }
.kb-dir, .kb-up, .kb-dn { width: 56px; height: 56px; }
.kb-hit, .kb-par { width: 64px; height: 64px; font-size: 13px; letter-spacing: .04em; }
.kb-par { width: 54px; height: 54px; font-size: 19px; }

/* left player: stick bottom-left, buttons above it */
.kb-pad-l .kb-dir[data-k="left"]  { left: 12px;  bottom: calc(14px + env(safe-area-inset-bottom,0px)); }
.kb-pad-l .kb-dir[data-k="right"] { left: 78px;  bottom: calc(14px + env(safe-area-inset-bottom,0px)); }
.kb-pad-l .kb-up  { left: 45px;  bottom: calc(76px + env(safe-area-inset-bottom,0px)); }
.kb-pad-l .kb-dn  { left: 45px;  bottom: calc(-46px + env(safe-area-inset-bottom,0px)); display:none; }
.kb-pad-l .kb-hit { left: 152px; bottom: calc(16px + env(safe-area-inset-bottom,0px)); }
.kb-pad-l .kb-par { left: 160px; bottom: calc(86px + env(safe-area-inset-bottom,0px)); }

/* right player mirrors it */
.kb-pad-r .kb-dir[data-k="right"] { right: 12px; bottom: calc(14px + env(safe-area-inset-bottom,0px)); }
.kb-pad-r .kb-dir[data-k="left"]  { right: 78px; bottom: calc(14px + env(safe-area-inset-bottom,0px)); }
.kb-pad-r .kb-up  { right: 45px;  bottom: calc(76px + env(safe-area-inset-bottom,0px)); }
.kb-pad-r .kb-dn  { right: 45px;  bottom: calc(-46px + env(safe-area-inset-bottom,0px)); display:none; }
.kb-pad-r .kb-hit { right: 152px; bottom: calc(16px + env(safe-area-inset-bottom,0px)); }
.kb-pad-r .kb-par { right: 160px; bottom: calc(86px + env(safe-area-inset-bottom,0px)); }

/* crouch shares the down direction: put it under the stick where a thumb rolls */
body.kb-touch .kb-pad .kb-dn { display: flex; bottom: calc(14px + env(safe-area-inset-bottom,0px)); }
.kb-pad-l .kb-dn { left: 45px; bottom: calc(76px + env(safe-area-inset-bottom,0px)); }
.kb-pad-l .kb-up { left: 45px; bottom: calc(138px + env(safe-area-inset-bottom,0px)); }
.kb-pad-r .kb-dn { right: 45px; bottom: calc(76px + env(safe-area-inset-bottom,0px)); }
.kb-pad-r .kb-up { right: 45px; bottom: calc(138px + env(safe-area-inset-bottom,0px)); }

/* portrait phone: say to turn it, since a fighter cannot use that shape */
@media (orientation: portrait) and (pointer: coarse) {
  .kb-rotate { display: block; color: var(--kb-gold) !important; }
}
@media (max-width: 560px) {
  .kb-logo span { font-size: 34px; }
  .kb-screen { gap: .6rem; padding: .9rem; }
  .kb-banner { font-size: 30px; }
}
