:root {
  --purple: #6f35ff;
  --purple-dark: #36156e;
  --pink: #ff3f9f;
  --yellow: #ffd94a;
  --cyan: #31e7ff;
  --green: #48f0a4;
  --ink: #160d36;
  --white: #ffffff;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 63, 159, .75), transparent 27%),
    radial-gradient(circle at 85% 15%, rgba(49, 231, 255, .65), transparent 28%),
    linear-gradient(155deg, #351271 0%, #6f35ff 48%, #9a36d8 100%);
  color: var(--white);
  touch-action: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 26px 26px;
  transform: perspective(450px) rotateX(45deg) scale(1.45);
  transform-origin: center bottom;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: min(100vw, 520px);
  height: 100dvh;
  min-height: 600px;
  margin: 0 auto;
  overflow: hidden;
  border-left: 1px solid rgba(255,255,255,.16);
  border-right: 1px solid rgba(255,255,255,.16);
  background: rgba(18, 7, 51, .28);
  box-shadow: 0 0 50px rgba(0,0,0,.28);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.screen.active {
  display: flex;
}

.start-screen,
.win-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.logo-orbit {
  position: relative;
  width: 176px;
  height: 176px;
  margin-bottom: 22px;
  border: 5px solid var(--yellow);
  border-radius: 50%;
  box-shadow:
    0 0 0 9px rgba(255,255,255,.12),
    0 0 35px rgba(255,217,74,.5),
    inset 0 0 30px rgba(49,231,255,.25);
  animation: pulse 2s ease-in-out infinite;
}

.logo-orbit::after {
  content: "10";
  position: absolute;
  inset: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--pink), #ff814a);
  color: white;
  font-size: 64px;
  font-weight: 900;
  text-shadow: 0 5px 0 rgba(61, 18, 94, .28);
}

.logo-orbit span {
  position: absolute;
  z-index: 2;
  font-size: 34px;
  filter: drop-shadow(0 5px 6px rgba(0,0,0,.25));
}

.logo-orbit span:nth-child(1) { top: -12px; left: 68px; }
.logo-orbit span:nth-child(2) { top: 62px; right: -17px; }
.logo-orbit span:nth-child(3) { bottom: -12px; left: 67px; }
.logo-orbit span:nth-child(4) { top: 62px; left: -17px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--yellow);
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 9vw, 54px);
  line-height: .98;
  letter-spacing: -.04em;
  text-shadow: 0 6px 0 rgba(45, 17, 91, .45);
}

.subtitle {
  max-width: 330px;
  margin: 18px auto 24px;
  font-size: 18px;
  line-height: 1.45;
  color: rgba(255,255,255,.88);
}

.rules-card {
  width: min(100%, 340px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  margin-bottom: 22px;
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 22px;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
}

.rules-card div {
  display: grid;
  grid-template-columns: 46px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: left;
  gap: 0 8px;
  padding: 9px;
  border-radius: 16px;
  background: rgba(20,8,55,.35);
}

.rule-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font-size: 28px;
  border-radius: 15px;
}

.rule-icon.good { background: rgba(72,240,164,.25); }
.rule-icon.bad { background: rgba(255,63,159,.25); }

.rules-card strong {
  font-size: 22px;
  line-height: 1;
}

.rules-card small {
  color: rgba(255,255,255,.72);
}

.primary-button {
  width: min(100%, 340px);
  min-height: 60px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--yellow), #ffb62f);
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  box-shadow:
    0 7px 0 #c8791a,
    0 14px 25px rgba(0,0,0,.25);
  cursor: pointer;
}

.primary-button:active {
  transform: translateY(5px);
  box-shadow:
    0 2px 0 #c8791a,
    0 8px 16px rgba(0,0,0,.22);
}

.control-hint {
  max-width: 330px;
  margin: 20px 0 0;
  color: rgba(255,255,255,.68);
  font-size: 13px;
  line-height: 1.4;
}

.game-screen {
  flex-direction: column;
  padding-left: 12px;
  padding-right: 12px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  z-index: 4;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  border: 2px solid rgba(255,255,255,.28);
  border-radius: 18px;
  background: rgba(18,7,51,.58);
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
}

.score-pill span {
  font-size: 12px;
  letter-spacing: .12em;
  font-weight: 900;
  color: var(--yellow);
}

.score-pill strong {
  font-size: 25px;
}

.score-pill strong span {
  font-size: inherit;
  letter-spacing: normal;
  color: white;
}

.icon-button {
  min-height: 44px;
  border: 2px solid rgba(255,255,255,.28);
  border-radius: 14px;
  padding: 0 13px;
  color: white;
  background: rgba(18,7,51,.58);
  font-weight: 800;
}

.game-area {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-top: 8px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,.28);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 15%, rgba(49,231,255,.22), transparent 30%),
    linear-gradient(180deg, rgba(18,7,51,.48), rgba(18,7,51,.82));
  box-shadow:
    inset 0 0 30px rgba(49,231,255,.12),
    0 12px 30px rgba(0,0,0,.2);
}

