body {
  margin: 0;
  background-color: #0C1A24;
  color: #e6e6e6;
  font-family: Arial, sans-serif;
}

#money {
  position: absolute;
  top: 0%;
  left: -1%;
  width: 101%;
  height: 6%;
  border-radius: 4px;
  background-color: rgba(9, 19, 28, 0.86);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
  user-select: none;
}

#birr {
  position: absolute;
  color: rgb(0, 204, 41);
  font-size: 100%;
  width: 10%;
  height: 90%;
  top: 5.8%;
  left: 107%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#money_box {
  position: absolute;
  color: #f8fafc;
  font-size: 100%;
  border: rgba(255, 255, 255, 0.14) solid 1px;
  width: 10%;
  height: 90%;
  top: 5.8%;
  left: 50%;
  background-color: #101f2d;
  border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: center;
  align-items: center;
}

#conves {
  position: absolute;
  background: linear-gradient(180deg, #132535 0%, #0d1b28 100%);
  width: 70%;
  height: 89%;
  top: 7%;
  left: 28.7%;
  border-radius: 0px 5px 5px 0px;
  user-select: none;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#box {
  position: absolute;
  width: 23%;
  height: 89%;
  top: 7%;
  left: 5.7%;
  background: linear-gradient(180deg, #26384b 0%, #172839 100%);
  border-radius: 10px 0px 0px 10px;
  user-select: none;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#balance {
  position: absolute;
  width: 55%;
  height: 3%;
  border-radius: 4px;
  padding: 10px;
  background-color: #0d1a27;
  color: white;
  border: 1px solid rgba(76, 154, 255, 0.55);
  top: 14%;
  left: 3%;
  font-size: 150%;
  outline: none;
  box-shadow: inset 0 1px 8px rgba(0, 0, 0, 0.28);
}

#bet_amount {
  position: absolute;
  color: #cbd5e1;
  font-size: 130%;
  top: 10%;
  left: 3%;
  user-select: none;
}

#incrementButton {
  position: absolute;
  color: white;
  background-color: #33465c;
  font-size: 130%;
  width: 15%;
  height: 7%;
  top: 14%;
  left: 83%;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#decrementButton {
  position: absolute;
  color: white;
  background-color: #33465c;
  font-size: 130%;
  width: 15%;
  height: 7%;
  top: 14%;
  left: 66.8%;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#incrementButton:hover,
#decrementButton:hover {
  background-color: #405772;
}

#add-ball {
  position: absolute;
  width: 93%;
  height: 10%;
  top: 51%;
  left: 3%;
  border: 0;
  background: linear-gradient(180deg, #27d34d 0%, #168b2c 100%);
  color: #06130b;
  font-size: 110%;
  font-weight: 800;
  cursor: pointer;
  border-radius: 7px;
  box-shadow: 0 10px 22px rgba(39, 211, 77, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

#add-ball:hover {
  filter: brightness(1.08);
}

#add-ball:disabled {
  cursor: wait;
  filter: grayscale(0.45);
  opacity: 0.75;
}

#buttons {
  position: absolute;
  top: 20%;
  left: 5.3%;
  width: 100%;
  height: 30%;
  display: grid;
  grid-column-gap: 30%;
  grid-row-gap: 1%;
  grid-template-columns: repeat(2, 50px);
}


#rode {
  position: absolute;
  width: 92%;
  height: 90%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 30%),
    linear-gradient(180deg, #31404f 0%, #1c2733 60%, #141b24 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  top: 5%;
  left: 4%;
  padding: 0 18px 0 68px;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: #9aa4b2 #1f2937;
  scrollbar-width: thin;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.26);
}

.rodes {
  position: relative;
  flex: 0 0 118px;
  width: 118px;
  height: 86%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10), transparent 26%),
    linear-gradient(90deg, #4a5260 0%, #626d7e 50%, #39404c 100%);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.rodes.crash-open {
  overflow: visible;
}

/* yellow center dashes down each lane */
.rodes::after {
  content: "";
  position: absolute;
  top: 3%;
  bottom: 15%;
  left: 50%;
  width: 4px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, #ffd83b 0 12px, transparent 12px 24px);
  border-radius: 2px;
  opacity: 0.85;
  z-index: 2;
}

