/* Cardoku (games/cardoku.html) */

/* On :root so the drag copy (attached to <body>) gets them too */
:root {
  --red: #c0392b;
  --red-50: #fbe3e0;
}

.cdk {
  --card-w: 68px;
  display: grid;
  grid-template-columns: minmax(0, 540px) 250px;
  gap: 2rem;
  justify-content: center;
  align-items: start;
}

/* Narrow screens: message and cards above the grid, stats below it */
@media (max-width: 860px) {
  .cdk {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    max-width: 540px;
    margin: 0 auto;
  }

  .cdk .cdk-side {
    display: contents;
  }

  .cdk-board {
    order: 1;
  }

  .cdk-footer {
    order: 2;
  }

  .cdk-table {
    justify-content: center;
    gap: 1.5rem;
  }
}

/* ---------- Grid ---------- */
/* minmax(0, 1fr) keeps every track equal so placed cards never resize cells */
.cdk-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  background: var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  aspect-ratio: 1 / 1;
}

.cdk-box {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--grey-300);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Round the four corner boxes to follow the frame's inner curve (frame radius minus its 3px padding) */
.cdk-box:nth-child(1) {
  border-top-left-radius: calc(var(--radius) - 3px);
}

.cdk-box:nth-child(3) {
  border-top-right-radius: calc(var(--radius) - 3px);
}

.cdk-box:nth-child(7) {
  border-bottom-left-radius: calc(var(--radius) - 3px);
}

.cdk-box:nth-child(9) {
  border-bottom-right-radius: calc(var(--radius) - 3px);
}

.cdk-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--navy);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background var(--transition);
}

.cdk-cell.red {
  color: var(--red);
}

.cdk-cell.setup-zone {
  background: var(--warm);
}

.cdk-cell.legal {
  background: var(--accent-100);
  cursor: pointer;
}

.cdk-cell.restricted {
  background: var(--warm-dark);
  box-shadow: inset 0 0 0 2px var(--warm-darker);
}

.cdk-cell.removable,
.cdk-cell.tappable {
  cursor: pointer;
}

