* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8fcbf0;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* the canvas takes every touch itself: no page zoom or scroll while playing */
canvas { display: block; touch-action: none; }
button { touch-action: manipulation; }

/* Question 15: money bottom right, you in the middle, nothing else. The
   banner comes and goes: a tsunami coming, or what a lucky block rolled. */

#fade {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 5;
}

#fade.on { opacity: 0.7; transition: none; }

/* ------------------------------------------ the list of games, and pause */

#list, #pause {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
}

#list {
  touch-action: pan-y;
  background: radial-gradient(circle at 50% 30%, #b8e3a0 0%, #6fae55 55%, #3d6b2e 100%);
  color: #1c3312;
  overflow-y: auto;
}

#pause { background: rgba(28, 51, 18, 0.72); gap: 14px; }

#list.hidden, #pause.hidden { display: none; }

#list h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 68px);
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 4px 0 #2f5a22, 0 10px 30px rgba(20, 40, 10, 0.45);
}

#list .tag {
  margin: 8px 0 24px;
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 700;
  letter-spacing: 1px;
  color: #22401a;
}

.games {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  max-width: 720px;
}

.game {
  display: flex;
  flex-direction: column;
  width: 230px;
  padding: 0 0 16px;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  color: #1c3312;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 0 #2f5a22;
  transition: transform 0.1s ease;
}

@media (hover: hover) { .game:hover { transform: translateY(-3px); } }
.game:active { transform: translateY(2px); box-shadow: 0 3px 0 #2f5a22; }

.game .pic { display: block; height: 110px; margin-bottom: 12px; }

/* pictures drawn in CSS: a gold lucky block on grass, and pillars in the sky */
.pic.tycoon {
  background:
    linear-gradient(#f7d25a, #e5a92c) 50% 46% / 54px 54px no-repeat,
    linear-gradient(#8fcbf0 62%, #5fae3c 62%);
}
.pic.obby {
  background:
    linear-gradient(#c49a5a, #c49a5a) 22% 70% / 22px 60px no-repeat,
    linear-gradient(#c49a5a, #c49a5a) 50% 55% / 22px 80px no-repeat,
    linear-gradient(#c49a5a, #c49a5a) 78% 40% / 22px 100px no-repeat,
    linear-gradient(#8fcbf0 80%, #5fae3c 80%);
}

.game .name { padding: 0 16px; font-size: 19px; font-weight: 700; }
.game .desc { padding: 4px 16px 0; font-size: 13px; line-height: 1.45; opacity: 0.8; }

#list .keys {
  margin: 26px 0 0;
  font-size: clamp(12px, 1.5vw, 14px);
  line-height: 2;
  color: #22401a;
}

/* the controls line says keys on a computer and thumbs on an iPad */
#list .forTouch, body.touch #list .forKeys { display: none; }
body.touch #list .forTouch { display: block; }

#list .keys b {
  padding: 1px 7px;
  border-radius: 6px;
  background: #1c3312;
  color: #fff;
  font-size: 0.9em;
}

#pause h2 { margin: 0 0 8px; font-size: 34px; letter-spacing: 3px; }

#resumeBtn, #toListBtn {
  min-width: 260px;
  padding: 14px 32px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
}

#resumeBtn { background: #f2b63a; color: #fff; box-shadow: 0 5px 0 #b67f14; }
#toListBtn { background: #fff; color: #1c3312; box-shadow: 0 5px 0 #9fb894; }

/* ------------------------------------------------ money, and the banner */

#br {
  position: fixed;
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
}

#br.hidden, #shop.hidden { display: none; }

#shopBtn {
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: #f2b63a;
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b67f14;
}

#shopBtn kbd {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.22);
  font: inherit;
  font-size: 12px;
}

#shopBtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b67f14; }

#money {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: 1px;
  color: #7dffa4;
  text-shadow: 0 3px 0 #1f5a2f, 0 4px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}


#banner {
  position: fixed;
  top: 12%;
  left: 50%;
  z-index: 30;
  transform: translate(-50%, -8px) scale(0.96);
  font-size: clamp(22px, 3.4vw, 36px);
  font-weight: 800;
  letter-spacing: 2px;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55), 0 6px 20px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#banner.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
#banner.big { font-size: clamp(30px, 5.5vw, 60px); }

/* -------------------------------------------------------------- the shop */

#shop {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  background: rgba(28, 51, 18, 0.82);
  text-align: center;
}

#shop h2 { margin: 0; font-size: 36px; letter-spacing: 3px; color: #ffd23d; }
#shop .shopMoney { margin: 0 0 8px; font-size: 18px; }
#shop .shopMoney b { color: #7dffa4; }

#shop .item {
  display: flex;
  align-items: center;
  gap: 20px;
  width: min(480px, 92vw);
  padding: 16px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: #1c3312;
  text-align: left;
}

#shop .item > div { flex: 1; }
#shop .name { font-size: 20px; font-weight: 800; }
#shop .desc { margin-top: 3px; font-size: 14px; }

#shop .pips { display: flex; gap: 4px; margin-top: 8px; }
#shop .pips i { flex: 1; height: 7px; border-radius: 4px; background: #d8e2d2; }
#shop .pips i.on { background: #4fc26a; }

#buySpeed, #buyBase, #shopClose {
  padding: 11px 20px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
}

#buySpeed, #buyBase { min-width: 100px; background: #f2b63a; color: #fff; box-shadow: 0 4px 0 #b67f14; }
#buySpeed:disabled, #buyBase:disabled { background: #b9c3b4; box-shadow: none; cursor: default; }
#shopClose { margin-top: 8px; background: #fff; color: #1c3312; box-shadow: 0 4px 0 #9fb894; }

/* ------------------------------------------------------------ iPad / touch */
/* Question 14's iPad: a thumbstick on the left walks, dragging anywhere else
   looks, a button jumps. The stick rests above the bottom-left corner (the
   Rigotti Games link lives there) and jumps to wherever your thumb lands. */

body.touch #shopBtn { min-height: 48px; padding: 12px 22px; }
body.touch #shopBtn kbd { display: none; }

#touch { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
#touch.hidden { display: none; }

#stick {
  position: absolute;
  left: calc(36px + env(safe-area-inset-left));
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: 130px;
  height: 130px;
  border: 3px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  background: rgba(28, 51, 18, 0.22);
  opacity: 0.7;
}

#stick.on { opacity: 1; }

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(28, 51, 18, 0.45);
}

#jumpBtn, #pauseBtn {
  position: absolute;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #1c3312;
  font: inherit;
  font-weight: 800;
  letter-spacing: 1.5px;
  box-shadow: 0 5px 0 #9fb894;
  pointer-events: auto;
  touch-action: none;
}

#jumpBtn {
  right: calc(30px + env(safe-area-inset-right));
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  font-size: 18px;
}

#pauseBtn {
  right: calc(18px + env(safe-area-inset-right));
  top: calc(16px + env(safe-area-inset-top));
  width: 52px;
  height: 52px;
  font-size: 18px;
  letter-spacing: 2px;
}

#jumpBtn.down, #pauseBtn:active { transform: translateY(3px); box-shadow: 0 2px 0 #9fb894; }
