/* === palette === */
:root {
  --ivory: #F4ECD8;
  --ink: #1A1A1A;
  --terracotta: #C8553D;
  --indigo: #2A4D6E;
  --mustard: #E4A11B;
  --charcoal: #3C2E26;

  --board-pad-x: 12px;
  --board-pad-y: 16px;
  --dice-size: 80px;
  --dice-block: 152px;  /* gap(16) + dice(80) + gap(16) + hint(~24) + buffer */
  /* 10 tiles + 9×2px gaps + padding + dice block must fit inside the viewport. */
  --tile-size: min(
    calc((100vw - 2 * var(--board-pad-x) - 18px) / 10),
    calc((100vh - 2 * var(--board-pad-y) - 18px - var(--dice-block)) / 10),
    140px
  );
}

/* === reset === */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }

/* === fonts ===
   Custom fonts not yet picked. System fallbacks below are used until
   the owner adds @font-face rules + woff2 files under assets/fonts/.
   The "ChikatiDisplay"/"ChikatiBody" names below remain in the font-family
   stacks so re-enabling fonts is a one-line addition. */

body {
  background: var(--ivory);
  color: var(--ink);
  font-family: "ChikatiBody", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* hide default cursor on desktop only; cursor.js draws a custom one */
  cursor: auto;
}
@media (pointer: fine) {
  body { cursor: none; }
  a, button { cursor: none; }
}

/* === board === */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

#board {
  flex: 0 0 auto;
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, var(--tile-size));
  grid-auto-rows: var(--tile-size);
  gap: 2px;
  padding: var(--board-pad-y) var(--board-pad-x);
  background: var(--ivory);
}

.tile {
  position: relative;
  background: rgba(196, 85, 61, 0.04);
  border: 1px solid var(--charcoal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "ChikatiBody", system-ui, sans-serif;
  font-size: 0.7rem;
  color: var(--charcoal);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 360ms ease, transform 360ms ease;
}
.tile.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.tile-number {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.6rem;
  opacity: 0.4;
}
.tile-fragment {
  /* Side-note: tucked into the bottom-right corner of the milestone tile,
     small italic, low contrast. Reads as an aside rather than a headline. */
  position: absolute;
  right: 4px;
  bottom: 2px;
  max-width: calc(100% - 8px);
  font-family: "ChikatiDisplay", Georgia, serif;
  font-style: italic;
  font-size: clamp(0.55rem, 0.85vw, 0.72rem);
  color: var(--charcoal);
  opacity: 0.55;
  line-height: 1.1;
  text-align: right;
  pointer-events: none;
}

/* === overlay layer (snakes, ladders) === */
#overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* === diya token === */
#diya {
  position: absolute;
  width: calc(var(--tile-size) * 0.6);
  height: calc(var(--tile-size) * 0.6);
  top: 0; left: 0;
  pointer-events: none;
  z-index: 5;
  /* GSAP will set transform; this is the starting point */
  transform: translate(0, 0);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}

/* === throw counter === */
#throw-counter {
  position: fixed;
  top: 12px;
  right: 16px;
  font-family: "ChikatiBody", system-ui, sans-serif;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--charcoal);
  opacity: 0.5;
  z-index: 50;
  user-select: none;
  pointer-events: none;
}

/* === dice === */
#dice {
  flex: 0 0 auto;
  width: var(--dice-size);
  height: var(--dice-size);
  background: var(--ivory);
  border: 2px solid var(--charcoal);
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  user-select: none;
  z-index: 10;
  transition: transform 120ms ease;
}
#dice:hover { transform: scale(1.05); }
.pip {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--charcoal);
  opacity: 0;
  transition: opacity 80ms ease;
}
#dice[data-face="1"] .pip[data-pos="mm"],
#dice[data-face="2"] .pip[data-pos="tl"],
#dice[data-face="2"] .pip[data-pos="br"],
#dice[data-face="3"] .pip[data-pos="tl"],
#dice[data-face="3"] .pip[data-pos="mm"],
#dice[data-face="3"] .pip[data-pos="br"],
#dice[data-face="4"] .pip[data-pos="tl"],
#dice[data-face="4"] .pip[data-pos="tr"],
#dice[data-face="4"] .pip[data-pos="bl"],
#dice[data-face="4"] .pip[data-pos="br"],
#dice[data-face="5"] .pip[data-pos="tl"],
#dice[data-face="5"] .pip[data-pos="tr"],
#dice[data-face="5"] .pip[data-pos="mm"],
#dice[data-face="5"] .pip[data-pos="bl"],
#dice[data-face="5"] .pip[data-pos="br"],
#dice[data-face="6"] .pip[data-pos="tl"],
#dice[data-face="6"] .pip[data-pos="tr"],
#dice[data-face="6"] .pip[data-pos="ml"],
#dice[data-face="6"] .pip[data-pos="mr"],
#dice[data-face="6"] .pip[data-pos="bl"],
#dice[data-face="6"] .pip[data-pos="br"] {
  opacity: 1;
}
#dice.is-rolling { animation: dice-wobble 0.4s ease; }
#dice.is-moving  { opacity: 0.6; pointer-events: none; }
@keyframes dice-wobble {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-10deg) scale(1.04); }
  75%      { transform: rotate(10deg)  scale(1.04); }
}
#dice-hint {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.85rem;
  color: var(--charcoal);
  opacity: 0.5;
  font-family: "ChikatiBody", system-ui, sans-serif;
  user-select: none;
  transition: opacity 200ms ease, color 200ms ease;
  text-align: center;
}
#dice-hint.is-sass {
  opacity: 0.95;
  color: var(--terracotta);
  font-style: italic;
  font-family: "ChikatiDisplay", Georgia, serif;
}

/* === custom cursor === */
#cursor {
  position: fixed;
  top: 0; left: 0;
  width: 14px;
  height: 14px;
  background: var(--terracotta);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: transform 120ms ease, width 180ms ease, height 180ms ease, background 180ms ease;
  display: none; /* enabled by cursor.js on (pointer: fine) */
}
#cursor.is-magnetized {
  width: 22px;
  height: 22px;
  background: var(--mustard);
}

/* === win card === */
#win-card {
  position: fixed;
  inset: 0;
  background: rgba(244, 236, 216, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 600ms ease;
}
#win-card.is-revealed {
  opacity: 1;
  pointer-events: auto;
}
#win-card h2 {
  font-family: "ChikatiDisplay", Georgia, serif;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: var(--terracotta);
  margin: 0 0 1rem;
}
#win-card a {
  color: var(--indigo);
  font-weight: 600;
}
#play-again {
  margin-top: 1.5rem;
  background: var(--terracotta);
  color: var(--ivory);
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 4px;
  font-family: "ChikatiDisplay", Georgia, serif;
  font-size: 1rem;
}

/* === reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.tile.is-milestone {
  background: rgba(228, 161, 27, 0.08);
  border-color: var(--mustard);
}

/* === keyboard focus === */
:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
  border-radius: 2px;
}
#play-again:focus-visible {
  outline-color: var(--ivory);
  outline-offset: 2px;
}