.cdk-cell.hover-legal {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cdk-cell.hover-neutral {
  box-shadow: inset 0 0 0 2px var(--navy-400);
}

.cdk-cell.rejected {
  box-shadow: inset 0 0 0 2px var(--red);
}

.cdk-cell.hover-illegal,
.cdk-cell.conflict {
  background: var(--red-50);
  box-shadow: inset 0 0 0 2px var(--red);
}

/* Placed card: thin suit outline with the rank on top */
.cell-suit {
  position: absolute;
  left: 12%;
  top: 12%;
  width: 76%;
  height: 76%;
  fill: none;
  stroke: currentColor;
  opacity: 0.75;
}

.cell-suit path {
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.cell-rank {
  position: relative;
  font-weight: 700;
  font-size: clamp(0.75rem, 2.6vw, 1.15rem);
  line-height: 1;
}

.cdk-cell.just-placed .cell-suit,
.cdk-cell.just-placed .cell-rank {
  animation: cdk-pop 0.25s ease-out;
}

@keyframes cdk-pop {
  from {
    transform: scale(1.3);
    opacity: 0;
  }
}

/* ---------- Playing cards ---------- */
.pc {
  position: relative;
  width: var(--card-w);
  height: calc(var(--card-w) * 1.4);
  background: var(--white);
  border: 1px solid var(--grey-300);
  border-radius: calc(var(--card-w) * 0.09);
  box-shadow: 0 1px 3px rgba(20, 54, 66, 0.18);
  color: var(--navy);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.pc.red {
  color: var(--red);
}

.pc-corner {
  position: absolute;
  top: 5%;
  left: 8%;
  font-weight: 700;
  font-size: calc(var(--card-w) * 0.2);
  line-height: 1.05;
  text-align: center;
}

.pc-corner.pc-br {
  top: auto;
  left: auto;
  bottom: 5%;
  right: 8%;
  transform: rotate(180deg);
}

.pc-pip {
  position: absolute;
  left: 25%;
  top: 28%;
  width: 50%;
  height: 44%;
  fill: currentColor;
}

.pc-joker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16%;
  text-align: center;
  font-size: calc(var(--card-w) * 0.12);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.pc-back {
  background: repeating-linear-gradient(45deg, var(--navy) 0 5px, var(--navy-600) 5px 10px);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 1px var(--grey-300), 0 1px 3px rgba(20, 54, 66, 0.18);
}

/* A card the player can pick up */
.cdk-card {
  border-radius: calc(var(--card-w) * 0.09);
  cursor: grab;
  touch-action: none;
  transition: transform var(--transition);
}

.cdk-card:hover {
  transform: translateY(-3px);
}

.cdk-card:active {
  cursor: grabbing;
}

.cdk-card:focus-visible {
  outline: 3px solid var(--navy-400);
  outline-offset: 2px;
}

.cdk-card.selected {
  transform: translateY(-8px) scale(1.04);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.cdk-card.selected .pc {
  box-shadow: 0 10px 20px rgba(20, 54, 66, 0.25);
}

.cdk-card.flip-in .pc {
  animation: cdk-flip 0.2s ease-out;
}

.cdk-card.shake {
  animation: cdk-shake 0.35s ease-in-out;
}

@keyframes cdk-flip {
  from {
    transform: scaleX(0);
  }
}

@keyframes cdk-shake {

  20%,
  60% {
    transform: translateX(-5px) rotate(-2deg);
  }

  40%,
  80% {
    transform: translateX(5px) rotate(2deg);
  }
}

/* The card being dragged: lifted off the table with a deep shadow */
.cdk-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  transform-origin: 0 0;
  cursor: grabbing;
}

/* The ghost itself only moves; the card inside lifts, tilts, and settles */
.cdk-ghost .pc {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cdk-ghost.lifted .pc {
  transform: scale(1.08) rotate(var(--tilt, 0deg));
  box-shadow: 0 16px 28px rgba(20, 54, 66, 0.28), 0 4px 8px rgba(20, 54, 66, 0.18);
}

/* Show possible moves / placement restrictions switches */
.cdk-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  user-select: none;
}

.cdk-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.cdk-switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: var(--grey-300);
  transition: background var(--transition);
}

.cdk-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition);
}

.cdk-toggle input:checked+.cdk-switch {
  background: var(--accent);
}

.cdk-toggle input:checked+.cdk-switch::after {
  transform: translateX(16px);
}

.cdk-toggle input:focus-visible+.cdk-switch {
  outline: 3px solid var(--navy-400);
  outline-offset: 2px;
}

/* ---------- Side panel ---------- */
.cdk-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Brief explanation over the cards (or setup tray) when a move is illegal */
.cdk-board,
#setupPanel,
.cdk-table {
  position: relative;
}

.cdk-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% - 6px));
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  background: var(--red);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 5;
}

.cdk-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%);
}

/* Wild reminder when hovering the card in hand */
.cdk-slot.has-wild:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  /* below the card, clear of the sticky navbar */
  transform: translateX(-50%);
  width: 190px;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 10;
}

body.cdk-dragging .cdk-slot.has-wild:hover::after {
  display: none;
}

/* End of game summary (in the results dialog) */
.cdk-over-score {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.cdk-over-note {
  font-size: 0.85rem;
  color: var(--grey-700);
  margin: 0.2rem 0 0;
}

.cdk-achievements {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
  text-align: left;
}

.cdk-achievement {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.35;
}

.cdk-achievement strong {
  display: block;
  color: var(--navy);
  font-size: 0.85rem;
}

.cdk-achievement-icon {
  font-size: 1.1rem;
  line-height: 1.2;
}

.cdk-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey-500);
}

.cdk-label b {
  color: var(--navy);
}

