html, body { overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }

.title-art { width: 100%; max-width: 288px; height: auto; image-rendering: pixelated; align-self: center; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; }
.title-note { margin: 0; color: var(--muted); font-size: 13px; }

.console {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #0e0b16;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.stage {
  position: relative;
  flex: none;
  width: min(100%, 640px, calc((100dvh - 236px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 240 / 208));
  aspect-ratio: 240 / 208;
  container-type: inline-size;
  overflow: hidden;
  background: #000;
}
.stage canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.stage #view3d { image-rendering: auto; }

.fade { position: absolute; inset: 0; background: #0e0b16; opacity: 0; pointer-events: none; transition: opacity .22s linear; }
.fade.on { opacity: 1; }

.place {
  position: absolute;
  top: 3cqw;
  left: 3cqw;
  padding: 1.2cqw 3cqw;
  font-size: clamp(12px, 3.6cqw, 20px);
  font-weight: 800;
  background: rgba(22, 19, 31, .86);
  border-left: 4px solid var(--sun);
}

.tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 0 1.2cqw;
  font-size: clamp(9px, 2.7cqw, 15px);
  font-weight: 800;
  white-space: nowrap;
  color: #fff6e6;
  background: rgba(22, 19, 31, .78);
  border-radius: 3px;
}

.invite {
  position: fixed;
  z-index: 40;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 800;
  background: var(--panel);
  border: 2px solid var(--sun);
  border-radius: 8px;
}
.invite span { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.invite .btn { flex: 1; }

.dialog {
  position: absolute;
  left: 2cqw;
  right: 2cqw;
  bottom: 2cqw;
  min-height: 17cqw;
  padding: 2.4cqw 3.4cqw;
  background: #fff6e6;
  color: #231a2c;
  border: 3px solid #231a2c;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px #e2b873;
}
.dialog p { margin: 0; font-size: clamp(14px, 4.2cqw, 23px); font-weight: 600; line-height: 1.32; }
#dialogMore {
  position: absolute;
  right: 3cqw;
  bottom: 1.6cqw;
  width: 0;
  height: 0;
  border: 1.5cqw solid transparent;
  border-top-color: var(--hot);
  border-bottom-width: 0;
  animation: bob .7s ease-in-out infinite alternate;
}
@keyframes bob { to { transform: translateY(1cqw); } }

.hud {
  position: absolute;
  width: 44cqw;
  padding: 1.2cqw 2.2cqw 1.4cqw;
  color: #231a2c;
  background: #fff6e6;
  border: 2px solid #231a2c;
  border-radius: 5px;
}
.hud.foe { top: 3.5cqw; left: 3cqw; }
.hud.me { top: 50cqw; right: 3cqw; }
.hud-top, .hud-bottom { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.hud-name { font-size: clamp(12px, 3.8cqw, 21px); font-weight: 900; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-lv { font-size: clamp(10px, 3cqw, 17px); font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-num { font-size: clamp(10px, 3cqw, 17px); font-weight: 800; font-variant-numeric: tabular-nums; margin-left: auto; }
.hud-st { font-size: clamp(9px, 2.5cqw, 14px); font-weight: 900; color: #fff; padding: 0 1cqw; border-radius: 3px; }
.hud-st:empty { display: none; }
.hud-bottom { min-height: 1.1em; }
.hud.foe .hud-bottom { min-height: 0; }

.bar { height: 1.9cqw; min-height: 6px; margin-top: .6cqw; background: #3b3144; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: #4cc265; transition: width .42s ease-out, background-color .2s; }
.bar i.mid { background: #e9b52c; }
.bar i.low { background: #e0483a; }
.bar.xp { height: 1.1cqw; min-height: 3px; }
.bar.xp i { background: #4d9de0; }

.deck { flex: 1; width: 100%; max-width: 640px; min-height: 0; display: flex; padding: 10px 14px; }

.pad { flex: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.dpad {
  position: relative;
  justify-self: start;
  width: min(162px, 42vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #2b2439 58%, #231e31 59%);
  touch-action: none;
}
.dpad::before, .dpad::after { content: ""; position: absolute; background: #41385a; border-radius: 8px; }
.dpad::before { left: 34%; right: 34%; top: 8%; bottom: 8%; }
.dpad::after { top: 34%; bottom: 34%; left: 8%; right: 8%; }
.arrow { position: absolute; z-index: 1; width: 0; height: 0; border: 8px solid transparent; opacity: .75; pointer-events: none; }
.arrow.up { top: 13%; left: calc(50% - 8px); border-bottom-color: var(--ink); border-top-width: 0; }
.arrow.down { bottom: 13%; left: calc(50% - 8px); border-top-color: var(--ink); border-bottom-width: 0; }
.arrow.left { left: 13%; top: calc(50% - 8px); border-right-color: var(--ink); border-left-width: 0; }
.arrow.right { right: 13%; top: calc(50% - 8px); border-left-color: var(--ink); border-right-width: 0; }
.dpad[data-dir="up"] .arrow.up, .dpad[data-dir="down"] .arrow.down, .dpad[data-dir="left"] .arrow.left, .dpad[data-dir="right"] .arrow.right { opacity: 1; filter: drop-shadow(0 0 4px var(--sun)); }

.centre { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.pill {
  min-width: 72px;
  min-height: 34px;
  padding: 2px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.actions-ab { position: relative; justify-self: end; width: min(136px, 34vw); aspect-ratio: 1.1; }
.round {
  position: absolute;
  width: 56%;
  aspect-ratio: 1;
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  color: #1d0f0a;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  touch-action: none;
}
.round.a { right: 0; top: 0; background: var(--hot); }
.round.b { left: 0; bottom: 0; background: var(--sun); }
.round:active { transform: scale(.94); }

.battle-menu { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(64px, 84px); gap: 8px; align-content: center; }
.battle-menu button {
  min-height: 52px;
  padding: 4px 10px;
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  font-style: italic;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-bottom-width: 5px;
  border-radius: 8px;
  cursor: pointer;
}
.battle-menu button:active { transform: translateY(2px); }
.battle-menu button:focus-visible, .sheet button:focus-visible, .pill:focus-visible { outline: 3px solid var(--sun); outline-offset: 1px; }
.battle-menu .fight { background: var(--hot); border-color: #b63b1f; color: #1d0f0a; }
.battle-menu .move { display: flex; flex-direction: column; justify-content: center; font-size: 16px; line-height: 1.15; text-align: left; border-color: var(--type); border-left-width: 8px; }
.battle-menu .move small { font-size: 12px; font-weight: 700; font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.battle-menu .move:disabled { opacity: .45; }
.battle-menu .wide { grid-column: 1 / -1; min-height: 40px; font-size: 14px; font-style: normal; }

.sheet { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--night); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 2px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 900; font-style: italic; color: var(--ink); text-transform: none; letter-spacing: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: 12px 16px 24px; width: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
button.row:active { transform: translateY(1px); }
.row:disabled { opacity: .5; cursor: default; }
.row.lead { border-color: var(--sun); }
.row img { flex: none; width: 56px; height: 56px; image-rendering: pixelated; }
.row img.unknown { filter: brightness(0) opacity(.55); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 800; }
.row-title small { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .cabar { flex: none; min-height: 40px; padding: 0 10px; }
input { -webkit-user-select: text; user-select: text; }
.name-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.sheet-body { color-scheme: dark; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head img { flex: none; width: 88px; height: 99px; image-rendering: pixelated; background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 6px; }
.profile-head div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-name { font-size: 24px; font-weight: 900; font-style: italic; overflow-wrap: anywhere; }
.profile-title { color: var(--sun); font-weight: 800; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { display: flex; flex-direction: column; padding: 8px 10px; background: var(--panel); border-radius: 8px; }
.stat small { color: var(--muted); font-size: 12px; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.team-strip { display: flex; flex-wrap: wrap; gap: 4px; }
.team-strip img { width: 52px; height: 52px; image-rendering: pixelated; background: var(--panel); border-radius: 8px; }
.look-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.look { padding: 6px; background: var(--panel); border: 2px solid var(--line); border-radius: 8px; cursor: pointer; }
.look.on { border-color: var(--sun); }
.look img { display: block; width: 100%; aspect-ratio: 16 / 18; image-rendering: pixelated; }
.row-sub { color: var(--muted); font-size: 13px; line-height: 1.3; }
.row .bar { height: 7px; margin-top: 0; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { padding: 1px 7px; font-size: 11px; font-weight: 900; font-style: normal; color: #fff; border-radius: 4px; }
.section-label { margin: 8px 0 0; }
.money { color: var(--sun); font-weight: 900; font-variant-numeric: tabular-nums; }
.starter-grid { display: flex; flex-direction: column; gap: 8px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions .btn { flex: 1 1 120px; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-mark { flex: 1 1 90px; padding: 10px 6px; text-align: center; font-size: 13px; font-weight: 800; color: var(--muted); background: var(--panel); border: 2px dashed var(--line); border-radius: 8px; }
.badge-mark.on { color: #1d0f0a; background: var(--sun); border: 2px solid var(--sun); }

@media (orientation: landscape) and (max-height: 560px) {
  .console { flex-direction: row; justify-content: center; }
  .stage { width: auto; height: 100%; }
  .deck { max-width: none; align-items: center; }
  .pad { height: 100%; }
  .dpad { width: min(150px, 38dvh + 20px); }
}

@media (prefers-reduced-motion: reduce) {
  #dialogMore { animation: none; }
  .bar i, .fade { transition-duration: .01s; }
}
