@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap");

:root {
  color-scheme: light;
  --canvas: #daceb3;
  --canvas-deep: #cdbd9a;
  --paper: #fffaf0;
  --paper-warm: #f5ead3;
  --ink: #2d3026;
  --muted: #797667;
  --moss: #455f45;
  --moss-deep: #304832;
  --leaf: #73895f;
  --clay: #c76543;
  --clay-deep: #99472f;
  --mustard: #d7a744;
  --line: rgba(62, 60, 45, 0.16);
  --serif: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  font-family: var(--sans);
  background: var(--canvas);
}

button,
input { font: inherit; }

button { color: inherit; }

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(199, 101, 67, 0.38);
  outline-offset: 3px;
}

.game-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
}

.craft-canvas {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background:
    linear-gradient(108deg, rgba(255, 255, 255, 0.17), transparent 34%),
    var(--canvas);
}

.craft-canvas.is-panning { cursor: grabbing; }

.canvas-texture {
  position: absolute;
  inset: -50px;
  opacity: 0.68;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 3px 3px, rgba(63, 59, 42, 0.09) 0 0.7px, transparent 0.9px),
    repeating-linear-gradient(7deg, transparent 0 25px, rgba(69, 63, 44, 0.02) 26px 27px);
  background-size: 26px 26px, auto;
}

.canvas-texture::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background:
    radial-gradient(circle at 19% 24%, rgba(255,255,255,.72) 0 2px, transparent 2.5px),
    radial-gradient(circle at 78% 18%, rgba(69,95,69,.23) 0 1.5px, transparent 2px),
    radial-gradient(circle at 62% 78%, rgba(199,101,67,.2) 0 1.5px, transparent 2px);
  background-size: 210px 170px, 270px 220px, 340px 290px;
}

.sun-patch {
  position: absolute;
  top: -12%;
  left: 23%;
  width: 42%;
  height: 80%;
  opacity: 0.28;
  pointer-events: none;
  background: linear-gradient(117deg, rgba(255, 249, 215, 0.8), transparent 65%);
  transform: skewX(-16deg);
}

.desk-sprig {
  position: absolute;
  right: 3%;
  bottom: -110px;
  width: 145px;
  height: 310px;
  border-left: 3px solid rgba(69, 95, 69, 0.14);
  border-radius: 50%;
  pointer-events: none;
  transform: rotate(29deg);
}

.desk-sprig i {
  position: absolute;
  width: 66px;
  height: 27px;
  border: 3px solid rgba(69, 95, 69, 0.12);
  border-radius: 100% 0 100% 0;
}

.desk-sprig i:nth-child(1) { top: 28px; left: -2px; transform: rotate(-22deg); }
.desk-sprig i:nth-child(2) { top: 90px; left: -58px; transform: rotate(158deg); }
.desk-sprig i:nth-child(3) { top: 154px; left: -2px; transform: rotate(-18deg); }
.desk-sprig i:nth-child(4) { top: 214px; left: -55px; transform: rotate(158deg); }

.floating-header {
  position: absolute;
  z-index: 20;
  top: 20px;
  left: 22px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 17px 0 13px;
  border: 1px solid rgba(72, 63, 44, 0.13);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.89);
  box-shadow: 0 10px 30px rgba(75, 61, 37, 0.13);
  backdrop-filter: blur(15px);
  cursor: default;
}

.brand {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -1px;
  text-decoration: none;
}

.brand b {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  background: var(--clay);
  box-shadow: 0 2px 0 rgba(102, 48, 29, 0.19);
  transform: rotate(-5deg);
}

.brand span:last-child { color: var(--moss); }

.header-rule {
  width: 1px;
  height: 27px;
  background: var(--line);
}

.found-count {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
}

.found-count strong {
  color: var(--clay-deep);
  font-family: var(--serif);
  font-size: 20px;
}

.found-count span {
  font-size: 10px;
  font-weight: 700;
}

.quest-ribbon {
  position: absolute;
  z-index: 19;
  top: 23px;
  right: 25px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px 10px 8px 5px;
  background: #f1d899;
  box-shadow: 4px 5px 0 rgba(92, 68, 33, 0.08);
  cursor: default;
  transform: rotate(0.7deg);
}

.quest-mark {
  color: var(--clay-deep);
  font-size: 19px;
}

.quest-ribbon small,
.quest-ribbon b { display: block; }