.cdk-layouts {
  display: flex;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0.4rem 0 0.75rem;
}

.cdk-layout {
  flex: 1;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.5rem;
  border: 0;
  background: var(--white);
  color: var(--grey-700);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.cdk-layout+.cdk-layout {
  border-left: 1px solid var(--grey-300);
}

.cdk-layout:hover {
  background: var(--navy-50);
}

.cdk-layout.active {
  background: var(--navy);
  color: var(--white);
}

.cdk-tray[hidden] {
  display: none;
}

.cdk-tray {
  --card-w: 44px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: calc(44px * 1.4);
  margin: 0.5rem 0 1rem;
}

.cdk-table {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cdk-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.cdk-slot,
.cdk-deck {
  position: relative;
  width: var(--card-w);
  height: calc(var(--card-w) * 1.4);
  border-radius: calc(var(--card-w) * 0.09);
  transition: box-shadow var(--transition);
}

.cdk-slot::before,
.cdk-deck.empty::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed var(--grey-300);
  border-radius: inherit;
}

.cdk-deck .pc {
  box-shadow: 2px 2px 0 var(--white), 3px 3px 0 var(--grey-300), 5px 5px 0 var(--white), 6px 6px 0 var(--grey-300);
}

.cdk-deck.shuffling .pc {
  animation: cdk-shuffle 0.6s ease-in-out;
}

@keyframes cdk-shuffle {
  20% {
    transform: translateX(-8px) rotate(-6deg);
  }

  40% {
    transform: translateX(8px) rotate(6deg);
  }

  60% {
    transform: translateX(-6px) rotate(-4deg);
  }

  80% {
    transform: translateX(6px) rotate(4deg);
  }
}

.cdk-discard {
  cursor: pointer;
}

.cdk-discard .pc {
  opacity: 0.5;
}

.cdk-discard.legal {
  box-shadow: 0 0 0 3px var(--accent-100);
}

.cdk-discard.hover {
  box-shadow: 0 0 0 3px var(--accent);
}

.cdk-discard.suggest {
  animation: cdk-pulse 1.2s ease-in-out infinite;
}

@keyframes cdk-pulse {
  50% {
    box-shadow: 0 0 0 4px var(--warm-darker);
  }
}

.cdk-footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cdk-btn-row {
  display: flex;
  gap: 0.5rem;
}

.cdk-btn-row .btn {
  flex: 1;
  justify-content: center;
}

.cdk-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
  background: var(--grey-50);
  border-radius: var(--radius);
  padding: 0.6rem 0.25rem;
}

.cdk-stats b {
  display: block;
  font-size: 1.2rem;
  color: var(--navy);
}

.cdk-stats span {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--grey-500);
}

.cdk-stats .cdk-score b {
  color: var(--accent);
}

/* Completed rows / columns / boxes and what they scored */
.cdk-breakdown {
  font-size: 0.85rem;
  border: 1px solid var(--grey-100);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}

.cdk-share-note {
  max-width: 820px;
  margin: 3rem auto 0;
  font-size: 0.85rem;
}

.cdk-breakdown:empty {
  display: none;
}

.cdk-breakdown p {
  color: var(--grey-500);
  margin: 0;
}

.cdk-breakdown ul {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cdk-breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.cdk-breakdown li span:first-child {
  color: var(--navy);
  font-weight: 600;
}

.cdk-breakdown li small {
  display: block;
  font-weight: 500;
  color: var(--warm-darker);
}

.cdk-breakdown li span:last-child {
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}

.cdk-cell.complete-flash {
  animation: cdk-glow 1s ease-out;
}

@keyframes cdk-glow {
  25% {
    background: #f6e7b0;
  }
}

.cdk-wide {
  width: 100%;
  justify-content: center;
}

.cdk .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Site .btn-outline is built for dark backgrounds; invert it on this light page */
.cdk .btn-outline {
  color: var(--navy);
  border-color: var(--navy-100);
  background: var(--white);
}

.cdk .btn-outline:hover:not(:disabled) {
  color: var(--navy);
  border-color: var(--navy);
  background: var(--navy-50);
}

/* ---------- Previous games ---------- */
.cdk-history {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

/* Lifetime best / average / games per starting layout, above the list */
.cdk-history-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cdk-history-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.7rem 0.5rem;
  border-radius: var(--radius);
  background: var(--grey-50);
  text-align: center;
}

.cdk-history-stat.is-total {
  background: var(--navy-50);
}

.cdk-history-stat-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
}