.tile-mult {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 70%;
  padding: 4px 8px;
  text-align: center;
  color: #f8fafc;
  font-size: clamp(11px, 1vw, 15px);
  font-weight: 800;
  background-color: rgba(5, 12, 18, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  z-index: 3;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.rodes[data-state="safe"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 30%),
    linear-gradient(90deg, #176936 0%, #24a148 50%, #176936 100%);
}

.rodes[data-state="crash"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 30%),
    linear-gradient(90deg, #761a1a 0%, #d13b34 50%, #761a1a 100%);
}

.rodes[data-state="finish"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 30%),
    linear-gradient(90deg, #8a6511 0%, #f5b82e 50%, #8a6511 100%);
}

.rodes::before {
  content: "";
  position: absolute;
  top: 1%;
  left: 0%;
  height: 100%;
  border-left: 3px dashed #fff;
  border-image: repeating-linear-gradient(to bottom, rgb(206, 206, 188) 0 14px, rgb(106, 80, 80) -10px 24px) 1;
  transform: translateX(-50%);
  opacity: 0.7;
  z-index: 2;
}

#movingBetBox {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 64px;
  height: 64px;
  font-size: 40px;
  line-height: 1;
  background:
    radial-gradient(circle at 36% 32%, #fff4bf 0 16%, transparent 17%),
    linear-gradient(180deg, #ffd166 0%, #f2a51a 100%);
  border: 2px solid #f8f0c8;
  border-radius: 999px;
  flex-shrink: 0;
  z-index: 4;
  box-shadow: 0 12px 18px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  pointer-events: none;
}

#defend {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  top: 42%;
  left: 50%;
  width: 80%;
  padding: 6px 4px;
  color: #f8fafc;
  font-size: clamp(11px, 1vw, 15px);
  font-weight: 800;
  background-color: rgba(5, 12, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  flex-shrink: 0;
  z-index: 5;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

/* start gate / side road: a wide yellow/black hazard ramp on the left
   edge of the rode with the gold gate bar facing the road */
.first {
  position: absolute;
  top: 50%;
  left: 24px;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 86%;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 40%),
    repeating-linear-gradient(45deg, #ffd83b 0 14px, #17181a 14px 28px);
  border: 2px solid #8c8c8c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 14px rgba(0, 0, 0, 0.3);
}

.first::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #ffe27a 0%, #f2a51a 100%);
  border-left: 1px solid #f8f0c8;
  box-shadow: 0 0 14px rgba(242, 165, 26, 0.55);
}

.show {
  font-size: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid #8b8b8b00;
}

#show {
  position: absolute;
  top: 7%;
  left: 0%;
  width: 5.4%;
  height: 89%;
  border-radius: 4px;
  user-select: none;
  z-index: 20;
}

#show_game {
  position: absolute;
  top: 0%;
  left: 5%;
  width: 90%;
  height: 5%;
  border-radius: 4px;
  user-select: none;
}

#show_mode {
  position: absolute;
  top: 5.4%;
  left: 5%;
  width: 90%;
  height: 6%;
  border-radius: 4px;
  user-select: none;
}

#show_money {
  position: absolute;
  top: 17.5%;
  left: 5%;
  width: 90%;
  height: 6%;
  border-radius: 4px;
  user-select: none;
}

#show_bet {
  position: absolute;
  top: 43%;
  left: 5%;
  width: 90%;
  height: 6%;
  border-radius: 4px;
  user-select: none;
}

#show_multi {
  position: absolute;
  top: 67%;
  left: 0%;
  width: 99%;
  height: 6%;
  border-radius: 4px;
  user-select: none;
}

#show_round {
  position: absolute;
  top: 94%;
  left: 5%;
  width: 90%;
  height: 6%;
}

.Ashow {
  border: #20c997 solid 1px;
  font-size: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#show_number {
  position: absolute;
  top: 28%;
  left: 5%;
  width: 90%;
  height: 6%;
}

#show_win {
  position: absolute;
  top: 37%;
  left: 5%;
  width: 90%;
  height: 6%;
}

#show_loss {
  position: absolute;
  top: 47%;
  left: 5%;
  width: 90%;
  height: 6%;
}

#show_onporfit {
  position: absolute;
  top: 56%;
  left: 5%;
  width: 90%;
  height: 6%;
}

#show_onloss {
  position: absolute;
  top: 66.6%;
  left: 5%;
  width: 90%;
  height: 6%;
}

#manual_auto {
  position: absolute;
  color: white;
  background-color: rgb(30, 43, 55);
  width: 94%;
  height: 8%;
  left: 3%;
  top: 1%;
  border-radius: 40px;
}

#manual {
  position: absolute;
  color: white;
  background-color: rgb(40, 56, 72);
  width: 48%;
  height: 80%;
  left: 2%;
  top: 10%;
  border: #0000000f solid 1px;
  cursor: pointer;
  border-radius: 40px;
}

#auto {
  position: absolute;
  color: white;
  background-color: rgb(30, 43, 55);
  width: 45%;
  height: 80%;
  left: 52%;
  top: 10%;
  border: #0000000f solid 1px;
  cursor: pointer;
  border-radius: 40px;
}

