/* Snug: a daily packing puzzle. Built on the site's base styles, with its
   own colour: mauve fog (a dusty grey-lilac),
   a deep plum tray, bright blocky pieces and white-beige buttons. */

:root {
  --table: #efe9ef;
  --card: #b29fb3;   /* cards, tabs and the board's frame */
  --tray: #2e2440;
  --tray-floor: #3d3154;
  --socket: rgba(255, 255, 255, 0.07);
  --mint-deep: #557344;
  --middle: #e4dbe4;  /* the lighter band the game sits on, on a big screen */
  --page: #d3c7d3;   /* the page itself: mauve fog */
  --button: #fbf7f2; /* white-beige buttons */
  --plum-soft: #4a3f5c; /* the site's soft purple is too faint on the mauve */
}

body { background: var(--page); }
/* Every button white-beige, primary or not, to sit on the mauve */
.btn, .btn.primary { background: var(--button); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}
.home-link { font-weight: 800; text-decoration: none; }
.home-link:hover { text-decoration: underline; }
.topbar-actions { display: flex; gap: 8px; }
#sound-btn .mute { display: none; }
#sound-btn[aria-pressed="false"] .wave { display: none; }
#sound-btn[aria-pressed="false"] .mute { display: inline; }

.stage {
  flex: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 0;
  font: 600 40px/1.1 var(--serif);
}
.logo { width: 34px; height: 34px; transform: rotate(5deg); }
.date { margin: 2px 0 14px; text-align: center; color: var(--plum-soft); font-weight: 700; }
.previewing .date { display: table; margin: 4px auto 14px; padding: 3px 12px; border: 2px dashed var(--plum); border-radius: 999px; background: var(--butter); color: var(--plum); }

