/* =========================================================
   每日拼图 — Daily Calendar Puzzle
   ========================================================= */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --bg: #ebe3d5;
  --bg-deep: #ddd1bf;
  --ink: #302218;
  --ink-soft: #5e4936;
  --muted: #8b7863;
  --line: rgba(80, 54, 32, .15);
  --cream: #fbf5ea;
  --gold: #bd812c;
  --gold-deep: #8f5c15;
  --gold-soft: #efd49b;
  --green: #55705a;
  --wood-dark: #94633e;
  --wood: #ba8759;
  --wood-light: #d9b486;
  --cell-bg: #e2c597;
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --radius-xl: 32px;
  --radius-lg: 22px;
  --shadow-card: 0 30px 70px -46px rgba(55, 34, 17, .65), 0 2px 0 rgba(255, 255, 255, .35) inset;
}

html { min-height: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 650px at 12% -10%, rgba(255, 252, 244, .95), transparent 65%),
    radial-gradient(900px 700px at 100% 5%, rgba(250, 238, 218, .6), transparent 60%),
    radial-gradient(900px 700px at 50% 110%, rgba(203, 184, 159, .55), transparent 65%),
    linear-gradient(145deg, #f0e8da 0%, #e9dfd0 48%, #e4d8c7 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .18;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

button,
input { font: inherit; }
button { color: inherit; }
button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(163, 104, 24, .85);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; }

.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------------------------------------------------------
   Header
--------------------------------------------------------- */

.topbar {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 3.2vw, 34px) clamp(18px, 4vw, 42px) 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  justify-self: start;
}

.brand-mark {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  filter: drop-shadow(0 5px 8px rgba(91, 60, 30, .2));
}
.brand-mark svg { display: block; width: 100%; height: 100%; }

.brand-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-title {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .17em;
  color: #3f2b1a;
  white-space: nowrap;
}
.brand-sub {
  font-family: var(--sans);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .255em;
  color: #8a7762;
  white-space: nowrap;
}

.date-nav {
  position: relative;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 7px;
}

.date-card {
  appearance: none;
  border: 1px solid rgba(91, 61, 34, .16);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, .92), rgba(250, 243, 231, .76));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .95) inset,
    0 10px 24px -18px rgba(70, 44, 22, .5);
  border-radius: 16px;
  padding: 8px 20px 8px;
  min-width: 158px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}
