:root {
  --bg-0: #fff2fb;
  --bg-1: #ffdff4;
  --card: rgba(255, 255, 255, 0.92);
  --ink: #2b1431;
  --muted: #7b4b73;
  --line: #f1c2e5;
  --blue: #ea3ea6;
  --blue-dark: #bf257f;
  --gold: #f3b21e;
  --top-hud-height: 62px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 0%, #ffe2f4, transparent 40%),
    radial-gradient(circle at 100% 100%, #ffd3ee, transparent 35%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1));
}

.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 212, 238, 0.95), rgba(255, 235, 247, 0.96)),
    linear-gradient(165deg, #fff1fb, #ffdff2);
  transition: opacity 260ms ease, visibility 260ms ease;
}

.boot-loader-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-loader-card {
  width: min(480px, 94vw);
  border-radius: 22px;
  border: 1px solid #f3c3e6;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 46px rgba(123, 27, 87, 0.2);
  padding: 22px 22px 20px;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.boot-loader-logo {
  width: min(340px, 74vw);
  max-height: 200px;
  object-fit: contain;
  filter: drop-shadow(0 9px 14px rgba(124, 36, 98, 0.24));
  animation: loaderFloat 2.2s ease-in-out infinite;
}

.boot-loader-status {
  margin: 0;
  font-weight: 700;
  color: #6f2d67;
  font-size: 15px;
}

.boot-loader-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  border: 1px solid #efc0df;
  background: #ffe8f6;
  overflow: hidden;
}

.boot-loader-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #de3198, #ff62b6);
  transition: width 120ms ease;
}

.boot-loader-percent {
  font-size: 18px;
  color: #8c2f6e;
}

@keyframes loaderFloat {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
  100% {
    transform: translateY(0);
  }
}

.layout {
  position: relative;
  width: 100vw;
  height: 100vh;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.hud {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: var(--top-hud-height);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.compact-hud {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.compact-hud::-webkit-scrollbar {
  height: 6px;
}

.hud-item {
  min-width: 98px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff6fc;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.hud-item strong {
  font-size: 18px;
}

button {
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
  font-size: 14px;
}

.main-btn {
  color: #fff;
  background: linear-gradient(180deg, var(--blue), var(--blue-dark));
}

.ghost-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.side-tab {
  position: absolute;
  left: 8px;
  top: calc(var(--top-hud-height) + 18px);
  z-index: 70;
  border: 1px solid #e2a5cc;
  border-radius: 0 12px 12px 0;
  padding: 10px 9px;
  min-width: 46px;
  color: #fff;
  background: linear-gradient(180deg, #f459b5, #c42a86);
  box-shadow: 0 8px 20px rgba(126, 27, 90, 0.24);
}

.side-drawer {
  position: absolute;
  left: 8px;
  top: calc(var(--top-hud-height) + 8px);
  bottom: 8px;
  width: min(332px, calc(100vw - 20px));
  z-index: 75;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid #efbfdc;
  background: rgba(255, 249, 253, 0.98);
  box-shadow: 0 14px 30px rgba(112, 23, 80, 0.22);
  display: grid;
  gap: 10px;
  align-content: start;
  overflow-y: auto;
  transform: translateX(calc(-100% - 20px));
  transition: transform 180ms ease;
  pointer-events: none;
}

.layout.drawer-open .side-drawer {
  transform: translateX(0);
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 17px;
}

.drawer-close-btn {
  padding: 6px 8px;
  font-size: 12px;
}

.drawer-section {
  border: 1px solid #efc7e1;
  border-radius: 10px;
  padding: 8px;
  background: #fff7fc;
}

.drawer-section summary {
  cursor: pointer;
  color: #6f2d67;
  font-weight: 700;
  font-size: 13px;
  list-style: none;
}

.drawer-section summary::-webkit-details-marker {
  display: none;
}

.drawer-section[open] summary {
  margin-bottom: 8px;
}

.high-scores-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.high-score-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #f1c7e6;
  background: #fff4fb;
}

.high-score-btn {
  all: unset;
  width: 100%;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

.high-score-item:hover {
  border-color: #ea8fcb;
  box-shadow: 0 4px 14px rgba(184, 41, 130, 0.14);
}

.high-score-rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-weight: 700;
  color: #6e2b62;
  background: #ffd9ef;
}

.high-score-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.high-score-value {
  font-size: 18px;
  font-weight: 700;
  color: #8f1f67;
}

.high-score-level {
  font-size: 13px;
  color: #803f73;
  font-weight: 700;
}

.high-score-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #8f6086;
}

.high-score-empty {
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed #eab7da;
  background: #fff7fc;
  color: #885f81;
  font-size: 13px;
}

.arena {
  position: relative;
  height: 100%;
  min-height: 0;
  border-radius: 14px;
  border: 1px solid #f0b7dd;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 218, 241, 0.75), rgba(255, 186, 224, 0.9)),
    linear-gradient(180deg, transparent 70%, rgba(172, 89, 131, 0.38) 100%);
}

.arena-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(transparent 95%, rgba(255, 255, 255, 0.2) 96%),
    linear-gradient(90deg, transparent 95%, rgba(255, 255, 255, 0.2) 96%);
  background-size: 48px 48px;
  pointer-events: none;
}

.arena-title {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 4;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 13px;
}

.platform {
  position: absolute;
  z-index: 2;
  height: 16px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, #3f3f46 0%, #232329 45%, #111114 100%);
  border: 2px solid #050506;
  box-shadow:
    0 8px 12px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.platform::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: -6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.bag {
  position: absolute;
  right: 16px;
  bottom: 0;
  width: 136px;
  aspect-ratio: 774 / 1254;
  z-index: 5;
  overflow: hidden;
  border-radius: 0;
  background: url("/images/tubo.webp") center bottom / contain no-repeat;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.34));
  transform-origin: 50% 100%;
}

.bag::before {
  content: none;
}

.bag::after {
  content: none;
}

.bag.bag-hit {
  animation: tubeNudge 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: brightness(1.16) drop-shadow(0 17px 22px rgba(0, 0, 0, 0.4));
}

.bag-cat {
  position: absolute;
  width: 44px;
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
  opacity: 0.86;
}

@keyframes tubeNudge {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  45% {
    transform: translateY(3px) rotate(-0.7deg);
  }
  78% {
    transform: translateY(1px) rotate(0.45deg);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

.cat {
  position: absolute;
  touch-action: none;
  user-select: none;
  pointer-events: auto;
  z-index: 3;
  transform-origin: center center;
}

.cat img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.2));
}