.quest-ribbon small {
  color: #8b6b34;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.quest-ribbon b { margin-top: 1px; font-size: 10px; }

.quest-dots { display: flex; gap: 3px; margin-left: 3px; }

.quest-dots i {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(69, 95, 69, 0.55);
  border-radius: 50%;
}

.quest-dots i.is-done { background: var(--moss); }

.canvas-world {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  transform-origin: 0 0;
  will-change: transform;
}

.nodes-layer,
.connection-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
}

.connection-layer { pointer-events: none; }

.craft-node {
  --node-accent: #71865f;
  position: absolute;
  z-index: 2;
  min-width: 100px;
  max-width: 190px;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px 6px 6px;
  border: 1px solid rgba(60, 58, 44, 0.17);
  border-radius: 13px 12px 14px 11px;
  color: var(--ink);
  text-align: left;
  background:
    linear-gradient(145deg, rgba(255,255,255,.96), rgba(250,242,224,.96));
  box-shadow:
    0 3px 0 color-mix(in srgb, var(--node-accent) 25%, transparent),
    0 7px 16px rgba(72, 58, 36, 0.13);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transform: translate(var(--x), var(--y)) rotate(var(--tilt, 0deg));
  transition: box-shadow 150ms ease, filter 150ms ease;
}

.craft-node::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  width: 23px;
  height: 7px;
  background: color-mix(in srgb, var(--node-accent) 27%, #f6e8c9);
  transform: translateX(-50%) rotate(-2deg);
}

.craft-node:hover {
  z-index: 9;
  filter: brightness(1.02);
  box-shadow:
    0 5px 0 color-mix(in srgb, var(--node-accent) 35%, transparent),
    0 14px 28px rgba(72, 58, 36, 0.19);
}

.craft-node.is-dragging {
  z-index: 1000;
  cursor: grabbing;
  filter: brightness(1.04);
  box-shadow: 0 18px 35px rgba(62, 50, 31, 0.25);
  transition: none;
}

.craft-node.is-target {
  outline: 3px solid color-mix(in srgb, var(--node-accent) 52%, transparent);
  outline-offset: 3px;
}

.craft-node.is-mixing {
  z-index: 12;
  cursor: wait;
  pointer-events: none;
  animation: mixing-glow 720ms ease-in-out infinite alternate;
}

.craft-node.is-born { animation: node-born 480ms cubic-bezier(.16,1.35,.35,1) both; }

.node-emoji {
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 19px;
  line-height: 1;
  background: color-mix(in srgb, var(--node-accent) 13%, white);
}

.node-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.node-name {
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  white-space: normal;
}

.node-copy small {
  color: var(--muted);
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.node-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 21px;
  height: 21px;
  display: none;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--paper);
  cursor: pointer;
}

.craft-node:hover .node-remove,
.craft-node:focus-within .node-remove { display: grid; }