/* Difficulty tabs */
.levels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border: 2px solid var(--plum);
  border-radius: 999px;
  background: #fff;
}
.level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--plum);
  font: 800 15px/1 var(--sans);
  cursor: pointer;
}
.level[aria-current="true"] { background: var(--card); box-shadow: inset 0 0 0 2px var(--plum); }
.level .done { color: var(--mint-deep); font-size: 13px; }
.level.endless { padding: 0 14px; color: var(--plum-soft); border-left: 2px dashed var(--line); border-radius: 0 999px 999px 0; }
.level.endless[aria-current="true"] { color: var(--plum); background: var(--butter); border-left-color: transparent; border-radius: 999px; }
.level.bonus { color: #7a4fd6; }
.level.bonus[aria-current="true"] { background: #7a4fd6; color: #fff; }
.level.bonus[aria-current="true"] .done { color: #fbeab0; }
.level:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }
@media (max-width: 480px) {
  .levels { gap: 2px; }
  .level { flex-direction: column; gap: 1px; min-height: 42px; font-size: 14px; }
  .level .done { font-size: 9px; letter-spacing: -0.5px; }
  .level.endless { padding: 0 10px; }
}

/* Endless: pick a difficulty, get as many trays as you like */
.endless-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: -4px 0 14px;
  padding: 8px 12px;
  border: 2px dashed var(--plum);
  border-radius: 18px;
  background: #fffbea;
  font-weight: 800;
  font-size: 14px;
}
.endless-levels { display: inline-flex; gap: 4px; }
.endless-levels button {
  padding: 5px 11px;
  border: 2px solid var(--plum);
  border-radius: 999px;
  background: #fff;
  color: var(--plum);
  font: 800 13px/1 var(--sans);
  cursor: pointer;
}
.endless-levels button[aria-pressed="true"] { background: var(--butter); }
.endless-levels .master[aria-pressed="true"] { background: #7a4fd6; color: #fff; }
.endless-count { color: var(--plum-soft); }

/* The board: a pale mauve table with the tray and the shelf of pieces on it */
.board-card {
  position: relative;
  padding: 8px;
  border: 2px solid var(--plum);
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 6px 0 var(--plum);
}
.board {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: var(--table);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;          /* no copy/save menu on a long press */
  -webkit-tap-highlight-color: transparent;
}
.board .tray-rim { fill: var(--tray); }
.board .tray-floor { fill: var(--tray-floor); }
/* Islands: raised bumps fixed in the tray that the pieces bend round */
.board .island { fill: #1f1830; }
.board .island-shadow { fill: #120c1c; }
.board .shelf { fill: rgba(46, 36, 64, 0.04); stroke: rgba(46, 36, 64, 0.22); stroke-width: 0.04; stroke-dasharray: 0.16 0.12; }
.board .shelf-label { fill: var(--plum-soft); font: 800 0.34px var(--sans); letter-spacing: 0.04px; text-transform: uppercase; }
.board .slot { fill: #fff; fill-opacity: 0; }
.board .piece { cursor: grab; }
/* Tubes: flat and blocky, one colour with a darker edge of the same colour.
   Square caps and mitred corners, so they look cut rather than squeezed. */
.board .piece path { fill: none; stroke-linecap: square; stroke-linejoin: miter; }
.board .tube-edge { stroke-width: 0.84; }
.board .tube { stroke-width: 0.66; }
/* Opacity on the whole line, so overlapping joins don't stack into dark spots */
.board .tube-shadow { stroke: var(--plum); stroke-width: 0.84; opacity: 0.25; }
.board .lifted .tube-shadow { transform: translate(0.1px, 0.2px); opacity: 0.2; }
.board .ghost { fill: none; stroke: rgba(255, 255, 255, 0.3); stroke-width: 0.8; stroke-linecap: square; stroke-linejoin: miter; }
.board .piece-body.spin { animation: spin 0.18s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes spin { from { transform: rotate(-90deg) scale(0.9); } }
.board .piece-body.pop { animation: pop 0.22s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes pop { 40% { transform: scale(1.06); } }
.board.solved .piece-body { animation: wiggle 0.5s ease-in-out; transform-box: fill-box; transform-origin: center; }
@keyframes wiggle { 30% { transform: scale(1.04) rotate(-2deg); } 60% { transform: scale(1.02) rotate(1deg); } }

/* Make mode: paint a tray on a grid of empty squares */
.board .make-socket { fill: rgba(46, 36, 64, 0.08); }
.board .make-socket:hover { fill: rgba(46, 36, 64, 0.16); }
.board .make-island { fill: rgba(46, 36, 64, 0.14); }
.making .board { cursor: crosshair; }

.nudge {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 6px 14px;
  border: 2px solid var(--plum);
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.nudge.show { opacity: 1; }

/* Filled meter */
.meter { margin-top: 18px; }
.meter-row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; }
.meter-row strong { font: 800 24px/1 var(--sans); font-variant-numeric: tabular-nums; }
.meter-row.small { margin-top: 6px; font-size: 14px; color: var(--plum-soft); }
.meter-track { height: 14px; margin-top: 6px; border: 2px solid var(--plum); border-radius: 999px; background: #fff; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--card); border-right: 2px solid var(--plum); transition: width 0.3s ease, background 0.3s; }
.meter-fill.close { background: var(--butter); }
.meter-fill.full { background: #8f7a90; }

.controls { display: flex; justify-content: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.controls .btn { background: #fff; }

/* Win */
.win { margin-top: 20px; }
.win-card {
  padding: 24px 20px;
  border: 2px solid var(--plum);
  border-radius: 24px;
  background: var(--card);
  text-align: center;
  box-shadow: 0 6px 0 var(--plum);
  animation: rise 0.45s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.win-kicker { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--plum-soft); }
.win-title { margin: 4px 0 6px; font: 600 34px/1.1 var(--serif); }
.stars { margin: 0; font-size: 34px; letter-spacing: 6px; }
.stars .off { opacity: 0.25; filter: grayscale(1); }
.win-line { margin: 8px 0 16px; font-weight: 700; }
.win-buttons { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.win-buttons .btn:not(.primary) { background: #fff; }
.share-note { min-height: 1.4em; margin: 10px 0 0; font-weight: 800; }
@keyframes rise { from { transform: translateY(20px) scale(0.96); opacity: 0; } }

.day-done { margin-top: 14px; text-align: center; font-weight: 700; color: var(--plum-soft); }
.day-done strong { color: var(--plum); font-variant-numeric: tabular-nums; }

/* Dialogs (same as the rest of the site) */
.sheet {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 28px 24px 24px;
  border: 2px solid var(--plum);
  border-radius: 24px;
  background: #f1faf5;
  color: var(--plum);
}
.sheet::backdrop { background: rgba(46, 36, 64, 0.35); }
.sheet h2 { margin: 0 0 14px; font: 600 26px/1.2 var(--serif); }
.sheet .close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; font-size: 14px; }
.rules { margin: 0 0 18px; padding-left: 22px; display: grid; gap: 8px; }
.wide { width: 100%; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-row > div { display: flex; flex-direction: column; padding: 14px 8px; border-radius: 18px; background: #fff; border: 2px solid var(--plum); text-align: center; font-size: 13px; font-weight: 700; color: var(--plum-soft); }
.big { font: 800 26px/1.2 var(--sans); color: var(--plum); }
.stats-note { margin: 14px 0 0; font-size: 13px; color: var(--plum-soft); text-align: center; }

/* Confetti in piece colours on a win */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.bit {
  position: absolute;
  top: 40%;
  left: 50%;
  width: var(--size);
  height: var(--size);
  background: var(--color);
  border: 1.5px solid var(--plum);
  border-radius: 3px;
  animation: tumble 1.3s cubic-bezier(0.15, 0.7, 0.4, 1) forwards;
}
@keyframes tumble { to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }

@media (min-width: 900px) {
  .title { font-size: 46px; }
}

/* About the game: for new players, and so search engines have real text to read */
.about-game { margin: 32px 0 0; padding: 20px 22px; border: 2px solid var(--line); border-radius: 20px; background: #fff; }
.about-game h2 { margin: 0 0 8px; font: 600 22px/1.2 var(--serif); }
.about-game p { margin: 0 0 10px; font-size: 15px; line-height: 1.6; color: var(--plum-soft); }
.about-game p:last-child { margin: 0; }

/* ---- Community trays ---- */

.make-bar, .tray-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin: -4px 0 14px;
  padding: 10px 14px;
  border: 2px solid var(--plum);
  border-radius: 18px;
  background: #fff;
}
.make-text, .tray-info { display: grid; gap: 2px; min-width: 0; }
.make-text strong, .tray-info strong { font: 600 19px/1.2 var(--serif); }
.make-text span, .tray-info span { font-size: 14px; font-weight: 700; color: var(--plum-soft); }
.tray-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.make-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.make-buttons .btn:not(.primary) { background: #fff; }
.make-buttons #make-cut:not(:disabled) { background: var(--button); }
.cut-styles { display: inline-flex; padding: 3px; border: 2px solid var(--plum); border-radius: 999px; background: #fff; }
.cut-styles button { padding: 6px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--plum); font: 800 13px/1 var(--sans); cursor: pointer; }
.cut-styles button[aria-pressed="true"] { background: var(--plum); color: #fff; }

.vote {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 14px;
  border: 2px solid var(--plum);
  border-radius: 999px;
  background: #fff;
  color: var(--plum);
  font: 800 14px/1 var(--sans);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--plum);
}
.vote[aria-pressed="true"] { background: var(--card); }
.vote:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.vote-count { padding: 2px 8px; border-radius: 999px; background: var(--card); font-variant-numeric: tabular-nums; }

/* Making: no meter, hints or game chrome */
.making .meter, .making .controls, .making .about-game, .making .community-link { display: none; }
.packing .community-link { display: none; }

.community-link {
  display: grid;
  gap: 2px;
  margin: 28px 0 0;
  padding: 16px 18px;
  border: 2px solid var(--plum);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--plum);
  text-decoration: none;
  font: 600 20px/1.2 var(--serif);
}
.community-link-sub { font: 700 14px/1.4 var(--sans); color: var(--plum-soft); }
.win-community { display: block; margin-top: 14px; font-weight: 800; color: var(--plum); }

/* Publish dialog */
.publish-lede { margin: -6px 0 14px; color: var(--plum-soft); font-weight: 700; }
#publish-form { display: grid; gap: 6px; }
#publish-form label { font-size: 13px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--plum-soft); }
#publish-form label small { text-transform: none; letter-spacing: 0; }
#publish-form input {
  min-height: 46px; margin-bottom: 8px; padding: 0 14px;
  border: 2px solid var(--plum); border-radius: 12px; background: #fff; color: var(--plum);
  font: 700 17px var(--sans); -webkit-appearance: none; appearance: none;
}
#publish-form input:focus { outline: none; box-shadow: 0 0 0 3px var(--card); }
.publish-error { min-height: 1.2em; margin: 0; color: #9e3b2f; font-weight: 800; }
.publish-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.publish-buttons .btn:not(.primary) { background: #fff; }
.publish-link { display: block; padding: 12px 14px; border: 2px dashed var(--plum); border-radius: 12px; background: #fff; font-weight: 800; word-break: break-all; color: var(--plum); }

/* ---- Side columns: only on a computer-sized screen, like Killer Clues ---- */
.side { display: none; }

.side-label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--plum-soft);
}
.side h2 { margin: 0 0 12px; font: 600 24px/1.2 var(--serif); }
.side .rules { padding-left: 20px; font-size: 16px; }
.side .example {
  padding: 16px 18px;
  border: 2px solid var(--plum);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--plum);
}
.side .example p { margin: 0; font-size: 15px; line-height: 1.5; }
.side .example-label { margin-bottom: 8px !important; font-size: 12px !important; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--plum-soft); }
.side .example-art { display: block; width: 120px; height: 120px; margin: 4px auto 12px; }
.side .stat-row { margin-bottom: 14px; }

.today-levels { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 2px; }
.today-levels li { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; border-bottom: 1px solid rgba(46, 36, 64, 0.12); font-weight: 800; }
.today-levels button { padding: 0; border: 0; background: none; color: var(--plum); font: 800 16px var(--sans); cursor: pointer; }
.today-levels button:hover { text-decoration: underline; }
.today-levels span { color: var(--plum-soft); letter-spacing: 2px; }

.next-trays {
  display: flex;
  flex-direction: column;
  margin-top: 18px;
  padding: 16px;
  border: 2px solid var(--plum);
  border-radius: 18px;
  background: var(--button);
  text-align: center;
}
.next-trays .side-label { margin: 0; }
.next-trays .big { font-size: 32px; font-variant-numeric: tabular-nums; }

.side-community { margin-top: 26px; }
.side-community-head { display: flex; justify-content: space-between; align-items: baseline; }
.side-community-head a { font-size: 14px; font-weight: 800; }
.side-trays { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.side-trays a {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 2px solid var(--plum);
  border-radius: 14px;
  background: var(--button);
  text-decoration: none;
}
.side-trays a:hover { transform: translateY(-1px); }
.side-trays svg { width: 56px; height: 56px; border-radius: 8px; background: var(--table); }
.side-trays .tray-rim { fill: var(--tray); }
.side-trays .tray-floor { fill: var(--tray-floor); }
.side-trays .island { fill: #1f1830; }
.side-trays .island-shadow { fill: #120c1c; }
.side-trays strong { display: block; font: 600 16px/1.2 var(--serif); }
.side-trays small { color: var(--plum-soft); font-weight: 700; }
.side-empty { padding: 14px; border: 2px dashed rgba(46, 36, 64, 0.3); border-radius: 14px; color: var(--plum-soft); font-weight: 700; font-size: 14px; }

.desk { flex: 1; }

@media (min-width: 1200px) {
  /* Three bands: the deeper dotted mauve either side, the game on a lighter
     band in the middle. (Game page only: the community page has no sides.) */
  body:has(> .desk) {
    background-color: var(--page);
    background-image:
      linear-gradient(90deg, transparent calc(50% - 320px), var(--middle) calc(50% - 320px), var(--middle) calc(50% + 320px), transparent calc(50% + 320px)),
      radial-gradient(rgba(46, 36, 64, 0.13) 1.5px, transparent 1.5px);
    background-size: auto, 22px 22px;
  }
  body:has(> .desk) > .topbar { max-width: none; padding: 20px 32px 8px; }
  .desk {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 640px minmax(0, 1fr);
  }
  .desk > .stage { max-width: none; padding: 0 40px 40px; }
  .side {
    display: block;
    align-self: start;
    position: sticky;
    top: 24px;
    padding: 24px 32px;
  }
  .side-inner { max-width: 320px; }
  .side-left .side-inner { margin-left: auto; }
  /* The right column already links to the community */
  .stage > .community-link { display: none; }
}
