:root {
  --ink: #f8fbff;
  --dark: #101820;
  --panel: rgba(16, 24, 32, 0.72);
  --line: rgba(255, 255, 255, 0.16);
  --acid: #d9ff45;
  --pink: #ff4f7a;
  --blue: #35c6ff;
  --paper: #f7f0da;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 79, 122, 0.38), transparent 19rem),
    radial-gradient(circle at 80% 72%, rgba(53, 198, 255, 0.34), transparent 20rem),
    linear-gradient(135deg, #101820, #172638 52%, #222b24);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

.app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #f7f0da;
  touch-action: none;
}

.xp-layer {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 50%;
  color: var(--acid);
  font-size: 24px;
  font-weight: 1000;
  pointer-events: none;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 18px rgba(217, 255, 69, 0.45);
  transform: translate(-50%, 18px);
  opacity: 0;
}

.xp-layer.pop {
  animation: xp-pop 620ms ease-out both;
}

.hud {
  position: absolute;
  z-index: 4;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.top-hud {
  left: 12px;
  right: auto;
  top: calc(10px + var(--safe-top));
  display: grid;
  grid-template-columns: 58px 58px 48px 48px;
  gap: 5px;
  align-items: center;
  min-height: 42px;
  padding: 5px;
  border-radius: 15px;
  opacity: 0.86;
}

.score-box {
  min-width: 0;
  border-radius: 10px;
}

.score-box span,
.title-lockup span,
.name-field span,
.avatar-title span {
  display: block;
  color: rgba(248, 251, 255, 0.64);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.score-box {
  display: grid;
  place-items: center;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.1);
}

.score-box.compact {
  min-height: 42px;
}

.score-box.compact strong {
  font-size: 17px;
}

.score-box strong {
  font-size: 15px;
  line-height: 1;
}

.side-hud {
  right: 12px;
  top: calc(10px + var(--safe-top));
  width: 104px;
  padding: 7px;
  border-radius: 14px;
  opacity: 0.78;
}

.side-hud h2 {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-hud ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-hud li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 5px;
  align-items: center;
  min-width: 0;
  font-size: 11px;
  font-weight: 800;
}

.side-hud .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: calc(91px + var(--safe-top));
  max-width: min(62vw, 340px);
  min-height: 30px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.62);
  color: #fff7b7;
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.notice:empty {
  display: none;
}

.power-dock {
  position: absolute;
  z-index: 5;
  right: 16px;
  bottom: calc(20px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, 54px);
  gap: 8px;
}

.power-button {
  position: relative;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  background: rgba(16, 24, 32, 0.78);
  box-shadow: 0 9px 22px rgba(0, 0, 0, 0.26);
  color: var(--ink);
  font-size: 25px;
  backdrop-filter: blur(12px);
}

.power-count {
  position: absolute;
  right: -3px;
  top: -6px;
  display: grid;
  min-width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 999px;
  background: var(--acid);
  color: #101820;
  font-size: 12px;
  font-weight: 1000;
}

.power-button.empty {
  color: rgba(248, 251, 255, 0.3);
  font-size: 20px;
}

.power-button:disabled {
  opacity: 0.52;
}

.power-button:not(:disabled):active {
  transform: translateY(4px);
}

.join-modal,
.home-modal {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  background:
    radial-gradient(circle at 22% 16%, rgba(217, 255, 69, 0.25), transparent 16rem),
    rgba(5, 10, 16, 0.62);
  backdrop-filter: blur(10px);
}

.join-modal.hidden,
.home-modal.hidden {
  display: none;
}

.join-panel,
.home-panel {
  width: min(100%, 420px);
  max-height: 100%;
  overflow: auto;
  padding: 22px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  background: rgba(16, 24, 32, 0.88);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.36);
}

.home-panel {
  display: grid;
  gap: 14px;
  text-align: center;
}

.title-lockup h1 {
  margin: 3px 0 18px;
  color: var(--acid);
  font-size: clamp(42px, 14vw, 66px);
  line-height: 0.86;
}

.name-field {
  display: grid;
  gap: 8px;
}

.name-field input {
  width: 100%;
  min-height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  padding: 0 14px;
  font-size: 18px;
  font-weight: 900;
  outline: 0;
}

.name-field input:focus {
  border-color: var(--acid);
}

.avatar-wrap {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.avatar-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.avatar-title strong {
  color: rgba(248, 251, 255, 0.72);
  font-size: 12px;
  text-align: right;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.avatar {
  position: relative;
  min-height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 30px;
}

.avatar.selected {
  border-color: var(--acid);
  background: rgba(217, 255, 69, 0.16);
}

.avatar.locked {
  filter: grayscale(1);
  opacity: 0.42;
}

.avatar.locked::after {
  position: absolute;
  right: 5px;
  top: 4px;
  content: "🔒";
  font-size: 13px;
}

.start-button {
  width: 100%;
  min-height: 56px;
  margin-top: 18px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--acid), #93d927);
  box-shadow: 0 9px 0 #5d8b19, 0 18px 28px rgba(0, 0, 0, 0.24);
  color: #172111;
  font-size: 19px;
  font-weight: 1000;
}

.fresh-button {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(248, 251, 255, 0.78);
  font-size: 14px;
  font-weight: 900;
}

.result-label {
  color: var(--acid);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.home-panel h2 {
  margin: 0;
  font-size: clamp(36px, 11vw, 58px);
  line-height: 0.9;
}

.round-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.round-stats div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
}

.round-stats span {
  color: rgba(248, 251, 255, 0.64);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.round-stats strong {
  color: var(--ink);
  font-size: 20px;
}

.xp-track {
  height: 18px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.xp-fill {
  width: 5%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--acid), var(--blue), var(--pink));
  transition: width 500ms ease;
}

.home-panel p {
  margin: 0;
  color: rgba(248, 251, 255, 0.74);
  font-size: 14px;
  font-weight: 800;
}

.store {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  max-height: 168px;
  overflow: auto;
  padding-right: 2px;
}

.store-item {
  display: grid;
  gap: 2px;
  min-height: 58px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.store-item span {
  font-size: 24px;
}

.store-item strong {
  color: var(--acid);
  font-size: 10px;
}

.store-item.owned {
  border-color: rgba(217, 255, 69, 0.48);
}

.store-item:disabled:not(.owned) {
  opacity: 0.38;
}

@keyframes xp-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 22px) scale(0.85);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -38px) scale(1.08);
  }
}

.start-button:active {
  transform: translateY(5px);
  box-shadow: 0 4px 0 #5d8b19, 0 12px 18px rgba(0, 0, 0, 0.24);
}

@media (min-width: 760px) {
}

@media (max-height: 700px) {
  .side-hud {
    display: none;
  }

  .top-hud {
    grid-template-columns: 54px 54px 44px 44px;
    gap: 5px;
  }
}
