:root,
html[data-theme="yin"] {
  --bg: #12100e;
  --ink: #f3eadc;
  --muted: #9a8f82;
  --gold: #f8b500;
  --panel: #1b1815;
  --line: #3a342c;
  --yang: #f7ecd4;
  --yin: #12100e;
  --wagara: rgba(109, 51, 133, 0.10);
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  --safe-l: env(safe-area-inset-left);
  --safe-r: env(safe-area-inset-right);
}
html[data-theme="yang"] {
  --bg: #f7ecd4;
  --ink: #3a2e22;
  --muted: #8a7a68;
  --gold: #f8b500;
  --panel: #fff8ea;
  --line: #d4c4a8;
  --yang: #f7ecd4;
  --yin: #12100e;
  --wagara: rgba(46, 93, 75, 0.12);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
html[data-theme="yin"] body {
  background-color: var(--bg);
  background-image:
    linear-gradient(30deg, var(--wagara) 12%, transparent 12.5%, transparent 50%, var(--wagara) 50.5%, var(--wagara) 62%, transparent 62.5%),
    linear-gradient(150deg, var(--wagara) 12%, transparent 12.5%, transparent 50%, var(--wagara) 50.5%, var(--wagara) 62%, transparent 62.5%);
  background-size: 28px 48px;
}
html[data-theme="yang"] body {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% 100%, transparent 11px, var(--wagara) 12px, transparent 13px),
    radial-gradient(circle at 0 100%, transparent 11px, var(--wagara) 12px, transparent 13px),
    radial-gradient(circle at 100% 100%, transparent 11px, var(--wagara) 12px, transparent 13px);
  background-size: 32px 16px;
  background-position: 0 0, 16px 0, 16px 0;
}
body.playing {
  background-image: none;
}
#app { position: relative; }
.theme-btn {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
  width: 44px;
  height: 44px;
  max-width: 44px;
  max-height: 44px;
  overflow: hidden;
  touch-action: manipulation;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}
.theme-btn svg {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}
.theme-btn[data-mode="yang"] .ico-moon { display: none; }
.theme-btn[data-mode="yin"] .ico-sun { display: none; }
body.playing .theme-btn { display: none; }
.mark-tomoe {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -1px;
  color: var(--gold);
}
.kicker { letter-spacing: 0.2em; color: var(--gold); margin: 0; font-size: 12px; }
html:fullscreen .play,
html:fullscreen .play *,
html:-webkit-full-screen .play,
html:-webkit-full-screen .play * {
  cursor: none;
}
html:fullscreen #pause-ov,
html:fullscreen #pause-ov *,
html:fullscreen #raid-ov,
html:fullscreen #raid-ov *,
html:fullscreen #result-ov,
html:fullscreen #result-ov *,
html:fullscreen #raise-ov,
html:fullscreen #raise-ov *,
html:-webkit-full-screen #pause-ov,
html:-webkit-full-screen #pause-ov *,
html:-webkit-full-screen #raid-ov,
html:-webkit-full-screen #raid-ov *,
html:-webkit-full-screen #result-ov,
html:-webkit-full-screen #result-ov *,
html:-webkit-full-screen #raise-ov,
html:-webkit-full-screen #raise-ov * {
  cursor: auto;
}
#pause-ov,
#raid-ov,
#result-ov {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(12, 11, 10, 0.58);
  pointer-events: auto;
  overflow: auto;
  padding: 16px;
}
#pause-ov.hidden, #raid-ov.hidden, #result-ov.hidden { display: none !important; }
#pause-ov h1, #raid-ov h1, #result-ov h1 { color: var(--gold); }
#result-ov .col { width: min(360px, 100%); }
#result-ov .flag-card {
  width: auto;
  height: auto;
  max-width: min(220px, 58vw);
  max-height: min(42vh, 280px);
  object-fit: contain;
  aspect-ratio: 1080 / 1350;
}
#bossbars {
  position: absolute;
  left: 50%;
  bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 5;
  width: min(64vw, 340px);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}
#bossbars.pair { width: min(94vw, 560px); }
#bosshp, #moogrehp {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  z-index: 5;
  flex: 1;
  width: auto;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: none;
  pointer-events: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
