:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #17262a;
  color: #f8f1dc;
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  margin: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(242, 205, 109, 0.18), transparent 34rem),
    linear-gradient(140deg, #17262a 0%, #2d3f35 45%, #18282d 100%);
}

.game-shell {
  width: min(100vw, 1180px);
  height: 100vh;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  position: relative;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 10px 14px;
  border: 3px solid #372f2c;
  background: #6f4e37;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18);
}

.hud > div:first-child {
  min-width: 0;
}

.hud strong,
.score {
  font-size: clamp(18px, 2.4vw, 28px);
  line-height: 1;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: #ffd97d;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hint-text {
  display: block;
  margin-top: 6px;
  color: #f8dcb0;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  display: flex;
  align-items: center;
  gap: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.hud-button,
.primary-button,
.secondary-button,
.mode-button,
.win-dialog button {
  border: 3px solid #372f2c;
  background: #d85f4f;
  color: #fff8e6;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  transition:
    transform 120ms ease,
    filter 120ms ease;
}

.hud-button:hover,
.primary-button:hover,
.secondary-button:hover,
.mode-button:hover,
.win-dialog button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.hud-button:active,
.primary-button:active,
.secondary-button:active,
.mode-button:active,
.win-dialog button:active {
  transform: translateY(1px);
}

.hud-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 15px;
}

#game {
  width: 100%;
  height: min(calc(100vh - 98px), 720px);
  min-height: 420px;
  display: block;
  border: 3px solid #372f2c;
  background: #7fc56d;
  image-rendering: pixelated;
  touch-action: none;
}

.menu-overlay {
  position: absolute;
  inset: 88px 14px 14px;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(23, 38, 42, 0.54), rgba(23, 38, 42, 0.7)),
    radial-gradient(circle at 30% 28%, rgba(255, 217, 125, 0.22), transparent 16rem);
  border: 3px solid #372f2c;
  z-index: 3;
}

.menu-overlay.hidden,
.hidden {
  display: none;
}

.menu-panel {
  width: min(92vw, 620px);
  padding: 26px;
  border: 4px solid #372f2c;
  background:
    linear-gradient(180deg, #fff4cf 0%, #f8f1dc 100%);
  color: #372f2c;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.menu-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(34px, 7vw, 58px);
  letter-spacing: 0;
}

.menu-panel p {
  margin: 0 0 20px;
  font-size: 18px;
}

.records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 20px;
}

.records span {
  min-height: 54px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 3px solid #372f2c;
  background: #7fc56d;
  color: #372f2c;
  font-size: 14px;
  font-weight: 800;
}

.records strong {
  font-size: 20px;
}

.primary-button {
  min-height: 50px;
  padding: 0 24px;
  font-size: 20px;
}

.secondary-button {
  min-height: 42px;
  margin-top: 16px;
  padding: 0 18px;
  background: #7c8581;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.mode-button {
  min-height: 118px;
  padding: 14px;
  background:
    linear-gradient(180deg, #7b583e 0%, #6f4e37 100%);
  text-align: left;
}

.mode-button strong,
.mode-button span,
.mode-button em {
  display: block;
}

.mode-button strong {
  margin-bottom: 8px;
  font-size: 19px;
}

.mode-button span {
  font-size: 14px;
  line-height: 1.25;
}

.mode-button em {
  margin-top: 10px;
  color: #ffd97d;
  font-size: 13px;
  font-style: normal;
}

.touch-controls {
  position: fixed;
  left: 0;
  top: 0;
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-9999px, -9999px);
  transition: opacity 100ms ease;
  z-index: 4;
}

.touch-controls.visible {
  opacity: 1;
}

.stick-base {
  width: 112px;
  height: 112px;
  border: 3px solid rgba(55, 47, 44, 0.78);
  border-radius: 999px;
  background: rgba(248, 241, 220, 0.28);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.stick-nub {
  width: 44px;
  height: 44px;
  border: 3px solid #372f2c;
  border-radius: 999px;
  background: #ffd97d;
  position: absolute;
  left: 31px;
  top: 31px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

.dash-button {
  position: fixed;
  right: max(72px, calc((100vw - 1180px) / 2 + 78px));
  bottom: 82px;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  gap: 0;
  border: 4px solid #372f2c;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 28%, #fff0c7 0 12%, transparent 13%),
    linear-gradient(180deg, #64a7d8 0%, #2d6d8f 100%);
  color: #fff8e6;
  font: inherit;
  font-weight: 900;
  pointer-events: auto;
  cursor: pointer;
  box-shadow:
    inset 0 -7px 0 rgba(0, 0, 0, 0.22),
    0 10px 28px rgba(0, 0, 0, 0.25);
  z-index: 6;
  touch-action: manipulation;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    opacity 120ms ease;
}

.dash-button strong {
  align-self: end;
  font-size: 18px;
  line-height: 1;
}

.dash-button span {
  align-self: start;
  min-width: 28px;
  min-height: 24px;
  display: grid;
  place-items: center;
  margin-top: 4px;
  border: 2px solid #372f2c;
  background: #ffd97d;
  color: #372f2c;
  font-size: 18px;
  line-height: 1;
}

.dash-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.dash-button:active {
  transform: translateY(2px) scale(0.97);
}

.dash-button:disabled {
  opacity: 0.45;
  cursor: default;
  filter: grayscale(0.25);
}

.dash-button.ready {
  animation: dashPulse 1.1s ease-in-out infinite;
}

@keyframes dashPulse {
  0%,
  100% {
    box-shadow:
      inset 0 -7px 0 rgba(0, 0, 0, 0.22),
      0 10px 28px rgba(0, 0, 0, 0.25);
  }

  50% {
    box-shadow:
      inset 0 -7px 0 rgba(0, 0, 0, 0.22),
      0 0 0 7px rgba(255, 217, 125, 0.24),
      0 12px 30px rgba(0, 0, 0, 0.25);
  }
}

.win-dialog {
  width: min(92vw, 520px);
  border: 4px solid #372f2c;
  padding: 28px;
  background: #f8f1dc;
  color: #372f2c;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.win-dialog::backdrop {
  background: rgba(19, 30, 34, 0.7);
}

.win-dialog h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 6vw, 46px);
  letter-spacing: 0;
}

.win-dialog p {
  margin: 0 0 22px;
  font-size: 18px;
}

.win-dialog button {
  min-height: 46px;
  padding: 0 20px;
}

.dialog-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

@media (pointer: coarse), (max-width: 760px) {
  .game-shell {
    padding: 8px;
  }

  .hud {
    min-height: 54px;
    padding: 8px 10px;
    align-items: flex-start;
  }

  .score {
    gap: 8px;
    font-size: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .hud-button {
    min-height: 32px;
    padding: 0 7px;
    font-size: 13px;
  }

  .dash-button {
    right: 54px;
    bottom: 96px;
    width: 86px;
    height: 86px;
  }

  .dash-button strong {
    font-size: 16px;
  }

  #game {
    height: calc(100vh - 78px);
    min-height: 360px;
  }

  .menu-overlay {
    inset: 72px 8px 8px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .records {
    grid-template-columns: 1fr;
  }
}