#labeltarget {
  position: absolute;
  color: #cbd5e1;
  font-size: 110%;
  top: 24%;
  left: 3%;
  user-select: none;
}

#target {
  position: absolute;
  width: 88%;
  height: 3%;
  border-radius: 4px;
  padding: 10px;
  background-color: #0d1a27;
  color: white;
  border: 1px solid rgba(76, 154, 255, 0.55);
  top: 28%;
  left: 3%;
  font-size: 130%;
  outline: none;
}

  #cashoutBtn {
    position: absolute;
    width: 93%;
    height: 10%;
    top: 62%;
    left: 3%;
  border: 0;
  background: linear-gradient(180deg, #f5b82e 0%, #b97e0e 100%);
  color: #231600;
  font-size: 110%;
  font-weight: 800;
  cursor: pointer;
  border-radius: 7px;
}

#add-ball2 {
  position: absolute;
  width: 93%;
  height: 8%;
  top: 88%;
  left: 3%;
  border: 0;
  background: linear-gradient(180deg, #27d34d 0%, #168b2c 100%);
  color: #06130b;
  font-size: 110%;
  font-weight: 800;
  cursor: pointer;
  border-radius: 7px;
}

#auto_view {
  position: absolute;
  top: 36%;
  left: 3%;
  width: 94%;
  height: 50%;
}

#Labelnumberofbet {
  position: absolute;
  font-size: 90%;
  left: 1%;
  top: 0%;
  color: #cbd5e1;
}

#numberofbet {
  position: absolute;
  left: 1%;
  top: 5%;
  width: 93%;
  height: 7%;
  border-radius: 4px;
  background-color: #0d1a27;
  color: white;
  border: 1px solid rgba(76, 154, 255, .55);
}

#reset1 {
  position: absolute;
  top: 14%;
  left: 1%;
  width: 25%;
  height: 7%;
  border-radius: 7px;
  background: #33465c;
  color: #fff;
  border: 1px solid #fff;
  cursor: pointer;
  font-size: 80%;
}

#Increase1 {
  position: absolute;
  top: 14%;
  left: 28%;
  width: 65%;
  height: 7%;
  border-radius: 7px;
  background: #33465c;
  color: #fff;
  border: 1px solid rgba(0, 0, 0, 0);
  cursor: pointer;
  font-size: 80%;
}

#Labelonwin {
  position: absolute;
  left: 1%;
  top: 23%;
  font-size: 90%;
  color: #cbd5e1;
}

#onwin {
  position: absolute;
  left: 1%;
  top: 28%;
  width: 93%;
  height: 7%;
  border-radius: 4px;
  background-color: #0d1a27;
  color: white;
  border: 1px solid rgba(76, 154, 255, .55);
  opacity: .5;
  pointer-events: none;
}

#reset2 {
  position: absolute;
  top: 37%;
  left: 1%;
  width: 25%;
  height: 7%;
  border-radius: 7px;
  background: #33465c;
  color: #fff;
  border: 1px solid #fff;
  cursor: pointer;
  font-size: 80%;
}

#Increase2 {
  position: absolute;
  top: 37%;
  left: 28%;
  width: 65%;
  height: 7%;
  border-radius: 7px;
  background: #33465c;
  color: #fff;
  border: 1px solid rgba(0, 0, 0, 0);
  cursor: pointer;
  font-size: 80%;
}

#Labelonloss {
  position: absolute;
  left: 1%;
  top: 46%;
  font-size: 90%;
  color: #cbd5e1;
}

#onloss {
  position: absolute;
  left: 1%;
  top: 51%;
  width: 93%;
  height: 7%;
  border-radius: 4px;
  background-color: #0d1a27;
  color: white;
  border: 1px solid rgba(76, 154, 255, .55);
  opacity: .5;
  pointer-events: none;
}

#Labelstoponprofit {
  position: absolute;
  left: 1%;
  top: 60%;
  font-size: 90%;
  color: #cbd5e1;
}

#onprofit {
  position: absolute;
  left: 1%;
  top: 65%;
  width: 93%;
  height: 7%;
  border-radius: 4px;
  background-color: #0d1a27;
  color: white;
  border: 1px solid rgba(76, 154, 255, .55);
}

#Labelstoponloss {
  position: absolute;
  left: 1%;
  top: 74%;
  font-size: 90%;
  color: #cbd5e1;
}

#stoponloss {
  position: absolute;
  left: 1%;
  top: 79%;
  width: 93%;
  height: 7%;
  border-radius: 4px;
  background-color: #0d1a27;
  color: white;
  border: 1px solid rgba(76, 154, 255, .55);
}