.category-nature,
.category-life { --node-accent: #70895b; }
.category-weather,
.category-place { --node-accent: #78989a; }
.category-material,
.category-invention { --node-accent: #b17452; }
.category-food { --node-accent: #d39b44; }
.category-character,
.category-feeling { --node-accent: #be705e; }
.category-myth,
.category-space,
.category-wonder,
.category-art { --node-accent: #8f775b; }

.mix-line {
  stroke: rgba(69, 95, 69, 0.45);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 4 7;
  animation: line-fade 1.15s ease both;
}

.spark {
  position: absolute;
  z-index: 1100;
  width: 8px;
  height: 8px;
  border-radius: 50% 0 50% 50%;
  background: var(--mustard);
  pointer-events: none;
  animation: spark-out 650ms ease-out both;
}

.empty-canvas {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 200ms ease;
}

.empty-canvas[hidden] {
  display: grid;
  opacity: 0;
  visibility: hidden;
}

.empty-orbit {
  position: relative;
  width: 112px;
  height: 58px;
  display: block;
  margin-bottom: 18px;
}

.empty-orbit::before {
  content: "";
  position: absolute;
  inset: 4px 9px;
  border: 1px dashed rgba(69, 95, 69, 0.32);
  border-radius: 50%;
  transform: rotate(-7deg);
}

.empty-orbit i {
  position: absolute;
  top: 7px;
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  font-size: 26px;
  font-style: normal;
  background: var(--paper);
  box-shadow: 0 7px 16px rgba(72, 58, 36, 0.13);
}

.empty-orbit i:first-child { left: 4px; transform: rotate(-8deg); }
.empty-orbit i:last-child { right: 4px; transform: rotate(8deg); }

.empty-canvas h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(27px, 3vw, 42px);
  letter-spacing: -1.3px;
}

.empty-canvas p {
  margin: 9px 0 20px;
  color: #716e60;
  font-size: 12px;
  line-height: 1.6;
}

.empty-canvas button {
  height: 42px;
  padding: 0 15px;
  border: 1px solid rgba(69,95,69,.26);
  border-radius: 13px;
  color: var(--moss-deep);
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,250,240,.69);
  box-shadow: 0 4px 0 rgba(69,95,69,.12);
  cursor: pointer;
  pointer-events: auto;
}

.empty-canvas button span { margin-left: 8px; color: var(--clay); }

.canvas-tip {
  position: absolute;
  z-index: 15;
  top: 95px;
  left: 25px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(58, 58, 45, 0.69);
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}

.canvas-tip span { color: var(--clay); }

.canvas-tools {
  position: absolute;
  z-index: 20;
  bottom: 20px;
  left: 20px;
  height: 50px;
  display: flex;
  align-items: stretch;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: 0 10px 30px rgba(75, 61, 37, 0.13);
  backdrop-filter: blur(14px);
}

.canvas-tools button {
  min-width: 56px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  padding: 0 9px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.canvas-tools button:last-child { border-right: 0; }
.canvas-tools button:hover { color: var(--moss); background: rgba(69,95,69,.06); }
.canvas-tools span { font-family: var(--serif); font-size: 15px; }
.canvas-tools b { font-size: 7px; }

.zoom-tools {
  position: absolute;
  z-index: 20;
  right: 20px;
  bottom: 20px;
  height: 37px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 7px 20px rgba(75, 61, 37, 0.1);
}

.zoom-tools button {
  width: 34px;
  height: 100%;
  padding: 0;
  border: 0;
  font-size: 18px;
  background: transparent;
  cursor: pointer;
}

.zoom-tools output {
  width: 45px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  text-align: center;
}

.ai-status {
  position: absolute;
  z-index: 20;
  top: 82px;
  right: 25px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--moss-deep);
  font-size: 8px;
  font-weight: 700;
  background: rgba(255,250,240,.75);
  border: 1px solid var(--line);
  cursor: pointer;
}

.ai-status i { width: 6px; height: 6px; border-radius: 50%; background: #6d985f; box-shadow: 0 0 0 3px rgba(109,152,95,.14); }
.ai-status.is-off i { background: var(--clay); box-shadow: 0 0 0 3px rgba(199,101,67,.14); }
.ai-status.is-loading i { background: var(--mustard); animation: target-pulse 650ms ease-in-out infinite alternate; }

.discovery-shelf {
  position: relative;
  z-index: 30;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 23px 18px 16px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(rgba(255,250,240,.94), rgba(251,244,229,.96)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(76,64,42,.025) 32px);
  box-shadow: -9px 0 30px rgba(68, 54, 33, 0.07);
}

.shelf-grab { display: none; }

.shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shelf-header p {
  margin: 0 0 3px;
  color: var(--clay-deep);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.shelf-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  letter-spacing: -.8px;
}

.shelf-header > button {
  display: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  font-size: 24px;
  background: var(--paper-warm);
}

.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.64);
}

.search-box > span { color: var(--muted); font-size: 20px; transform: rotate(-15deg); }

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-box input::placeholder { color: #9b9788; }

.search-box kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #a09b8b;
  font: 9px var(--sans);
  background: var(--paper-warm);
}

.filter-row {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

.filter-chip,
.sort-button {
  height: 27px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  background: transparent;
  cursor: pointer;
}

.filter-chip.is-active,
.filter-chip:hover {
  border-color: var(--moss);
  color: white;
  background: var(--moss);
}

.sort-button { margin-left: auto; padding: 0 7px; }

.shelf-help {
  display: flex;
  justify-content: space-between;
  margin: 15px 2px 8px;
  color: #969181;
  font-size: 8px;
  font-weight: 600;
}

.item-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  align-content: start;
  flex: 1;
  overflow: auto;
  padding: 2px 2px 16px;
  scrollbar-color: #d8cbb0 transparent;
}

.item-card {
  --item-accent: #70895b;
  position: relative;
  min-width: 0;
  min-height: 49px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  overflow: hidden;
  border: 1px solid rgba(62,60,45,.12);
  border-radius: 10px 11px 9px 11px;
  text-align: left;
  background: rgba(255,255,255,.68);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--item-accent) 18%, transparent);
  cursor: grab;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.item-card:hover {
  z-index: 2;
  border-color: color-mix(in srgb, var(--item-accent) 45%, transparent);
  box-shadow: 0 6px 14px rgba(74,59,35,.12);
  transform: translateY(-2px) rotate(-.4deg);
}

.item-card-emoji {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 17px;
  background: color-mix(in srgb, var(--item-accent) 12%, white);
}

.item-card-name {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.favorite-button {
  position: absolute;
  top: 3px;
  right: 5px;
  border: 0;
  color: #bbb5a5;
  font-size: 10px;
  background: none;
  opacity: 0;
  cursor: pointer;
}

.item-card:hover .favorite-button,
.favorite-button.is-favorite { opacity: 1; }
.favorite-button.is-favorite { color: var(--clay); }

.item-card.category-weather,
.item-card.category-place { --item-accent: #78989a; }
.item-card.category-material,
.item-card.category-invention { --item-accent: #b17452; }
.item-card.category-food { --item-accent: #d39b44; }
.item-card.category-character,
.item-card.category-feeling { --item-accent: #be705e; }
.item-card.category-myth,
.item-card.category-space,
.item-card.category-wonder,
.item-card.category-art { --item-accent: #8f775b; }

.empty-state {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.shelf-footer {
  min-height: 63px;
  display: grid;
  grid-template-columns: 42px 1fr 27px;
  align-items: center;
  gap: 9px;
  padding: 9px 2px 0;
  border-top: 1px solid var(--line);
}

.progress-seal {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--clay);
  border-radius: 50%;
  color: var(--clay-deep);
  font-family: var(--serif);
  font-size: 13px;
  transform: rotate(-7deg);
}

.progress-seal::after {
  content: "FOUND";
  position: absolute;
  margin-top: 18px;
  font: 5px var(--sans);
  letter-spacing: .12em;
}

.shelf-footer p { margin: 0; min-width: 0; }
.shelf-footer b,
.shelf-footer span { display: block; }
.shelf-footer b { font-family: var(--serif); font-size: 11px; }
.shelf-footer span { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.shelf-footer button { width: 27px; height: 27px; border: 1px solid var(--line); border-radius: 50%; color: var(--moss); background: transparent; cursor: pointer; }

.shelf-tab { display: none; }

.craft-flash {
  position: fixed;
  z-index: 100;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 233, 157, 0.8);
  box-shadow: 0 0 0 15px rgba(255, 233, 157, 0.22), 0 0 45px 22px rgba(255, 233, 157, 0.35);
  opacity: 0;
  pointer-events: none;
}

.craft-flash.is-active { animation: flash 520ms ease-out both; }

.toast-stack {
  position: fixed;
  z-index: 200;
  right: 344px;
  bottom: 20px;
  width: min(340px, calc(100vw - 40px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 13px;
  color: white;
  font-size: 11px;
  background: var(--moss-deep);
  box-shadow: 0 13px 32px rgba(45,48,38,.24);
  animation: toast-in 260ms ease both;
}

.toast span { font-size: 19px; }
.toast.is-leaving { animation: toast-out 220ms ease both; }

.modal {
  width: min(92vw, 510px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 28px 90px rgba(45,42,33,.3);
}

.modal::backdrop { background: rgba(45,48,38,.5); backdrop-filter: blur(5px); }
.modal form { position: relative; padding: 30px; }
.modal h2 { margin: 5px 0 10px; font-family: var(--serif); font-size: 29px; letter-spacing: -.7px; }
.modal p { color: var(--muted); font-size: 12px; line-height: 1.65; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 15px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  font-size: 22px;
  background: var(--paper-warm);
  cursor: pointer;
}

.modal-kicker { color: var(--clay-deep); font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button { border: 1px solid var(--moss); color: white; background: var(--moss); }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.danger-button { border: 1px solid rgba(153,71,47,.28); color: var(--clay-deep); background: rgba(199,101,67,.07); }
.full-button { width: 100%; margin-top: 17px; }

.setting-row {
  min-height: 61px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-top: 1px solid var(--line);
}

.setting-row:first-of-type { margin-top: 15px; }
.setting-row b,
.setting-row small { display: block; }
.setting-row b { font-size: 12px; }
.setting-row small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.setting-row input {
  width: 42px;
  height: 23px;
  flex: 0 0 auto;
  appearance: none;
  border-radius: 999px;
  background: #cbc3b0;
  cursor: pointer;
}

.setting-row input::before {
  content: "";
  width: 17px;
  height: 17px;
  display: block;
  margin: 3px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform 160ms ease;
}

.setting-row input:checked { background: var(--moss); }
.setting-row input:checked::before { transform: translateX(19px); }
.setting-status {
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--moss);
  background: rgba(69, 95, 69, 0.09);
}
.settings-modal .danger-button { margin-top: 14px; }

.history-list { max-height: 55vh; display: grid; gap: 6px; margin: 18px 0 0; padding: 0; overflow: auto; list-style: none; }
.history-item { display: grid; grid-template-columns: 37px 1fr; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-warm); }
.history-item > span { font-size: 24px; text-align: center; }
.history-item p { margin: 0; }
.history-item b,
.history-item i { display: block; }
.history-item b { font-family: var(--serif); font-size: 13px; }
.history-item i { margin-top: 2px; color: var(--muted); font-size: 9px; font-style: normal; }
.history-empty { padding: 24px; color: var(--muted); font-size: 11px; text-align: center; }

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}

@keyframes node-born {
  from { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--tilt)) scale(.5); }
  70% { transform: translate(var(--x), var(--y)) rotate(var(--tilt)) scale(1.08); }
}

@keyframes target-pulse { to { outline-color: rgba(199,101,67,.5); } }
@keyframes mixing-glow {
  from {
    filter: brightness(1);
    box-shadow:
      0 3px 0 color-mix(in srgb, var(--node-accent) 25%, transparent),
      0 7px 16px rgba(72,58,36,.13);
  }
  to {
    filter: brightness(1.08);
    box-shadow:
      0 3px 0 color-mix(in srgb, var(--node-accent) 48%, transparent),
      0 0 0 6px color-mix(in srgb, var(--node-accent) 16%, transparent),
      0 10px 24px rgba(72,58,36,.2);
  }
}
@keyframes line-fade { 0% { opacity: 0; stroke-dashoffset: 20; } 30% { opacity: 1; } 100% { opacity: 0; stroke-dashoffset: 0; } }
@keyframes spark-out {
  from { opacity: 1; transform: translate(0,0) rotate(0) scale(1); }
  to { opacity: 0; transform: translate(var(--sx),var(--sy)) rotate(180deg) scale(.2); }
}
@keyframes flash { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.2); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-50%) scale(3.8); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }

@media (max-width: 800px) {
  .game-shell { display: block; }
  .craft-canvas { width: 100%; }
  .floating-header { top: 12px; left: 12px; height: 51px; padding-right: 11px; }
  .brand { font-size: 19px; }
  .brand b { width: 22px; height: 22px; font-size: 15px; }
  .found-count span { display: none; }
  .quest-ribbon { top: 69px; right: 12px; }
  .canvas-tip { top: 73px; left: 16px; }

  .discovery-shelf {
    position: fixed;
    z-index: 80;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    height: min(72vh, 620px);
    padding: 13px 16px 12px;
    border: 1px solid var(--line);
    border-radius: 24px 24px 17px 17px;
    box-shadow: 0 -20px 70px rgba(54,45,30,.24);
    transform: translateY(calc(100% + 18px));
    transition: transform 260ms cubic-bezier(.2,.85,.2,1);
  }

  .discovery-shelf.is-open { transform: none; }
  .shelf-grab { width: 40px; height: 4px; display: block; margin: -3px auto 8px; border-radius: 999px; background: #d1c6ae; }
  .shelf-header > button { display: grid; place-items: center; }
  .item-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .shelf-footer { display: none; }

  .shelf-tab {
    position: fixed;
    z-index: 40;
    right: 14px;
    bottom: 15px;
    min-width: 65px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid rgba(255,255,255,.17);
    border-radius: 17px;
    color: white;
    background: var(--moss);
    box-shadow: 0 8px 0 var(--moss-deep), 0 15px 30px rgba(48,72,50,.22);
  }

  .shelf-tab span { color: #f1d899; }
  .canvas-tools { right: 91px; bottom: 14px; left: 12px; width: auto; height: 52px; }
  .canvas-tools button { min-width: 0; flex: 1; padding: 0 4px; }
  .canvas-tools button:nth-child(4),
  .canvas-tools button:nth-child(5) { display: none; }
  .zoom-tools { right: 14px; bottom: 79px; }
  .toast-stack { right: 14px; bottom: 84px; }
  .ai-status { top: 119px; right: 12px; bottom: auto; }
}

@media (max-width: 480px) {
  .item-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .quest-ribbon { display: none; }
  .ai-status { top: 70px; }
  .canvas-tip { top: 74px; }
  .empty-canvas { width: 88%; }
  .empty-canvas p br { display: none; }
  .craft-node { min-width: 94px; min-height: 44px; padding: 5px 9px 5px 5px; }
  .node-emoji { width: 29px; height: 29px; font-size: 18px; }
  .node-name { font-size: 11px; }
  .modal form { padding: 27px 21px 22px; }
}