.cdk-history-stat b {
  font-size: 1.4rem;
  line-height: 1.2;
  color: var(--navy);
}

.cdk-history-stat.is-total b {
  color: var(--accent);
}

.cdk-history-stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--grey-500);
}

.cdk-history-stat-meta {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--grey-500);
}

@media (max-width: 560px) {
  .cdk-history-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.cdk-history-empty {
  color: var(--grey-500);
}

.cdk-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cdk-game {
  border: 1px solid var(--grey-100);
  border-radius: var(--radius);
  background: var(--white);
}

.cdk-game summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
}

.cdk-game summary::-webkit-details-marker {
  display: none;
}

.cdk-game summary::after {
  content: '▸';
  margin-left: auto;
  color: var(--grey-500);
  transition: transform var(--transition);
}

.cdk-game[open] summary::after {
  transform: rotate(90deg);
}

.cdk-game-score {
  font-weight: 700;
  color: var(--navy);
  min-width: 3.5rem;
}

.cdk-game-meta {
  color: var(--grey-500);
}

/* Starting layout: Default, Random, or Custom */
.cdk-game-layout {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--navy-50);
  color: var(--navy-400);
  font-size: 0.72rem;
  font-weight: 600;
}

.cdk-game-badges {
  color: var(--warm-darker);
  font-weight: 600;
}

.cdk-game-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 0 0.9rem 0.9rem;
  font-size: 0.85rem;
}

.cdk-game-body h4 {
  color: var(--navy);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

/* Achievement pills in a past game: gold if earned without Undo, grey otherwise (like the share image) */
.cdk-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.cdk-pill {
  padding: 0.15rem 0.55rem;
  border: 1px solid #d6d9df;
  border-radius: 999px;
  background: #eceef1;
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.cdk-pill.gold {
  border-color: var(--warm-darker);
  background: #f6ecc9;
}

/* Read-only mini board for a past game */
.cdk-mini {
  display: grid;
  grid-template-columns: repeat(9, 22px);
  grid-auto-rows: 22px;
  gap: 1px;
  background: var(--grey-300);
  border: 2px solid var(--navy);
  width: max-content;
}

.cdk-mini span {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--navy);
}

.cdk-mini span.red {
  color: var(--red);
}

/* Box edges drawn into the 1px gap */
.cdk-mini .br {
  box-shadow: 1px 0 0 var(--navy);
}

.cdk-mini .bb {
  box-shadow: 0 1px 0 var(--navy);
}

.cdk-mini .br.bb {
  box-shadow: 1px 0 0 var(--navy), 0 1px 0 var(--navy), 1px 1px 0 var(--navy);
}

.cdk-game-discards {
  max-width: 340px;
  line-height: 1.6;
}

.cdk-resend {
  margin-top: 0.75rem;
}

.cdk-game .btn-outline {
  color: var(--navy);
  border-color: var(--navy-100);
  background: var(--white);
}

.cdk-game .btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.cdk-game-discards .red {
  color: var(--red);
}

/* Hint at one achievement the player hasn't unlocked yet */
.cdk-over-teaser {
  margin: 0.75rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--warm-dark);
  font-size: 0.82rem;
  color: var(--grey-700);
}

.cdk-over-teaser strong {
  color: var(--navy);
}

.cdk-over-teaser small {
  display: block;
  margin-top: 0.15rem;
  color: var(--grey-500);
}

