/* styles.css is what the mines page adds to the shared theme
   (web/sdk/theme.css, docs/design/ui.md): the 5x5 board and its motion.
   Everything else -- the header, the bet panel, the toast, the history, the
   fairness panel, the layout at three widths -- is the theme's. Colours,
   durations and radii are the theme's tokens; nothing here is a literal of
   its own but the board's geometry. The cell classes (cell/closed/open/
   mine/hit/rest) come from grid.js; the motion classes (flip/boom/wave)
   from app.js, which sets them only for what the server's steps changed. */

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-16);
  line-height: var(--lh);
}

h1,
h2 {
  margin: 0;
}

.side h2 {
  font-size: var(--fs-14);
  color: var(--muted);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

/* The header carries Exit after "Fairness": the balance and both buttons
   sit together on the right. */
.app > header .balance {
  margin-left: auto;
}

/* ---- board ------------------------------------------------------------ */

.board {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
  aspect-ratio: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-3);
  background: var(--panel) url("assets/background.png") center / cover;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  perspective: 600px;
}

.cell {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-24);
  line-height: 1;
  transition:
    transform var(--dur-fast) ease-out,
    border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.cell.closed:not(:disabled) {
  cursor: pointer;
}

.cell.closed:not(:disabled):hover,
.cell.closed:not(:disabled):focus-visible {
  border-color: var(--accent);
}

.cell.closed:not(:disabled):active {
  transform: scale(0.96);
}

.cell:disabled {
  cursor: default;
}

.cell.open {
  color: var(--win);
  border-color: var(--win);
  background: var(--panel);
}

.cell.mine {
  color: var(--lose);
  background: var(--panel);
}

.cell.hit {
  border-color: var(--lose);
  background: var(--lose);
  color: var(--accent-ink);
}

.cell.rest {
  opacity: 0.55;
}

.result {
  margin: 0;
  min-height: 1.5em;
  text-align: center;
  font-size: var(--fs-20);
  font-weight: 600;
}

.error {
  margin: 0;
  color: var(--lose);
  text-align: center;
}

.notice {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent-2);
}

.closed {
  text-align: center;
}

/* ---- the round in play ------------------------------------------------ */

.moves {
  display: grid;
  gap: var(--space-2);
}

.moves p {
  margin: 0;
}

.moves .next {
  color: var(--accent-2);
  font-weight: 600;
}

.btn-primary.pulse {
  animation: cash-pulse var(--dur) var(--ease) 2;
}

@keyframes cash-pulse {
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 var(--space-1) var(--win);
  }
}

/* ---- motion: flip, burst, wave ---------------------------------------- */

/* A reveal turns the cell over (300ms) and shows the gem. */
.cell.flip {
  animation: flip var(--dur) var(--ease);
}

@keyframes flip {
  from {
    transform: rotateY(90deg);
    background: var(--panel-2);
  }
}

/* The mine that ends the round swells and shakes (400ms), lit red. */
.cell.boom {
  animation: boom calc(var(--dur) + 100ms) ease-out;
  box-shadow: 0 0 var(--space-4) var(--lose);
}

@keyframes boom {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.25);
  }
  45% {
    transform: scale(1.15) translateX(-4px);
  }
  60% {
    transform: scale(1.1) translateX(4px);
  }
  75% {
    transform: scale(1.05) translateX(-2px);
  }
  100% {
    transform: scale(1);
  }
}

/* After the round the layout uncovers cell by cell, 40ms apart. */
.cell.wave {
  animation: flip var(--dur) var(--ease) backwards;
  animation-delay: calc(var(--wave, 0) * 40ms);
}

/* ---- widths ----------------------------------------------------------- */

@media (max-width: 767px) {
  .grid {
    max-width: none;
    padding: var(--space-2);
  }
}

@media (max-width: 420px) {
  .grid {
    gap: var(--space-1);
    padding: var(--space-1);
  }

  .cell {
    font-size: var(--fs-20);
  }

  .app > header .btn {
    padding-inline: var(--space-2);
  }

  /* The round in play takes the bet panel's place at the bottom. */
  .panel.moves {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
    box-shadow: var(--shadow-lg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell.wave {
    animation-delay: 0s !important;
  }
}
