:root {
  --ink: #241f1a;
  --ink-soft: #5c5244;
  --paper: #f7f0df;
  --card: #fbf6e8;
  --rule: rgba(36, 31, 26, 0.22);
  --ground: #f6d55c;
  --ground-2: #eebf3d;
  --display: 'IM Fell English SC', 'IM Fell English', Georgia, serif;
  --body: 'EB Garamond', Georgia, serif;
  color-scheme: light;
}

body[data-season='H'] { --ground: #e3dc72; --ground-2: #c4cd63; }
body[data-season='D'] { --ground: #f6d55c; --ground-2: #eebf3d; }
body[data-season='C'] { --ground: #eaa45a; --ground-2: #d9803f; }
body[data-season='S'] { --ground: #c9d6df; --ground-2: #a9bccb; }
body[data-season='end'] { --ground: #e6edf2; --ground-2: #cfdbe4; }

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; overflow-x: clip; }

body {
  background: radial-gradient(120% 90% at 50% 0%, var(--ground), var(--ground-2));
  background-attachment: fixed;
  color: var(--ink);
  font: 18px/1.4 var(--body);
  transition: background 2s;
}

h1, h3, h4 { font-family: var(--display); font-weight: 400; margin: 0; }
p { margin: 0 0 0.6em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
jelly-button[variant='graphite'] { --jelly-fill: #2b2520; }

.row { display: flex; gap: 10px; align-items: end; }
.row > jelly-input { flex: 1 1 160px; min-width: 0; width: 100%; }
.home .row { flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.hint { color: var(--ink-soft); font-size: 16px; font-style: italic; }

/* Home and lobby */

.home {
  max-width: 460px;
  margin: 0 auto;
  padding: 10vh 16px 40px;
  text-align: center;
}
.home h1 { font-size: clamp(42px, 9vw, 60px); line-height: 1; }
.home .sub { margin: 12px 0 28px; font-style: italic; }
.sheet {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 1px 0 #fff8 inset, 0 12px 30px rgba(70, 50, 10, 0.22);
  text-align: left;
}
.seats-list { display: grid; gap: 4px; font-size: 20px; }
.seats-list li { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.turn-label { flex: none; width: 5.2em; font-style: italic; color: var(--ink-soft); }
.who { flex: 1; min-width: 0; }
.who em { font-size: 15px; color: var(--ink-soft); }
.next-tag { font: italic 15px var(--body); color: var(--ink-soft); border-bottom: 1px solid var(--ink-soft); }
jelly-button[hidden] { display: none; }
.order-body { display: grid; gap: 10px; font-family: var(--body); color: var(--ink); }
.seats-list .empty { color: var(--ink-soft); font-style: italic; }
.seats-list .off { color: var(--ink-soft); font-size: 15px; }
.sheet .row:last-child { justify-content: space-between; }

/* The table */

.table {
  display: grid;
  grid-template: 'bar bar' auto 'board side' 1fr / minmax(0, 1fr) 380px;
  gap: 12px 16px;
  min-height: 100dvh;
  padding: 10px 16px 16px;
}

.bar { grid-area: bar; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.bar h1 { font-size: 24px; }
.when { font-style: italic; }
.bar-tools { display: flex; gap: 6px; margin-inline-start: auto; }

.deck { display: flex; gap: 12px; align-items: flex-end; }
.stack {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 34px;
  background: var(--card);
  border-radius: 3px;
  box-shadow: 0 calc(var(--layers) * 1px) 0 -0.5px #cdbf9f, 0 calc(var(--layers) * 1px + 2px) 3px rgba(40, 25, 0, 0.35);
  transform: translateY(calc(var(--layers) * -1px));
  font-size: 15px;
  transition: box-shadow 0.4s, transform 0.4s;
}
.stack b { font-weight: 400; }
.stack.now { outline: 2px solid var(--ink); outline-offset: 1px; }
.stack.gone { opacity: 0.25; box-shadow: none; }

.board { grid-area: board; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-content: start; min-width: 0; position: relative; }

.paper {
  position: relative;
  aspect-ratio: 2200 / 1700;
  width: min(100%, calc((100dvh - 214px) * 2200 / 1700));
  margin: 0 auto;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .18 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)'/%3E%3C/svg%3E");
  border-radius: 3px;
  box-shadow: 0 18px 40px rgba(60, 40, 5, 0.3), 0 2px 3px rgba(60, 40, 5, 0.3);
  overflow: hidden;
  touch-action: none;
}
.paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.paper .live { touch-action: none; }
.paper[data-mode='draw'] .live { cursor: crosshair; }
.paper[data-mode='draw'][data-tool='text'] .live { cursor: text; }
.paper[data-mode='draw'][data-tool='move'] .live { cursor: default; }
.paper[data-mode='draw'][data-tool='move'][data-hit='1'] .live { cursor: grab; }
.paper[data-mode='draw'][data-tool='erase'] .live,
.paper[data-mode='draw'][data-tool='fill'] .live { cursor: cell; }
.paper[data-mode='pick'] .live { cursor: copy; }
.paper[data-mode='pick'] { box-shadow: 0 0 0 3px var(--ink), 0 18px 40px rgba(60, 40, 5, 0.3); }

.frost {
  --frost: 0;
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--frost);
  transition: opacity 3s;
  background:
    radial-gradient(70% 70% at 50% 50%, transparent 55%, rgba(226, 239, 248, 0.92) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='turbulence' baseFrequency='.018 .03' numOctaves='5' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .9 0 0 0 0 .96 0 0 0 0 1 0 0 0 1.6 -.45'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23f)'/%3E%3C/svg%3E");
  mask-image: radial-gradient(75% 75% at 50% 50%, transparent 30%, #000 92%);
}

.stamp {
  position: absolute;
  z-index: 2;
  outline: 2px dashed var(--ink);
  cursor: move;
  touch-action: none;
}
.stamp img { display: block; width: 100%; height: 100%; pointer-events: none; }
.grip {
  position: absolute;
  right: -11px;
  bottom: -11px;
  width: 22px;
  height: 22px;
  background: var(--ink);
  border: 2px solid var(--paper);
  border-radius: 50%;
  cursor: nwse-resize;
}
.paper.dropping { box-shadow: 0 0 0 3px var(--ink), 0 18px 40px rgba(60, 40, 5, 0.3); }

.pieces, .cursors { position: absolute; inset: 0; pointer-events: none; }

.die {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(26px, 3.2vw, 38px);
  aspect-ratio: 1;
  padding: 0;
  transform: translate(-50%, -50%) rotate(-6deg);
  background: #fffdf6;
  border: 1px solid #6f6250;
  border-radius: 22%;
  box-shadow: 0 2px 0 #b9ab90, 0 4px 6px rgba(30, 20, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
}
.paper[data-mode='pick'] .die { pointer-events: none; }
.die svg { width: 100%; height: 100%; fill: var(--ink); }
.die span { font: 600 18px var(--body); }
.die.wobble { animation: wobble 0.7s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes wobble {
  0% { transform: translate(-50%, -50%) rotate(-6deg) scale(1); }
  30% { transform: translate(-50%, -62%) rotate(14deg) scale(1.16, 0.88); }
  60% { transform: translate(-50%, -48%) rotate(-12deg) scale(0.94, 1.08); }
  100% { transform: translate(-50%, -50%) rotate(-6deg) scale(1); }
}

.dot {
  position: absolute;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -50%);
  background: var(--ink);
  border-radius: 50%;
  opacity: 0.85;
}

.cursor {
  position: absolute;
  padding: 0 6px;
  transform: translate(8px, 8px);
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.4s, left 0.09s linear, top 0.09s linear;
}
.cursor.on { opacity: 0.9; }

.banner {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 99px;
  font-size: 16px;
  white-space: nowrap;
}

.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 36px; }

.tool-scroll { max-width: 100%; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.tool-scroll jelly-segmented { width: max-content; }
.swatches { display: flex; gap: 6px; align-items: center; }
.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  background: var(--c);
  border: 2px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(40, 25, 0, 0.4);
  cursor: pointer;
}
.size {
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  font: italic var(--s) 'IM Fell English', Georgia, serif;
  cursor: pointer;
}
.size.on { background: var(--card); outline: 2px solid var(--ink); }
.text-edit {
  position: absolute;
  z-index: 2;
  max-width: 100%;
  padding: 0;
  transform: translateY(-50%);
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--ink);
  border-radius: 0;
  color: var(--ink);
  outline: none;
}
.swatch.on { outline: 2px solid var(--ink); outline-offset: 1px; }

.seats { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.seat {
  flex: 1 1 200px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 8px;
  padding: 6px 10px;
  background: rgba(255, 252, 240, 0.45);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background 0.4s, border-color 0.4s;
}
.seat.active { background: var(--card); border-color: var(--ink); }
.seat.away { opacity: 0.6; }
.seat-name { font-family: var(--display); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-name em { font: italic 15px var(--body); color: var(--ink-soft); }
.stones { grid-column: 1; display: flex; flex-wrap: wrap; gap: 3px; min-height: 14px; }
.stone {
  width: 15px;
  height: 12px;
  background: radial-gradient(60% 60% at 35% 30%, #8b8b90, #39393f);
  border-radius: 48% 52% 55% 45% / 58% 50% 50% 42%;
  transform: rotate(calc(var(--r) * 9deg));
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
  animation: drop 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes drop { from { transform: translateY(-14px) scale(1.3); opacity: 0; } }
.seat-do { grid-area: 1 / 2 / 3 / 3; display: flex; gap: 6px; }
.discard { display: grid; gap: 6px; }
.pool { align-self: center; padding: 0 6px; font-style: italic; color: var(--ink-soft); white-space: nowrap; }
.pool span { font: 22px var(--display); color: var(--ink); }

/* The side column */

.side { grid-area: side; display: grid; gap: 12px; align-content: start; min-width: 0; }

.turn {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: rgba(255, 252, 240, 0.72);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(70, 50, 10, 0.16);
}
.turn h3 { font-size: 24px; }

.card {
  position: relative;
  padding: 12px 14px 14px;
  background: var(--card);
  border: 1px solid #cbbd9b;
  border-radius: 10px;
  box-shadow: 0 2px 0 #e4d7b8, 0 8px 14px rgba(60, 40, 5, 0.18);
}
.card.flip { animation: flip 0.45s cubic-bezier(0.2, 1.2, 0.4, 1); }
@keyframes flip { from { transform: perspective(700px) rotateY(70deg); opacity: 0; } }
.card h3 { font-size: 21px; padding-left: 58px; }
.pip { position: absolute; top: 13px; left: 14px; display: flex; gap: 3px; align-items: baseline; line-height: 1; font-size: 20px; }
.pip b { font: 22px var(--display); }
.pip i { font-style: normal; }
.card.red .pip { color: #a42e22; }
.lead { margin: 8px 0 0; }
.opts { display: grid; gap: 4px; margin-top: 8px; }
.opt { display: block; padding: 8px 10px; font-size: 18px; line-height: 1.3; }
.opt.only { padding: 0; }
.opt.passed { opacity: 0.42; }
div.opt.chosen { background: rgba(36, 31, 26, 0.07); border-radius: 8px; }
jelly-card.opt { cursor: pointer; }
.opt span { font-family: var(--body); }
.turn jelly-input { display: block; width: 100%; }
.or { text-align: center; font-size: 15px; font-style: italic; color: var(--ink-soft); }

.cardback { cursor: pointer; }
.cardback span {
  display: grid;
  place-items: center;
  min-height: 170px;
  font: 24px var(--display);
  text-align: center;
}

.waiting { padding: 10px 2px; font-style: italic; color: var(--ink-soft); }
.stage { font-style: italic; }
.stage-head { font: 19px var(--display); margin-bottom: 2px; }
.stack-form { display: grid; gap: 10px; margin-top: 8px; }
.tickrow { justify-content: space-between; align-items: center; font-size: 16px; }
.tell { padding: 8px 10px; background: var(--card); border-radius: 8px; }

.discussion blockquote { margin: 4px 0 8px; padding-left: 10px; border-left: 2px solid var(--ink); font-size: 19px; }
.order { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.order li { padding: 0 8px; border: 1px solid var(--rule); border-radius: 99px; font-size: 16px; }
.order li.now { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.order li.said { opacity: 0.45; text-decoration: line-through; }

.crumbs { display: flex; gap: 12px; font-size: 15px; color: var(--ink-soft); }
.crumbs .now { color: var(--ink); font-weight: 600; }
.crumbs .said { opacity: 0.5; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.res { display: grid; gap: 6px; margin: 8px 0; }
.res .by { font-size: 15px; font-style: italic; color: var(--ink-soft); }

.indexcard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 12px;
  background: repeating-linear-gradient(#fdfaf0 0 25px, #bcd2e3 25px 26px);
  border-radius: 3px;
  box-shadow: 0 6px 12px rgba(60, 40, 5, 0.2);
  transform: rotate(-0.4deg);
}
.indexcard h4 { font: 600 15px/26px var(--body); color: #a42e22; }
.indexcard li { display: flex; justify-content: space-between; gap: 4px; font-size: 16px; line-height: 26px; overflow-wrap: anywhere; }
.x { padding: 0 2px; background: none; border: 0; color: var(--ink-soft); cursor: pointer; opacity: 0.5; }
.x:hover, .x:focus-visible { opacity: 1; }
.ruled {
  width: 100%;
  height: 26px;
  padding: 0;
  background: none;
  border: 0;
  font: italic 16px var(--body);
  outline: none;
}

.projects h4 { font-size: 18px; }
.projects li { display: flex; justify-content: space-between; gap: 8px; }
.link { padding: 0; background: none; border: 0; text-align: left; text-decoration: underline; text-decoration-color: var(--rule); cursor: pointer; }
.left { flex: none; font-style: italic; color: var(--ink-soft); }

.chron { display: grid; gap: 14px; font-family: var(--body); color: var(--ink); }
.chron h4 { font-size: 18px; }
.chron p { margin: 2px 0; }
.chron .chose { font-style: italic; }
.chron .small { font-size: 15px; color: var(--ink-soft); }
.ref { font-family: var(--body); }
.ref h3 { font-size: 20px; margin: 12px 0 4px; }
.ref ol { list-style: decimal; padding-left: 20px; }

/* The end */

.after { display: grid; gap: 8px; }
.after h4 { font-size: 19px; margin-top: 6px; }
.lapse { display: flex; gap: 8px; }
.scrub { width: 100%; accent-color: var(--ink); }
.lapse-week { font-style: italic; min-height: 1.4em; }
.talk { display: grid; gap: 4px; }
.talk b { font-weight: 600; }

.ending { display: none; }
body.shepherds .ending {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: #eef5fa;
  animation: whiteout 9s ease forwards;
}
body.shepherds .ending::after {
  content: 'The Frost Shepherds arrive.';
  padding: 0 16px;
  font: clamp(30px, 6vw, 60px) var(--display);
  text-align: center;
}
@keyframes whiteout {
  0% { opacity: 0; }
  12%, 62% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 960px) {
  .table { grid-template: 'bar' auto 'board' auto 'side' auto / minmax(0, 1fr); }
  .paper { width: 100%; }
  .bar-tools { margin-inline-start: 0; }
  .banner { white-space: normal; width: max-content; max-width: 90%; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