.cdk-storage-warning {
  max-width: 820px;
  margin: 0 auto 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--red-50);
  border: 1px solid var(--red);
  color: var(--grey-800);
  font-size: 0.9rem;
}

.cdk-storage-warning[hidden] {
  display: none;
}

/* ---------- Dialogs (feedback, board guide, results) ---------- */
.cdk-feedback,
.cdk-modal {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  color: var(--grey-700);
}

.cdk-feedback::backdrop,
.cdk-modal::backdrop {
  background: rgba(20, 54, 66, 0.6);
}

.cdk-feedback h2,
.cdk-modal h2 {
  color: var(--navy);
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

/* Dialogs open focused on their top, not scrolled down to the first button */
.cdk-modal [autofocus]:focus {
  outline: none;
}

/* Close (×) in a dialog's top right corner */
.cdk-modal-x {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--grey-500);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.cdk-modal-x:hover {
  background: var(--grey-100);
  color: var(--navy);
}

.cdk-modal-x:focus-visible {
  outline: 2px solid var(--navy-400);
}

.cdk-modal h3 {
  color: var(--navy);
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

.cdk-modal-note {
  font-size: 0.9rem;
  color: var(--grey-500);
  margin-bottom: 1rem;
}

.cdk-modal .btn-row,
.cdk-modal .cdk-btn-row {
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.cdk-modal .btn-outline {
  color: var(--navy);
  border-color: var(--navy-100);
  background: var(--white);
}

/* Small text-style button that opens the board guide */
.cdk-link {
  display: block;
  margin: 0.6rem auto 0;
  padding: 0.2rem;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.82rem;
  color: var(--navy-400);
  text-decoration: underline;
  cursor: pointer;
}

.cdk-link:hover {
  color: var(--navy);
}

/* Board guide: rows, columns, and boxes labeled with what each is worth */
.cdk-guide {
  width: min(540px, calc(100% - 32px));
}

.cdk-guide-board {
  display: grid;
  grid-template-columns: 2.1rem repeat(9, minmax(0, 1fr));
  grid-template-rows: 2.1rem repeat(9, auto);
  gap: 2px;
  font-size: 0.7rem;
  line-height: 1.1;
  text-align: center;
}

.cdk-guide-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--navy);
  font-weight: 700;
}

.cdk-guide-head small {
  font-weight: 500;
  font-size: 0.62rem;
  opacity: 0.8;
}

.cdk-guide-box {
  grid-row: span 3;
  grid-column: span 3;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  outline: 2px solid var(--navy);
  outline-offset: -1px;
}

.cdk-guide-box>span {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.55);
}

.cdk-guide-box b {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-size: 0.78rem;
}

.cdk-guide-box b small {
  font-size: 0.68rem;
  font-weight: 600;
}

.cdk-guide .t27 {
  background: var(--warm-dark);
}

.cdk-guide .t18 {
  background: var(--navy-100);
}

.cdk-guide .t9 {
  background: var(--grey-100);
}

.cdk-guide-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  justify-content: center;
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: var(--grey-700);
}

.cdk-guide-legend span::before {
  content: '';
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.3rem;
  vertical-align: -1px;
  border-radius: 2px;
}

.cdk-guide-legend .t27::before {
  background: var(--warm-dark);
}

.cdk-guide-legend .t18::before {
  background: var(--navy-100);
}

.cdk-guide-legend .t9::before {
  background: var(--grey-100);
}

.cdk-guide-legend span {
  background: none !important;
}

.cdk-guide-tips {
  margin: 1rem 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.cdk-guide-tips p+p,
.cdk-guide-tips ul+p {
  margin-top: 0.6rem;
}

.cdk-modal .cdk-guide-heading {
  margin: 1rem 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy-400);
}

.cdk-modal .cdk-guide-tips .cdk-guide-heading:first-child {
  margin-top: 0;
}