.speed-lines {
  position: absolute;
  inset: 0;
  opacity: .16;
  background-image: linear-gradient(90deg, transparent 48%, rgba(255,255,255,.5) 50%, transparent 52%);
  background-size: 92px 100%;
  animation: streak 1.1s linear infinite;
}

.status-text {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 30px);
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(18,7,51,.55);
  color: rgba(255,255,255,.85);
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

.falling-item {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  font-size: 38px;
  user-select: none;
  filter: drop-shadow(0 8px 7px rgba(0,0,0,.28));
  will-change: transform;
}

.falling-item.coffee {
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,217,74,.22), transparent 66%);
}

.basket {
  position: absolute;
  z-index: 5;
  bottom: 16px;
  left: 50%;
  width: 104px;
  height: 74px;
  transform: translateX(-50%);
  will-change: left;
}

.basket-handle {
  position: absolute;
  top: 0;
  left: 21px;
  width: 62px;
  height: 38px;
  border: 7px solid var(--yellow);
  border-bottom: 0;
  border-radius: 40px 40px 0 0;
}

.basket-body {
  position: absolute;
  bottom: 0;
  width: 104px;
  height: 54px;
  display: grid;
  place-items: center;
  padding-top: 3px;
  border: 4px solid white;
  border-radius: 15px 15px 26px 26px;
  background:
    repeating-linear-gradient(45deg, #ff3f9f 0 10px, #7d37ff 10px 20px);
  box-shadow: 0 8px 0 rgba(28,7,69,.35);
  font-size: 30px;
}

.mobile-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 12px;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.control-button {
  min-height: 58px;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 18px;
  color: white;
  background: rgba(18,7,51,.6);
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 5px 0 rgba(18,7,51,.65);
}

.control-button:active,
.control-button.pressed {
  transform: translateY(4px);
  background: rgba(255,63,159,.5);
  box-shadow: 0 1px 0 rgba(18,7,51,.65);
}

.game-area.hit-good {
  animation: goodFlash .25s ease;
}

.game-area.hit-bad {
  animation: badFlash .3s ease;
}

.app-shell.shake {
  animation: shake .28s linear;
}

.win-screen {
  overflow: hidden;
}

#confettiCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.win-content {
  position: relative;
  z-index: 2;
  width: min(100%, 390px);
  padding: 28px 22px 32px;
  border: 3px solid rgba(255,255,255,.34);
  border-radius: 30px;
  background: rgba(18,7,51,.64);
  box-shadow: 0 20px 55px rgba(0,0,0,.3);
  backdrop-filter: blur(12px);
}

.trophy {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--yellow), #ff934a);
  box-shadow: 0 0 0 10px rgba(255,255,255,.12), 0 0 36px rgba(255,217,74,.6);
  font-size: 61px;
  animation: bounce 1.2s ease-in-out infinite;
}

.win-content p:not(.eyebrow) {
  margin: 20px auto 27px;
  color: rgba(255,255,255,.86);
  font-size: 17px;
  line-height: 1.55;
}

.rotate-notice {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #351271, #6f35ff);
  color: white;
  text-align: center;
}

.rotate-card {
  max-width: 360px;
  padding: 32px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 28px;
  background: rgba(18,7,51,.45);
}

.rotate-icon {
  font-size: 72px;
  color: var(--yellow);
}

.rotate-card h2 {
  margin: 8px 0;
  font-size: 30px;
}

.rotate-card p {
  margin: 0;
  color: rgba(255,255,255,.78);
  line-height: 1.5;
}

@keyframes pulse {
  50% { transform: scale(1.04); }
}

@keyframes bounce {
  50% { transform: translateY(-9px) rotate(-3deg); }
}

@keyframes streak {
  from { transform: translateY(-100px); }
  to { transform: translateY(100px); }
}

@keyframes goodFlash {
  50% { box-shadow: inset 0 0 70px rgba(72,240,164,.75); }
}

@keyframes badFlash {
  50% { box-shadow: inset 0 0 70px rgba(255,63,159,.78); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(5px); }
}

@media (orientation: landscape) and (max-height: 650px) {
  .rotate-notice {
    display: grid;
  }
}

@media (max-height: 690px) {
  .logo-orbit {
    width: 132px;
    height: 132px;
    margin-bottom: 15px;
  }

  .logo-orbit::after {
    inset: 23px;
    font-size: 48px;
  }

  .logo-orbit span:nth-child(1) { left: 48px; }
  .logo-orbit span:nth-child(2) { top: 43px; }
  .logo-orbit span:nth-child(3) { left: 48px; }
  .logo-orbit span:nth-child(4) { top: 43px; }

  h1 {
    font-size: 36px;
  }

  .subtitle {
    margin: 12px auto 15px;
    font-size: 16px;
  }

  .rules-card {
    margin-bottom: 15px;
  }

  .control-hint {
    margin-top: 14px;
  }
}