#bosshp .bossava, #moogrehp .bossava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #f8b500;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(18, 16, 14, 0.35);
}
#bosshp .bossmeta, #moogrehp .bossmeta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#bosshp .bosslabel, #moogrehp .bosslabel {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  line-height: 1.2;
  padding: 2px 8px;
  border-radius: 999px;
  -webkit-text-stroke: 0;
  background: #fff8ea;
  color: #12100e;
  -webkit-text-fill-color: #12100e;
  text-shadow: none;
}
body.yang #bosshp .bosslabel, body.yang #moogrehp .bosslabel {
  background: #fff8ea;
  color: #12100e;
  -webkit-text-fill-color: #12100e;
  text-shadow: none;
}
body.yin #bosshp .bosslabel, body.yin #moogrehp .bosslabel {
  background: #1b1815;
  color: #f8b500;
  -webkit-text-fill-color: #f8b500;
  text-shadow: none;
}
#bosshp.hidden, #moogrehp.hidden { display: none !important; }
#bosshp.hit .hpbar, #moogrehp.hit .hpbar { box-shadow: 0 0 12px #f8b500; }
#bosshp.rage .hpbar, #moogrehp.rage .hpbar { box-shadow: 0 0 14px #ff3d8a; }
#bosshp .hpbar, #moogrehp .hpbar {
  width: 100%;
  flex: 1 1 auto;
  height: 10px;
  background: rgba(18, 16, 14, 0.2);
  border: 1px solid rgba(248, 181, 0, 0.85);
  box-shadow: 0 0 0 1px rgba(26, 20, 8, 0.45), 0 0 8px rgba(248, 181, 0, 0.2);
}
.hpbar.boss i { background: linear-gradient(90deg, #c94a4a, #f8b500); }
#ready {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(18, 16, 14, 0.42);
  pointer-events: none;
  color: #f8b500;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
#ready.hidden { display: none !important; }
#ready .readybar {
  display: block;
  width: min(52vw, 280px);
  height: 8px;
  border: 1px solid var(--gold);
  background: rgba(18, 16, 14, 0.28);
  overflow: hidden;
}
#ready .readybar i {
  display: block;
  height: 100%;
  width: 12%;
  background: var(--gold);
}
body.playing {
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  touch-action: none;
}
body.playing #app {
  max-width: none;
  width: 100vw;
  height: 100dvh;
  padding: 0;
  margin: 0;
}
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-t)) 16px calc(40px + var(--safe-b));
}
.screen { display: flex; flex-direction: column; gap: 14px; }
.screen:not([data-screen="play"]) {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px 22px;
}
.hidden { display: none !important; }
.dc-hello {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--gold);
  font-size: 18px;
}
.dc-hello.guest { color: var(--muted); font-size: 16px; }
.dc-mark {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: #5865f2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: transparent;
  text-decoration: none;
}
.dc-ask {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.dc-ask p { margin: 0 0 10px; }
.dc-mark svg {
  width: 13px;
  height: 10px;
  display: block;
  pointer-events: none;
}
.dc-mark.dc-mute {
  opacity: 0.45;
  filter: grayscale(1);
}
.dc-ava {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--line);
}
.ba-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ba-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}
.ba-n {
  width: 1.6em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ba-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ba-score {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.ba-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ba-ok {
  font-size: 11px;
  color: var(--gold);
}
.nan-card {
  margin: 14px 0;
  padding: 12px 14px;
  border: 2px solid var(--gold);
  border-radius: 14px;
  background: var(--bg);
}
.nan-card h2 {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 16px;
}
.ba-ph { display: inline-block; }
[data-katsudo-connect] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.kicker { letter-spacing: 0.2em; color: var(--gold); margin: 0; font-size: 12px; }
.ver {
  margin: 18px 0 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
  align-self: flex-end;
}
h1 { font-size: 28px; margin: 0; font-weight: 700; }
h2 { font-size: 13px; margin: 8px 0 0; color: var(--muted); font-weight: 600; }
.blurb, .hint, .thanks { color: var(--muted); margin: 0; line-height: 1.6; }
.thanks { color: var(--gold); font-size: 18px; }
.streak {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 8px;
}
.streak i {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg);
  box-shadow: inset 0 0 0 2px var(--panel);
}
.streak i.on {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: none;
}
.streak i.today {
  box-shadow: 0 0 0 3px rgba(248, 181, 0, 0.38);
}
.flag-card {
  width: auto;
  max-width: 360px;
  height: auto;
  object-fit: contain;
  align-self: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}
#raise-ov {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: var(--bg);
}
#raise-ov.hidden { display: none !important; }
#raise-ov h1 { color: var(--gold); }
#raise-ov .col { width: min(360px, 100%); }
.col, .row { display: flex; gap: 10px; }
.col { flex-direction: column; }
.row { justify-content: space-between; flex-wrap: wrap; }
.btn {
  appearance: none;
  touch-action: manipulation;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 14px 18px;
  min-height: 44px;
  font: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn.gold { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 700; }
.btn.ghost { background: var(--panel); color: var(--ink); }
.btn.tiny { padding: 8px 12px; font-size: 13px; min-height: 40px; }
.btn.on { outline: 2px solid var(--gold); }
.row .btn { flex: 1 1 140px; }
.chips, .mates { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .mate {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.chip.on, .mate.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.mate { min-width: 140px; flex: 1 1 140px; }
.mate img { display: block; height: 72px; width: auto; margin-bottom: 6px; pointer-events: none; }
.mate b { display: block; }
.mate span { color: var(--muted); font-size: 12px; }
.how { margin: 0; padding-left: 1.2em; color: var(--muted); line-height: 1.7; }
.play {
  max-width: none;
  padding: 0;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 2;
  background: #0c0b0a;
  gap: 0;
  display: block;
}
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px 6px;
  align-items: center;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l));
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  color: #fff8e8;
  text-shadow: 0 1px 2px #000, 0 0 8px #000;
  pointer-events: none;
}
#hud > span,
#hud .hpchip {
  background: rgba(12, 11, 10, 0.55);
  border: 1px solid rgba(248, 181, 0, 0.4);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
