/* ABOUTME: Speedoku page styles: the game card (timer, stars, grid with diamond clues, keypad, finish screen) and How to play. */
/* ABOUTME: Grid positions use --row/--col custom properties set by js/speedoku.js for each clue. */

.speedoku-stage {
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse 60% 70% at 50% 30%, #6b2c65 0%, transparent 70%), linear-gradient(160deg, var(--plum) 0%, var(--plum-900) 100%);
  color: var(--white);
  padding-block: clamp(1.5rem, 1rem + 2vw, 3rem) clamp(3rem, 2rem + 4vw, 5rem);
}

.speedoku-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgb(255 255 255 / 0.08) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  pointer-events: none;
}

.speedoku-stage__inner {
  position: relative;
  display: grid;
  justify-items: center;
}

.speedoku-head {
  text-align: center;
  margin-bottom: 1.5rem;
}

.speedoku-head .eyebrow {
  justify-content: center;
}

.speedoku-head h1 {
  margin-bottom: 0.2rem;
  font-size: clamp(2.6rem, 2rem + 3vw, 4rem);
  font-weight: 500;
  font-variation-settings: "SOFT" 50, "opsz" 144;
}

.speedoku-head__info {
  margin: 0;
  color: var(--rose-300);
  font-weight: 600;
}

/* Game card */

.game {
  --cell: clamp(72px, 19vw, 104px);
  --gap: clamp(22px, 6vw, 32px);
  --board: calc(var(--cell) * 3 + var(--gap) * 2);
  position: relative;
  width: min(100%, calc(var(--board) + 3rem));
  padding: 1.25rem 1.5rem 1.5rem;
  border-radius: 28px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 40px 80px -30px rgb(0 0 0 / 0.55), 0 0 0 1px rgb(255 255 255 / 0.1);
}

.game.is-shaking {
  animation: shake 0.4s;
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .game.is-shaking {
    animation: none;
  }
}

.game__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.game__timer {
  min-width: 4.5ch;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: var(--cream);
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #2f7d4a;
  transition: color 0.4s, background-color 0.4s;
}

.game__timer[data-band="2"] {
  color: #b2731d;
}
.game__timer[data-band="1"] {
  color: #c4541f;
}
.game__timer[data-band="0"] {
  color: #b42d2d;
}

.game__stars {
  display: flex;
  gap: 0.25rem;
}

.star {
  display: inline-block;
  width: 26px;
  height: 26px;
  background: #e2a93b;
  clip-path: polygon(50% 0%, 61.8% 35.3%, 100% 35.3%, 69.1% 57.1%, 80.9% 91.5%, 50% 70%, 19.1% 91.5%, 30.9% 57.1%, 0% 35.3%, 38.2% 35.3%);
  transition: background-color 0.4s, transform 0.4s var(--ease);
}

.star.is-lost {
  background: var(--sand-200);
  transform: scale(0.85);
}

/* Board */

.game__board {
  position: relative;
  width: var(--board);
  margin-inline: auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, var(--cell));
  gap: var(--gap);
}

.board__cell {
  display: grid;
  place-items: center;
  height: var(--cell);
  padding: 0;
  border: 2px solid transparent;
  border-radius: 16px;
  background: var(--cream);
  color: var(--plum);
  font-family: var(--font-display);
  font-size: calc(var(--cell) * 0.5);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}

.board__cell:disabled {
  cursor: default;
}

.board__cell:not(:disabled):hover {
  border-color: var(--plum-300);
}

.board__cell.is-selected {
  border-color: var(--plum);
  background: var(--plum-100);
  transform: scale(1.03);
}

.board__cell.is-filled {
  animation: pop 0.22s var(--ease);
}

@keyframes pop {
  50% {
    transform: scale(1.08);
  }
}

.board__cell:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.board__clues {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.clue {
  position: absolute;
  left: calc(var(--col) * (var(--cell) + var(--gap)) + var(--cell) / 2);
  top: calc(var(--row) * (var(--cell) + var(--gap)) + var(--cell) / 2);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  color: var(--white);
  font-weight: 800;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  isolation: isolate;
  animation: clue-in 0.4s var(--ease) both;
}

.clue::before {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: -1;
  border-radius: 7px;
  background: var(--plum);
  rotate: 45deg;
  box-shadow: 0 4px 10px rgb(78 25 74 / 0.3);
}

@keyframes clue-in {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}

/* Cover shown before the game starts */

.game__cover {
  position: absolute;
  inset: -0.5rem;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  border-radius: 20px;
  background: rgb(62 20 57 / 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--white);
  text-align: center;
}

.game__cover-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
}

