/* ด่วนจี๋ทะลุแยก */
.rr .rr-big { font-size: 20px; min-height: 56px; }
.rr-money { font-family: "Fredoka", "Mitr", sans-serif; color: var(--sk-green-dark); }
.rr-center { text-align: center; margin: 0; }

/* start */
.rr-demo { font-size: clamp(20px, 6vw, 28px); text-align: center; letter-spacing: 1px; line-height: 1.4; }
.rr-best { text-align: center; font-weight: 600; }

/* play */
#scrPlay { display: grid; gap: 10px; max-width: 460px; margin: 0 auto; }
#scrPlay[hidden] { display: none; }
.rr-hud {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; align-items: center; gap: 6px;
  padding: 8px 10px !important; text-align: center;
}
.rr-hud small { display: block; font-size: 12px; color: var(--sk-muted); }
.rr-hud b { font-family: "Fredoka", "Mitr", sans-serif; font-size: 24px; line-height: 1.15; }
.rr-clock.hurry b { display: inline-block; color: var(--sg-red); animation: rrPulse 0.5s infinite alternate; }
.rr-pause {
  width: 42px; height: 42px; border: 2.5px solid var(--sg-ink); border-radius: 12px; background: #fff;
  color: var(--sg-ink); font-size: 16px; cursor: pointer; box-shadow: 0 2px 0 var(--sg-ink);
}