#hud .hpchip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#hud .btn { pointer-events: auto; }
#hud .pause {
  margin-left: auto;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  color: #fff8e8;
  background: #1b1815;
  border-color: rgba(248, 181, 0, 0.55);
}
#hud .pause svg {
  width: 12px;
  height: 14px;
  display: block;
  fill: currentColor;
  pointer-events: none;
}
#hud [data-hud-skill],
#hud [data-hud-combo],
#hud [data-hud-buff] { color: var(--gold); }
.hpbar {
  width: 92px;
  height: 12px;
  background: #2a2218;
  border-radius: 99px;
  overflow: hidden;
  display: inline-block;
  flex: 0 0 92px;
  border: 1px solid rgba(248, 181, 0, 0.7);
  box-shadow: inset 0 0 0 1px #1a1408;
}
.hpbar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c94a4a, #e07a7a);
  transform-origin: left center;
}
.hpbar.low i { animation: hpblink 0.55s ease-in-out infinite; }
@keyframes hpblink {
  50% { opacity: 0.35; }
}
.hpbar.heal i { background: linear-gradient(90deg, #2f9e8a, #7ecfff); }
.hpbar.heal { box-shadow: 0 0 12px #7ecfff; }
#fx {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
}
#fx.dmg { background: rgba(160, 30, 30, 0.32); animation: fxpop 320ms ease-out; }
#fx.heal { background: rgba(126, 207, 255, 0.28); animation: fxpop 320ms ease-out; }
#fx.stop { background: rgba(248, 181, 0, 0.42); }
#fx.graze { background: rgba(255, 244, 163, 0.22); animation: fxpop 200ms ease-out; }
#hud [data-hud-graze],
#hud [data-hud-score] { color: var(--gold); }
.play.combo::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 56px rgba(248, 181, 0, 0.4);
  animation: combopulse 480ms ease-in-out infinite;
}
@keyframes combopulse {
  50% { box-shadow: inset 0 0 80px rgba(255, 61, 138, 0.5); }
}
.hpbar.buff i { background: linear-gradient(90deg, #f8b500, #fff4a3); }
@keyframes fxpop {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
#arena {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #000;
  touch-action: none;
}
#arena canvas {
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#stick {
  position: absolute;
  left: calc(12px + var(--safe-l));
  bottom: calc(12px + var(--safe-b));
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1.5px solid rgba(248, 181, 0, 0.28);
  background: rgba(243, 234, 220, 0.08);
  z-index: 4;
  touch-action: none;
}
#stick.right {
  left: auto;
  right: calc(12px + var(--safe-r));
}
#bossbars.pair .bossava { width: 28px; height: 28px; }
#bossbars.pair .bosslabel { font-size: 10px; padding: 1px 6px; }
#stick-ov {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(12, 11, 10, 0.72);
}
#stick-ov.hidden { display: none !important; }
#stick-ov h1 { font-size: 40px; }
#stick-ov .row { width: min(280px, 90%); }
#stick-ov .btn[data-stick-back] { width: min(280px, 90%); }
#stick i {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(248, 181, 0, 0.42);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#rotate {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg);
  color: var(--gold);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  padding: 24px;
}
#rotate.hidden,
#stick.hidden { display: none !important; }
#toast-ov {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 16, 14, 0.38);
  pointer-events: auto;
  padding: 24px;
}
#toast-ov.hidden,
#raise-ov.hidden,
#stick-ov.hidden {
  display: none !important;
  pointer-events: none !important;
}
#toast-ov p {
  margin: 0;
  color: var(--gold);
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}
html:fullscreen #toast-ov,
html:fullscreen #toast-ov *,
html:-webkit-full-screen #toast-ov,
html:-webkit-full-screen #toast-ov * {
  cursor: auto;
}
@media (max-width: 900px), (max-height: 500px) {
  #hud { font-size: 10px; gap: 3px 4px; }
  #hud > span,
  #hud .hpchip { padding: 2px 6px; }
  .hpbar { width: 56px; flex: 0 0 56px; }
}
@media (orientation: landscape) and (max-height: 480px) {
  #result-ov {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 16px;
  }
  #result-ov .flag-card {
    max-height: 78vh;
    max-width: min(32vw, 200px);
  }
  #result-ov .col { width: min(260px, 46%); }
}
