/* Shared palette. Tiles must use these variables rather than their own hex values
   so all 20 scenes read as one set. */
:root {
  --xc-night: #14233b;       /* tile background (provided by the frame) */
  --xc-night-2: #1e3353;     /* lighter night, distant hills, shadows on night */
  --xc-snow: #fdf8ee;        /* snow, highlights, eyes */
  --xc-snow-shade: #d9e2ee;  /* snow shadow */
  --xc-red: #c8323c;
  --xc-red-dark: #8f1f2b;
  --xc-green: #1f6b4a;
  --xc-green-dark: #134532;
  --xc-green-light: #3f9a6b;
  --xc-gold: #e8b84a;
  --xc-gold-light: #ffe29a;  /* glows, flames, star light */
  --xc-brown: #7a4a2b;
  --xc-brown-dark: #4e2d19;
  --xc-tan: #d9a066;         /* gingerbread, wood highlights */
  --xc-skin: #f2c7a5;
  --xc-coal: #1b1b22;        /* eyes, buttons, boots */
  --xc-orange: #e8772e;      /* carrot nose, beak, fire */
  --xc-ice: #9fd3e6;         /* ice, glass */
  --xc-paper: #f6efe2;
}

* { box-sizing: border-box; }

body {
  overflow-x: clip;
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #0b1626;
  color: var(--xc-paper);
  font-family: Georgia, 'Times New Roman', serif;
}

.xc-card {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(5, auto);
  gap: clamp(4px, 0.9vw, 10px);
  padding: clamp(6px, 1.2vw, 14px);
  background: var(--xc-paper);
  border-radius: clamp(10px, 2vw, 22px);
}

/* Narrow portrait screens: the border reflows to 5 x 7 (still 20 tiles). */
.xc-card--tall { grid-template-columns: repeat(5, 1fr); }

.xc-stage {
  grid-column: 2 / 7;
  grid-row: 2 / 5;
  position: relative;
  container-type: size;
  border-radius: clamp(6px, 1.2vw, 14px);
  background: var(--xc-night);
  color: var(--xc-paper);
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr);
  align-items: center;
  gap: 2cqw;
  padding: 3cqw 2cqw 3cqw 4cqw;
  min-width: 0;
  min-height: 0;
}
.xc-card--tall .xc-stage {
  grid-column: 2 / 5;
  grid-row: 2 / 7;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  padding: 5cqw 4cqw 3cqw;
  text-align: center;
}

.xc-words { min-width: 0; }
.xc-greeting {
  margin: 0;
  font-size: 6.4cqw;
  line-height: 1.08;
  font-weight: 400;
  font-style: italic;
  color: var(--xc-gold-light);
  text-wrap: balance;
}
.xc-message, .xc-signoff {
  margin: 2.2cqw 0 0;
  font-size: max(11px, 2.3cqw);
  line-height: 1.4;
  color: var(--xc-paper);
  text-wrap: pretty;
}
.xc-signoff { font-style: italic; color: var(--xc-gold-light); }
.xc-foot {
  margin: 4cqw 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: max(10px, 1.7cqw);
  color: var(--xc-snow-shade);
}
.xc-hint { transition: opacity 0.6s; }
.xc-hint.is-used { opacity: 0; }
.xc-count { font-variant-numeric: tabular-nums; opacity: 0.75; }

.xc-card--tall .xc-greeting { font-size: 11cqw; }
.xc-card--tall .xc-message, .xc-card--tall .xc-signoff { font-size: max(11px, 4.6cqw); margin-top: 2cqw; }
.xc-card--tall .xc-foot { margin-top: 2.5cqw; font-size: max(10px, 3.6cqw); flex-direction: row; justify-content: center; gap: 1em; }
.xc-card--tall .xc-hint.is-used { display: none; }

/* The pile is one big button; each print sizes itself to its photo's shape. */
.xc-pile {
  all: unset;
  box-sizing: border-box;
  container-type: size;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: clamp(6px, 1.2vw, 14px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.xc-pile:focus-visible { box-shadow: 0 0 0 3px var(--xc-gold); }
.xc-print {
  grid-area: 1 / 1;
  display: block;
  width: min(84cqw, 84cqh * var(--r), var(--nw) * 1.7px);
  aspect-ratio: var(--r);
  box-sizing: content-box;
  padding: 1.6cqmin 1.6cqmin 1.6cqmin;
  background: var(--xc-snow);
  border-radius: 3px;
  box-shadow: 0 0.8cqmin 2.4cqmin rgba(5, 12, 24, 0.55);
  will-change: transform;
  user-select: none;
}
.xc-print img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--xc-night-2);
  border-radius: 1px;
}
.xc-pile:active .xc-print { filter: brightness(0.97); }

.xc-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: clamp(6px, 1.2vw, 14px);
  background: var(--xc-night);
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.xc-tile:focus-visible { box-shadow: 0 0 0 3px var(--xc-gold); }
.xc-tile > svg { display: block; width: 100%; height: 100%; }

.xc-tile__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4px;
  font-size: clamp(8px, 1.1vw, 13px);
  text-align: center;
  color: var(--xc-snow-shade);
  opacity: 0.6;
}