.game__cover-text {
  max-width: 26ch;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: rgb(255 255 255 / 0.8);
}

.game__start {
  min-width: 160px;
  font-size: 1.1rem;
}

.game__message {
  min-height: 1.6em;
  margin: 1rem 0 0.5rem;
  text-align: center;
  font-weight: 600;
  color: #b42d2d;
}

/* Keypad: digits 1–5, then 6–9 and delete, with Clear below */

.keypad {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}

.keypad__key {
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--plum);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s, transform 0.1s;
}

.keypad__key:active:not(:disabled) {
  transform: scale(0.94);
}

.keypad__key:hover:not(:disabled) {
  background: var(--plum-800);
}

.keypad__key:disabled {
  background: var(--sand-200);
  color: var(--ink-soft);
  opacity: 0.55;
  cursor: default;
}

.keypad__key--delete {
  background: var(--cream);
  color: var(--plum);
  font-family: var(--font-body);
  font-size: 1.3rem;
}

.keypad__key--delete:hover:not(:disabled) {
  background: var(--rose-100);
}

.keypad__clear {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 0;
  background: none;
  color: var(--blue-700);
  font: 600 0.92rem var(--font-body);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.keypad__clear:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Finish screen */

.game.is-solved .keypad,
.game.is-solved .game__message {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.victory {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.35rem;
  padding: 2rem 1.5rem;
  border-radius: 28px;
  background: linear-gradient(160deg, var(--plum) 0%, var(--plum-900) 100%);
  color: var(--white);
  text-align: center;
  animation: victory-in 0.5s var(--ease) both;
}

@keyframes victory-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

.victory__eyebrow {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rose-300);
}

.victory__time {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 2.5rem + 5vw, 5rem);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.victory__stars {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.victory__stars .star {
  width: 44px;
  height: 44px;
  animation: star-in 0.5s var(--ease) both;
  animation-delay: calc(var(--i) * 0.15s + 0.4s);
}

.victory__stars .star.is-lost {
  background: rgb(255 255 255 / 0.18);
}

@keyframes star-in {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-40deg);
  }
}

.victory__message {
  max-width: 28ch;
  margin: 0 0 1rem;
  color: rgb(255 255 255 / 0.86);
}

.victory__share-text {
  width: min(100%, 22rem);
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.1);
  color: var(--white);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
}

.victory__next {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: rgb(255 255 255 / 0.7);
  font-variant-numeric: tabular-nums;
}

/* How to play */

.how-to {
  padding-block: clamp(3rem, 2rem + 4vw, 6rem);
}

.how-to h2 {
  color: var(--plum);
}

/* The intro and steps sit beside the video on wide screens; on narrow ones the video follows the intro. */
.how-to__intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  grid-template-areas:
    "head video"
    "steps video";
  grid-template-rows: auto 1fr;
  gap: 0 clamp(2rem, 1rem + 3vw, 4rem);
  margin-bottom: clamp(2rem, 1.5rem + 2vw, 3rem);
}

.how-to__head {
  grid-area: head;
}

.how-to__video {
  grid-area: video;
  align-self: center;
}

.how-to__video .video {
  margin: 0;
}

.how-to__steps {
  grid-area: steps;
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-step {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--white);
  border: 1px solid var(--line);
}

.how-step__number {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--white);
  font-weight: 800;
  isolation: isolate;
  position: relative;
}

.how-step__number::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  border-radius: 8px;
  background: var(--plum);
  rotate: 45deg;
}

.how-step h3 {
  margin: 0.4rem 0 0.35rem;
  font-size: var(--step-1);
  color: var(--plum);
}

.how-step p {
  margin: 0;
  color: var(--ink-soft);
}

.how-to__extra {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.stars-guide {
  padding: 1.75rem 1.5rem;
  border-radius: var(--radius);
  background: var(--cream);
}

.stars-guide h3 {
  font-size: var(--step-1);
  color: var(--plum);
}

.stars-guide p {
  color: var(--ink-soft);
}

.stars-guide ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stars-guide li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.stars-guide__stars {
  min-width: 4.5em;
  color: #e2a93b;
  font-size: 1.2rem;
  letter-spacing: 0.1em;
}

.stars-guide__stars span {
  color: var(--sand);
}

.stars-guide--tip {
  background: var(--blue-100);
}

@media (max-width: 860px) {
  .how-to__intro {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "video"
      "steps";
    grid-template-rows: auto;
  }

  .how-to__video {
    margin-bottom: 1.5rem;
  }

  .how-to__extra {
    grid-template-columns: 1fr;
  }
}
