:root {
  color-scheme: dark;
  --bg: #11100d;
  --text: #fffaf1;
  --muted: #b5aa9b;
  --cream: #f4ead9;
  --tile: #565249;
  --brown: #4a2515;
  --green: #9fd55d;
  --red: #ff4c3f;
  --line: rgba(255, 255, 255, 0.16);
  --glass: rgba(17, 16, 13, 0.72);
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
}

body {
  display: grid;
  place-items: center;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 480px;
  overflow: hidden;
  background:
    radial-gradient(circle at 46% 78%, rgba(159, 213, 93, 0.08), transparent 26%),
    radial-gradient(circle at 30% 16%, rgba(244, 234, 217, 0.12), transparent 30%),
    linear-gradient(180deg, #191713 0%, #0d0b09 100%);
}

canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 5;
  display: flex;
  gap: 9px;
  justify-content: center;
  width: min(520px, calc(100vw - 24px));
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 160ms ease;
}

.hud.is-visible {
  opacity: 1;
}

.hud div,
.best-panel,
.result div,
.rules-strip span {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
}

.hud div {
  min-width: 82px;
  padding: 9px 10px;
  text-align: center;
}

.hud span,
.best-panel span,
dt {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hud strong,
.best-panel strong,
dd {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  line-height: 1;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 21px;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
  transition: opacity 180ms ease, transform 180ms ease;
}

.screen::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    radial-gradient(circle at 50% 48%, rgba(11, 10, 8, 0.22), rgba(11, 10, 8, 0.78) 68%),
    linear-gradient(180deg, rgba(11, 10, 8, 0.42), rgba(11, 10, 8, 0.84));
}

.screen > * {
  position: relative;
}

.screen--active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.brand,
.result {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.kicker {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(159, 213, 93, 0.8);
}

h1,
h2 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(42px, 10vw, 82px);
  font-weight: 950;
  line-height: 0.92;
  text-shadow:
    0 0 24px rgba(159, 213, 93, 0.25),
    0 18px 46px rgba(0, 0, 0, 0.5);
}

h2 {
  color: #fff2e6;
}

.brand p:not(.kicker) {
  max-width: 390px;
  margin: 0;
  color: #eadfce;
  font-size: 17px;
  font-weight: 720;
}

.rules-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: min(520px, calc(100vw - 36px));
}

.rules-strip span {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  color: #fff7ec;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.drain-icon,
.speed-icon,
.roach-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
}

.drain-icon {
  border: 2px solid #c8c0b2;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px #33302b, 0 0 12px rgba(255, 255, 255, 0.25);
}

.roach-icon {
  width: 20px;
  height: 12px;
  background: #4a2515;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(74, 37, 21, 0.9);
}

.roach-icon::before,
.roach-icon::after {
  position: absolute;
  top: 5px;
  width: 8px;
  height: 1px;
  content: "";
  background: #d1a17c;
}

.roach-icon::before {
  left: -6px;
  transform: rotate(-28deg);
}

.roach-icon::after {
  right: -6px;
  transform: rotate(28deg);
}

.speed-icon::before {
  position: absolute;
  inset: 3px;
  content: "";
  border-top: 3px solid var(--green);
  border-right: 3px solid var(--green);
  transform: rotate(45deg);
}

.best-panel {
  min-width: 150px;
  padding: 14px 18px;
}

.tap-copy {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: pulse 850ms ease-in-out infinite alternate;
}

.result dl {
  display: flex;
  gap: 12px;
  margin: 8px 0 0;
}

.result div {
  min-width: 116px;
  padding: 14px 16px;
}

dt,
dd {
  margin: 0;
}

.sound-toggle {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 8;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  opacity: 1;
  transition: opacity 160ms ease, transform 160ms ease;
}

.sound-toggle.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

.sound-toggle span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  white-space: nowrap;
  text-indent: 999px;
}

.sound-toggle span::before,
.sound-toggle span::after {
  position: absolute;
  text-indent: 0;
}

.sound-toggle span::before {
  width: 12px;
  height: 14px;
  content: "";
  background: currentColor;
  border-radius: 2px 8px 8px 2px;
  clip-path: polygon(0 32%, 42% 32%, 100% 0, 100% 100%, 42% 68%, 0 68%);
}

.sound-toggle span::after {
  width: 18px;
  height: 18px;
  margin-left: 18px;
  content: "";
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 50%;
}

.sound-toggle.is-muted {
  color: var(--muted);
}

.sound-toggle.is-muted span::after {
  width: 22px;
  height: 2px;
  margin-left: 12px;
  background: currentColor;
  border: 0;
  border-radius: 999px;
  transform: rotate(-42deg);
}

@keyframes pulse {
  from {
    opacity: 0.6;
    transform: translateY(0);
  }

  to {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 430px) {
  .hud {
    gap: 7px;
  }

  .hud div {
    min-width: 74px;
    padding: 8px 7px;
  }

  .hud strong,
  .best-panel strong,
  dd {
    font-size: 22px;
  }

  .rules-strip span {
    min-height: 30px;
    padding: 7px 8px;
    font-size: 10px;
  }
}

@media (max-height: 560px) {
  .screen {
    gap: 14px;
  }

  h1,
  h2 {
    font-size: clamp(34px, 9vw, 60px);
  }
}
