:root {
  color-scheme: light;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #432f45;
  color: #4d2943;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  background: #432f45;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-frame {
  position: relative;
  width: min(100vw, 430px);
  height: min(100svh, 760px);
  max-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: #f4bdca;
  box-shadow: 0 20px 70px rgb(40 14 38 / 42%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.damage-flash {
  background: radial-gradient(circle at center, rgba(255, 81, 87, 0.7), rgba(187, 13, 45, 0.58));
  inset: 0;
  mix-blend-mode: multiply;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.damage-flash--active {
  animation: damage-flash 1s ease-out both;
}

@keyframes damage-flash {
  0% { opacity: 0.62; }
  25% { opacity: 0.44; }
  100% { opacity: 0; }
}

.hud {
  position: absolute;
  inset: 16px 0 auto;
  z-index: 2;
  text-align: center;
  pointer-events: none;
  color: white;
  font-size: clamp(3rem, 15vw, 5rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 rgb(103 48 85 / 45%), 0 5px 10px rgb(82 30 65 / 24%);
}

.health-hud {
  display: flex;
  gap: 3px;
  left: max(16px, env(safe-area-inset-left));
  pointer-events: none;
  position: absolute;
  top: max(15px, env(safe-area-inset-top));
  z-index: 2;
}

.health-heart {
  color: rgba(113, 46, 80, 0.35);
  font-size: 1.55rem;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(81, 29, 61, 0.2);
  transform: scale(0.92);
  transition: color 180ms ease, filter 180ms ease, transform 180ms ease;
}

.health-heart--active {
  color: #fff4f6;
  filter: drop-shadow(0 0 5px rgba(196, 45, 90, 0.78));
  transform: scale(1);
}

.boost-meter {
  --boost-progress: 1;
  align-items: center;
  background: conic-gradient(
    from -90deg,
    #fff7be calc(var(--boost-progress) * 1turn),
    rgba(255, 247, 190, 0.16) 0
  );
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 225, 101, 0.78), 0 0 34px rgba(205, 73, 150, 0.35);
  display: flex;
  height: 54px;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  top: max(16px, env(safe-area-inset-top));
  transform: scale(0.82);
  transition: opacity 160ms ease, transform 160ms ease;
  width: 54px;
  z-index: 3;
}

.boost-meter::before {
  background: rgba(88, 35, 79, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: inherit;
  content: "";
  inset: 4px;
  position: absolute;
}

.boost-meter--visible {
  opacity: 1;
  transform: scale(1);
}

.boost-meter__label {
  color: #fff7cf;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: -0.06em;
  position: relative;
  text-shadow: 0 0 9px rgba(255, 228, 99, 0.92);
  z-index: 1;
}

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(180deg, rgb(91 45 82 / 8%), rgb(69 27 60 / 30%));
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.screen--visible {
  opacity: 1;
  pointer-events: auto;
}

.card {
  width: min(100%, 330px);
  padding: 28px 24px 24px;
  border: 3px solid rgb(255 250 252 / 82%);
  border-radius: 24px;
  background: rgb(255 248 249 / 95%);
  box-shadow: 0 18px 0 rgb(112 60 93 / 19%), 0 24px 50px rgb(66 25 57 / 27%);
  text-align: center;
}

.card--compact {
  padding-top: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #9b486f;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: #4d2943;
  font-size: clamp(2.45rem, 12vw, 3.5rem);
  line-height: 0.98;
  letter-spacing: -0.07em;
}

h2 {
  font-size: 2.5rem;
}

.intro {
  margin: 17px auto 22px;
  max-width: 250px;
  color: #795766;
  font-size: 0.98rem;
  line-height: 1.45;
}

.primary-button {
  min-height: 54px;
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: #b84d79;
  color: white;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 850;
  box-shadow: inset 0 -4px 0 rgb(92 27 60 / 32%), 0 5px 0 #873957;
  transition: transform 100ms ease, box-shadow 100ms ease, filter 100ms ease;
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: inset 0 -2px 0 rgb(92 27 60 / 32%), 0 1px 0 #873957;
}

.primary-button:focus-visible {
  outline: 4px solid rgb(202 100 143 / 38%);
  outline-offset: 3px;
}

.motion-status {
  min-height: 1.3em;
  margin: 17px 0 0;
  color: #9b486f;
  font-size: 0.78rem;
  font-weight: 750;
}

.hint {
  margin: 18px 0 0;
  color: #806573;
  font-size: 0.75rem;
  line-height: 1.5;
}

.result {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 25px 0 7px;
  color: #b84d79;
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1;
}

.result small {
  color: #806573;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.best {
  margin: 0 0 24px;
  color: #795766;
  font-size: 0.9rem;
}

.best strong {
  color: #4d2943;
}

.rules-link {
  display: inline-block;
  margin: 18px 0 0;
  color: #9b486f;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.rules-link:focus-visible {
  outline: 3px solid rgb(202 100 143 / 38%);
  outline-offset: 4px;
}

.rules-link--start {
  margin-top: 13px;
}

.rules-modal {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  position: absolute;
  z-index: 6;
}

.rules-modal[hidden] {
  display: none;
}

.rules-modal__backdrop {
  background: rgb(50 18 44 / 72%);
  backdrop-filter: blur(6px);
  inset: 0;
  position: absolute;
}

.rules-modal__card {
  position: relative;
  z-index: 1;
  width: min(100%, 355px);
  max-height: min(680px, calc(100svh - 40px));
  overflow-y: auto;
  padding: 24px 20px 22px;
  border: 2px solid rgb(255 250 252 / 82%);
  border-radius: 24px;
  background: rgb(255 248 249 / 98%);
  box-shadow: 0 22px 60px rgb(46 12 39 / 48%);
}

.rules-modal__card h2 {
  font-size: 2.25rem;
}

.rules-modal__close {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f1d4df;
  color: #713b5b;
  cursor: pointer;
  font-size: 1.65rem;
  line-height: 1;
}

.rules-modal__close:focus-visible {
  outline: 3px solid rgb(202 100 143 / 48%);
  outline-offset: 2px;
}

.legend-preview {
  display: block;
  width: 100%;
  margin: 16px 0 14px;
  border: 2px solid rgb(159 73 113 / 24%);
  border-radius: 17px;
  background: #f5cfda;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 44%);
}

.rules-modal__lead {
  margin: 0 0 14px;
  color: #795766;
  font-size: 0.9rem;
  line-height: 1.42;
}

.modal-legend {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: #795766;
  font-size: 0.82rem;
  line-height: 1.35;
  list-style: none;
}

.modal-legend li {
  padding: 9px 10px;
  border-radius: 11px;
  background: rgb(251 226 233 / 72%);
}

.modal-legend strong {
  color: #5b304e;
}

.motion-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgb(78 39 66 / 76%);
  color: white;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.motion-badge.motion-badge--visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 500px) {
  .game-frame {
    border-radius: 28px;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  .game-frame {
    width: min(100vw, 900px);
    height: 100svh;
  }

  .card {
    padding: 18px 24px;
  }

  .intro,
  .motion-status,
  .hint {
    margin-top: 10px;
    margin-bottom: 10px;
  }
}
