/* The Puzzle of the day card of Fianchetto. The board is one square layer (two warm tones), a layer of marks (last move,
   check, the thin rings of the possible squares), the coordinates and the pieces. Every piece is a box one square big,
   moved by GSAP in xPercent / yPercent (100 = one square), so nothing is measured in pixels and a resize keeps it all
   in place. Inside the box: .pc__lift (height and tilt, for GSAP) holds the ground shadow and the drawn piece. */
:root {
  --page: #efeae2;          /* the page */
  --card: #fbf9f5;          /* the card */
  --ink: #26221e;           /* the words */
  --muted: #8b8379;         /* the small words */
  --line: rgba(38, 34, 30, 0.09); /* thin lines */
  --light: #efe6d6;         /* the light squares */
  --dark: #b89d7e;          /* the dark squares */
  --accent: #e0573c;        /* the accent: check, solved */
  --white-piece: #fbf8f1;   /* the white pieces */
  --white-edge: #3b342d;    /* their outline */
  --black-piece: #2e2925;   /* the black pieces */
  --black-edge: #171411;    /* their outline */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: radial-gradient(120% 90% at 50% 30%, #f6f2ec 0%, var(--page) 62%, #e6e0d6 100%);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  --b: min(62vw, 50vh, 440px);   /* the side of the board */
  --sq: calc(var(--b) / 8);
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: min(2.4vh, 14px);
  padding: 12px;
  overflow: hidden;
}

