/* ================= Red Light Green Light Dogs — styles ================= */

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

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "Baloo 2", system-ui, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  background: #4b2a6e;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  height: 100dvh;
}

#race {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --------------------------- Touch buttons --------------------------- */
/* Each pad covers its player's half (the middle strip is 34px tall). */

.pad {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(50% - 17px);
  display: none;
  pointer-events: none;
  padding: 0 calc(10px + env(safe-area-inset-right, 0px)) 10px calc(10px + env(safe-area-inset-left, 0px));
  align-items: flex-end;
  justify-content: space-between;
}

.pad[data-p="0"] { top: 0; }
.pad[data-p="1"] { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }

body.touch.playing .pad { display: flex; }

/* Playing alone: one big screen, the strip along the bottom. */
body.solo .pad[data-p="0"] { height: calc(100% - 34px); }
body.solo.touch.playing .pad[data-p="1"] { display: none; }
body.solo #music-btn { top: calc(100% - 32px); }
body.solo #practice-hud { top: calc(100% - 34px); }

.run-btns { display: flex; gap: 10px; }

.pad button {
  pointer-events: auto;
  touch-action: none;
  width: clamp(54px, 12vmin, 84px);
  height: clamp(54px, 12vmin, 84px);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: rgba(75, 42, 110, 0.45);
  color: #fff;
  font-family: inherit;
  font-size: clamp(22px, 5vmin, 34px);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.pad[data-p="0"] button { border-color: #ff8cc4; }
.pad[data-p="1"] button { border-color: #a996ff; }
.pad button.held { background: rgba(255, 255, 255, 0.55); transform: scale(0.94); }
.pad .jump-btn { width: clamp(64px, 14vmin, 96px); height: clamp(64px, 14vmin, 96px); }

/* ---------------------------- Music button --------------------------- */
/* Sits on the left end of the middle strip (34px tall) while you race. */

#music-btn {
  position: absolute;
  top: calc(50% - 15px);
  left: calc(4px + env(safe-area-inset-left, 0px));
  width: 30px;
  height: 30px;
  padding: 0;
  display: none;
  font-size: 16px;
  line-height: 1;
  background: #fff;
  border: 2px solid #a996ff;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 10;
}

body.playing #music-btn { display: block; }

/* --------------------------- Practice HUD ---------------------------- */

#practice-hud {
  position: absolute;
  top: calc(50% - 17px);
  left: 50%;
  transform: translate(-50%, -100%);
  display: none;
  gap: 8px;
  align-items: center;
  padding-bottom: 6px;
  z-index: 10;
}

#practice-hud.show { display: flex; }

.practice-badge {
  font-weight: 800;
  font-size: 15px;
  color: #b02c78;
  background: #fff;
  border-radius: 99px;
  padding: 2px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.practice-done {
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  background: #e0459d;
  border: none;
  border-radius: 99px;
  padding: 3px 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ---------------------------- Overlays ------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(180deg, #8fd3ff, #c8f0c0);
  overflow-y: auto;
  touch-action: pan-y;
}

.overlay.show { display: flex; }
.overlay.win { background: rgba(255, 220, 120, 0.55); backdrop-filter: blur(3px); }

.card {
  background: #fff;
  border-radius: 28px;
  border: 6px solid #9fd77c;
  box-shadow: 0 16px 0 rgba(60, 120, 60, 0.25), 0 24px 40px rgba(0, 0, 0, 0.3);
  padding: clamp(18px, 4.5vw, 36px);
  max-width: 520px;
  width: 100%;
  margin: auto;
  text-align: center;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardIn { from { transform: scale(0.6) translateY(30px); opacity: 0; } }

.card-emoji { font-size: clamp(46px, 12vw, 72px); line-height: 1; margin-bottom: 6px; }

.card h1 {
  margin: 6px 0 4px;
  font-size: clamp(26px, 6.5vw, 40px);
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(90deg, #e03131, #f59f00, #2f9e44);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card p {
  margin: 8px 0;
  font-size: clamp(15px, 3.6vw, 19px);
  font-weight: 500;
  color: #3a3a5a;
}

.card p.byline {
  margin: 0 0 10px;
  font-size: clamp(15px, 3.6vw, 18px);
  font-weight: 800;
  color: #2f9e44;
}

.card p.small { font-size: clamp(13px, 3vw, 16px); color: #6a6a8a; }

.mode-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.mode-btn {
  font-family: inherit;
  font-size: clamp(15px, 3.6vw, 18px);
  font-weight: 800;
  color: #2f9e44;
  background: #fff;
  border: 3px solid #b9e5a8;
  border-radius: 99px;
  padding: 6px 16px;
  cursor: pointer;
}

.mode-btn.on { color: #fff; background: #2f9e44; border-color: #2f9e44; }

.names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.keys-one { display: none !important; }
.card.solo .keys-one { display: block !important; }
.card.solo .keys-two { display: none !important; }
.card.solo .names { grid-template-columns: 1fr; max-width: 260px; margin-left: auto; margin-right: auto; }
.card.solo .name-row:nth-child(2) { display: none; }

.name-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font-weight: 800;
  color: var(--kid);
  font-size: 16px;
}

.name-row small { display: block; font-weight: 700; color: #8a8aa8; font-size: 12px; }

.name-box {
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 14px;
  border: 3px solid var(--kid);
  outline: none;
  width: 100%;
  user-select: text;
  -webkit-user-select: text;
}

.btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 14px; }

.big-btn {
  margin-top: 18px;
  font-family: inherit;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #51cf66, #2f9e44);
  border: none;
  border-radius: 99px;
  padding: 12px 32px;
  cursor: pointer;
  box-shadow: 0 6px 0 #237032, 0 10px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #237032, 0 4px 10px rgba(0, 0, 0, 0.25); }

.big-btn.alt-btn {
  color: #2f9e44;
  background: linear-gradient(180deg, #fff, #effbea);
  box-shadow: 0 6px 0 #b9e5a8, 0 10px 18px rgba(0, 0, 0, 0.18);
}

.lang-btn {
  display: block;
  margin: 18px auto 0;
  font-family: inherit;
  font-size: clamp(13px, 3vw, 16px);
  font-weight: 700;
  color: #2f9e44;
  background: #fff;
  border: 2px solid #b9e5a8;
  border-radius: 99px;
  padding: 4px 16px;
  cursor: pointer;
}