#Gbutton {
  position: absolute;
  z-index: 40;
  left: 80%;
  top: 10%;
  width: clamp(54px, 7vw, 86px);
  height: clamp(28px, 3.2vh, 36px);
  cursor: pointer;
  border-radius: 7%;
  background: linear-gradient(180deg, #1a444e, #1e2c36);
  border: 1px solid rgb(29 176 171 / 92%);
  color: #e0e0e0;
}

@media (max-width: 900px) {

  #rode {
    position: absolute;
    width: 92%;
    height: 90%;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 30%),
      linear-gradient(180deg, #31404f 0%, #1c2733 60%, #141b24 100%);
    display: flex;
    align-items: center;
    gap: 1px;
    top: 5%;
    left: 4%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-color: #9aa4b2 #1f2937;
    scrollbar-width: thin;
  }

  .rodes {
    position: relative;
    flex: 0 0 92px;
    width: 92px;
    height: 86%;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 24%),
      linear-gradient(90deg, #3e4650 0%, #586371 50%, #3e4650 100%);
    border-radius: 8px;
  }

  #movingBetBox {
    width: 52px;
    height: 52px;
    font-size: 32px;
  }
}

/* ============================================================
     GAME LOOK — start gate, finish flag, living chicken
     ============================================================ */

/* start gate / side road is defined above (.first);
   the chicken waits next to it before the first Go. */

/* finish flag on the last tile (added by JS) */
.tile-flag {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  line-height: 1;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

/* chicken bobs so the road feels alive */
#movingBetBox {
  animation: none;
  /* controlled by state classes below */
}

/* ============================================================
     CHICKEN — idle(stay) / jump / crash / win + CARS + DIFFICULTY
     ============================================================ */

  /* ---- difficulty bar (inside #box controls) ---- */
  #diffbar {
    position: absolute;
    top: 34.5%;
    left: 3%;
    width: 94%;
    display: flex;
    gap: 6px;
    z-index: 30;
  }

#diffbar button {
  flex: 1;
  padding: 6px 4px;
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #dbe7f3;
  background: rgba(8, 18, 27, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

#diffbar button:hover {
  transform: translateY(-1px);
}

#diffbar button.on {
  color: #06130b;
  background: linear-gradient(180deg, #ffe27a, #f2a51a);
  border-color: #f8f0c8;
  box-shadow: 0 4px 14px rgba(242, 165, 26, 0.45);
}

#diffbar.locked {
  opacity: 0.55;
  pointer-events: none;
  filter: saturate(0.6);
}

/* per-difficulty glow on the active button */
body[data-diff="easy"] #diffbar button.on {
  background: linear-gradient(180deg, #7dffab, #1faa53);
  border-color: #d2ffe2;
  box-shadow: 0 4px 14px rgba(39, 211, 77, .5);
}

body[data-diff="medium"] #diffbar button.on {
  background: linear-gradient(180deg, #ffe27a, #f2a51a);
}

body[data-diff="hard"] #diffbar button.on {
  background: linear-gradient(180deg, #ffb27a, #f26a1a);
  border-color: #ffe2c8;
  box-shadow: 0 4px 14px rgba(242, 106, 26, .5);
}

body[data-diff="hardcore"] #diffbar button.on {
  background: linear-gradient(180deg, #ff8a8a, #d11f1f);
  color: #fff;
  border-color: #ffd2d2;
  box-shadow: 0 4px 16px rgba(209, 31, 31, .6);
}

/* road tint per difficulty */
#conves[data-diff="easy"] #rode {
  box-shadow: inset 0 0 34px rgba(0, 0, 0, .26), inset 0 0 0 2px rgba(39, 211, 77, .35);
}

#conves[data-diff="medium"] #rode {
  box-shadow: inset 0 0 34px rgba(0, 0, 0, .26), inset 0 0 0 2px rgba(242, 165, 26, .4);
}

#conves[data-diff="hard"] #rode {
  box-shadow: inset 0 0 34px rgba(0, 0, 0, .3), inset 0 0 0 2px rgba(242, 106, 26, .55);
}

#conves[data-diff="hardcore"] #rode {
  box-shadow: inset 0 0 34px rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(209, 31, 31, .65);
}

#conves[data-diff="hardcore"] .rodes {
  filter: saturate(1.15) contrast(1.05);
}

/* ---- real chicken (like the original Chicken Road game) ---- */
#movingBetBox.chicken {
  width: 58px;
  height: 62px;
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
  zoom: 2.18;
}

#movingBetBox.chicken .ch-shadow {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 8px;
  background: rgba(0, 0, 0, .35);
  border-radius: 50%;
  filter: blur(1px);
}

/* chicken PNG sprite sheet: 6 cols x 3 rows */
#movingBetBox.chicken .ch-view {
  height: 100%;
  aspect-ratio: 256 / 341;
  margin: 0 auto;
  overflow: hidden;
}

