:root {
  --ink: #fbf3e6;
  --muted: #cdb9a0;
  --accent: #ffcf5c;
  --pop: #ff6b6b;
  --wood-1: #3b2417;
  --wood-2: #2c1a10;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  /* walnut desk under a warm lamp */
  background:
    radial-gradient(ellipse 70% 55% at 30% 8%, rgba(255, 210, 140, 0.32), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 120%, rgba(0, 0, 0, 0.55), transparent 60%),
    repeating-linear-gradient(92deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(88deg, rgba(0, 0, 0, 0.06) 0 1px, transparent 1px 23px),
    linear-gradient(180deg, var(--wood-1), var(--wood-2));
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
#app { max-width: 820px; margin: 0 auto; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; min-height: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
.error { color: #ffb4a8; }
.dt-loading { color: var(--muted); text-align: center; padding: 60px 0; font-size: 18px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.dt-head { display: flex; align-items: flex-end; justify-content: space-between; }
.dt-title {
  margin: 0; font-size: 30px; font-weight: 900; letter-spacing: -0.02em; line-height: 1;
  background: linear-gradient(90deg, #ffcf5c, #ff6b6b 45%, #4fd1c5 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}
.dt-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

.dt-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.dt-tab {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 9px 4px 8px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06); font-size: 13px; font-weight: 700;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.dt-tab:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.1); }
.dt-tab.on { background: rgba(255, 207, 92, 0.16); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 207, 92, 0.18), 0 8px 18px rgba(0, 0, 0, 0.35); }
.dt-chip { display: flex; width: 44px; height: 14px; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3); }
.dt-chip i { flex: 1; }
.dt-chip.ant-chip { background: linear-gradient(180deg, #cfe6ee 0 30%, #7b5638 30%); position: relative; }
.dt-chip.ant-chip::after { content: ""; position: absolute; left: 18px; top: 4px; width: 3px; height: 9px; background: #3a271b; border-radius: 2px; box-shadow: 7px 3px 0 -0.5px #3a271b; }

.dt-desk { display: flex; justify-content: center; align-items: flex-start; min-height: 240px; }
.dt-controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }
.dt-btn {
  padding: 8px 16px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08); font-size: 13.5px; font-weight: 700;
  transition: transform .1s, background .15s;
}
.dt-btn:hover { background: rgba(255, 255, 255, 0.16); }
.dt-btn:active { transform: scale(0.94); }
.dt-btn.primary { background: linear-gradient(180deg, #ffd77a, #f6b73c); color: #3a2410; border-color: #f6b73c; box-shadow: 0 4px 0 #b9821f, 0 8px 16px rgba(0, 0, 0, 0.3); }
.dt-btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9821f; }
.dt-btn.speed.on { background: var(--accent); color: #3a2410; border-color: var(--accent); }
.dt-stat { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 6px; }

.dt-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; font-size: 13px; }
.dt-key { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.dt-key i { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.4); }
.dt-key b { color: var(--ink); }
.dt-caption { margin: 0; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------------- sand picture: white lacquer frame on steel arms and a white base */
.sand-stage { position: relative; display: flex; justify-content: center; align-items: flex-start; width: 100%; padding-top: 6px; }
.sand-rig { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; transform-origin: 50% 100%; will-change: transform; }
.sand-holder { position: relative; z-index: 2; transform-style: preserve-3d; will-change: transform; }
.sand-frame {
  position: relative; overflow: hidden; touch-action: none; cursor: grab;
  border: 16px solid #f7f6f3;
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(0, 0, 0, 0.14),
    inset 0 4px 10px rgba(0, 0, 0, 0.16);
  outline: 1px solid rgba(0, 0, 0, 0.18);
  backface-visibility: hidden;
}
.sand-frame::after {
  /* mitered lacquer bevel on the frame face */
  content: ""; position: absolute; inset: -16px; pointer-events: none; z-index: 3;
  border: 16px solid transparent;
  border-image: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.08)) 1;
}
.sand-frame:active { cursor: grabbing; }
.sand-canvas { display: block; width: 100%; height: 100%; }
.sand-glare {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0.06) 22%, transparent 34%),
    linear-gradient(118deg, transparent 60%, rgba(255, 255, 255, 0.14) 64%, transparent 70%);
  box-shadow: inset 0 0 16px rgba(0, 40, 70, 0.18);
}
.sand-base {
  position: relative; z-index: 1; margin-top: 30px; width: 100%; height: 30px; border-radius: 4px;
  background: linear-gradient(180deg, #ffffff, #e9e7e3 70%, #d3d0cb);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 -1px 0 rgba(0, 0, 0, 0.08) inset, 0 12px 22px rgba(0, 0, 0, 0.45);
}
/* brushed-steel arms: up from the base, bending in to a pin at mid-height of the frame */
.sand-arm { position: absolute; z-index: 1; bottom: 26px; top: 46%; width: 40px; }
.sand-arm::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 7px; border-radius: 8px 8px 0 0;
  background: linear-gradient(90deg, #858b93, #eef0f3 45%, #9aa0a8);
}
.sand-arm::after {
  content: ""; position: absolute; top: 0; height: 7px; width: 36px;
  background: linear-gradient(180deg, #eef0f3, #9aa0a8);
}
.sand-arm.left { left: 12px; }
.sand-arm.left::before { left: 0; }
.sand-arm.left::after { left: 3px; border-radius: 6px 0 0 0; }
.sand-arm.right { right: 12px; }
.sand-arm.right::before { right: 0; }
.sand-arm.right::after { right: 3px; border-radius: 0 6px 0 0; }
.sand-arm .pin {
  position: absolute; top: -4px; width: 14px; height: 14px; border-radius: 50%; z-index: 4;
  background: radial-gradient(circle at 35% 35%, #fbfcfd, #8d939b); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.sand-arm.left .pin { right: -10px; }
.sand-arm.right .pin { left: -10px; }
.sand-shadow {
  position: absolute; bottom: -10px; left: 10%; width: 80%; height: 34px; transform-origin: 50% 50%; z-index: 0;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.55), transparent 70%);
}

/* ---------------- ant farm */
.ant-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ant-frame {
  position: relative; box-sizing: content-box; border: 14px solid transparent; border-radius: 8px;
  background:
    linear-gradient(#0000, #0000) padding-box,
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 7px) border-box,
    linear-gradient(180deg, #c48a52, #8e5a2e) border-box;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.ant-soil, .ant-over { position: absolute; left: 0; top: 0; display: block; image-rendering: auto; }
.ant-over { image-rendering: auto; cursor: pointer; touch-action: none; }
.ant-glare {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.04) 22%, transparent 34%, transparent 70%, rgba(255, 255, 255, 0.08) 76%, transparent 82%);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.3);
}
.screw { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f4e2b8, #9b7b3f); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); z-index: 3; }
.screw::after { content: ""; position: absolute; left: 1px; right: 1px; top: 3.5px; height: 1px; background: rgba(0, 0, 0, 0.45); transform: rotate(35deg); }
.screw.tl { left: -11px; top: -11px; } .screw.tr { right: -11px; top: -11px; }
.screw.bl { left: -11px; bottom: -11px; } .screw.br { right: -11px; bottom: -11px; }
.ant-card {
  min-height: 34px; padding: 8px 14px; border-radius: 12px; font-size: 13.5px; opacity: 0;
  background: rgba(20, 12, 7, 0.75); border: 1px solid rgba(255, 207, 92, 0.4);
  transform: translateY(6px); transition: opacity .2s, transform .2s;
}
.ant-card.on { opacity: 1; transform: none; }
.ant-card b { color: var(--accent); }
.ant-card em { color: var(--pop); font-style: normal; font-weight: 700; }