.rr-order { display: flex; align-items: center; gap: 10px; padding: 8px 12px !important; min-height: 62px; }
.rr-ordemo { font-size: 34px; line-height: 1; flex: none; }
.rr-ordtext { flex: 1; min-width: 0; display: grid; }
.rr-ordtext b { font-size: 17px; line-height: 1.3; }
.rr-ordtext small { color: var(--sk-muted); font-size: 13px; }
.rr-heat {
  position: relative; flex: 0 0 92px; height: 24px; border: 2.5px solid var(--sg-ink); border-radius: 999px;
  background: #e0f2fe; overflow: hidden;
}
.rr-heat[hidden] { display: none; }
.rr-heat i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #ffc21a, #ff7a1a 50%, #e8202a); transition: width 0.2s linear; }
.rr-heat.cold i { background: #7dd3fc; }
.rr-heat span { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 14px; line-height: 1; }

/* board */
.rr-boardwrap {
  position: relative; margin: 0 auto; aspect-ratio: 6 / 8;
  width: min(100%, 440px, max(270px, calc((100svh - 350px) * 0.75)));
}
.rr-board {
  position: relative; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(8, 1fr);
  width: 100%; height: 100%; border: 3px solid var(--sg-ink); border-radius: 18px; overflow: hidden;
  background: #b7e19c; box-shadow: 0 4px 0 var(--sg-ink);
}
.rr-cell {
  position: relative; margin: 0; padding: 0; border: 0; border-radius: 0; background: #b7e19c; font: inherit;
  cursor: pointer; overflow: hidden; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.rr-cell.alt { background: #a9d98d; }
.rr-cell:focus-visible { outline: 3px solid var(--sg-blue); outline-offset: -3px; z-index: 1; }

.rr-rd { position: absolute; inset: 0; transition: transform 0.14s ease-out; }
.rr-rd i { position: absolute; background: #6b7080; transition: background 0.15s; }
.rr-rd .hub { left: 31%; right: 31%; top: 31%; bottom: 31%; }
.rr-rd .n { left: 31%; right: 31%; top: 0; bottom: 50%; }
.rr-rd .s { left: 31%; right: 31%; top: 50%; bottom: 0; }
.rr-rd .e { left: 50%; right: 0; top: 31%; bottom: 31%; }
.rr-rd .w { left: 0; right: 50%; top: 31%; bottom: 31%; }
.rr-cell.lit .rr-rd i { background: var(--sg-blue); }
.rr-cell.locked { cursor: not-allowed; background: #c9c4b8; box-shadow: inset 0 0 0 2px #8f897c; }
.rr-cell.locked .rr-rd i { background: #3a3e4d; }
.rr-cell.locked.lit .rr-rd i { background: #0d6fb3; }
.rr-lock {
  position: absolute; right: 2px; top: 2px; z-index: 1; display: grid; place-items: center;
  width: 40%; aspect-ratio: 1; border-radius: 50%; background: #fff; border: 1.5px solid var(--sg-ink);
  font-size: clamp(9px, 2.6vw, 13px); line-height: 1;
}
.rr-car {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: clamp(14px, 4.5vw, 22px); line-height: 1; pointer-events: none;
}
.rr-cell.jam .rr-car { animation: rrShake 0.25s infinite; }

.rr-cell.block { cursor: not-allowed; background: repeating-linear-gradient(45deg, #ffc21a 0 7px, #231f20 7px 14px); }
.rr-ob {
  position: absolute; inset: 14%; display: grid; place-items: center; border-radius: 10px;
  background: rgba(255, 255, 255, 0.85); font-size: clamp(16px, 5vw, 26px); line-height: 1;
}

.rr-cell.spot { cursor: default; }
.rr-pad { position: absolute; inset: 9%; border-radius: 24%; background: #fff; border: 2.5px solid var(--sg-ink); }
.rr-cell.lit .rr-pad { border-color: var(--sg-blue); }
.rr-cell.goal .rr-pad { background: var(--sg-yellow); border-color: var(--sg-ink); animation: rrGoal 0.7s infinite alternate; }
.rr-spot { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(20px, 7vw, 32px); line-height: 1; }

.rr-dog {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(22px, 7.5vw, 34px);
  line-height: 1; background: rgba(232, 32, 42, 0.18); animation: rrWag 0.3s infinite alternate;
}
.rr-cell.shake { animation: rrShake 0.3s; }

.rr-rider {
  position: absolute; left: 0; top: 0; width: calc(100% / 6); height: calc(100% / 8); z-index: 3;
  display: grid; place-items: center; font-size: clamp(22px, 7.5vw, 34px); line-height: 1; pointer-events: none;
  transition: left 0.1s linear, top 0.1s linear; filter: drop-shadow(0 3px 0 rgba(35, 31, 32, 0.35));
}
.rr-rider.snap { transition: none; }
.riding .rr-rider { animation: rrBounce 0.2s infinite alternate; }

/* overlays */
.rr-toasts {
  display: grid; justify-items: center; align-content: start; gap: 6px; min-height: 74px; pointer-events: none;
  padding: 0 44px; /* clear of the fixed 🔊 button */
}
.rr-toast {
  max-width: 100%; padding: 6px 14px; border: 2.5px solid var(--sg-ink); border-radius: 999px; background: #fff;
  box-shadow: 0 3px 0 var(--sg-ink); font-weight: 600; font-size: 14px; text-align: center; line-height: 1.35;
  animation: rrToast 2.6s ease forwards;
}
.rr-toast.good { background: var(--sk-green); color: #fff; }
.rr-toast.review { background: var(--sk-cream); }
.rr-toast.news { background: var(--sg-yellow); }
.rr-layer {
  position: absolute; inset: 0; z-index: 8; display: grid; place-content: center; justify-items: center; gap: 12px;
  border-radius: 18px; background: rgba(255, 250, 240, 0.86); text-align: center;
}
.rr-layer[hidden] { display: none; }
.rr-layer > b { font-size: 26px; }
.rr-count { background: rgba(255, 250, 240, 0.6); pointer-events: none; }
.rr-count b {
  font-family: "Fredoka", "Kanit", sans-serif; font-size: 96px; line-height: 1; color: var(--sg-ink);
  text-shadow: 0 4px 0 var(--sg-yellow); animation: rrCount 0.6s ease-out;
}

.rr-boardwrap::after {
  content: ""; position: absolute; inset: 3px; border-radius: 15px; pointer-events: none; z-index: 4; opacity: 0;
  background: repeating-linear-gradient(105deg, transparent 0 14px, rgba(56, 120, 200, 0.35) 14px 16px);
  background-size: 200% 200%; transition: opacity 0.4s;
}
.rr-boardwrap.raining::after { opacity: 1; animation: rrRain 0.5s linear infinite; }

/* game over */
.rr-over { text-align: center; }
.rr-overtitle { font-family: "Kanit", "Mitr", sans-serif; font-size: 30px; font-weight: 800; }
.rr-rank { font-size: 20px; font-weight: 600; }
.rr-record {
  justify-self: center; padding: 4px 14px; border: 2.5px solid var(--sg-ink); border-radius: 999px;
  background: var(--sg-yellow); font-weight: 700; animation: rrGoal 0.6s infinite alternate;
}
.rr-record[hidden] { display: none; }
.rr-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rr-stats > div { padding: 10px; border: 2.5px solid var(--sg-ink); border-radius: 16px; background: var(--sk-cream); }
.rr-stats small { display: block; color: var(--sk-muted); font-size: 13px; }
.rr-stats b { font-family: "Fredoka", "Mitr", sans-serif; font-size: 38px; line-height: 1.1; }

@keyframes rrPulse { to { transform: scale(1.18); } }
@keyframes rrGoal { to { transform: scale(0.9); } }
@keyframes rrWag { to { transform: rotate(8deg); } }
@keyframes rrShake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes rrBounce { to { transform: translateY(-3px); } }
@keyframes rrToast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@keyframes rrCount { from { transform: scale(1.6); opacity: 0; } }
@keyframes rrRain { to { background-position: -40px 80px; } }
@media (prefers-reduced-motion: reduce) {
  .rr-rd, .rr-rider { transition: none; }
  .rr-cell.goal .rr-pad, .rr-dog, .riding .rr-rider, .rr-record, .rr-clock.hurry b, .rr-boardwrap.raining::after { animation: none; }
}

/* wide screens: HUD and order card in a side column so the board can use the full height */
@media (min-width: 860px) {
  #scrPlay {
    max-width: 920px; grid-template-columns: 250px auto; grid-template-rows: auto auto 1fr;
    justify-content: center; align-items: start; column-gap: 18px;
  }
  .rr-hud { grid-column: 1; grid-row: 1; grid-template-columns: 1fr 1fr; row-gap: 10px; }
  .rr-hud .rr-clock { grid-column: 1 / -1; }
  .rr-hud .rr-clock b { font-size: 44px; }
  .rr-pause { justify-self: center; }
  .rr-order { grid-column: 1; grid-row: 2; flex-wrap: wrap; }
  .rr-order .rr-heat { flex: 1 0 100%; }
  .rr-boardwrap { grid-column: 2; grid-row: 1 / 4; width: min(600px, max(320px, calc((100svh - 130px) * 0.75))); }
  .rr-toasts { grid-column: 1; grid-row: 3; justify-items: stretch; padding: 0; }
  .rr-toast { font-size: 15px; border-radius: 16px; }
}

/* share sheet */
.rr-sheet {
  position: fixed; inset: 0; z-index: 200; display: flex; padding: 16px; overflow-y: auto;
  background: rgba(29, 27, 46, 0.6);
}
.rr-sheet[hidden] { display: none; }
.rr-sheetcard {
  position: relative; margin: auto; width: min(100%, 400px); display: grid; gap: 10px; text-align: center;
  animation: rrCount 0.25s ease-out;
}
.rr-sheetcard > b { font-size: 20px; }
.rr-sheetx {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 2px solid var(--sg-ink);
  border-radius: 50%; background: #fff; color: var(--sg-ink); cursor: pointer; font-size: 15px;
}
.rr-sheetimg {
  position: relative; aspect-ratio: 1080 / 1350; width: min(100%, calc((100svh - 300px) * 0.8)); justify-self: center;
  border-radius: 14px; overflow: hidden; background: var(--sk-soft);
}
.rr-sheetimg img { display: block; width: 100%; height: 100%; object-fit: contain; }
.rr-spin { position: absolute; inset: 0; display: none; place-items: center; color: var(--sk-muted); }
.rr-sheet.loading .rr-spin { display: grid; }
.rr-sheet.loading img { visibility: hidden; }
.rr-sheetcard a.sg-btn { text-decoration: none; }
.rr-sheet.loading a.sg-btn { pointer-events: none; opacity: 0.5; }

/* tiles the game just rewrote (new route piece, new obstacle) */
.rr-cell.fresh::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: rgba(255, 194, 26, 0.75); animation: rrFresh 0.9s ease-out forwards;
}
@keyframes rrFresh { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .rr-cell.fresh::after { animation-duration: 0.01s; } }