#movingBetBox.chicken .ch-cells {
  width: 600%;
  height: 300%;
}

#movingBetBox.chicken .ch-png {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* idle: row 0 walk cycle (6 frames) */
#movingBetBox.chicken.idle .ch-cells {
  animation: pngWalk0 0.9s steps(6) infinite;
}

@keyframes pngWalk0 {
  from { transform: translate(0, 0); }
  to { transform: translate(-100%, 0); }
}

/* hop: freeze on a tucked-leg frame (row 2, col 2) */
#movingBetBox.chicken.hop .ch-cells {
  animation: none;
  transform: translate(-33.333%, -66.666%);
}

/* win: row 1 cycle, fast, twice */
#movingBetBox.chicken.win .ch-cells {
  animation: pngWalk1 0.45s steps(6) 2;
}

@keyframes pngWalk1 {
  from { transform: translate(0, -33.333%); }
  to { transform: translate(-100%, -33.333%); }
}

/* crash: freeze first frame + dizzy wobble */
#movingBetBox.chicken.crashed .ch-cells {
  animation: none;
  transform: translate(0, 0);
}

#movingBetBox.chicken.crashed .ch-view {
  transform-origin: 50% 50%;
  animation: hoseDizzy 0.55s linear 1;
}

@keyframes hoseDizzy {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-16deg) scale(1.1, 0.9); }
  50% { transform: rotate(14deg) scale(1.05); }
  75% { transform: rotate(-10deg) scale(1.1, 0.9); }
  100% { transform: rotate(0deg) scale(1); }
}

#movingBetBox.chicken .ch-tail {
  position: absolute;
  left: 2px;
  top: 18px;
  width: 16px;
  height: 22px;
  background: #e9e2cf;
  border-radius: 70% 30% 60% 40%;
  transform: rotate(-24deg);
  box-shadow: inset -3px 0 0 #cfc6ab;
}

#movingBetBox.chicken .ch-body-real {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 44px;
  height: 40px;
  background: radial-gradient(circle at 35% 28%, #ffffff 0 45%, #f1e9d2 78%, #ddd2b4 100%);
  border-radius: 50% 50% 46% 46%;
  box-shadow: 0 4px 8px rgba(0, 0, 0, .3), inset -3px -4px 0 rgba(0, 0, 0, .06);
  transform-origin: 50% 80%;
}

#movingBetBox.chicken .ch-wing {
  position: absolute;
  left: 10px;
  top: 16px;
  width: 20px;
  height: 14px;
  background: #e4d9b8;
  border-radius: 60% 20% 60% 45%;
  box-shadow: inset -2px -2px 0 #c9bc96;
  transform-origin: right center;
  right: auto;
}

#movingBetBox.chicken .ch-comb-real {
  position: absolute;
  top: -9px;
  left: 22px;
  display: flex;
  gap: 0;
}

#movingBetBox.chicken .ch-comb-real i {
  width: 9px;
  height: 12px;
  background: #e23b3b;
  border-radius: 50% 50% 40% 40%;
  border: 1px solid #b01e1e;
  margin-left: -3px;
  display: block;
}

#movingBetBox.chicken .ch-comb-real i:first-child {
  margin-left: 0;
  transform: rotate(-12deg);
}

#movingBetBox.chicken .ch-comb-real i:last-child {
  transform: rotate(12deg);
}

#movingBetBox.chicken .ch-eye {
  position: absolute;
  right: 9px;
  top: 12px;
  width: 8px;
  height: 10px;
  background: #fff;
  border: 1px solid #333;
  border-radius: 50%;
  overflow: hidden;
}

#movingBetBox.chicken .ch-eye::after {
  content: "";
  position: absolute;
  left: 1.5px;
  top: 2px;
  width: 4px;
  height: 5px;
  background: #111;
  border-radius: 50%;
}

#movingBetBox.chicken .ch-beak {
  position: absolute;
  right: -7px;
  top: 18px;
  width: 0;
  height: 0;
  border-left: 10px solid #f59b1a;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  filter: drop-shadow(0 1px 0 #a86400);
}

#movingBetBox.chicken .ch-wattle {
  position: absolute;
  right: 2px;
  top: 29px;
  width: 9px;
  height: 11px;
  background: #e23b3b;
  border-radius: 50% 50% 60% 60%;
  border: 1px solid #b01e1e;
}

#movingBetBox.chicken .ch-leg {
  position: absolute;
  bottom: 2px;
  width: 3px;
  height: 12px;
  background: #f59b1a;
}

#movingBetBox.chicken .ch-leg::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: -4px;
  width: 11px;
  height: 4px;
  background: #f59b1a;
  border-radius: 3px;
}

#movingBetBox.chicken .ch-leg.l {
  left: 24px;
}