.cat.dragging {
  z-index: 8;
}

.by-type-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}

.by-type-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  background: #fff4fb;
  border: 1px solid #f1c7e6;
  font-size: 14px;
}

.by-type-list .icon-only-row {
  min-height: 38px;
  padding: 6px 8px;
}

.type-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.type-cell img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.by-type-list.compact li {
  font-size: 13px;
  padding: 6px 8px;
}

.by-type-list.compact .type-cell img {
  width: 22px;
  height: 22px;
}

.dialog-by-type-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-cat-card {
  position: relative;
  min-height: 92px;
  border-radius: 12px;
  border: 1px solid #efbfdf;
  background:
    radial-gradient(circle at 30% 15%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.25)),
    linear-gradient(180deg, #fff6fc 0%, #ffe8f5 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.summary-cat-img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.22));
  animation: summaryCatFloat var(--float-duration, 2.2s) ease-in-out infinite;
  animation-delay: var(--float-delay, 0s);
}

.summary-cat-count {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ff6f57, #da3f2f);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.summary-empty {
  grid-column: 1 / -1;
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed #e8b2d7;
  background: #fff7fc;
  color: #7f567a;
  font-size: 13px;
  text-align: center;
}

@keyframes summaryCatFloat {
  0% {
    transform: translateY(0) rotate(calc(var(--float-tilt, 3deg) * -1));
  }
  50% {
    transform: translateY(-4px) rotate(var(--float-tilt, 3deg));
  }
  100% {
    transform: translateY(0) rotate(calc(var(--float-tilt, 3deg) * -1));
  }
}

.level-dialog {
  width: min(500px, 92vw);
  border: 0;
  border-radius: 14px;
  padding: 16px;
}

.score-dialog {
  width: min(520px, 94vw);
  border: 0;
  border-radius: 14px;
  padding: 16px;
}

.score-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.score-dialog h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.score-dialog p {
  margin: 0 0 10px;
  color: #75456d;
}

.high-scores-dialog {
  width: min(620px, 96vw);
}

.player-dialog {
  width: min(420px, 92vw);
  border: 0;
  border-radius: 14px;
  padding: 16px;
}

.player-dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.player-form h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.player-form p {
  margin: 0 0 12px;
  color: #7d5276;
}

.player-form input {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #ecb7db;
  background: #fff6fc;
  color: #442138;
  font-size: 16px;
  padding: 0 12px;
  outline: none;
}

.player-form input:focus {
  border-color: #e54da7;
  box-shadow: 0 0 0 3px rgba(229, 77, 167, 0.22);
}

.player-error {
  margin-top: 8px;
  margin-bottom: 0;
  color: #b62b2b;
  font-size: 13px;
  font-weight: 600;
}

.level-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.level-dialog h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.level-dialog p {
  margin: 0 0 10px;
  color: #75456d;
}

.dialog-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  :root {
    --top-hud-height: 108px;
  }

  .layout {
    padding: 6px;
    gap: 6px;
  }

  .compact-hud {
    flex-wrap: wrap;
    align-content: center;
    overflow-x: hidden;
  }

  .hud-item {
    min-width: 86px;
  }

  .side-tab {
    top: calc(var(--top-hud-height) + 12px);
  }

  .side-drawer {
    top: calc(var(--top-hud-height) + 6px);
    bottom: 6px;
    left: 6px;
    width: min(324px, calc(100vw - 12px));
  }

  .arena-title {
    font-size: 12px;
    padding: 5px 9px;
  }
}
