:root {
  color-scheme: dark;
  --ink: #f8f5e7;
  --muted: #a8b5a7;
  --panel: #203722;
  --panel-deep: #132516;
  --lime: #d8ff47;
  --orange: #ff7b32;
  --brown: #92512e;
  --line: rgba(216, 255, 71, .15);
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(89, 124, 62, .3), transparent 30rem),
    #0d1b10;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.page-shell {
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: auto;
  padding: 0 clamp(16px, 4vw, 64px) 36px;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  font-weight: 950;
  letter-spacing: -.04em;
  text-transform: uppercase;
}

.brand-mark { color: var(--orange); margin-right: 8px; }

.primary-button, .submit-button, .secondary-button {
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  position: fixed;
  top: 20px;
  right: clamp(16px, 4vw, 64px);
  z-index: 90;
  padding: 12px 20px;
  color: #16200e;
  background: var(--lime);
  box-shadow: 0 4px 0 #7f9b1b;
}

.primary-button:active { transform: translateY(3px); box-shadow: 0 1px 0 #7f9b1b; }

.hero {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  padding: clamp(28px, 5vw, 64px) 0 28px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--orange);
  font-size: .73rem;
  font-weight: 950;
  letter-spacing: .14em;
}

h1, h2 { margin: 0; line-height: .95; letter-spacing: -.055em; }
h1 { max-width: 820px; font-size: clamp(2.5rem, 6vw, 6rem); text-transform: uppercase; }
.hero-title {
  max-width: none;
  font-size: clamp(.75rem, 2.2vw, 2.25rem);
  line-height: 1;
  white-space: nowrap;
}
h2 { font-size: clamp(2rem, 5vw, 3rem); }

.hero-copy {
  max-width: 660px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
}

.score-card {
  flex: 0 0 auto;
  min-width: 170px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(32, 55, 34, .68);
  text-align: right;
}

.score-card span { display: block; font-size: .75rem; text-transform: uppercase; }
.score-card strong { color: var(--lime); font-size: 2.1rem; }

.game-area {
  position: relative;
  height: max(460px, calc(100vh - 330px));
  min-height: 460px;
  overflow: hidden;
  border: 1px solid rgba(216, 255, 71, .22);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(42, 77, 44, .8), rgba(20, 43, 24, .95)),
    var(--panel);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, .28), 0 28px 80px rgba(0, 0, 0, .2);
  cursor: none;
  touch-action: manipulation;
}

.game-grid {
  position: absolute;
  inset: 0;
  opacity: .12;
  background-image:
    linear-gradient(var(--lime) 1px, transparent 1px),
    linear-gradient(90deg, var(--lime) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent);
}

.game-area::after {
  content: "";
  position: absolute;
  right: -4%;
  bottom: -60px;
  left: -4%;
  height: 105px;
  border-radius: 50% 50% 0 0;
  background: #0c1a0f;
  box-shadow: 0 -12px 30px rgba(0,0,0,.3);
  pointer-events: none;
  z-index: 4;
}

.game-area.smash-impact {
  animation: gameImpact .26s ease-out;
}

.loading-state, .empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong { color: var(--ink); font-size: 1.3rem; }
[hidden] { display: none !important; }

.roach-unit {
  --rotation: 0deg;
  position: absolute;
  z-index: 2;
  width: 86px;
  height: 112px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  cursor: none;
  transform: translate3d(var(--x), var(--y), 0) rotate(var(--rotation));
  transform-origin: center 72px;
  will-change: transform;
}

.roach-unit:focus-visible .roach-visual { outline: 3px solid white; outline-offset: 5px; }

.roach-label {
  position: absolute;
  top: 0;
  left: 50%;
  max-width: 150px;
  overflow: hidden;
  padding: 4px 9px;
  border-radius: 8px;
  color: #17200d;
  background: var(--lime);
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  font-size: .72rem;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%) rotate(calc(-1 * var(--rotation)));
}

.roach-badge {
  position: absolute;
  top: 26px;
  right: 2px;
  z-index: 2;
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 2px solid var(--panel-deep);
  border-radius: 50%;
  color: var(--panel-deep);
  background: var(--orange);
  font-size: .65rem;
  font-weight: 950;
}