#movingBetBox.chicken .ch-leg.r {
  left: 36px;
}

/* keep old emoji selector harmless if cached JS runs */
#movingBetBox.chicken .ch-body {
  display: none;
}

#movingBetBox.chicken .ch-comb {
  display: none;
}

/* STAYING / IDLE: breathe + blink + occasional peck */
#movingBetBox.chicken.idle .ch-body-real {
  animation: chBreathe 1.2s ease-in-out infinite;
}

/* side-walk in place: legs alternate while waiting */
#movingBetBox.chicken.idle .ch-leg.l {
  animation: legStep 1.2s ease-in-out infinite;
}

#movingBetBox.chicken.idle .ch-leg.r {
  animation: legStep 1.2s ease-in-out -0.6s infinite;
}

#movingBetBox.chicken.idle .ch-wing {
  animation: wingFold 2.4s ease-in-out infinite;
}

#movingBetBox.chicken.idle .ch-eye::after {
  animation: eyeBlink 3.8s linear infinite;
}

#movingBetBox.chicken.idle {
  animation: chBobStay 1.2s ease-in-out infinite;
}

#movingBetBox.chicken.idle.peck .ch-body-real {
  animation: chPeck 0.5s ease-in-out 1;
}

@keyframes chBreathe {

  0%,
  100% {
    transform: scale(1) rotate(-2deg);
  }

  50% {
    transform: scale(1.05, 0.95) rotate(2deg);
  }
}

@keyframes legStep {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-2px);
  }
}

@keyframes eyeBlink {

  0%,
  92%,
  100% {
    transform: scaleY(1);
  }

  95% {
    transform: scaleY(0.1);
  }
}

@keyframes chBobStay {

  0%,
  100% {
    margin-top: 0;
  }

  50% {
    margin-top: -5px;
  }
}

@keyframes wingFold {

  0%,
  100% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(-14deg);
  }
}

@keyframes chPeck {
  0% {
    transform: rotate(0);
  }

  40% {
    transform: rotate(18deg) translateY(5px);
  }

  100% {
    transform: rotate(0);
  }
}

/* JUMP / HOP: parabolic arc + wing flap + dust puff */
#movingBetBox.chicken.hop {
  animation: jumpArc 0.45s cubic-bezier(.3, .7, .4, 1) 1;
}

#movingBetBox.chicken.hop .ch-body-real {
  animation: sideWaddle 0.45s ease-in-out 1;
}

/* side walk: legs stride left-right-left while crossing */
#movingBetBox.chicken.hop .ch-leg.l {
  animation: legStride 0.45s linear 1;
}

#movingBetBox.chicken.hop .ch-leg.r {
  animation: legStride 0.45s linear -0.11s 1;
}

#movingBetBox.chicken.hop .ch-wing {
  animation: wingFlap 0.45s linear 1;
}

#movingBetBox.chicken.hop .ch-shadow {
  animation: shadowShrink 0.45s ease-in-out 1;
}

@keyframes jumpArc {
  0% {
    margin-top: 0;
    transform: translate(-50%, -50%) scale(1);
  }

  35% {
    margin-top: -34px;
    transform: translate(-50%, -50%) scale(1.08, 0.94) rotate(-6deg);
  }

  70% {
    margin-top: -10px;
    transform: translate(-50%, -50%) scale(0.96, 1.05);
  }

  100% {
    margin-top: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes hopTilt {
  0% {
    transform: rotate(-8deg);
  }

  50% {
    transform: rotate(6deg) scale(1.05);
  }

  100% {
    transform: rotate(0);
  }
}

/* side-to-side waddle + marching legs for the walk */
@keyframes sideWaddle {
  0% {
    transform: translateX(0) rotate(-9deg);
  }

  25% {
    transform: translateX(-3px) rotate(7deg) scale(1.04);
  }

  50% {
    transform: translateX(3px) rotate(-7deg) scale(1.04);
  }

  75% {
    transform: translateX(-2px) rotate(5deg);
  }

  100% {
    transform: translateX(0) rotate(0);
  }
}

@keyframes legStride {

  0%,
  100% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(-3px, -7px);
  }

  50% {
    transform: translate(0, 0);
  }

  75% {
    transform: translate(3px, -7px);
  }
}

@keyframes legTuck {

  0%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-6px);
  }
}

@keyframes wingFlap {

  0%,
  100% {
    transform: rotate(0);
  }

  25% {
    transform: rotate(-55deg);
  }

  50% {
    transform: rotate(10deg);
  }

  75% {
    transform: rotate(-40deg);
  }
}

@keyframes shadowShrink {

  0%,
  100% {
    transform: translateX(-50%) scaleX(1);
    opacity: 1;
  }

  35% {
    transform: translateX(-50%) scaleX(0.55);
    opacity: 0.6;
  }
}