.card {
  position: relative;
  padding: calc(var(--sq) * 0.42) calc(var(--sq) * 0.42) calc(var(--sq) * 0.36);
  border-radius: calc(var(--sq) * 0.62);
  background: linear-gradient(180deg, #fffdf9 0%, var(--card) 100%);
  box-shadow:
    0 0 0 1px rgba(38, 34, 30, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(38, 34, 30, 0.05),
    0 8px 18px -6px rgba(60, 44, 28, 0.12),
    0 30px 60px -24px rgba(60, 44, 28, 0.24);
  opacity: 0;
}

/* the head: the mark, the app's name, the title, the date */
.head {
  display: flex;
  align-items: center;
  gap: calc(var(--sq) * 0.26);
  margin-bottom: calc(var(--sq) * 0.36);
}

.mark {
  width: calc(var(--sq) * 0.78);
  height: calc(var(--sq) * 0.78);
  flex: none;
}

.mark svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mark rect {
  fill: var(--ink);
  stroke: none;
}

.mark .mark__sq {
  fill: #f4ede1;
}

.mark .mark__hot {
  fill: var(--accent);
}

.head__text {
  flex: 1;
  min-width: 0;
}

.brand,
.title,
.date {
  margin: 0;
  line-height: 1.15;
}

.brand {
  font-size: max(8px, calc(var(--sq) * 0.27));
  font-weight: 560;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.title {
  font-size: max(11px, calc(var(--sq) * 0.42));
  font-weight: 640;
  letter-spacing: -0.012em;
}

.date {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: max(8px, calc(var(--sq) * 0.25));
  color: var(--muted);
  white-space: nowrap;
}

/* the table: the tray of the captured pieces on the left, then the board */
.table {
  position: relative;
  display: flex;
  gap: calc(var(--sq) * 0.22);
}

.tray {
  position: relative;
  width: calc(var(--sq) * 0.78);
  height: var(--b);
  border-radius: calc(var(--sq) * 0.39);
  background: linear-gradient(90deg, #ece5da 0%, #f4efe7 50%, #ece5da 100%);
  box-shadow:
    inset 0 1px 3px rgba(60, 44, 28, 0.16),
    inset 0 0 0 1px rgba(38, 34, 30, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.8);
}

.tray__groove {
  position: absolute;
  inset: calc(var(--sq) * 0.12) 46%;
  border-radius: 2px;
  background: rgba(60, 44, 28, 0.06);
}

.board {
  position: relative;
  width: var(--b);
  height: var(--b);
  border-radius: calc(var(--sq) * 0.14);
  box-shadow:
    0 0 0 1px rgba(60, 44, 28, 0.22),
    0 2px 3px rgba(60, 44, 28, 0.12),
    0 12px 24px -10px rgba(60, 44, 28, 0.3);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.squares {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 45%, rgba(60, 40, 20, 0.06)),
    repeating-conic-gradient(var(--dark) 0% 25%, var(--light) 0% 50%) 0 0 / calc(var(--sq) * 2) calc(var(--sq) * 2);
}

.marks,
.coords,
.pieces {
  position: absolute;
  inset: 0;
}

.marks > *,
.pieces > * {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
}

/* the last move: a quiet warm wash on the two squares */
.mark-move {
  background: rgba(214, 178, 92, 0.34);
  opacity: 0;
}

/* the check: the king's square takes the accent, deeper at the rim */
.mark-check {
  background: radial-gradient(circle at 50% 50%, rgba(224, 87, 60, 0.55) 0%, rgba(224, 87, 60, 0.82) 70%, var(--accent) 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 30, 14, 0.25);
  opacity: 0;
}

/* the rings of the possible squares: thin, never filled */
.ring {
  display: grid;
  place-items: center;
  pointer-events: none;
}

.ring i {
  display: block;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  border: max(1px, calc(var(--sq) * 0.035)) solid rgba(38, 34, 30, 0.42);
}

.ring--take i {
  width: 88%;
  height: 88%;
  border-color: rgba(38, 34, 30, 0.36);
}

.ring--right i {
  border-color: rgba(38, 34, 30, 0.55);
}

/* the coordinates, very small, in the corners of the edge squares */
.coords span {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  padding: calc(var(--sq) * 0.06) calc(var(--sq) * 0.08);
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: max(6px, calc(var(--sq) * 0.19));
  font-weight: 560;
  line-height: 1;
  pointer-events: none;
}

.coords .file {
  align-items: flex-end;
  justify-content: flex-end;
}

.coords .rank {
  align-items: flex-start;
  justify-content: flex-start;
}

.coords .on-light {
  color: var(--dark);
}

.coords .on-dark {
  color: var(--light);
}

/* the pieces */
.pc {
  pointer-events: none;
}

.pc__lift {
  position: absolute;
  inset: 0;
  transform-origin: 50% 84%;
}

.pc__shadow {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 6%;
  height: 17%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 26, 12, 0.42), rgba(40, 26, 12, 0));
  transform-origin: 50% 50%;
}

.pc__body {
  position: absolute;
  left: -5%;
  top: -7%;
  width: 110%;
  height: 110%;
  overflow: visible;
}

.pc__body use {
  stroke-width: 2.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.pc--w .pc__body use {
  fill: var(--white-piece);
  stroke: var(--white-edge);
  --pd: rgba(59, 52, 45, 0.55);
}

.pc--b .pc__body use {
  fill: var(--black-piece);
  stroke: var(--black-edge);
  --pd: rgba(255, 246, 232, 0.22);
}

/* a soft light on the left of every piece, the same for all */
.pc__body {
  filter: drop-shadow(0 calc(var(--sq) * 0.012) 0 rgba(30, 20, 10, 0.18));
}

/* the footer: whose turn, the goal, the rating */
.foot {
  display: flex;
  align-items: center;
  gap: calc(var(--sq) * 0.3);
  margin-top: calc(var(--sq) * 0.36);
  padding-left: calc(var(--sq) * 1);
}

.turn {
  display: flex;
  align-items: center;
  gap: calc(var(--sq) * 0.16);
  flex: 1;
  min-width: 0;
  font-size: max(9px, calc(var(--sq) * 0.3));
  font-weight: 520;
  white-space: nowrap;
}

.turn__swatch {
  width: calc(var(--sq) * 0.28);
  height: calc(var(--sq) * 0.28);
  flex: none;
  border-radius: 3px;
  background: var(--white-piece);
  box-shadow: 0 0 0 1px rgba(38, 34, 30, 0.3);
}

.turn__text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal {
  position: relative;
  display: grid;
  height: calc(var(--sq) * 0.6);
  padding: 0 calc(var(--sq) * 0.24);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(38, 34, 30, 0.05);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: max(9px, calc(var(--sq) * 0.29));
  font-weight: 600;
  white-space: nowrap;
}

.goal__bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  opacity: 0;
}

.goal__face {
  grid-area: 1 / 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--sq) * 0.1);
}

.goal__face--done {
  color: #fff;
  opacity: 0;
}

.tick {
  width: calc(var(--sq) * 0.3);
  height: calc(var(--sq) * 0.3);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rating {
  display: flex;
  align-items: baseline;
  gap: calc(var(--sq) * 0.1);
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: max(8px, calc(var(--sq) * 0.26));
  white-space: nowrap;
}

.rating__label {
  color: var(--muted);
}

.rating__num {
  font-variant-numeric: tabular-nums;
}

.rating__gain {
  color: var(--accent);
  opacity: 0;
}

.hint {
  margin: 0;
  font-size: max(9px, calc(var(--sq) * 0.27));
  color: var(--muted);
  opacity: 0;
}

@media (hover: hover) {
  .board.is-hovering {
    cursor: pointer;
  }
}

@media (max-width: 520px) {
  .rating__label {
    display: none;
  }
}