.roach-visual {
  position: absolute;
  top: 34px;
  left: 14px;
  width: 58px;
  height: 70px;
  transition: filter .18s, transform .18s;
}

.roach-body {
  position: absolute;
  top: 21px;
  left: 11px;
  width: 38px;
  height: 50px;
  overflow: hidden;
  border: 3px solid #3b2218;
  border-radius: 48% 48% 44% 44%;
  background: linear-gradient(90deg, #774026 48%, #4f2e20 50%);
  box-shadow: inset 0 5px rgba(255,255,255,.09), 0 5px 5px rgba(0,0,0,.3);
}

.roach-body::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 4px;
  left: 50%;
  width: 2px;
  background: rgba(34, 18, 13, .48);
}

.roach-shine {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 7px;
  height: 19px;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  transform: rotate(14deg);
}

.roach-head {
  position: absolute;
  top: 12px;
  left: 17px;
  width: 27px;
  height: 25px;
  border: 3px solid #3b2218;
  border-radius: 48%;
  background: #8c4c2c;
}

.roach-eye {
  position: absolute;
  top: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 5px var(--lime);
}

.eye-left { left: 4px; }
.eye-right { right: 4px; }

.antenna {
  position: absolute;
  top: 1px;
  width: 27px;
  height: 22px;
  border-top: 2px solid #3b2218;
  border-radius: 50%;
}

.antenna-left { left: 2px; transform: rotate(-25deg); }
.antenna-right { right: 0; transform: rotate(25deg); }

.leg {
  position: absolute;
  z-index: -1;
  width: 25px;
  height: 13px;
  border-bottom: 3px solid #4b291c;
}

.leg-1 { top: 27px; left: 0; transform: rotate(25deg); }
.leg-2 { top: 45px; left: -2px; transform: rotate(4deg); }
.leg-3 { top: 60px; left: 1px; transform: rotate(-24deg); }
.leg-4 { top: 27px; right: -2px; transform: rotate(-25deg); }
.leg-5 { top: 45px; right: -4px; transform: rotate(-4deg); }
.leg-6 { top: 60px; right: -1px; transform: rotate(24deg); }

.roach-unit:not(.crushed) .leg { animation: legScuttle .16s infinite alternate ease-in-out; }
.roach-unit.bumped .roach-visual { animation: collisionJolt .12s ease-out; }

@keyframes legScuttle {
  to { transform: rotate(0deg) scaleX(.75); }
}

.speech-bubble {
  position: absolute;
  z-index: 7;
  bottom: 92px;
  left: 50%;
  display: none;
  width: min(230px, 62vw);
  padding: 12px 14px;
  border: 2px solid #17200d;
  border-radius: 15px 15px 15px 3px;
  color: #17200d;
  background: #fffbea;
  box-shadow: 5px 6px 0 rgba(0,0,0,.25);
  text-align: left;
  transform: translateX(-50%) rotate(calc(-1 * var(--rotation)));
}

.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 18px;
  border-width: 10px 10px 0 0;
  border-style: solid;
  border-color: #fffbea transparent transparent;
}