/* CRASHED: knocked over, X eye, feathers + boom stamp */
#movingBetBox.chicken.crashed {
  animation: crashShake 0.55s ease-in-out 1;
}

#movingBetBox.chicken.crashed .ch-body-real {
  animation: crashFlat 0.5s ease-in 1 both;
  background: radial-gradient(circle at 35% 28%, #d8d2c0 0 45%, #a9a294 78%, #6f6a5e 100%);
}

#movingBetBox.chicken.crashed .ch-eye::after {
  animation: none;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  color: #111;
  content: "✕";
  font-size: 9px;
  font-weight: 900;
  line-height: 10px;
  text-align: center;
}

#movingBetBox.chicken.crashed .ch-comb-real {
  transform: rotate(38deg);
  transform-origin: left bottom;
}

#movingBetBox.chicken.crashed .ch-wing {
  animation: none;
  transform: rotate(-70deg);
  background: #8d8674;
}

@keyframes crashShake {
  0% {
    margin-left: 0;
    transform: translate(-50%, -50%) rotate(0);
  }

  20% {
    margin-left: -7px;
    transform: translate(-50%, -50%) rotate(-14deg) scale(1.15, 0.8);
  }

  45% {
    margin-left: 6px;
    transform: translate(-50%, -50%) rotate(10deg) scale(0.85, 0.7);
  }

  70% {
    margin-left: -3px;
    transform: translate(-50%, -50%) rotate(-5deg) scale(1.1, 0.75);
  }

  100% {
    margin-left: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(1.2, 0.65);
  }
}

@keyframes crashFlat {
  to {
    transform: scale(1.25, 0.6) rotate(-20deg);
  }
}

/* WIN: happy dance */
#movingBetBox.chicken.win {
  animation: winDance 0.7s ease-in-out 2;
  border-color: #ffe27a;
  box-shadow: 0 0 22px rgba(242, 165, 26, .8);
}

#movingBetBox.chicken.win .ch-wing {
  animation: wingFlap 0.35s linear 2;
}

@keyframes winDance {

  0%,
  100% {
    margin-top: 0;
    transform: translate(-50%, -50%) rotate(0) scale(1);
  }

  25% {
    margin-top: -18px;
    transform: translate(-50%, -50%) rotate(-10deg) scale(1.1);
  }

  50% {
    margin-top: 0;
    transform: translate(-50%, -50%) rotate(8deg) scale(0.95, 1.08);
  }

  75% {
    margin-top: -12px;
    transform: translate(-50%, -50%) rotate(-6deg) scale(1.05);
  }
}

/* feathers + dust + boom */
.feather {
  position: absolute;
  z-index: 9;
  font-size: 16px;
  pointer-events: none;
  animation: featherFly 0.9s ease-out forwards;
}

@keyframes featherFly {
  0% {
    transform: translate(0, 0) rotate(0) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(var(--fx, 30px), var(--fy, -46px)) rotate(var(--fr, 220deg)) scale(0.7);
    opacity: 0;
  }
}

.dust-puff {
  position: absolute;
  z-index: 8;
  width: 26px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  filter: blur(2px);
  pointer-events: none;
  animation: dustOut 0.45s ease-out forwards;
}

@keyframes dustOut {
  from {
    transform: scale(0.5);
    opacity: 0.9;
  }

  to {
    transform: scale(1.8);
    opacity: 0;
  }
}

.crash-boom {
  position: absolute;
  z-index: 9;
  font-size: 34px;
  pointer-events: none;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  animation: boomPop 0.6s cubic-bezier(.34, 1.56, .64, 1) forwards;
}

@keyframes boomPop {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }

  40% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
}

/* ---- CARS: real image sprites, vertical on every .rodes lane ---- */
.traffic-car {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: -24%;
  transform: translateX(-50%);
  width: 100%;
  height: 104px;
  pointer-events: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  animation: laneDrive var(--drive-dur, 5s) linear forwards;
}

/* permanent lane cars loop forever so every tile always shows traffic */
.traffic-car.loop {
  animation-iteration-count: infinite;
}

/* win freeze: all driving cars halt in place (toggled from JS) */
#rode.traffic-stopped .traffic-car {
  animation-play-state: paused;
}

.traffic-car img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform: rotate(180deg);
  /* sprites face up, lanes drive top -> bottom */
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, .45));
}

.traffic-car.truck {
  height: 84px;
  width: 36px;
}

@keyframes laneDrive {
  from {
    top: -22%;
  }

  to {
    top: 108%;
  }
}

.killer-car {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: -26%;
  transform: translateX(-50%);
  width: 64px;
  height: 120px;
  pointer-events: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  animation: killerDrop 0.55s cubic-bezier(.5, 0, .8, .4) forwards;
}