.cdk-guide-tips .cdk-guide-questions {
  margin-top: 1.5rem;
}

.cdk-guide-tips ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  list-style: disc;
}

.cdk-guide-tips li+li {
  margin-top: 0.15rem;
}

.cdk-guide-tips strong {
  color: var(--navy);
}

/* Results: score, achievements, and the Completionist checklist after a game */
.cdk-results {
  width: min(860px, calc(100% - 32px));
  padding-top: 3rem;  /* room for the × above the score */
}

.cdk-results-head {
  text-align: center;
  background: var(--warm);
  border: 1px solid var(--warm-dark);
  border-radius: var(--radius);
  padding: 0.9rem;
}

.cdk-results .cdk-achievements {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  margin-top: 0;
}

/* Achievements earned again (not new): collapsed under one line */
.cdk-repeats {
  margin-top: 0.6rem;
}

.cdk-repeats>summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy-400);
}

.cdk-repeats>summary::-webkit-details-marker {
  display: none;
}

.cdk-repeats>summary::before {
  content: '▸';
  transition: transform var(--transition);
}

.cdk-repeats[open]>summary::before {
  transform: rotate(90deg);
}

.cdk-repeats>summary:hover {
  color: var(--navy);
}

.cdk-repeats .cdk-achievements {
  margin-top: 0.5rem;
}

.cdk-results .cdk-achievement {
  background: var(--warm);
  border: 1px solid var(--warm-dark);
}

.cdk-results .cdk-over-teaser {
  border-top-color: var(--grey-100);
}

.cdk-results-comp-note {
  font-size: 0.85rem;
  color: var(--grey-500);
  margin-bottom: 0.5rem;
}

.cdk-results-comp-note b {
  color: var(--warm-darker);
}

/* Completionist boxes checked (or turned gold) for the first time this game: a glow and a pop.
   Gold itself means earned without Undo (.cdk-check.gold) */
.cdk-comp td.fresh {
  background: var(--accent-100) !important;
}

.cdk-check.on.fresh {
  box-shadow: 0 0 0 3px var(--accent-100);
  animation: cdk-check-pop 0.5s ease-out both;
}

.cdk-check.on.gold.fresh {
  box-shadow: 0 0 0 3px var(--warm-dark);
}

@keyframes cdk-check-pop {
  0% {
    transform: scale(0.4);
  }

  70% {
    transform: scale(1.25);
  }

  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cdk-check.on.fresh {
    animation: none;
  }
}

.cdk-results-btn {
  margin-bottom: 0.75rem;
}

.cdk-results-btn[hidden],
.cdk-modal [hidden] {
  display: none;
}

.cdk-feedback-note {
  font-size: 0.85rem;
  color: var(--grey-500);
  margin-bottom: 0.75rem;
}

.cdk-feedback img {
  display: block;
  width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border: 1px solid var(--grey-100);
  border-radius: var(--radius);
  margin-bottom: 0.9rem;
}

