:root { color-scheme: dark; font: 600 14px system-ui, sans-serif; color: #f3efff; background: #0e0b1b; }
* { box-sizing: border-box; }
body { margin: 0; }
#app { height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
#boot-stage { position: relative; display: grid; place-items: center; width: 100%; height: 100%; min-height: 0; overflow: hidden; }
#boot-stage > img { width: 86%; height: 84%; object-fit: contain; }
#boot-status { min-height: 54px; }
#card-stage { position: relative; display: grid; place-items: center; overflow: hidden; }
#card-stage img { width: 86%; height: 84%; object-fit: contain; }
#card-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; visibility: hidden; }
#card-stage.ready canvas { visibility: visible; }
#card-stage.ready img { visibility: hidden; }
.kni-loading-overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background: rgb(11 9 23 / 92%);
  color: #f3efff;
  pointer-events: none;
}
.kni-loading-content {
  display: grid;
  justify-items: center;
  gap: 13px;
  width: min(440px, 88vw);
  text-align: center;
}
.kni-loading-animation {
  width: min(128px, 34vw);
  aspect-ratio: 32 / 39;
  overflow: hidden;
}
.kni-loading-animation img {
  display: block;
  width: 400%;
  height: 100%;
  max-width: none;
  object-fit: fill;
  animation: kni-forge-frames 880ms steps(1, end) infinite;
  will-change: transform;
}
.kni-loading-bar {
  position: relative;
  width: min(360px, 80vw);
  height: 13px;
  overflow: hidden;
  border: 1px solid #8c6bb5;
  border-radius: 999px;
  background: #151124;
  box-shadow: 0 0 16px rgb(104 222 255 / 18%), inset 0 1px 3px #000a;
}
.kni-loading-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38c8f3, #ff5fc0 60%, #ffe08a);
  box-shadow: 0 0 12px rgb(255 96 193 / 65%);
  transition: width 180ms ease-out;
}
.kni-loading-bar[data-indeterminate="true"] span {
  width: 32% !important;
  animation: kni-loading-sweep 1.15s ease-in-out infinite alternate;
}
.kni-loading-status {
  min-height: 1.5em;
  margin: 0;
  color: #e8def4;
  font-size: clamp(13px, 1.9vw, 16px);
  font-weight: 650;
  letter-spacing: .015em;
  text-shadow: 0 1px 4px #080611;
}
@keyframes kni-forge-frames {
  0% { transform: translateX(0); }
  25% { transform: translateX(-25%); }
  50% { transform: translateX(-50%); }
  75%, 100% { transform: translateX(-75%); }
}
@keyframes kni-loading-sweep {
  from { transform: translateX(-120%); }
  to { transform: translateX(320%); }
}
.controls { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 54px; padding: 6px; }
button { font: inherit; min-width: 44px; min-height: 42px; padding: 4px 12px; color: inherit;
  background: #1d1831; border: 1px solid #544665; border-radius: 24px; cursor: pointer; }
button:hover:not(:disabled), button:focus-visible { border-color: #49e4ff; outline-color: #49e4ff; }
button:disabled { opacity: .55; cursor: wait; }

body:has(#account-binder-stage) { overflow: hidden; }
body:has(#account-binder-stage) #app { display: block; height: 100%; overflow: hidden; }
#account-binder-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #322043, #0e0b1b 72%);
  touch-action: none;
  outline: none;
}
#account-binder-stage canvas { display: block; width: 100%; height: 100%; outline: none; }
.binder-turn-controls {
  position: absolute;
  inset: auto 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}
.binder-turn-controls button {
  width: 54px;
  height: 54px;
  padding: 0;
  border-color: #9b75c1;
  background: #171126df;
  box-shadow: 0 5px 18px #0008;
  font-size: 26px;
  pointer-events: auto;
}
.binder-turn-controls span {
  padding: 8px 14px;
  border: 1px solid #59456f;
  border-radius: 999px;
  background: #171126df;
  color: #ded4ea;
  font-size: 13px;
  pointer-events: none;
}
.binder-caption {
  position: absolute;
  inset: 14px auto auto 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  border: 1px solid #59456f;
  border-radius: 999px;
  background: #171126df;
  color: #ded4ea;
  font-size: 13px;
  transform: translateX(-50%);
  pointer-events: auto;
}
.binder-caption:empty { display: none; }
.binder-caption a { color: #ff9ad8; text-decoration: underline; }
@media (max-width: 540px) {
  .binder-turn-controls { bottom: 10px; gap: 8px; }
  .binder-turn-controls button { width: 48px; height: 48px; }
  .binder-turn-controls span { max-width: 190px; font-size: 11px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .kni-loading-animation img { animation-duration: 2.4s; }
  .kni-loading-bar[data-indeterminate="true"] span { animation-duration: 2.4s; }
}
