:root {
  --yellow: #f8cf17;
  --ink: #111318;
  --paper: #fffaf0;
  --mint: #7ff4d2;
  --rose: #ff4477;
  --blue: #6fc2ff;
  --lime: #b9ff66;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(110deg, rgba(248, 207, 23, 0.96) 0 38%, rgba(17, 19, 24, 0.92) 38% 100%),
    radial-gradient(circle at 80% 12%, rgba(111, 194, 255, 0.28), transparent 34%),
    #17191e;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 84px 84px;
  opacity: 0.42;
}

#play-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.cat-portrait {
  position: absolute;
  left: clamp(16px, 5vw, 76px);
  bottom: clamp(12px, 4vh, 56px);
  z-index: 1;
  width: min(42vw, 440px);
  max-height: 66vh;
  object-fit: cover;
  object-position: 50% 58%;
  aspect-ratio: 3 / 4;
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: rotate(-3deg);
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: clamp(12px, 2.5vw, 28px);
  left: clamp(12px, 2.5vw, 28px);
  right: clamp(12px, 2.5vw, 28px);
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}

.brand,
.mode-switch,
.tools,
.score-strip,
.start-cover {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(17, 19, 24, 0.68);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  width: fit-content;
  max-width: min(540px, 100%);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--rose) 0 23%, transparent 24%),
    radial-gradient(circle at 50% 50%, rgba(255, 68, 119, 0.4) 0 52%, transparent 53%);
  box-shadow: 0 0 26px rgba(255, 68, 119, 0.95);
}

.brand h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 40px);
  line-height: 0.95;
  font-weight: 900;
}

.brand p {
  margin: 4px 0 0;
  color: rgba(255, 250, 240, 0.72);
  font-size: 13px;
}

.mode-switch,
.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
}

.mode-btn,
.icon-button,
.wallet-button {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.mode-btn:hover,
.icon-button:hover,
.wallet-button:hover,
.wallet-button.is-connected,
.mode-btn.is-active {
  transform: translateY(-1px);
  color: var(--ink);
  background: var(--yellow);
}

.wallet-button {
  display: inline-flex;
  width: auto;
  min-width: 76px;
  gap: 8px;
  padding: 0 12px;
  font-weight: 900;
}

.wallet-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #ff7a1a;
  box-shadow: 0 0 14px rgba(255, 122, 26, 0.85);
}

.wallet-button.is-connected .wallet-dot {
  background: var(--lime);
  box-shadow: 0 0 14px rgba(185, 255, 102, 0.88);
}

.speed-control {
  display: flex;
  width: clamp(120px, 12vw, 180px);
  height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.speed-control input {
  width: 100%;
  accent-color: var(--yellow);
}

.score-strip {
  position: absolute;
  right: clamp(12px, 2.5vw, 28px);
  bottom: clamp(12px, 2.5vw, 28px);
  z-index: 4;
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.score-strip > div {
  min-width: 76px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.score-label {
  display: block;
  margin-bottom: 3px;
  color: rgba(255, 250, 240, 0.65);
  font-size: 12px;
}

.score-strip strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.start-cover {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 5;
  display: grid;
  min-width: min(310px, calc(100vw - 32px));
  justify-items: center;
  gap: 10px;
  padding: 22px 24px;
  border-radius: 8px;
  color: var(--paper);
  transform: translate(-50%, -50%);
}

.start-cover strong {
  font-size: clamp(28px, 6vw, 56px);
  line-height: 1;
}

.start-cover small {
  color: rgba(255, 250, 240, 0.7);
  font-size: 14px;
}

.start-cover.is-hidden {
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.96);
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease;
}

.start-orbit {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--rose) 0 18%, transparent 19%),
    conic-gradient(from 0deg, var(--yellow), var(--blue), var(--lime), var(--rose), var(--yellow));
  box-shadow: 0 0 36px rgba(255, 68, 119, 0.75);
  animation: orbitSpin 1.8s linear infinite;
}

.icon-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 18px var(--rose);
}

.icon-feather,
.icon-ribbon {
  width: 24px;
  height: 10px;
  border-radius: 100% 10% 100% 10%;
  background: currentColor;
  transform: rotate(-25deg);
}

.icon-feather::after,
.icon-ribbon::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 2px;
  background: currentColor;
  transform: translate(10px, 8px) rotate(32deg);
}

.icon-yarn {
  width: 24px;
  height: 24px;
  border: 3px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 8px 0 0 rgba(255, 255, 255, 0.16);
}

.speed-icon {
  width: 19px;
  height: 19px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.icon-sound {
  width: 18px;
  height: 18px;
  border-left: 7px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.icon-fullscreen {
  width: 20px;
  height: 20px;
  border: 3px solid currentColor;
  border-radius: 3px;
}

@keyframes orbitSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 820px) {
  .app-shell {
    min-height: 100svh;
    background:
      linear-gradient(165deg, rgba(248, 207, 23, 0.96) 0 42%, rgba(17, 19, 24, 0.94) 42% 100%),
      #17191e;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .brand,
  .mode-switch,
  .tools {
    width: 100%;
  }

  .mode-switch,
  .tools {
    justify-content: center;
  }

  .cat-portrait {
    left: 14px;
    bottom: 96px;
    width: min(48vw, 260px);
    max-height: 45vh;
  }

  .score-strip {
    left: 12px;
    right: 12px;
    justify-content: space-between;
  }

  .score-strip > div {
    flex: 1;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .start-orbit {
    animation: none;
  }
}