.cdk-feedback textarea {
  display: block;
  width: 100%;
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.cdk-feedback-status {
  min-height: 1.3em;
  font-size: 0.85rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.cdk-feedback .btn-outline {
  color: var(--navy);
  border-color: var(--navy-100);
  background: var(--white);
}

.cdk-feedback {
  width: min(460px, calc(100% - 32px));
}

/* Share Your Progress: below the sections, outside the collapsibles */
.cdk-progress-btn:not([hidden]) {
  display: flex;
  justify-content: center;
  width: min(320px, 100%);
  margin: 2.5rem auto 0;
}

/* Achievement picker for the report card */
.cdk-share select {
  display: block;
  width: 100%;
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy);
}

.cdk-share img {
  max-height: 55vh;
}

.cdk-feedback .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Completionist checklist ---------- */
.cdk-completionist {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Collapsible sections below the board ---------- */
.cdk-section {
  margin-top: 2.25rem;
}

.cdk-section>summary {
  position: relative;
  display: block;
  list-style: none;
  cursor: pointer;
  padding-right: 2.5rem;
  margin-bottom: 0;
}

.cdk-section>summary::-webkit-details-marker {
  display: none;
}

/* Arrow on the right that turns when the section opens */
.cdk-section>summary::after {
  content: '';
  position: absolute;
  right: 0.5rem;
  top: 0.7rem;
  width: 0.6rem;
  height: 0.6rem;
  border-right: 2px solid var(--navy-400);
  border-bottom: 2px solid var(--navy-400);
  transform: rotate(-45deg);
  transition: transform var(--transition);
}

.cdk-section[open]>summary::after {
  transform: rotate(45deg);
}

.cdk-section[open]>summary {
  margin-bottom: 1.5rem;
}

/* Closed sections show just the title; the grey line under it appears once opened */
.cdk-section:not([open])>summary .text-muted {
  display: none;
}

.cdk-section>summary:hover h2 {
  color: var(--navy-400);
}

.cdk-section>summary:focus-visible {
  outline: 3px solid var(--navy-400);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* Row, Column, and Box tables sit side by side; on phones, tabs show one at a time */
.cdk-comp-wrap {
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  overflow: hidden;
}

.cdk-comp-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cdk-comp-group+.cdk-comp-group {
  border-left: 2px solid var(--navy);
}

.cdk-comp-tabs {
  display: none;
  border-bottom: 1px solid var(--grey-300);
  background: var(--grey-50);
}

.cdk-comp-tab {
  flex: 1;
  padding: 0.55rem 0.25rem;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--grey-500);
  cursor: pointer;
}

.cdk-comp-tab small {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
}

.cdk-comp-tab.active {
  color: var(--navy);
  border-bottom-color: var(--accent);
  background: var(--white);
}

.cdk-comp-tab .fresh-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 0.25rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 2px;
}

@media (max-width: 640px) {
  .cdk-comp-tabs {
    display: flex;
  }

  .cdk-comp-groups {
    grid-template-columns: 1fr;
  }

  .cdk-comp-group:not(.active) {
    display: none;
  }

  .cdk-comp-group+.cdk-comp-group {
    border-left: 0;
  }

  .cdk-comp thead tr:first-child {
    display: none;
    /* the tab already names the group */
  }

  .cdk-comp {
    font-size: 0.8rem;
  }

  .cdk-comp thead tr:last-child th {
    font-size: 0.72rem;
  }

  .cdk-comp th,
  .cdk-comp td {
    padding: 0.45rem 0.25rem;
  }
}

/* Fixed layout + a colgroup keeps the checkbox columns the same width */
.cdk-comp {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  font-size: 0.72rem;
  text-align: center;
}

.cdk-comp-pct {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-100);
  color: var(--accent-hover);
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: 2px;
}

.cdk-comp col.cdk-comp-index-col {
  width: 1.6rem;
}

/* "Completed" is the longest header */
.cdk-comp col.cdk-comp-done-col {
  width: 24%;
}

.cdk-comp thead tr:last-child th {
  font-size: 0.62rem;
  padding-left: 0;
  padding-right: 0;
}

.cdk-comp th,
.cdk-comp td {
  padding: 0.35rem 0.25rem;
  border-bottom: 1px solid var(--grey-100);
}

.cdk-comp thead th {
  color: var(--navy);
  background: var(--grey-50);
  font-weight: 600;
}

.cdk-comp thead tr:first-child th small {
  margin-left: 0.35rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--grey-500);
}

.cdk-comp thead tr:first-child th {
  background: var(--navy-50);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cdk-comp tbody tr:nth-child(even) td {
  background: var(--grey-50);
}

.cdk-comp .cdk-comp-index {
  color: var(--grey-500);
  font-weight: 600;
}

.cdk-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--grey-300);
  border-radius: 3px;
  background: var(--white);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.cdk-check.on {
  background: var(--accent);
  border-color: var(--accent);
}