.speech-bubble strong, .speech-bubble span { display: block; }
.speech-bubble strong { overflow-wrap: anywhere; font-size: .82rem; }
.speech-bubble span { margin-top: 5px; color: #687060; font-size: .72rem; }

.smash-effect {
  position: absolute;
  z-index: 0;
  top: 61px;
  left: 43px;
  display: none;
  width: 1px;
  height: 1px;
  pointer-events: none;
  transform: rotate(calc(-1 * var(--rotation)));
}

.smash-ring, .smash-splat, .smash-drop {
  position: absolute;
  display: block;
}

.smash-ring {
  top: -31px;
  left: -31px;
  width: 62px;
  height: 62px;
  border: 5px solid rgba(255, 45, 45, .92);
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(255, 0, 0, .45);
}

.smash-splat {
  top: -16px;
  left: -29px;
  width: 58px;
  height: 32px;
  border: 3px solid #420307;
  border-radius: 48% 52% 46% 54%;
  background:
    radial-gradient(circle at 35% 35%, #ff4a4a 0 10%, transparent 11%),
    radial-gradient(circle at 58% 65%, #7f0008 0 18%, transparent 19%),
    #b20d18;
  box-shadow:
    inset 0 5px 7px rgba(255, 112, 112, .28),
    -13px 5px 0 -5px #a80712,
    14px 2px 0 -6px #d11722,
    2px 10px 0 -6px #780008;
}

.smash-drop {
  width: 8px;
  height: 18px;
  border-radius: 50% 50% 45% 15%;
  border: 1px solid #5f0006;
  background: radial-gradient(circle at 35% 30%, #ff5a5a, #ba0712 48%, #720008 100%);
  box-shadow: 0 2px 4px rgba(65, 0, 4, .5);
  transform-origin: top center;
}

.smash-drop::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 1px;
  width: 4px;
  height: 95px;
  border-radius: 0 0 8px 8px;
  opacity: .72;
  background: linear-gradient(#a5000a, rgba(91, 0, 7, .7) 72%, transparent);
  filter: blur(.35px);
}

.drop-1 { --drop-x: -42px; --drop-y: -33px; }
.drop-2 { --drop-x: 38px; --drop-y: -28px; }
.drop-3 { --drop-x: -47px; --drop-y: 12px; }
.drop-4 { --drop-x: 43px; --drop-y: 16px; }
.drop-5 { --drop-x: -18px; --drop-y: 39px; }
.drop-6 { --drop-x: 18px; --drop-y: -45px; }

.roach-unit.crushed { z-index: 6; pointer-events: none; }
.roach-unit.crushed .speech-bubble { display: block; animation: bubblePop .3s both; }
.roach-unit.crushed .roach-visual { animation: squashAndFall 2.5s both; }
.roach-unit.crushed .smash-effect { display: block; }
.roach-unit.crushed .smash-ring { animation: impactRing .46s ease-out both; }
.roach-unit.crushed .smash-splat { animation: splatLifecycle 2.7s .05s both; }
.roach-unit.crushed .smash-drop { animation: dropLifecycle 2.55s both; }
.roach-unit.crushed .roach-label, .roach-unit.crushed .roach-badge { opacity: 0; }
.roach-unit.respawning { animation: respawn .35s both; }
.roach-unit.featured .roach-label { background: #fff; box-shadow: 0 0 0 3px var(--orange), 0 4px 0 rgba(0,0,0,.25); }

@keyframes squashAndFall {
  0% { transform: translateY(0) scale(1); filter: saturate(1); }
  4% { transform: translateY(7px) scale(1.28, .24); filter: brightness(1.35) saturate(.8); }
  8% { transform: translateY(2px) scale(.92, .48); }
  13%, 54% { opacity: 1; transform: translateY(8px) scale(1.35, .12); filter: grayscale(.45) brightness(.72); }
  100% { opacity: 0; transform: translateY(288px) scale(1.55, .08) rotate(18deg); filter: grayscale(.65) brightness(.55); }
}

@keyframes bubblePop {
  from { opacity: 0; transform: translateX(-50%) scale(.5) rotate(calc(-1 * var(--rotation))); }
}

@keyframes impactRing {
  from { opacity: 1; transform: scale(.15); }
  to { opacity: 0; transform: scale(2.15); }
}

@keyframes splatLifecycle {
  0% { opacity: 0; transform: scale(.1) rotate(-18deg); }
  12%, 38% { opacity: .95; transform: scale(1) rotate(5deg); }
  68% { opacity: .88; transform: translateY(105px) scale(.82, 2.8) rotate(2deg); }
  100% { opacity: 0; transform: translateY(330px) scale(.42, 4.4) rotate(1deg); }
}

@keyframes dropLifecycle {
  0% { opacity: 1; transform: translate(-4px, -4px) scale(.3) rotate(0); }
  18% { opacity: .9; transform: translate(var(--drop-x), var(--drop-y)) scale(1) rotate(0); }
  45% { opacity: .88; transform: translate(var(--drop-x), calc(var(--drop-y) + 75px)) scale(.82, 2.1) rotate(0); }
  100% { opacity: 0; transform: translate(var(--drop-x), calc(var(--drop-y) + 390px)) scale(.55, 3.2) rotate(0); }
}

@keyframes collisionJolt {
  50% { transform: scale(.9, 1.08); filter: brightness(1.2); }
}

@keyframes gameImpact {
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}

@keyframes respawn {
  from { opacity: 0; filter: blur(5px); }
}

.hammer {
  position: fixed;
  z-index: 100;
  width: 55px;
  height: 72px;
  pointer-events: none;
  opacity: 0;
  transform: translate(6px, -54px) rotate(-28deg);
  transform-origin: 22px 58px;
  transition: opacity .12s;
}

.hammer.visible { opacity: 1; }
.hammer.swing { animation: hammerSwing .2s ease-in-out; }

.hammer-head {
  position: absolute;
  top: 1px;
  left: 0;
  width: 48px;
  height: 25px;
  border: 3px solid #161b19;
  border-radius: 7px;
  background: linear-gradient(#d9e1dc, #74817b);
  box-shadow: inset 0 3px rgba(255,255,255,.6), 3px 4px 0 rgba(0,0,0,.25);
}

.hammer-handle {
  position: absolute;
  top: 20px;
  left: 22px;
  width: 13px;
  height: 50px;
  border: 3px solid #40291e;
  border-radius: 5px 5px 8px 8px;
  background: #bd743e;
}

@keyframes hammerSwing {
  50% { transform: translate(6px, -54px) rotate(24deg); }
}

dialog {
  width: min(620px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 0;
  border: 1px solid rgba(216, 255, 71, .25);
  border-radius: 26px;
  color: var(--ink);
  background: #172b1a;
  box-shadow: 0 30px 100px #000;
}

dialog::backdrop { background: rgba(4, 10, 5, .78); backdrop-filter: blur(7px); }

.roach-form, .share-dialog { padding: clamp(22px, 5vw, 38px); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 30px; }

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
}

.roach-form > label, .share-link-field {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  color: var(--ink);
  font-size: .84rem;
  font-weight: 850;
}

input, textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: #0f2112;
}

input { height: 48px; padding: 0 14px; }
textarea { min-height: 105px; padding: 13px 14px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(216,255,71,.12); }

label small { justify-self: end; color: var(--muted); font-weight: 500; }

fieldset { margin: 20px 0 0; padding: 0; border: 0; }
legend { margin-bottom: 9px; font-size: .84rem; font-weight: 850; }
.type-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.type-card {
  position: relative;
  display: flex;
  min-height: 88px;
  align-items: center;
  padding: 15px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 15px;
  background: #0f2112;
  cursor: pointer;
}

.type-card:has(input:checked) { border-color: var(--lime); background: rgba(216,255,71,.09); }
.type-card input { width: 18px; height: 18px; margin: 0 11px 0 0; accent-color: var(--lime); }
.type-card strong, .type-card small { display: block; }
.type-card small { margin-top: 4px; }

.submit-button {
  display: flex;
  width: 100%;
  margin-top: 26px;
  padding: 15px 20px;
  justify-content: space-between;
  color: #15200f;
  background: var(--lime);
}

.submit-button:disabled { cursor: wait; opacity: .55; }
.form-error { margin: 15px 0 0; color: #ff9c88; }

.email-preview { display: grid; gap: 14px; }
.email-preview div { padding: 13px; border-radius: 12px; background: #0f2112; }
.email-preview dt { margin-bottom: 5px; color: var(--orange); font-size: .7rem; font-weight: 900; text-transform: uppercase; }
.email-preview dd { margin: 0; color: var(--muted); font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.copy-row { display: flex; gap: 8px; }
.secondary-button { padding: 0 18px; color: #17200d; background: var(--orange); }

@media (max-width: 680px) {
  .page-shell { padding-inline: 12px; }
  .topbar { min-height: 66px; }
  .primary-button { top: 14px; right: 12px; padding: 10px 14px; font-size: .8rem; }
  .hero { display: block; padding: 28px 4px 20px; }
  .hero-title { font-size: clamp(.7rem, 2.125vw, .9rem); }
  .hero-copy { margin-top: 12px; font-size: .95rem; }
  .score-card { display: flex; min-width: 0; margin-top: 18px; align-items: center; justify-content: space-between; text-align: left; }
  .score-card strong { font-size: 1.5rem; }
  .game-area { height: 60vh; min-height: 430px; border-radius: 20px; }
  .type-options { grid-template-columns: 1fr; }
  .copy-row { display: grid; }
  .secondary-button { min-height: 44px; }
  .hammer { display: none; }
}

@media (pointer: coarse) {
  .game-area, .roach-unit { cursor: pointer; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