.date-card:hover {
  background: linear-gradient(180deg, #fffdf8, #fcf4e7);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 #fff inset, 0 16px 26px -20px rgba(70, 44, 22, .6);
}
.date-main {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: .06em;
  color: #3b2817;
  white-space: nowrap;
}
.date-sub {
  font-size: 10.5px;
  letter-spacing: .045em;
  color: #816d57;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.date-sep { opacity: .55; }
.today-badge,
.done-badge {
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
}
.today-badge { color: #815119; background: #f2dfb5; }
.done-badge { color: #3f5a45; background: #dce9dc; }
.today-badge[hidden], .done-badge[hidden] { display: none; }

.nav-arrow {
  width: 34px !important;
  height: 34px !important;
  color: #6e563e !important;
}
.nav-arrow svg { width: 16px; height: 16px; }

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(91, 61, 34, .12);
  background: rgba(255, 252, 246, .5);
  color: #6b5540;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  white-space: nowrap;
}
.timer-pill.is-running { color: #533b26; background: rgba(255, 250, 239, .72); }
.timer-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; opacity: .72; }

/* Buttons */
.icon-btn {
  appearance: none;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #6d5842;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease, border-color .18s ease;
}
.icon-btn:hover { background: rgba(255, 252, 246, .7); color: #3c2919; border-color: rgba(91, 61, 34, .1); }
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  appearance: none;
  height: 38px;
  padding: 0 15px;
  border-radius: 12px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .16s ease, box-shadow .18s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.hint-btn {
  background: rgba(255, 253, 247, .8);
  border-color: rgba(92, 61, 33, .14);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
  color: #5f452d;
}
.hint-btn:hover { background: #fffdf7; border-color: rgba(147, 97, 37, .3); color: #3f2b18; }
.btn-primary {
  color: #fffaf0;
  background: linear-gradient(180deg, #5a4935, #3e2f22);
  border-color: rgba(38, 26, 16, .2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .16) inset, 0 10px 22px -16px rgba(44, 29, 16, .8);
}
.btn-primary:hover { background: linear-gradient(180deg, #66523b, #473528); }
.btn-quiet {
  color: #5b4733;
  background: rgba(255, 252, 245, .55);
  border-color: rgba(92, 61, 33, .13);
}
.btn-quiet:hover { background: rgba(255, 253, 248, .9); }
.text-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px;
  color: #725b43;
  font-size: 11.5px;
  text-decoration: underline;
  text-decoration-color: rgba(114, 91, 67, .35);
  text-underline-offset: 4px;
  cursor: pointer;
}
.text-btn:hover { color: #3e2b1a; }

/* Date popover */
.date-popover {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: 252px;
  padding: 15px;
  border-radius: 18px;
  background: rgba(255, 252, 245, .98);
  border: 1px solid rgba(95, 63, 34, .16);
  box-shadow: 0 24px 50px -24px rgba(49, 31, 17, .55), 0 1px 0 #fff inset;
  animation: popoverIn .18s ease-out both;
}
.date-popover[hidden] { display: none; }
.popover-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  color: #91775d;
  margin-bottom: 8px;
}
.date-input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid rgba(94, 62, 33, .2);
  background: #fdf8ee;
  color: #46311e;
  font-size: 13px;
}
.popover-actions { display: flex; gap: 7px; margin-top: 10px; }
.popover-actions .btn { flex: 1; height: 36px; font-size: 12px; }

@keyframes popoverIn {
  from { opacity: 0; transform: translate(-50%, -5px) scale(.98); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ---------------------------------------------------------
   Layout
--------------------------------------------------------- */

.stage {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 3.8vw, 46px) clamp(16px, 4vw, 42px) 0;
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(300px, .92fr);
  gap: clamp(22px, 3.2vw, 42px);
  align-items: start;
  flex: 1;
}

/* ---------------------------------------------------------
   Board
--------------------------------------------------------- */

.board-card {
  position: relative;
  isolation: isolate;
  border-radius: var(--radius-xl);
  padding: clamp(14px, 1.9vw, 22px);
  color: #4d2f18;
  background:
    radial-gradient(120% 75% at 22% -5%, rgba(255, 241, 216, .3), transparent 58%),
    repeating-linear-gradient(93deg, rgba(74, 42, 18, .035) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(3deg, rgba(255, 242, 218, .035) 0 1px, transparent 1px 13px),
    linear-gradient(148deg, #bd875a 0%, #9d6a43 47%, #ad7950 74%, #c08a5c 100%);
  border: 1px solid rgba(86, 51, 24, .4);
  box-shadow:
    0 1px 0 rgba(255, 242, 218, .36) inset,
    0 -1px 0 rgba(56, 33, 15, .3) inset,
    0 36px 80px -50px rgba(56, 34, 16, .9),
    0 5px 16px -10px rgba(58, 36, 17, .4);
  transition: box-shadow .35s ease;
}
.board-card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: calc(var(--radius-xl) - 5px);
  border: 1px solid rgba(255, 233, 199, .13);
  pointer-events: none;
  z-index: 0;
}
.board-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: .35;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.12 .7' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)' opacity='.28'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  z-index: 0;
}
.board-heading { position: relative; z-index: 1; text-align: center; padding: 2px 6px 13px; }
.board-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  letter-spacing: .34em;
  text-indent: .34em;
  color: #432714;
  text-shadow: 0 1px 0 rgba(255, 238, 207, .28);
}
.board-sub {
  margin: 6px 0 0;
  font-size: 9px;
  letter-spacing: .22em;
  color: rgba(63, 38, 19, .6);
  font-weight: 600;
}

.board-frame {
  position: relative;
  z-index: 1;
  padding: clamp(8px, 1.1vw, 12px);
  border-radius: 20px;
  background:
    linear-gradient(155deg, rgba(255, 240, 213, .44), rgba(255, 238, 209, .1) 45%, rgba(98, 61, 30, .08)),
    linear-gradient(160deg, #e2c397 0%, #d6b07e 48%, #cfaa77 100%);
  box-shadow:
    0 1px 0 rgba(255, 247, 229, .65) inset,
    0 -2px 3px rgba(91, 55, 25, .2) inset,
    0 4px 12px -5px rgba(55, 32, 14, .45);
  border: 1px solid rgba(100, 63, 30, .28);
  transition: box-shadow .2s ease;
}
.board-frame.can-drop {
  box-shadow:
    0 1px 0 rgba(255, 247, 229, .65) inset,
    0 -2px 3px rgba(91, 55, 25, .2) inset,
    0 0 0 2px rgba(197, 140, 53, .35),
    0 4px 18px -4px rgba(55, 32, 14, .35);
}
.board-frame.drop-bad {
  box-shadow:
    0 1px 0 rgba(255, 247, 229, .65) inset,
    0 -2px 3px rgba(91, 55, 25, .2) inset,
    0 0 0 2px rgba(157, 72, 48, .32),
    0 4px 18px -4px rgba(55, 32, 14, .35);
}

.board-grid {
  --cell: 64px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 7 / 8;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(91, 57, 28, .035), rgba(91, 57, 28, .075)),
    #d8b586;
  box-shadow: inset 0 0 0 1px rgba(92, 58, 29, .16);
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .045em;
  padding: .1em .05em .06em;
  border: 1px solid rgba(103, 67, 35, .185);
  background:
    linear-gradient(180deg, rgba(255, 246, 227, .28), rgba(117, 77, 39, .035)),
    linear-gradient(155deg, #e5c9a0 0%, #ddbd90 56%, #d9b98b 100%);
  color: #5b3a20;
  font-family: var(--serif);
  font-weight: 700;
  font-size: calc(var(--cell) * .275);
  line-height: 1;
  letter-spacing: -.045em;
  user-select: none;
  text-shadow: 0 1px 0 rgba(255, 244, 222, .5);
  transition: background .25s ease, color .25s ease, box-shadow .25s ease;
}
.cell .unit { font-size: .72em; font-weight: 600; letter-spacing: 0; margin-left: .03em; }

.cell--weekday {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .02em;
  letter-spacing: 0;
  line-height: 1;
}
.wd-top { font-size: .52em; font-weight: 600; letter-spacing: .02em; opacity: .9; }
.wd-char { font-size: 1em; font-weight: 700; letter-spacing: 0; }

.cell.is-target {
  z-index: 2;
  color: #74410d;
  background:
    radial-gradient(85% 75% at 50% 42%, rgba(255, 241, 193, .95), rgba(244, 211, 144, .58) 65%, rgba(225, 188, 117, .38)),
    #e8c88f;
  box-shadow:
    inset 0 0 0 1.5px rgba(170, 108, 29, .62),
    inset 0 0 16px rgba(255, 207, 106, .4),
    0 0 0 1px rgba(255, 233, 174, .22);
  animation: targetBreathe 3.4s ease-in-out infinite;
}
.cell.is-target::after {
  content: "";
  position: absolute;
  top: 16%;
  right: 14%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #b67a24;
  opacity: .55;
  box-shadow: 0 0 0 2px rgba(255, 232, 168, .35);
}
.board-card.is-complete .cell.is-target {
  animation: none;
  color: #4c5f45;
  background:
    radial-gradient(80% 70% at 50% 45%, #f8efce, #e8d9a9 70%, #decf9f);
  box-shadow: inset 0 0 0 1.5px rgba(105, 130, 91, .55), inset 0 0 15px rgba(255, 245, 195, .65);
}
.board-card.is-complete .cell.is-target::after { background: #657d5d; }

@keyframes targetBreathe {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1.5px rgba(170, 108, 29, .58),
      inset 0 0 13px rgba(255, 207, 106, .32),
      0 0 0 1px rgba(255, 233, 174, .15);
  }
  50% {
    box-shadow:
      inset 0 0 0 2px rgba(184, 119, 31, .8),
      inset 0 0 22px rgba(255, 211, 116, .52),
      0 0 0 1px rgba(255, 239, 190, .35);
  }
}

.motto {
  grid-column: 1 / 5;
  grid-row: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 .2em;
  font-family: var(--serif);
  font-weight: 600;
  font-size: calc(var(--cell) * .205);
  letter-spacing: .28em;
  text-indent: .28em;
  color: rgba(75, 45, 22, .72);
  text-shadow: 0 1px 0 rgba(255, 243, 217, .36);
  white-space: nowrap;
  user-select: none;
}

.corner-mark {
  grid-column: 7;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: rgba(76, 46, 21, .52);
  user-select: none;
}
.corner-mark svg { width: calc(var(--cell) * .5); height: auto; }
.corner-mark span { font-family: var(--serif); font-size: calc(var(--cell) * .18); letter-spacing: .24em; text-indent: .24em; }
.corner-mark .complete-check { display: none; }
.board-card.is-complete .corner-mark .daily-sun { display: none; }
.board-card.is-complete .corner-mark .complete-check { display: block; color: #5d775b; }

.board-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 4px 1px;
  font-size: 10px;
  letter-spacing: .06em;
  color: rgba(63, 38, 19, .62);
}
.meta-dot { width: 3px; height: 3px; border-radius: 50%; background: rgba(63, 38, 19, .3); }
.meta-hint { opacity: .86; }

/* Layers */
.preview-layer,
.piece-layer {
  position: absolute;
  inset: clamp(8px, 1.1vw, 12px);
  pointer-events: none;
  z-index: 4;
}
.piece-layer { z-index: 5; }

.preview-cell {
  position: absolute;
  border-radius: 7%;
  background: rgba(249, 202, 111, .42);
  border: 1.5px solid rgba(159, 100, 24, .7);
  box-shadow: inset 0 0 12px rgba(255, 220, 143, .4);
  animation: previewIn .11s ease-out both;
}
.preview-cell.is-bad {
  background: rgba(178, 79, 55, .2);
  border-color: rgba(153, 60, 38, .65);
  box-shadow: inset 0 0 12px rgba(192, 94, 65, .2);
}
@keyframes previewIn { from { opacity: 0; } to { opacity: 1; } }

.board-piece {
  position: absolute;
  pointer-events: none;
  cursor: grab;
  touch-action: none;
  transform-origin: center;
  transition: filter .15s ease, opacity .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.board-piece:active { cursor: grabbing; }
.board-piece:hover .piece-svg { filter: brightness(1.035) drop-shadow(0 5px 4px rgba(49, 29, 13, .32)); }
.board-piece.is-dragging-source { opacity: 0; pointer-events: none; }
.board-piece.is-selected .piece-svg {
  filter: drop-shadow(0 0 6px rgba(209, 156, 67, .6)) drop-shadow(0 3px 2px rgba(46, 27, 12, .28));
}
.board-piece:focus-visible { outline: none; }
.board-piece:focus-visible .piece-svg {
  filter: drop-shadow(0 0 0.09em rgba(255, 245, 219, .9)) drop-shadow(0 0 0.16em rgba(173, 112, 28, .85)) drop-shadow(0 3px 2px rgba(46, 27, 12, .28));
}
.board-piece.just-placed .piece-svg { animation: pieceDrop .26s cubic-bezier(.22, .9, .3, 1.18) both; }
.board-piece.hint-placed .piece-svg { animation: hintPlaced 1.2s ease-out both; }
@keyframes pieceDrop {
  0% { transform: scale(1.035); opacity: .55; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes hintPlaced {
  0%, 100% { filter: drop-shadow(0 3px 2px rgba(46, 27, 12, .28)); }
  30% { filter: drop-shadow(0 0 8px rgba(255, 211, 116, .95)) drop-shadow(0 3px 2px rgba(46, 27, 12, .28)); }
}

.piece-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 3px 2px rgba(46, 27, 12, .26));
  transition: filter .15s ease;
}
.piece-face {
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  stroke: rgba(82, 50, 24, .46);
  stroke-width: .045;
  stroke-linejoin: round;
  paint-order: stroke fill;
}
.piece-bevel {
  fill: none;
  stroke: rgba(255, 249, 232, .5);
  stroke-width: .028;
  stroke-linejoin: round;
}
.piece-grain { pointer-events: none; }
.piece-grain path {
  fill: none;
  stroke: rgba(82, 51, 24, .2);
  stroke-width: .016;
  stroke-linecap: round;
}
.piece-shade {
  fill: none;
  stroke: rgba(78, 46, 20, .1);
  stroke-width: .1;
  stroke-linejoin: round;
  transform: translateY(.035px);
}

/* Drag ghost */
.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  will-change: left, top;
  filter: drop-shadow(0 16px 15px rgba(47, 28, 12, .28));
}
.drag-ghost .piece-svg { filter: none; }
body.is-dragging { user-select: none; cursor: grabbing; }
body.is-dragging * { cursor: grabbing !important; }

/* ---------------------------------------------------------
   Tray
--------------------------------------------------------- */

.tray-card {
  position: sticky;
  top: 22px;
  border-radius: 26px;
  padding: clamp(17px, 2vw, 22px);
  background:
    radial-gradient(130% 100% at 10% 0%, rgba(255, 255, 252, .9), transparent 55%),
    linear-gradient(165deg, rgba(255, 252, 246, .8), rgba(245, 235, 220, .72));
  border: 1px solid rgba(91, 62, 35, .14);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .92) inset,
    0 30px 65px -46px rgba(65, 42, 22, .55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.tray-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tray-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: .12em;
  color: #3e2a18;
}
.tray-sub {
  margin: 5px 0 0;
  font-size: 10.5px;
  line-height: 1.4;
  letter-spacing: .025em;
  color: #8a745c;
}
.tray-count {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: #8b745b;
  font-family: var(--mono);
  font-size: 10px;
  padding-top: 2px;
  white-space: nowrap;
}
.tray-count strong { font-size: 18px; font-weight: 500; color: #4c3622; letter-spacing: -.04em; }

.goal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 15px 0 14px;
  padding: 10px 12px;
  border-radius: 13px;
  background: rgba(113, 77, 43, .055);
  border: 1px solid rgba(103, 69, 38, .08);
}
.goal-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #947b61;
  margin-right: 2px;
}
.goal-chip {
  display: inline-flex;
  align-items: center;
  height: 23px;
  padding: 0 8px;
  border-radius: 7px;
  color: #75480f;
  background: linear-gradient(180deg, rgba(255, 246, 219, .95), rgba(241, 218, 171, .85));
  border: 1px solid rgba(174, 117, 35, .2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
  font-family: var(--serif);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  transition: color .25s ease, background .25s ease, border-color .25s ease;
}
.goal-chip.is-done {
  color: #526a4e;
  background: #e5eee1;
  border-color: rgba(91, 119, 83, .22);
}

.tray {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.piece-slot {
  appearance: none;
  position: relative;
  height: 82px;
  min-width: 0;
  padding: 9px 9px 7px;
  border-radius: 15px;
  border: 1px solid rgba(94, 63, 34, .13);
  background:
    radial-gradient(120% 100% at 25% 0%, rgba(255, 255, 255, .65), transparent 60%),
    linear-gradient(150deg, rgba(159, 117, 72, .075), rgba(112, 78, 43, .035));
  box-shadow: inset 0 1px 2px rgba(93, 61, 31, .04);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease, opacity .25s ease;
  -webkit-tap-highlight-color: transparent;
}
.piece-slot:hover {
  border-color: rgba(145, 94, 38, .28);
  background:
    radial-gradient(120% 100% at 25% 0%, rgba(255, 255, 255, .8), transparent 60%),
    linear-gradient(150deg, rgba(173, 124, 70, .1), rgba(112, 78, 43, .04));
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -14px rgba(66, 42, 21, .45);
}
.piece-slot:active { cursor: grabbing; }
.piece-slot.is-selected {
  border-color: rgba(170, 107, 25, .65);
  box-shadow: 0 0 0 2px rgba(208, 154, 62, .2), 0 8px 18px -14px rgba(66, 42, 21, .45);
  background:
    radial-gradient(120% 100% at 25% 0%, rgba(255, 252, 242, .9), transparent 60%),
    linear-gradient(150deg, rgba(230, 187, 104, .2), rgba(112, 78, 43, .04));
}
.piece-slot.is-dragging-source { opacity: .22; filter: saturate(.65); }
.piece-slot.is-placed { opacity: .38; cursor: default; filter: saturate(.6); }
.piece-slot.is-placed:hover { transform: none; box-shadow: none; border-color: rgba(94, 63, 34, .13); }
.piece-slot.is-placed .slot-piece { opacity: 0; }
.slot-piece { display: flex; align-items: center; justify-content: center; max-width: 100%; pointer-events: none; }
.slot-piece svg { display: block; overflow: visible; filter: drop-shadow(0 3px 2px rgba(66, 42, 22, .2)); }
.slot-num {
  position: absolute;
  top: 7px;
  left: 9px;
  font-family: var(--mono);
  font-size: 8px;
  color: rgba(97, 67, 40, .4);
  letter-spacing: .05em;
  pointer-events: none;
}
.slot-check {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #6e8065;
  font-size: 9px;
  letter-spacing: .1em;
}
.slot-check svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.piece-slot.is-placed .slot-check { display: flex; }

.piece-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid rgba(91, 62, 35, .1);
}
.selection-label {
  min-width: 0;
  font-size: 10.5px;
  letter-spacing: .03em;
  color: #8c735b;
  line-height: 1.35;
}
.selection-label strong { color: #59422c; font-weight: 600; }
.piece-tool-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.tool-btn {
  appearance: none;
  height: 33px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid rgba(93, 61, 33, .14);
  background: rgba(255, 252, 245, .57);
  color: #5b4530;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, opacity .16s ease, transform .16s ease;
}
.tool-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn:hover:not(:disabled) { background: #fffdf7; border-color: rgba(147, 95, 35, .28); }
.tool-btn:active:not(:disabled) { transform: translateY(1px); }
.tool-btn:disabled { opacity: .4; }

.tray-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin: 13px 0 0;
  font-size: 9.5px;
  letter-spacing: .03em;
  color: #9a846c;
}
.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 5px;
  background: rgba(255, 253, 247, .7);
  border: 1px solid rgba(96, 64, 35, .16);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset;
  color: #7c644c;
  font-family: var(--mono);
  font-size: 8.5px;
}
.foot-divider { opacity: .45; margin: 0 1px; }

/* ---------------------------------------------------------
   Footer
--------------------------------------------------------- */

.footer {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 42px) 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 10px;
  letter-spacing: .08em;
  color: rgba(104, 82, 59, .65);
}

/* ---------------------------------------------------------
   Modals
--------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(37, 24, 13, .5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .22s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal-backdrop.is-open { opacity: 1; }

.modal {
  position: relative;
  width: min(464px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: clamp(24px, 4vw, 34px);
  border-radius: 28px;
  background:
    radial-gradient(120% 80% at 15% 0%, #fffcf6, transparent 58%),
    linear-gradient(155deg, #fbf4e8, #f3e8d6);
  border: 1px solid rgba(92, 60, 31, .18);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .95) inset,
    0 40px 90px -30px rgba(38, 23, 11, .7);
  transform: translateY(12px) scale(.97);
  transition: transform .26s cubic-bezier(.2, .8, .25, 1);
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(92, 60, 31, .1);
  background: rgba(255, 252, 245, .55);
  color: #806a53;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: #fffdf8; color: #4a3420; }
.modal-eyebrow {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .24em;
  color: #9b7f60;
  margin-bottom: 9px;
}
.modal-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 35px);
  font-weight: 700;
  letter-spacing: .06em;
  color: #382515;
}
.modal-lede {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: #6d5741;
}
.modal-lede strong { color: #4a3320; }

.help-list {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.help-list li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: 12px;
  line-height: 1.65;
  color: #6b5540;
}
.help-num {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #eee0c9;
  color: #765326;
  font-family: var(--mono);
  font-size: 9px;
}
.help-list kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 252, 245, .8);
  border: 1px solid rgba(96, 64, 35, .15);
  font-family: var(--mono);
  font-size: 9px;
  text-align: center;
  color: #70583f;
}
.help-targets {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(129, 91, 49, .06);
  border: 1px solid rgba(112, 76, 40, .08);
  font-size: 10.5px;
  letter-spacing: .07em;
  color: #8a7056;
}
.help-targets strong { color: #65471f; font-family: var(--serif); font-size: 12px; letter-spacing: .03em; }
.modal-primary { width: 100%; margin-top: 22px; height: 43px; }

/* Win modal */
.win-modal { text-align: center; width: min(492px, 100%); }
.win-seal { width: 66px; height: 66px; margin: 0 auto 15px; color: #a97727; }
.win-seal svg { width: 100%; height: 100%; }
.win-date {
  margin: 9px 0 0;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: .04em;
  color: #6a4c2b;
}
.win-target {
  margin: 5px 0 0;
  font-size: 11px;
  letter-spacing: .03em;
  color: #94795e;
}
.win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 22px;
  padding: 15px 6px;
  border-radius: 15px;
  background: rgba(127, 91, 49, .055);
  border: 1px solid rgba(105, 71, 36, .08);
}
.win-stats div + div { border-left: 1px solid rgba(95, 63, 33, .1); }
.win-stats span { display: block; font-size: 9px; letter-spacing: .1em; color: #947b61; margin-bottom: 5px; }
.win-stats strong { display: block; font-family: var(--mono); font-size: 15px; font-weight: 500; color: #4b3520; letter-spacing: -.02em; }
.win-streak {
  margin: 13px 0 0;
  font-size: 10.5px;
  letter-spacing: .04em;
  color: #7e674b;
}
.win-actions { display: flex; gap: 8px; margin-top: 23px; }
.win-actions .btn { flex: 1; height: 42px; }

/* ---------------------------------------------------------
   Toast + confetti
--------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  transform: translate(-50%, 12px);
  max-width: min(90vw, 430px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(46, 32, 20, .93);
  color: #fbf2e2;
  font-size: 11.5px;
  letter-spacing: .03em;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 16px 36px -16px rgba(26, 17, 10, .65);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .24s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: rgba(101, 49, 32, .94); }

#confetti {
  position: fixed;
  inset: 0;
  z-index: 110;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.noscript {
  position: fixed;
  inset: auto 20px 20px;
  padding: 14px;
  border-radius: 12px;
  background: #3c2b1b;
  color: #fff;
  text-align: center;
  z-index: 999;
}

/* ---------------------------------------------------------
   Responsive
--------------------------------------------------------- */

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr auto;
    row-gap: 16px;
  }
  .date-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .top-actions { grid-column: 2; grid-row: 1; }
  .stage { grid-template-columns: minmax(0, 1.55fr) minmax(280px, .9fr); gap: 24px; }
  .brand-title { font-size: 22px; }
}

@media (max-width: 840px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    max-width: 640px;
    gap: 22px;
    padding-top: 26px;
  }
  .board-card { width: 100%; }
  .tray-card { position: static; }
  .tray { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
  .piece-slot { height: 67px; padding: 5px; }
  .slot-num { top: 5px; left: 6px; }
  .tray-foot { justify-content: center; }
  .piece-tools { justify-content: center; flex-wrap: wrap; }
  .selection-label { text-align: center; }
}

@media (max-width: 620px) {
  .topbar { padding-top: 16px; gap: 12px; }
  .brand { gap: 9px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-title { font-size: 19px; letter-spacing: .12em; }
  .brand-sub { font-size: 7px; letter-spacing: .18em; }
  .top-actions { gap: 2px; }
  .top-actions .icon-btn { width: 34px; height: 34px; }
  .timer-pill { height: 32px; padding: 0 9px; font-size: 11px; }
  .timer-pill .timer-icon { display: none; }
  .hint-btn { height: 34px; padding: 0 10px; font-size: 11px; }
  .hint-btn svg { width: 15px; height: 15px; }
  .date-card { min-width: 146px; padding: 7px 16px; }
  .date-main { font-size: 19px; }
  .date-sub { font-size: 9.5px; }
  .nav-arrow { width: 30px !important; height: 30px !important; }
  .stage { padding: 20px 12px 0; gap: 16px; }
  .board-card { border-radius: 25px; padding: 10px; }
  .board-heading { padding-bottom: 9px; }
  .board-title { font-size: 18px; letter-spacing: .24em; text-indent: .24em; }
  .board-sub { font-size: 8px; letter-spacing: .16em; margin-top: 4px; }
  .board-frame { border-radius: 16px; }
  .board-grid { border-radius: 9px; }
  .board-meta { padding-top: 10px; font-size: 9px; gap: 7px; }
  .meta-hint, .meta-dot { display: none; }
  .corner-mark span { display: none; }
  .tray-card { border-radius: 22px; padding: 15px; }
  .tray-title { font-size: 17px; }
  .tray-sub { font-size: 9.5px; }
  .goal-row { margin: 12px 0; padding: 8px 10px; gap: 5px; }
  .goal-label { font-size: 8.5px; }
  .goal-chip { height: 21px; font-size: 10.5px; padding: 0 6px; }
  .tray { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .piece-slot { height: 72px; border-radius: 12px; }
  .slot-piece svg { transform: scale(.86); }
  .top-actions { gap: 0; }
  .slot-num { font-size: 7px; }
  .tray-foot { margin-top: 11px; font-size: 9px; }
  .piece-tools { margin-top: 12px; padding-top: 11px; }
  .selection-label { font-size: 9.5px; }
  .tool-btn { height: 30px; padding: 0 8px; font-size: 9.5px; }
  .footer { padding: 20px 16px 22px; gap: 10px; }
  .modal { border-radius: 24px; padding: 24px 20px; }
  .win-stats strong { font-size: 13px; }
  .win-actions .btn { font-size: 11.5px; }
}

@media (max-width: 390px) {
  .brand-sub { display: none; }
  .top-actions .icon-btn { width: 32px; height: 32px; }
  .timer-pill { padding: 0 7px; }
  .date-card { min-width: 132px; }
  .goal-label { display: none; }
}

@media (max-width: 360px) {
  .timer-pill { display: none; }
  .topbar { gap: 8px; }
  .top-actions { gap: 0; }
  .hint-btn { padding: 0 8px; }
  .brand-title { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