.cdk-check.on.gold {
  background: var(--warm-darker);
  border-color: var(--warm-darker);
}

/* ---------- Achievements (locked until earned) ---------- */
.cdk-trophies {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.cdk-trophy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 0.75rem;
}

.cdk-trophy {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--warm-dark);
  background: var(--warm);
  font-size: 0.85rem;
  line-height: 1.4;
}

.cdk-trophy-icon {
  font-size: 1.5rem;
  line-height: 1.1;
}

.cdk-trophy strong {
  display: block;
  color: var(--navy);
  font-size: 0.95rem;
}

.cdk-trophy small {
  display: block;
  margin-top: 0.3rem;
  color: var(--warm-darker);
  font-weight: 600;
}

.cdk-trophy.locked {
  background: var(--grey-50);
  border: 1px dashed var(--grey-300);
  color: var(--grey-500);
}

.cdk-trophy.locked strong {
  color: var(--grey-500);
  letter-spacing: 0.1em;
}

.cdk-trophy.locked.revealed strong {
  color: var(--grey-700);
  letter-spacing: normal;
}

.cdk-trophy-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--navy);
  font-size: 1.05rem;
  margin: 1.75rem 0 0.75rem;
}

.cdk-trophy-group:first-child {
  margin-top: 0.5rem;
}

.cdk-trophy-group span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--grey-700);
  background: var(--grey-100);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

.cdk-trophy-empty {
  color: var(--grey-500);
  font-size: 0.9rem;
  margin: 0;
}

.cdk-trophy.locked .cdk-trophy-icon {
  filter: grayscale(1);
  opacity: 0.6;
}

/* Optional flavor line under an achievement's name */
.cdk-subtitle {
  display: block;
  font-style: italic;
  color: var(--warm-darker);
  margin-bottom: 0.15rem;
}

.cdk-subtitle.after {
  margin: 0.15rem 0 0;
}

/* Checklist boxes that can't be earned (Flush/Royal in rows and boxes 7–9) */
.cdk-comp-na {
  color: var(--grey-300);
}

.cdk-new {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  vertical-align: middle;
}

/* Achievements earned without pressing Undo: a gold tag, and a gold border in the Achievements list */
.cdk-no-undo {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--warm-darker);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  font-style: normal;
  vertical-align: middle;
  white-space: nowrap;
}

.cdk-undo-note {
  font-size: 0.85rem;
  color: var(--grey-500);
  margin-bottom: 0.75rem;
}

.cdk-undo-note .cdk-no-undo {
  margin-left: 0.15rem;
}

.cdk-new.cdk-upgraded {
  background: var(--warm-darker);
}

.cdk-upgraded-head {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.85rem;
  color: var(--warm-darker);
}

.cdk-trophy.no-undo {
  border: 2px solid var(--warm-darker);
  box-shadow: 0 0 0 3px var(--warm);
}

.cdk-undo-voided {
  margin-top: 0.5rem;
}

/* ---------- Rules ---------- */
/* First section below the board: a bit more room above it than between sections */
.cdk-section.cdk-rules {
  max-width: 820px;
  margin: 3rem auto 0;
}

.cdk-rules h3 {
  color: var(--navy);
  margin: 1.25rem 0 0.4rem;
}

.cdk-rules ol,
.cdk-rules ul {
  padding-left: 1.25rem;
  list-style: revert;
}

.cdk-rules li {
  margin-bottom: 0.35rem;
}

.cdk-table-scores {
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  text-align: center;
}

.cdk-table-scores th,
.cdk-table-scores td {
  padding: 0.35rem 1.1rem;
  border-bottom: 1px solid var(--grey-100);
}

.cdk-table-scores th {
  color: var(--navy);
}

.cdk-table-scores td:first-child {
  color: var(--grey-500);
}

/* Inline "See it on the board." link in How to Play */
.cdk-link-inline {
  display: inline;
  margin: 0;
}