.killer-car img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform: rotate(180deg);
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .55));
}

@keyframes hazardBlink {
  50% {
    filter: brightness(1.6);
  }
}

@keyframes killerDrop {
  0% {
    top: -26%;
    transform: translateX(-50%) rotate(-4deg);
  }

  60% {
    top: 30%;
    transform: translateX(-50%) rotate(3deg);
  }

  100% {
    top: 34%;
    transform: translateX(-50%) rotate(0deg);
  }
}

/* ---- ROAD OBSTACLE: striped barricade the crash car smashes into ----
   Pops onto the crash lane first, the killer car drops against it,
   then the whole round stays frozen until the next Bet. */
.road-obstacle {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  width: 68px;
  height: 30px;
  background: repeating-linear-gradient(45deg, #ff7a1a 0 10px, #f5f5f5 10px 20px);
  border: 3px solid #23272e;
  border-radius: 6px;
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: obstacleIn 0.28s ease-out 1, obstacleHit 0.45s ease-in-out 0.62s 1;
}

.road-obstacle::before,
.road-obstacle::after {
  content: "";
  position: absolute;
  top: 100%;
  width: 6px;
  height: 16px;
  background: #23272e;
  border-radius: 0 0 3px 3px;
}

.road-obstacle::before {
  left: 8px;
}

.road-obstacle::after {
  right: 8px;
}

@keyframes obstacleIn {
  from {
    transform: translateX(-50%) scale(0.4);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

@keyframes obstacleHit {
  0%,
  100% {
    transform: translateX(-50%) rotate(0deg);
  }

  25% {
    transform: translateX(-58%) rotate(-7deg);
  }

  60% {
    transform: translateX(-44%) rotate(5deg);
  }
}

/* faster + denser traffic on harder difficulties */
#conves[data-diff="easy"] .traffic-car {
  --drive-dur: 7s;
}

#conves[data-diff="medium"] .traffic-car {
  --drive-dur: 5s;
}

#conves[data-diff="hard"] .traffic-car {
  --drive-dur: 3.4s;
}

#conves[data-diff="hardcore"] .traffic-car {
  --drive-dur: 2.2s;
}

/* crash / win stamps pop like a real game */
#defend {
  white-space: nowrap;
  animation: stampIn 0.3s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes stampIn {
  0% {
    transform: translate(-50%, -50%) scale(0.4) rotate(-10deg);
    opacity: 0;
  }

  60% {
    transform: translate(-50%, -50%) scale(1.15) rotate(3deg);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

/* ============================================================
     MOBILE — stack road on top, controls below (was missing,
     so the phone showed the squished desktop side-by-side)
     ============================================================ */

@media (max-width: 900px) {
  #money {
    width: 100%;
    left: 0;
    transform: none;
  }

  #money_box {
    width: 26%;
    left: 44%;
  }

  #Gbutton {
    left: auto;
    right: 8px;
  }

  #conves {
    width: 100%;
    height: 44%;
    top: 6.5%;
    left: 0;
    transform: none;
    border-radius: 0;
  }

  #box {
    width: 100%;
    height: 47%;
    top: 52%;
    left: 0;
    transform: none;
    border-radius: 0;
  }

  #show {
    display: none;
  }

  #rode {
    gap: 6px;
    padding: 0 10px 0 68px;
  }

  .rodes {
    flex: 0 0 84px;
    width: 84px;
    height: 88%;
  }

  .traffic-car {
    width: 113%;
    height: 86px;
  }

  .killer-car {
    width: 54px;
    height: 100px;
  }

  #movingBetBox {
    width: 46px;
    height: 46px;
    font-size: 30px;
  }

  /* real chicken keeps its drawn size on mobile */
  #movingBetBox.chicken {
    width: 58px;
    height: 62px;
    font-size: 0;
    zoom: 1.8;
    transform: translate(-50%, -50%);
  }

  .tile-mult {
    font-size: 12px;
    min-width: 80%;
  }

  .tile-flag {
    font-size: 18px;
  }
}

@media (max-width: 400px) {
  .rodes {
    flex: 0 0 78px;
    width: 78px;
  }

  .traffic-car {
    width: 113%;
    height: 78px;
  }

  .killer-car {
    width: 48px;
    height: 92px;
  }

  #movingBetBox {
    width: 42px;
    height: 42px;
    font-size: 27px;
  }

  #movingBetBox.chicken {
    width: 58px;
    height: 62px;
    font-size: 0;
    zoom: 1.65;
    transform: translate(-50%, -50%);
  }
}

/* Cheat overlay: auto-hide on mobile so it never covers the board */
@media (max-width: 900px) {
  #show {
    display: none !important;
  }
}