html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0618;
  --font: "Arial Black", "Trebuchet MS", sans-serif;
  --gold: #ffd77a;
  --ink: #1a0b33;
}
#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#ui {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  font-family: var(--font);
}
#ui > .screen {
  pointer-events: auto;
}
.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 420px);
  max-height: 96vh;
  box-sizing: border-box;
}
.screen.full {
  position: absolute;
  inset: 0;
  width: auto;
  max-height: none;
  justify-content: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 4vw calc(14px + env(safe-area-inset-bottom, 0px));
  background: radial-gradient(ellipse at 50% 40%, rgba(30, 14, 60, 0.35), rgba(8, 3, 20, 0.82));
}
.screen.full > .panel {
  max-width: 420px;
}
.logo-small {
  width: min(70vw, 300px);
  max-height: 18vh;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
  margin-bottom: 4px;
}
.panel {
  box-sizing: border-box;
  width: 100%;
  border-style: solid;
  border-width: 26px;
  border-color: transparent;
  border-image: var(--panel-bi, url("../assets/ui-panel.png") 22% fill / 26px stretch);
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.55));
  overflow-y: auto;
  max-height: 78vh;
}
.ptitle {
  text-align: center;
  color: var(--gold);
  font: 900 26px var(--font);
  letter-spacing: 0.03em;
  text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink), 0 4px 0 rgba(0, 0, 0, 0.4);
}
.txt {
  color: #f2ecff;
  font: 800 15px var(--font);
  text-align: center;
  line-height: 1.45;
  text-shadow: 0 2px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink);
}
.txt.small {
  font-size: 13px;
  color: #cfc4ef;
}
.txt.err {
  color: #ff9aa6;
  min-height: 1.2em;
}
.btn {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  min-height: 54px;
  min-width: 44px;
  border-style: solid;
  border-width: 12px 15px;
  border-color: transparent;
  border-image: var(--btn-bi, url("../assets/ui-button.png") 30% 16% fill / 14px 18px stretch);
  background: transparent;
  padding: 2px 6px;
  color: #fffbe8;
  font: 900 18px var(--font);
  letter-spacing: 0.02em;
  cursor: pointer;
  text-shadow: 2px 0 0 #0d3320, -2px 0 0 #0d3320, 0 2px 0 #0d3320, 0 -2px 0 #0d3320, 2px 2px 0 #0d3320, -2px 2px 0 #0d3320, 2px -2px 0 #0d3320, -2px -2px 0 #0d3320, 0 4px 0 rgba(0, 0, 0, 0.35);
  transition: transform 90ms ease-out, filter 120ms ease-out;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.12;
}
.btn .sub {
  font: 800 12px var(--font);
  color: #d9ffe6;
  opacity: 0.95;
  margin-top: 2px;
}
.btn.big {
  min-height: 70px;
  font-size: 22px;
}
.btn.alt {
  filter: hue-rotate(230deg) saturate(1.1);
}
.btn.alt.focus,
.btn.alt:hover {
  filter: hue-rotate(230deg) saturate(1.2) brightness(1.2);
}
.btn.focus,
.btn:hover {
  filter: brightness(1.2) saturate(1.1);
  transform: translateY(-2px) scale(1.02);
}
.btn:active {
  transform: translateY(2px) scale(0.96);
}
.btn[disabled] {
  filter: grayscale(0.8) brightness(0.7);
  cursor: default;
}
.row {
  display: flex;
  gap: 10px;
}
.row > * {
  flex: 1 1 0;
}
.row > .btn {
  font-size: 16px;
}
.namebar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.namebar .nm {
  color: #fff;
  font: 900 17px var(--font);
  text-shadow: 0 2px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink);
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.namebar .lbl {
  color: var(--gold);
  font: 900 14px var(--font);
  text-shadow: 0 2px 0 var(--ink);
}
.namebar .btn {
  min-height: 46px;
  font-size: 15px;
  flex: 0 0 auto;
  padding: 0 10px;
}
.field {
  box-sizing: border-box;
  width: 100%;
  height: 54px;
  border: 3px solid #e8b44a;
  border-radius: 10px;
  background: rgba(8, 3, 22, 0.85);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.6), 0 0 0 2px #2a1846;
  color: #fff;
  font: 900 22px var(--font);
  text-align: center;
  outline: none;
  letter-spacing: 0.06em;
}
.field:focus {
  border-color: #fff2b0;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.6), 0 0 12px rgba(255, 215, 122, 0.7);
}
.code {
  text-align: center;
  font: 900 52px var(--font);
  letter-spacing: 0.18em;
  color: #fff6c8;
  text-shadow: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 0 6px 0 rgba(0, 0, 0, 0.4), 0 0 18px rgba(255, 210, 90, 0.6);
}
.list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #f2ecff;
  font: 800 15px var(--font);
  text-shadow: 0 2px 0 var(--ink);
}
.li.me {
  background: rgba(255, 215, 122, 0.22);
  box-shadow: inset 0 0 0 2px rgba(255, 215, 122, 0.6);
}
.li .rk {
  width: 2em;
  color: var(--gold);
  font-weight: 900;
}
.li .nm {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.li .sc {
  font-weight: 900;
  color: #9dffc0;
}
.li .dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: 0 0 6px currentColor;
}
.tag {
  font: 900 11px var(--font);
  padding: 2px 6px;
  border-radius: 6px;
  background: #e8b44a;
  color: #2a1846;
  text-shadow: none;
}
.place {
  text-align: center;
  font: 900 46px var(--font);
  color: #ffd23a;
  text-shadow: 3px 0 0 #3a1660, -3px 0 0 #3a1660, 0 3px 0 #3a1660, 0 -3px 0 #3a1660, 0 7px 0 rgba(0, 0, 0, 0.4), 0 0 24px rgba(255, 200, 60, 0.7);
}
.stats {
  display: flex;
  justify-content: center;
  gap: 18px;
}
.stat {
  text-align: center;
}
.stat .v {
  font: 900 34px var(--font);
  color: #9dffc0;
  text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 0 5px 0 rgba(0, 0, 0, 0.4);
}
.stat .k {
  font: 900 13px var(--font);
  color: var(--gold);
  text-shadow: 0 2px 0 var(--ink);
}
.record {
  text-align: center;
  font: 900 20px var(--font);
  color: #ff9ae0;
  min-height: 1.2em;
  text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(255, 120, 220, 0.8);
}
.pop {
  animation: pop 320ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.slam {
  animation: slam 420ms cubic-bezier(0.3, 1.7, 0.6, 1) both;
}
.rise {
  animation: rise 300ms ease-out both;
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.75); }
  to { opacity: 1; transform: none; }
}
@keyframes slam {
  from { opacity: 0; transform: scale(2.2); }
  to { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
#intro-wrap {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  background: #000 url("../assets/cover-bg.png") center / cover no-repeat;
}
#intro {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#skip {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  min-height: 48px;
  font-size: 16px;
  padding: 0 12px;
}
#subtitle {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  z-index: 30;
  max-width: 86vw;
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(10, 4, 26, 0.6);
  color: #fff4d0;
  font: 900 18px var(--font);
  text-align: center;
  text-shadow: 0 2px 0 var(--ink);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms;
}
#subtitle.on {
  opacity: 1;
}
#fade {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #1a0b33 0%, #05020c 70%);
  opacity: 0;
  transition: opacity 260ms ease;
}
#fade.on {
  opacity: 1;
}
